debugfs: fix mount options not being applied
Subsystems (2)
PATCH v3 1/1 debugfs: fix mount options not being applied
Mount options (uid, gid, mode) are silently ignored when debugfs is mounted. This is a regression introduced during the conversion to the new mount API.
When the mount API conversion was done, the parsed options were never applied to the superblock when it was reused. As a result, the mount options were ignored when debugfs was mounted.
Fix this by following the same pattern as the tracefs fix in commit e4d32142d1de ("tracing: Fix tracefs mount options"). Call debugfs_reconfigure() in debugfs_get_tree() to apply the mount options to the superblock after it has been created or reused.
As an example, with the bug the "mode" mount option is ignored:
$ mount -o mode=0666 -t debugfs debugfs /tmp/debugfs_test $ mount | grep debugfs_test debugfs on /tmp/debugfs_test type debugfs (rw,relatime) $ ls -ld /tmp/debugfs_test drwx------ 25 root root 0 Aug 4 14:16 /tmp/debugfs_test
With the fix applied, it works as expected:
$ mount -o mode=0666 -t debugfs debugfs /tmp/debugfs_test $ mount | grep debugfs_test debugfs on /tmp/debugfs_test type debugfs (rw,relatime,mode=666) $ ls -ld /tmp/debugfs_test drw-rw-rw- 37 root root 0 Aug 2 17:28 /tmp/debugfs_test
---
Changes in v3:
- Reworded patch description to avoid confusion about OOPs
- Link to v2: https://lore.kernel.org/r/[email protected]
Changes in v2:
- Follow the same pattern as e4d32142d1de ("tracing: Fix tracefs mount options")
- Add Cc: stable tag
- Link to v1: https://lore.kernel.org/r/[email protected]
--- fs/debugfs/inode.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)
fs/debugfs/inode.c +10 -1
@@ -183,6 +183,9 @@ static int debugfs_reconfigure(struct fs_context *fc)struct debugfs_fs_info *sb_opts = sb->s_fs_info;struct debugfs_fs_info *new_opts = fc->s_fs_info; +if (!new_opts) +return 0 ; +sync_filesystem (sb);/* structure copy of new mount options to sb */
@@ -282,10 +285,16 @@ static int debugfs_fill_super(struct super_block *sb, struct fs_context *fc)static int debugfs_get_tree (struct fs_context *fc) { +int err; +if (!(debugfs_allow &DEBUGFS_ALLOW_API ))return -EPERM ; -return get_tree_single (fc, debugfs_fill_super); + err =get_tree_single (fc, debugfs_fill_super); +if (err) +return err; + +return debugfs_reconfigure (fc); }static void debugfs_free_fc (struct fs_context *fc)
---
base-commit: 3c4a063b1f8ab71352df1421d9668521acb63cd9
change-id: 20250804-debugfs-mount-opts-2a68d7741f05
Best regards,
Signature · 1 line
Charalampos Mitrodimas <[email protected]>
Christian Brauner
AppliedQuoted 9 lines · Charalampos Mitrodimas
Mount options (uid, gid, mode) are silently ignored when debugfs is mounted. This is a regression introduced during the conversion to the new mount API.
When the mount API conversion was done, the parsed options were never applied to the superblock when it was reused. As a result, the mount options were ignored when debugfs was mounted.
[...]
Applied to the vfs-6.18.misc branch of the vfs/vfs.git tree. Patches in the vfs-6.18.misc branch should appear in linux-next soon.
Please report any outstanding bugs that were missed during review in a new review to the original patch series allowing us to drop it.
It's encouraged to provide Acked-bys and Reviewed-bys even though the patch has now been applied. If possible patch trailers will be updated.
Note that commit hashes shown below are subject to change due to rebase, trailer updates or similar. If in doubt, please check the listed branch.
tree: https://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs.git branch: vfs-6.18.misc
[1/1] debugfs: fix mount options not being applied
https://git.kernel.org/vfs/vfs/c/8e7e265d558e
Greg Kroah-Hartman
maintainerQuoted 20 lines · Christian Brauner
Quoted 9 lines · Charalampos Mitrodimas
Mount options (uid, gid, mode) are silently ignored when debugfs is mounted. This is a regression introduced during the conversion to the new mount API.
When the mount API conversion was done, the parsed options were never applied to the superblock when it was reused. As a result, the mount options were ignored when debugfs was mounted.
[...]
Applied to the vfs-6.18.misc branch of the vfs/vfs.git tree. Patches in the vfs-6.18.misc branch should appear in linux-next soon.
Please report any outstanding bugs that were missed during review in a new review to the original patch series allowing us to drop it.
It's encouraged to provide Acked-bys and Reviewed-bys even though the patch has now been applied. If possible patch trailers will be updated.
Quoted 8 lines
Note that commit hashes shown below are subject to change due to rebase, trailer updates or similar. If in doubt, please check the listed branch.
tree: https://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs.git branch: vfs-6.18.misc[1/1] debugfs: fix mount options not being applied
https://git.kernel.org/vfs/vfs/c/8e7e265d558e
I've also included this in the driver-core -linus branch, so it should have been in linux-next for a few days now. I guess both versions can't hurt :)
thanks
greg k-h