Skip to content

Commit e4d3214

Browse files
Kalesh Singhrostedt
authored andcommitted
tracing: Fix tracefs mount options
Commit 78ff640 ("vfs: Convert tracefs to use the new mount API") converted tracefs to use the new mount APIs caused mount options (e.g. gid=<gid>) to not take effect. The tracefs superblock can be updated from multiple paths: - on fs_initcall() to init_trace_printk_function_export() - from a work queue to initialize eventfs tracer_init_tracefs_work_func() - fsconfig() syscall to mount or remount of tracefs The tracefs superblock root inode gets created early on in init_trace_printk_function_export(). With the new mount API, tracefs effectively uses get_tree_single() instead of the old API mount_single(). Previously, mount_single() ensured that the options are always applied to the superblock root inode: (1) If the root inode didn't exist, call fill_super() to create it and apply the options. (2) If the root inode exists, call reconfigure_single() which effectively calls tracefs_apply_options() to parse and apply options to the subperblock's fs_info and inode and remount eventfs (if necessary) On the other hand, get_tree_single() effectively calls vfs_get_super() which: (3) If the root inode doesn't exists, calls fill_super() to create it and apply the options. (4) If the root inode already exists, updates the fs_context root with the superblock's root inode. (4) above is always the case for tracefs mounts, since the super block's root inode will already be created by init_trace_printk_function_export(). This means that the mount options get ignored: - Since it isn't applied to the superblock's root inode, it doesn't get inherited by the children. - Since eventfs is initialized from a separate work queue and before call to mount with the options, and it doesn't get remounted for mount. Ensure that the mount options are applied to the super block and eventfs is remounted to respect the mount options. To understand this better, if fstab has the following: tracefs /sys/kernel/tracing tracefs nosuid,nodev,noexec,gid=tracing 0 0 On boot up, permissions look like: # ls -l /sys/kernel/tracing/trace -rw-r----- 1 root root 0 Nov 1 08:37 /sys/kernel/tracing/trace When it should look like: # ls -l /sys/kernel/tracing/trace -rw-r----- 1 root tracing 0 Nov 1 08:37 /sys/kernel/tracing/trace Link: https://lore.kernel.org/r/[email protected]/ Cc: Eric Sandeen <[email protected]> Cc: Mathieu Desnoyers <[email protected]> Cc: Shuah Khan <[email protected]> Cc: Ali Zahraee <[email protected]> Cc: Christian Brauner <[email protected]> Cc: David Howells <[email protected]> Cc: Steven Rostedt <[email protected]> Cc: Masami Hiramatsu <[email protected]> Cc: [email protected] Fixes: 78ff640 ("vfs: Convert tracefs to use the new mount API") Link: https://lore.kernel.org/[email protected] Signed-off-by: Kalesh Singh <[email protected]> Signed-off-by: Steven Rostedt (Google) <[email protected]>
1 parent 8198375 commit e4d3214

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

fs/tracefs/inode.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -392,6 +392,9 @@ static int tracefs_reconfigure(struct fs_context *fc)
392392
struct tracefs_fs_info *sb_opts = sb->s_fs_info;
393393
struct tracefs_fs_info *new_opts = fc->s_fs_info;
394394

395+
if (!new_opts)
396+
return 0;
397+
395398
sync_filesystem(sb);
396399
/* structure copy of new mount options to sb */
397400
*sb_opts = *new_opts;
@@ -478,14 +481,17 @@ static int tracefs_fill_super(struct super_block *sb, struct fs_context *fc)
478481
sb->s_op = &tracefs_super_operations;
479482
sb->s_d_op = &tracefs_dentry_operations;
480483

481-
tracefs_apply_options(sb, false);
482-
483484
return 0;
484485
}
485486

486487
static int tracefs_get_tree(struct fs_context *fc)
487488
{
488-
return get_tree_single(fc, tracefs_fill_super);
489+
int err = get_tree_single(fc, tracefs_fill_super);
490+
491+
if (err)
492+
return err;
493+
494+
return tracefs_reconfigure(fc);
489495
}
490496

491497
static void tracefs_free_fc(struct fs_context *fc)

0 commit comments

Comments
 (0)