Skip to content

Commit 3a1dd56

Browse files
rostedtgregkh
authored andcommitted
tracefs: Set the group ownership in apply_options() not parse_options()
commit 851e99e upstream. 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/20220225165219.737025658@goodmis.org/ Link: https://lkml.kernel.org/r/20220225153426.1c4cab6b@gandalf.local.home Cc: stable@vger.kernel.org Acked-by: Al Viro <viro@zeniv.linux.org.uk> Reported-by: Al Viro <viro@zeniv.linux.org.uk> Fixes: 48b27b6 ("tracefs: Set all files to the same group ownership as the mount option") Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent bfa8ffb commit 3a1dd56

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

fs/tracefs/inode.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,6 @@ static int tracefs_parse_options(char *data, struct tracefs_mount_opts *opts)
262262
if (!gid_valid(gid))
263263
return -EINVAL;
264264
opts->gid = gid;
265-
set_gid(tracefs_mount->mnt_root, gid);
266265
break;
267266
case Opt_mode:
268267
if (match_octal(&args[0], &option))
@@ -289,7 +288,9 @@ static int tracefs_apply_options(struct super_block *sb)
289288
inode->i_mode |= opts->mode;
290289

291290
inode->i_uid = opts->uid;
292-
inode->i_gid = opts->gid;
291+
292+
/* Set all the group ids to the mount option */
293+
set_gid(sb->s_root, opts->gid);
293294

294295
return 0;
295296
}

0 commit comments

Comments
 (0)