Skip to content

Commit a0a6df9

Browse files
author
Al Viro
committed
umount(2): move the flag validity checks first
Unfortunately, there's userland code that used to rely upon these checks being done before anything else to check for UMOUNT_NOFOLLOW support. That broke in 41525f5 ("fs: refactor ksys_umount"). Separate those from the rest of checks and move them to ksys_umount(); unlike everything else in there, this can be sanely done there. Reported-by: Sargun Dhillon <[email protected]> Fixes: 41525f5 ("fs: refactor ksys_umount") Signed-off-by: Al Viro <[email protected]>
1 parent 5c8fe58 commit a0a6df9

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

fs/namespace.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1713,8 +1713,6 @@ static int can_umount(const struct path *path, int flags)
17131713
{
17141714
struct mount *mnt = real_mount(path->mnt);
17151715

1716-
if (flags & ~(MNT_FORCE | MNT_DETACH | MNT_EXPIRE | UMOUNT_NOFOLLOW))
1717-
return -EINVAL;
17181716
if (!may_mount())
17191717
return -EPERM;
17201718
if (path->dentry != path->mnt->mnt_root)
@@ -1728,6 +1726,7 @@ static int can_umount(const struct path *path, int flags)
17281726
return 0;
17291727
}
17301728

1729+
// caller is responsible for flags being sane
17311730
int path_umount(struct path *path, int flags)
17321731
{
17331732
struct mount *mnt = real_mount(path->mnt);
@@ -1749,6 +1748,10 @@ static int ksys_umount(char __user *name, int flags)
17491748
struct path path;
17501749
int ret;
17511750

1751+
// basic validity checks done first
1752+
if (flags & ~(MNT_FORCE | MNT_DETACH | MNT_EXPIRE | UMOUNT_NOFOLLOW))
1753+
return -EINVAL;
1754+
17521755
if (!(flags & UMOUNT_NOFOLLOW))
17531756
lookup_flags |= LOOKUP_FOLLOW;
17541757
ret = user_path_at(AT_FDCWD, name, lookup_flags, &path);

0 commit comments

Comments
 (0)