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 <vaurora@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
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. */