From: Eric W. Biederman Date: Wed, 13 Aug 2014 08:33:38 +0000 (-0700) Subject: mnt: Implicitly add MNT_NODEV on remount when it was implicitly added by mount X-Git-Tag: firefly_0821_release~3679^2~1044 X-Git-Url: http://plrg.eecs.uci.edu/git/?a=commitdiff_plain;h=4be461b16020beb18a0cd680ec74ba63f83b677c;p=firefly-linux-kernel-4.4.55.git mnt: Implicitly add MNT_NODEV on remount when it was implicitly added by mount commit 3e1866410f11356a9fd869beb3e95983dc79c067 upstream. Now that remount is properly enforcing the rule that you can't remove nodev at least sandstorm.io is breaking when performing a remount. It turns out that there is an easy intuitive solution implicitly add nodev on remount when nodev was implicitly added on mount. Tested-by: Cedric Bosdonnat Tested-by: Richard Weinberger Signed-off-by: "Eric W. Biederman" Signed-off-by: Greg Kroah-Hartman --- diff --git a/fs/namespace.c b/fs/namespace.c index 154822397780..fb2d1ad022bf 100644 --- a/fs/namespace.c +++ b/fs/namespace.c @@ -1816,7 +1816,13 @@ static int do_remount(struct path *path, int flags, int mnt_flags, } if ((mnt->mnt.mnt_flags & MNT_LOCK_NODEV) && !(mnt_flags & MNT_NODEV)) { - return -EPERM; + /* Was the nodev implicitly added in mount? */ + if ((mnt->mnt_ns->user_ns != &init_user_ns) && + !(sb->s_type->fs_flags & FS_USERNS_DEV_MOUNT)) { + mnt_flags |= MNT_NODEV; + } else { + return -EPERM; + } } if ((mnt->mnt.mnt_flags & MNT_LOCK_NOSUID) && !(mnt_flags & MNT_NOSUID)) {