From 0828125895f7323e39b87673dbdbef4c70da5fdb Mon Sep 17 00:00:00 2001 From: Karel Zak Date: Fri, 27 Aug 2010 12:22:27 +0200 Subject: [PATCH] mount: sanity check mount flags for MS_PROPAGATION mount(8) reuses mount flags from fstab/mtab, the problem is that for MS_PROPAGATION operations kernel incorrectly evaluates mount flags if the flags contains any non-propagation stuff (e.g. MS_RDONLY). For example --make-shared on read-only FS: # strace -e mount mount --make-shared /mnt/test mount("/dev/sda1", "/mnt/test", "none", MS_RDONLY|MS_SHARED, NULL) = 0 must be: # strace -e mount mount --make-shared /mnt/test mount("/dev/sda1", "/mnt/test", "none", MS_SHARED, NULL) = 0 Reported-by: Valerie Aurora Signed-off-by: Karel Zak --- mount/mount.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/mount/mount.c b/mount/mount.c index 2e819e95..f2b6ee23 100644 --- a/mount/mount.c +++ b/mount/mount.c @@ -491,9 +491,11 @@ parse_opts (const char *options, int *flags, char **extra_opts) { if (readwrite) *flags &= ~MS_RDONLY; - if (mounttype & MS_PROPAGATION) - *flags &= ~MS_BIND; *flags |= mounttype; + + /* The propagation flags should not be used together with any other flags */ + if (*flags & MS_PROPAGATION) + *flags &= MS_PROPAGATION; } /* Try to build a canonical options string. */ -- 2.39.5