Skip to content

Commit 2dd00ac

Browse files
committed
eventfs: Do not use attributes for events directory
The top "events" directory has a static inode (it's created when it is and removed when the directory is removed). There's no need to use the events ei->attr to determine its permissions. But it is used for saving the permissions of the "events" directory for when it is created, as that is needed for the default permissions for the files and directories underneath it. For example: # cd /sys/kernel/tracing # mkdir instances/foo # chown 1001 instances/foo/events The files under instances/foo/events should still have the same owner as instances/foo (which the instances/foo/events ei->attr will hold), but the events directory now has owner 1001. Link: https://lore.kernel.org/lkml/[email protected] Cc: Linus Torvalds <[email protected]> Cc: Masami Hiramatsu <[email protected]> Cc: Mark Rutland <[email protected]> Cc: Mathieu Desnoyers <[email protected]> Cc: Andrew Morton <[email protected]> Signed-off-by: Steven Rostedt (Google) <[email protected]>
1 parent 6e3d7c9 commit 2dd00ac

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

fs/tracefs/event_inode.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,9 @@ static int eventfs_set_attr(struct mnt_idmap *idmap, struct dentry *dentry,
210210
* determined by the parent directory.
211211
*/
212212
if (dentry->d_inode->i_mode & S_IFDIR) {
213-
update_attr(&ei->attr, iattr);
213+
/* Just use the inode permissions for the events directory */
214+
if (!ei->is_events)
215+
update_attr(&ei->attr, iattr);
214216

215217
} else {
216218
name = dentry->d_name.name;
@@ -789,14 +791,12 @@ struct eventfs_inode *eventfs_create_events_dir(const char *name, struct dentry
789791
uid = d_inode(dentry->d_parent)->i_uid;
790792
gid = d_inode(dentry->d_parent)->i_gid;
791793

792-
ei->attr.uid = uid;
793-
ei->attr.gid = gid;
794-
795794
/*
796-
* When the "events" directory is created, it takes on the
797-
* permissions of its parent. But can be reset on remount.
795+
* The ei->attr will be used as the default values for the
796+
* files beneath this directory.
798797
*/
799-
ei->attr.mode |= EVENTFS_SAVE_UID | EVENTFS_SAVE_GID;
798+
ei->attr.uid = uid;
799+
ei->attr.gid = gid;
800800

801801
INIT_LIST_HEAD(&ei->children);
802802
INIT_LIST_HEAD(&ei->list);

0 commit comments

Comments
 (0)