Skip to content

Commit ba6cc29

Browse files
charmitrogregkh
authored andcommitted
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 e4d3214 ("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 Fixes: a20971c ("vfs: Convert debugfs to use the new mount API") Closes: https://bugzilla.kernel.org/show_bug.cgi?id=220406 Cc: stable <[email protected]> Reviewed-by: Eric Sandeen <[email protected]> Signed-off-by: Charalampos Mitrodimas <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 75a7b15 commit ba6cc29

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

fs/debugfs/inode.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,9 @@ static int debugfs_reconfigure(struct fs_context *fc)
183183
struct debugfs_fs_info *sb_opts = sb->s_fs_info;
184184
struct debugfs_fs_info *new_opts = fc->s_fs_info;
185185

186+
if (!new_opts)
187+
return 0;
188+
186189
sync_filesystem(sb);
187190

188191
/* 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)
282285

283286
static int debugfs_get_tree(struct fs_context *fc)
284287
{
288+
int err;
289+
285290
if (!(debugfs_allow & DEBUGFS_ALLOW_API))
286291
return -EPERM;
287292

288-
return get_tree_single(fc, debugfs_fill_super);
293+
err = get_tree_single(fc, debugfs_fill_super);
294+
if (err)
295+
return err;
296+
297+
return debugfs_reconfigure(fc);
289298
}
290299

291300
static void debugfs_free_fc(struct fs_context *fc)

0 commit comments

Comments
 (0)