linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3] tracefs: Set the group ownership in apply_options() not parse_options()
@ 2022-02-25 20:34 Steven Rostedt
  2022-02-25 23:12 ` Al Viro
  0 siblings, 1 reply; 2+ messages in thread
From: Steven Rostedt @ 2022-02-25 20:34 UTC (permalink / raw)
  To: LKML; +Cc: Al Viro

From: "Steven Rostedt (Google)" <rostedt@goodmis.org>

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/

Cc: stable@vger.kernel.org
Reported-by: Al Viro <viro@zeniv.linux.org.uk>
Fixes: 48b27b6b5191 ("tracefs: Set all files to the same group ownership as the mount option")
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
---
 fs/tracefs/inode.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/fs/tracefs/inode.c b/fs/tracefs/inode.c
index bafc02bf8220..de7252715b12 100644
--- a/fs/tracefs/inode.c
+++ b/fs/tracefs/inode.c
@@ -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;
 }
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH v3] tracefs: Set the group ownership in apply_options() not parse_options()
  2022-02-25 20:34 [PATCH v3] tracefs: Set the group ownership in apply_options() not parse_options() Steven Rostedt
@ 2022-02-25 23:12 ` Al Viro
  0 siblings, 0 replies; 2+ messages in thread
From: Al Viro @ 2022-02-25 23:12 UTC (permalink / raw)
  To: Steven Rostedt; +Cc: LKML

On Fri, Feb 25, 2022 at 03:34:26PM -0500, Steven Rostedt wrote:
> From: "Steven Rostedt (Google)" <rostedt@goodmis.org>
> 
> 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().

Feel free to slap my Acked-by on that variant...

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-02-25 23:12 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-25 20:34 [PATCH v3] tracefs: Set the group ownership in apply_options() not parse_options() Steven Rostedt
2022-02-25 23:12 ` Al Viro

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).