Skip to content

Commit ee7f366

Browse files
committed
tracefs: Have new files inherit the ownership of their parent
If directories in tracefs have their ownership changed, then any new files and directories that are created under those directories should inherit the ownership of the director they are created in. Link: https://lkml.kernel.org/r/[email protected] Cc: Kees Cook <[email protected]> Cc: Ingo Molnar <[email protected]> Cc: Andrew Morton <[email protected]> Cc: Linus Torvalds <[email protected]> Cc: Al Viro <[email protected]> Cc: Greg Kroah-Hartman <[email protected]> Cc: Yabin Cui <[email protected]> Cc: Christian Brauner <[email protected]> Cc: [email protected] Fixes: 4282d60 ("tracefs: Add new tracefs file system") Reported-by: Kalesh Singh <[email protected]> Reported: https://lore.kernel.org/all/CAC_TJve8MMAv+H_NdLSJXZUSoxOEq2zB_pVaJ9p=7H6Bu3X76g@mail.gmail.com/ Signed-off-by: Steven Rostedt (VMware) <[email protected]>
1 parent 0fcfb00 commit ee7f366

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

fs/tracefs/inode.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -414,6 +414,8 @@ struct dentry *tracefs_create_file(const char *name, umode_t mode,
414414
inode->i_mode = mode;
415415
inode->i_fop = fops ? fops : &tracefs_file_operations;
416416
inode->i_private = data;
417+
inode->i_uid = d_inode(dentry->d_parent)->i_uid;
418+
inode->i_gid = d_inode(dentry->d_parent)->i_gid;
417419
d_instantiate(dentry, inode);
418420
fsnotify_create(dentry->d_parent->d_inode, dentry);
419421
return end_creating(dentry);
@@ -436,6 +438,8 @@ static struct dentry *__create_dir(const char *name, struct dentry *parent,
436438
inode->i_mode = S_IFDIR | S_IRWXU | S_IRUSR| S_IRGRP | S_IXUSR | S_IXGRP;
437439
inode->i_op = ops;
438440
inode->i_fop = &simple_dir_operations;
441+
inode->i_uid = d_inode(dentry->d_parent)->i_uid;
442+
inode->i_gid = d_inode(dentry->d_parent)->i_gid;
439443

440444
/* directory inodes start off with i_nlink == 2 (for "." entry) */
441445
inc_nlink(inode);

0 commit comments

Comments
 (0)