• Thomas Bertschinger's avatar
    bcachefs: don't expose "read_only" as a mount option · babe30fe
    Thomas Bertschinger authored
    When "read_only" is exposed as a mount option, it is redundant with the
    standard option "ro" and gives users multiple ways to specify that a
    bcachefs filesystem should be mounted read-only. This presents the risk
    of having inconsistent options specified.
    
    This can be seen when remounting a read-only filesystem in read-write
    mode, using mount(8) from util-linux. Because mount(8) parses the
    existing mount options from `/proc/mounts` and applies them when
    remounting, it can end up applying both "read_only" and "rw":
    
    $ mount img -o ro /mnt
    $ strace mount -o remount,rw /mnt
    ...
    fsconfig(4, FSCONFIG_SET_FLAG, "read_only", NULL, 0) = 0
    fsconfig(4, FSCONFIG_SET_FLAG, "rw", NULL, 0) = 0
    ...
    
    Making "read_only" no longer a mount option means this edge case cannot
    occur.
    
    Fixes: 62719cf3 ("bcachefs: Fix nochanges/read_only interaction")
    Signed-off-by: default avatarThomas Bertschinger <tahbertschinger@gmail.com>
    Signed-off-by: default avatarKent Overstreet <kent.overstreet@linux.dev>
    babe30fe
opts.h 19.2 KB