Skip to content

Commit d53891d

Browse files
committed
eventfs: Do not differentiate the toplevel events directory
The toplevel events directory is really no different than the events directory of instances. Having the two be different caused inconsistencies and made it harder to fix the permissions bugs. Make all events directories act the same. Link: https://lore.kernel.org/linux-trace-kernel/[email protected] Cc: [email protected] Cc: Masami Hiramatsu <[email protected]> Cc: Mark Rutland <[email protected]> Cc: Mathieu Desnoyers <[email protected]> Cc: Andrew Morton <[email protected]> Fixes: 8186fff ("tracefs/eventfs: Use root and instance inodes as default ownership") Signed-off-by: Steven Rostedt (Google) <[email protected]>
1 parent 6599bd5 commit d53891d

File tree

2 files changed

+11
-25
lines changed

2 files changed

+11
-25
lines changed

fs/tracefs/event_inode.c

Lines changed: 8 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@ enum {
6868
EVENTFS_SAVE_MODE = BIT(16),
6969
EVENTFS_SAVE_UID = BIT(17),
7070
EVENTFS_SAVE_GID = BIT(18),
71-
EVENTFS_TOPLEVEL = BIT(19),
7271
};
7372

7473
#define EVENTFS_MODE_MASK (EVENTFS_SAVE_MODE - 1)
@@ -239,14 +238,10 @@ static int eventfs_set_attr(struct mnt_idmap *idmap, struct dentry *dentry,
239238
return ret;
240239
}
241240

242-
static void update_top_events_attr(struct eventfs_inode *ei, struct super_block *sb)
241+
static void update_events_attr(struct eventfs_inode *ei, struct super_block *sb)
243242
{
244243
struct inode *root;
245244

246-
/* Only update if the "events" was on the top level */
247-
if (!ei || !(ei->attr.mode & EVENTFS_TOPLEVEL))
248-
return;
249-
250245
/* Get the tracefs root inode. */
251246
root = d_inode(sb->s_root);
252247
ei->attr.uid = root->i_uid;
@@ -259,10 +254,10 @@ static void set_top_events_ownership(struct inode *inode)
259254
struct eventfs_inode *ei = ti->private;
260255

261256
/* The top events directory doesn't get automatically updated */
262-
if (!ei || !ei->is_events || !(ei->attr.mode & EVENTFS_TOPLEVEL))
257+
if (!ei || !ei->is_events)
263258
return;
264259

265-
update_top_events_attr(ei, inode->i_sb);
260+
update_events_attr(ei, inode->i_sb);
266261

267262
if (!(ei->attr.mode & EVENTFS_SAVE_UID))
268263
inode->i_uid = ei->attr.uid;
@@ -291,7 +286,7 @@ static int eventfs_permission(struct mnt_idmap *idmap,
291286
return generic_permission(idmap, inode, mask);
292287
}
293288

294-
static const struct inode_operations eventfs_root_dir_inode_operations = {
289+
static const struct inode_operations eventfs_dir_inode_operations = {
295290
.lookup = eventfs_root_lookup,
296291
.setattr = eventfs_set_attr,
297292
.getattr = eventfs_get_attr,
@@ -359,7 +354,7 @@ static struct eventfs_inode *eventfs_find_events(struct dentry *dentry)
359354
// Walk upwards until you find the events inode
360355
} while (!ei->is_events);
361356

362-
update_top_events_attr(ei, dentry->d_sb);
357+
update_events_attr(ei, dentry->d_sb);
363358

364359
return ei;
365360
}
@@ -465,7 +460,7 @@ static struct dentry *lookup_dir_entry(struct dentry *dentry,
465460
update_inode_attr(dentry, inode, &ei->attr,
466461
S_IFDIR | S_IRWXU | S_IRUGO | S_IXUGO);
467462

468-
inode->i_op = &eventfs_root_dir_inode_operations;
463+
inode->i_op = &eventfs_dir_inode_operations;
469464
inode->i_fop = &eventfs_file_operations;
470465

471466
/* All directories will have the same inode number */
@@ -845,14 +840,6 @@ struct eventfs_inode *eventfs_create_events_dir(const char *name, struct dentry
845840
uid = d_inode(dentry->d_parent)->i_uid;
846841
gid = d_inode(dentry->d_parent)->i_gid;
847842

848-
/*
849-
* If the events directory is of the top instance, then parent
850-
* is NULL. Set the attr.mode to reflect this and its permissions will
851-
* default to the tracefs root dentry.
852-
*/
853-
if (!parent)
854-
ei->attr.mode = EVENTFS_TOPLEVEL;
855-
856843
/* This is used as the default ownership of the files and directories */
857844
ei->attr.uid = uid;
858845
ei->attr.gid = gid;
@@ -861,13 +848,13 @@ struct eventfs_inode *eventfs_create_events_dir(const char *name, struct dentry
861848
INIT_LIST_HEAD(&ei->list);
862849

863850
ti = get_tracefs(inode);
864-
ti->flags |= TRACEFS_EVENT_INODE | TRACEFS_EVENT_TOP_INODE;
851+
ti->flags |= TRACEFS_EVENT_INODE;
865852
ti->private = ei;
866853

867854
inode->i_mode = S_IFDIR | S_IRWXU | S_IRUGO | S_IXUGO;
868855
inode->i_uid = uid;
869856
inode->i_gid = gid;
870-
inode->i_op = &eventfs_root_dir_inode_operations;
857+
inode->i_op = &eventfs_dir_inode_operations;
871858
inode->i_fop = &eventfs_file_operations;
872859

873860
dentry->d_fsdata = get_ei(ei);

fs/tracefs/internal.h

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,9 @@
44

55
enum {
66
TRACEFS_EVENT_INODE = BIT(1),
7-
TRACEFS_EVENT_TOP_INODE = BIT(2),
8-
TRACEFS_GID_PERM_SET = BIT(3),
9-
TRACEFS_UID_PERM_SET = BIT(4),
10-
TRACEFS_INSTANCE_INODE = BIT(5),
7+
TRACEFS_GID_PERM_SET = BIT(2),
8+
TRACEFS_UID_PERM_SET = BIT(3),
9+
TRACEFS_INSTANCE_INODE = BIT(4),
1110
};
1211

1312
struct tracefs_inode {

0 commit comments

Comments
 (0)