]> Git Repo - linux.git/commitdiff
tracefs: Set the group ownership in apply_options() not parse_options()
authorSteven Rostedt (Google) <[email protected]>
Fri, 25 Feb 2022 20:34:26 +0000 (15:34 -0500)
committerSteven Rostedt (Google) <[email protected]>
Sat, 26 Feb 2022 02:05:04 +0000 (21:05 -0500)
Al Viro brought it to my attention that the dentries may not be filled
when the parse_options() is called, causing the call to set_gid() to
possibly crash. It should only be called if parse_options() succeeds
totally anyway.

He suggested the logical place to do the update is in apply_options().

Link: https://lore.kernel.org/all/[email protected]/
Link: https://lkml.kernel.org/r/[email protected]
Cc: [email protected]
Acked-by: Al Viro <[email protected]>
Reported-by: Al Viro <[email protected]>
Fixes: 48b27b6b5191 ("tracefs: Set all files to the same group ownership as the mount option")
Signed-off-by: Steven Rostedt (Google) <[email protected]>
fs/tracefs/inode.c

index bafc02bf82203a2699e6b2a879e628060891498f..de7252715b1251dd71004b73e2b7983d5778bb67 100644 (file)
@@ -264,7 +264,6 @@ static int tracefs_parse_options(char *data, struct tracefs_mount_opts *opts)
                        if (!gid_valid(gid))
                                return -EINVAL;
                        opts->gid = gid;
-                       set_gid(tracefs_mount->mnt_root, gid);
                        break;
                case Opt_mode:
                        if (match_octal(&args[0], &option))
@@ -291,7 +290,9 @@ static int tracefs_apply_options(struct super_block *sb)
        inode->i_mode |= opts->mode;
 
        inode->i_uid = opts->uid;
-       inode->i_gid = opts->gid;
+
+       /* Set all the group ids to the mount option */
+       set_gid(sb->s_root, opts->gid);
 
        return 0;
 }
This page took 0.065319 seconds and 4 git commands to generate.