vfs: fsmount: add missing mntget()
authorEric Biggers <ebiggers@google.com>
Wed, 12 Jun 2019 18:43:13 +0000 (11:43 -0700)
committerAl Viro <viro@zeniv.linux.org.uk>
Mon, 17 Jun 2019 21:36:07 +0000 (17:36 -0400)
sys_fsmount() needs to take a reference to the new mount when adding it
to the anonymous mount namespace.  Otherwise the filesystem can be
unmounted while it's still in use, as found by syzkaller.

Reported-by: Mark Rutland <mark.rutland@arm.com>
Reported-by: syzbot+99de05d099a170867f22@syzkaller.appspotmail.com
Reported-by: syzbot+7008b8b8ba7df475fdc8@syzkaller.appspotmail.com
Fixes: 93766fbd2696 ("vfs: syscall: Add fsmount() to create a mount for a superblock")
Signed-off-by: Eric Biggers <ebiggers@google.com>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
fs/namespace.c

index b26778bdc236e83595d6c2129d4f61ae45dbc0f2..5dc137a22d406c0f20d276adb7895dbb602f3546 100644 (file)
@@ -3445,6 +3445,7 @@ SYSCALL_DEFINE3(fsmount, int, fs_fd, unsigned int, flags,
        ns->root = mnt;
        ns->mounts = 1;
        list_add(&mnt->mnt_list, &ns->list);
+       mntget(newmount.mnt);
 
        /* Attach to an apparent O_PATH fd with a note that we need to unmount
         * it, not just simply put it.