Skip to content

Commit 4cb6829

Browse files
dhowellstorvalds
authored andcommitted
afs: Fix memory leak when mounting with multiple source parameters
There's a memory leak in afs_parse_source() whereby multiple source= parameters overwrite fc->source in the fs_context struct without freeing the previously recorded source. Fix this by only permitting a single source parameter and rejecting with an error all subsequent ones. This was caught by syzbot with the kernel memory leak detector, showing something like the following trace: unreferenced object 0xffff888114375440 (size 32): comm "repro", pid 5168, jiffies 4294923723 (age 569.948s) backtrace: slab_post_alloc_hook+0x42/0x79 __kmalloc_track_caller+0x125/0x16a kmemdup_nul+0x24/0x3c vfs_parse_fs_string+0x5a/0xa1 generic_parse_monolithic+0x9d/0xc5 do_new_mount+0x10d/0x15a do_mount+0x5f/0x8e __do_sys_mount+0xff/0x127 do_syscall_64+0x2d/0x3a entry_SYSCALL_64_after_hwframe+0x44/0xa9 Fixes: 13fcc68 ("afs: Add fs_context support") Reported-by: [email protected] Signed-off-by: David Howells <[email protected]> cc: Randy Dunlap <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent c6f7e15 commit 4cb6829

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

fs/afs/super.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,9 @@ static int afs_parse_source(struct fs_context *fc, struct fs_parameter *param)
230230

231231
_enter(",%s", name);
232232

233+
if (fc->source)
234+
return invalf(fc, "kAFS: Multiple sources not supported");
235+
233236
if (!name) {
234237
printk(KERN_ERR "kAFS: no volume name specified\n");
235238
return -EINVAL;

0 commit comments

Comments
 (0)