• Brian Norris's avatar
    debugfs: Only clobber mode/uid/gid on remount if asked · b8de524c
    Brian Norris authored
    Users may have explicitly configured their debugfs permissions; we
    shouldn't overwrite those just because a second mount appeared.
    
    Only clobber if the options were provided at mount time.
    
    Existing behavior:
    
      ## Pre-existing status: debugfs is 0755.
      # chmod 755 /sys/kernel/debug/
      # stat -c '%A' /sys/kernel/debug/
      drwxr-xr-x
    
      ## New mount sets kernel-default permissions:
      # mount -t debugfs none /mnt/foo
      # stat -c '%A' /mnt/foo
      drwx------
    
      ## Unexpected: the original mount changed permissions:
      # stat -c '%A' /sys/kernel/debug
      drwx------
    
    New behavior:
    
      ## Pre-existing status: debugfs is 0755.
      # chmod 755 /sys/kernel/debug/
      # stat -c '%A' /sys/kernel/debug/
      drwxr-xr-x
    
      ## New mount inherits existing permissions:
      # mount -t debugfs none /mnt/foo
      # stat -c '%A' /mnt/foo
      drwxr-xr-x
    
      ## Expected: old mount is unchanged:
      # stat -c '%A' /sys/kernel/debug
      drwxr-xr-x
    
    Full test cases are being submitted to LTP.
    Signed-off-by: default avatarBrian Norris <briannorris@chromium.org>
    Link: https://lore.kernel.org/r/20220912163042.v3.1.Icbd40fce59f55ad74b80e5d435ea233579348a78@changeidSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
    b8de524c
inode.c 26.1 KB