All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] tracefs: Have new files inherit the ownership of their parent
@ 2021-12-07 19:48 Steven Rostedt
  2021-12-08 10:44 ` Christian Brauner
  0 siblings, 1 reply; 3+ messages in thread
From: Steven Rostedt @ 2021-12-07 19:48 UTC (permalink / raw)
  To: LKML
  Cc: Kalesh Singh, Kees Cook, Ingo Molnar, Andrew Morton,
	Linus Torvalds, linux-fsdevel, Al Viro, Greg Kroah-Hartman,
	Yabin Cui

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

If the tracefs system is set to a specific owner and group, then the files
and directories that are created under them should inherit the owner and
group of the parent.

Cc: stable@vger.kernel.org
Fixes: 4282d60689d4f ("tracefs: Add new tracefs file system")
Reported-by: Kalesh Singh <kaleshsingh@google.com>
Reported: https://lore.kernel.org/all/CAC_TJve8MMAv+H_NdLSJXZUSoxOEq2zB_pVaJ9p=7H6Bu3X76g@mail.gmail.com/
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
---
 fs/tracefs/inode.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/fs/tracefs/inode.c b/fs/tracefs/inode.c
index f20f575cdaef..6b16d89cf187 100644
--- a/fs/tracefs/inode.c
+++ b/fs/tracefs/inode.c
@@ -488,6 +488,8 @@ struct dentry *tracefs_create_file(const char *name, umode_t mode,
 	inode->i_mode = mode;
 	inode->i_fop = fops ? fops : &tracefs_file_operations;
 	inode->i_private = data;
+	inode->i_uid = dentry->d_parent->d_inode->i_uid;
+	inode->i_gid = dentry->d_parent->d_inode->i_gid;
 	d_instantiate(dentry, inode);
 	fsnotify_create(dentry->d_parent->d_inode, dentry);
 	return end_creating(dentry);
@@ -510,6 +512,8 @@ static struct dentry *__create_dir(const char *name, struct dentry *parent,
 	inode->i_mode = S_IFDIR | S_IRWXU | S_IRUSR| S_IRGRP | S_IXUSR | S_IXGRP;
 	inode->i_op = ops;
 	inode->i_fop = &simple_dir_operations;
+	inode->i_uid = dentry->d_parent->d_inode->i_uid;
+	inode->i_gid = dentry->d_parent->d_inode->i_gid;
 
 	/* directory inodes start off with i_nlink == 2 (for "." entry) */
 	inc_nlink(inode);
-- 
2.31.1


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

end of thread, other threads:[~2021-12-08 12:47 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-07 19:48 [PATCH] tracefs: Have new files inherit the ownership of their parent Steven Rostedt
2021-12-08 10:44 ` Christian Brauner
2021-12-08 12:47   ` Steven Rostedt

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.