Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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 41525f56e256 ("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 <sargun@sargun.me>
Fixes: 41525f56e256 ("fs: refactor ksys_umount")
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>

Al Viro a0a6df9a 5c8fe583

+5 -2
+5 -2
fs/namespace.c
··· 1713 1713 { 1714 1714 struct mount *mnt = real_mount(path->mnt); 1715 1715 1716 - if (flags & ~(MNT_FORCE | MNT_DETACH | MNT_EXPIRE | UMOUNT_NOFOLLOW)) 1717 - return -EINVAL; 1718 1716 if (!may_mount()) 1719 1717 return -EPERM; 1720 1718 if (path->dentry != path->mnt->mnt_root) ··· 1726 1728 return 0; 1727 1729 } 1728 1730 1731 + // caller is responsible for flags being sane 1729 1732 int path_umount(struct path *path, int flags) 1730 1733 { 1731 1734 struct mount *mnt = real_mount(path->mnt); ··· 1747 1748 int lookup_flags = LOOKUP_MOUNTPOINT; 1748 1749 struct path path; 1749 1750 int ret; 1751 + 1752 + // basic validity checks done first 1753 + if (flags & ~(MNT_FORCE | MNT_DETACH | MNT_EXPIRE | UMOUNT_NOFOLLOW)) 1754 + return -EINVAL; 1750 1755 1751 1756 if (!(flags & UMOUNT_NOFOLLOW)) 1752 1757 lookup_flags |= LOOKUP_FOLLOW;