mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2025-01-09 22:50:41 +00:00
Merge branch 'fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs
Pull mount leak fix from Al Viro: "Regression fix for the syscalls-for-init series - fix a leak of a 'struct path'" * 'fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs: fs: fix a struct path leak in path_umount
This commit is contained in:
commit
d57b2b5bc4
@ -1706,34 +1706,38 @@ static inline bool may_mandlock(void)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int path_umount(struct path *path, int flags)
|
static int can_umount(const struct path *path, int flags)
|
||||||
{
|
{
|
||||||
struct mount *mnt;
|
struct mount *mnt = real_mount(path->mnt);
|
||||||
int retval;
|
|
||||||
|
|
||||||
if (flags & ~(MNT_FORCE | MNT_DETACH | MNT_EXPIRE | UMOUNT_NOFOLLOW))
|
if (flags & ~(MNT_FORCE | MNT_DETACH | MNT_EXPIRE | UMOUNT_NOFOLLOW))
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
if (!may_mount())
|
if (!may_mount())
|
||||||
return -EPERM;
|
return -EPERM;
|
||||||
|
|
||||||
mnt = real_mount(path->mnt);
|
|
||||||
retval = -EINVAL;
|
|
||||||
if (path->dentry != path->mnt->mnt_root)
|
if (path->dentry != path->mnt->mnt_root)
|
||||||
goto dput_and_out;
|
return -EINVAL;
|
||||||
if (!check_mnt(mnt))
|
if (!check_mnt(mnt))
|
||||||
goto dput_and_out;
|
return -EINVAL;
|
||||||
if (mnt->mnt.mnt_flags & MNT_LOCKED) /* Check optimistically */
|
if (mnt->mnt.mnt_flags & MNT_LOCKED) /* Check optimistically */
|
||||||
goto dput_and_out;
|
return -EINVAL;
|
||||||
retval = -EPERM;
|
|
||||||
if (flags & MNT_FORCE && !capable(CAP_SYS_ADMIN))
|
if (flags & MNT_FORCE && !capable(CAP_SYS_ADMIN))
|
||||||
goto dput_and_out;
|
return -EPERM;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int path_umount(struct path *path, int flags)
|
||||||
|
{
|
||||||
|
struct mount *mnt = real_mount(path->mnt);
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
ret = can_umount(path, flags);
|
||||||
|
if (!ret)
|
||||||
|
ret = do_umount(mnt, flags);
|
||||||
|
|
||||||
retval = do_umount(mnt, flags);
|
|
||||||
dput_and_out:
|
|
||||||
/* we mustn't call path_put() as that would clear mnt_expiry_mark */
|
/* we mustn't call path_put() as that would clear mnt_expiry_mark */
|
||||||
dput(path->dentry);
|
dput(path->dentry);
|
||||||
mntput_no_expire(mnt);
|
mntput_no_expire(mnt);
|
||||||
return retval;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int ksys_umount(char __user *name, int flags)
|
static int ksys_umount(char __user *name, int flags)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user