[PATCH 3.16.y-ckt 072/216] umount: Disallow unprivileged mount force

Luis Henriques
2015-01-12T18:19:20Z

From: "Eric W. Biederman" <ebiederm@xmission.com>

commit b2f5d4dc38e034eecb7987e513255265ff9aa1cf upstream.

Forced unmount affects not just the mount namespace but the underlying
superblock as well. Restrict forced unmount to the global root user
for now. Otherwise it becomes possible a user in a less privileged
mount namespace to force the shutdown of a superblock of a filesystem
in a more privileged mount namespace, allowing a DOS attack on root.

Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
Signed-off-by: Luis Henriques <luis.henriques@canonical.com>
---
fs/namespace.c | 3 +++
1 file changed, 3 insertions(+)

diff --git a/fs/namespace.c b/fs/namespace.c
index e718c7a0437a..67645ea593f2 100644
--- a/fs/namespace.c
+++ b/fs/namespace.c
@@ -1448,6 +1448,9 @@ SYSCALL_DEFINE2(umount, char __user *, name, int, flags)
goto dput_and_out;
if (mnt->mnt.mnt_flags & MNT_LOCKED)
goto dput_and_out;
+ retval = -EPERM;
+ if (flags & MNT_FORCE && !capable(CAP_SYS_ADMIN))
+ goto dput_and_out;

retval = do_umount(mnt, flags);
dput_and_out:
--
2.1.4