diff options
author | Steven Rostedt (Google) <rostedt@goodmis.org> | 2023-11-01 13:25:45 -0400 |
---|---|---|
committer | Steven Rostedt (Google) <rostedt@goodmis.org> | 2023-11-01 23:55:12 -0400 |
commit | 28e12c09f5aa081b2d13d1340e3610070b6c624d (patch) | |
tree | 19d23158cb294a7c8eca32d1863bd537f11c935b /fs/tracefs/internal.h | |
parent | 77a06c33a22d13f3a6e31f06f6ee6bca666e6898 (diff) | |
download | lwn-28e12c09f5aa081b2d13d1340e3610070b6c624d.tar.gz lwn-28e12c09f5aa081b2d13d1340e3610070b6c624d.zip |
eventfs: Save ownership and mode
Now that inodes and dentries are created on the fly, they are also
reclaimed on memory pressure. Since the ownership and file mode are saved
in the inode, if they are freed, any changes to the ownership and mode
will be lost.
To counter this, if the user changes the permissions or ownership, save
them, and when creating the inodes again, restore those changes.
Link: https://lkml.kernel.org/r/20231101172649.691841445@goodmis.org
Cc: stable@vger.kernel.org
Cc: Ajay Kaher <akaher@vmware.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Fixes: 63940449555e7 ("eventfs: Implement eventfs lookup, read, open functions")
Reviewed-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
Diffstat (limited to 'fs/tracefs/internal.h')
-rw-r--r-- | fs/tracefs/internal.h | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/fs/tracefs/internal.h b/fs/tracefs/internal.h index 5a98e87dd3d1..5f60bcd69289 100644 --- a/fs/tracefs/internal.h +++ b/fs/tracefs/internal.h @@ -14,6 +14,18 @@ struct tracefs_inode { }; /* + * struct eventfs_attr - cache the mode and ownership of a eventfs entry + * @mode: saved mode plus flags of what is saved + * @uid: saved uid if changed + * @gid: saved gid if changed + */ +struct eventfs_attr { + int mode; + kuid_t uid; + kgid_t gid; +}; + +/* * struct eventfs_inode - hold the properties of the eventfs directories. * @list: link list into the parent directory * @entries: the array of entries representing the files in the directory @@ -22,6 +34,8 @@ struct tracefs_inode { * @dentry: the dentry of the directory * @d_parent: pointer to the parent's dentry * @d_children: The array of dentries to represent the files when created + * @entry_attrs: Saved mode and ownership of the @d_children + * @attr: Saved mode and ownership of eventfs_inode itself * @data: The private data to pass to the callbacks * @is_freed: Flag set if the eventfs is on its way to be freed * Note if is_freed is set, then dentry is corrupted. @@ -35,6 +49,8 @@ struct eventfs_inode { struct dentry *dentry; /* Check is_freed to access */ struct dentry *d_parent; struct dentry **d_children; + struct eventfs_attr *entry_attrs; + struct eventfs_attr attr; void *data; /* * Union - used for deletion |