Skip to content

Commit

Permalink
tracefs: Set the group ownership in apply_options() not parse_options()
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
rostedt committed Feb 26, 2022
1 parent dd99035 commit 851e99e
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions fs/tracefs/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand All @@ -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;
}
Expand Down

0 comments on commit 851e99e

Please sign in to comment.