mirror of
https://github.com/torvalds/linux.git
synced 2024-11-24 21:21:41 +00:00
tracefs: Still use mount point as default permissions for instances
If the instances directory's permissions were never change, then have it
and its children use the mount point permissions as the default.
Currently, the permissions of instance directories are determined by the
instance directory's permissions itself. But if the tracefs file system is
remounted and changes the permissions, the instance directory and its
children should use the new permission.
But because both the instance directory and its children use the instance
directory's inode for permissions, it misses the update.
To demonstrate this:
# cd /sys/kernel/tracing/
# mkdir instances/foo
# ls -ld instances/foo
drwxr-x--- 5 root root 0 May 1 19:07 instances/foo
# ls -ld instances
drwxr-x--- 3 root root 0 May 1 18:57 instances
# ls -ld current_tracer
-rw-r----- 1 root root 0 May 1 18:57 current_tracer
# mount -o remount,gid=1002 .
# ls -ld instances
drwxr-x--- 3 root root 0 May 1 18:57 instances
# ls -ld instances/foo/
drwxr-x--- 5 root root 0 May 1 19:07 instances/foo/
# ls -ld current_tracer
-rw-r----- 1 root lkp 0 May 1 18:57 current_tracer
Notice that changing the group id to that of "lkp" did not affect the
instances directory nor its children. It should have been:
# ls -ld current_tracer
-rw-r----- 1 root root 0 May 1 19:19 current_tracer
# ls -ld instances/foo/
drwxr-x--- 5 root root 0 May 1 19:25 instances/foo/
# ls -ld instances
drwxr-x--- 3 root root 0 May 1 19:19 instances
# mount -o remount,gid=1002 .
# ls -ld current_tracer
-rw-r----- 1 root lkp 0 May 1 19:19 current_tracer
# ls -ld instances
drwxr-x--- 3 root lkp 0 May 1 19:19 instances
# ls -ld instances/foo/
drwxr-x--- 5 root lkp 0 May 1 19:25 instances/foo/
Where all files were updated by the remount gid update.
Link: https://lore.kernel.org/linux-trace-kernel/20240502200905.686838327@goodmis.org
Cc: stable@vger.kernel.org
Cc: Masami Hiramatsu <mhiramat@kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Fixes: 8186fff7ab
("tracefs/eventfs: Use root and instance inodes as default ownership")
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
This commit is contained in:
parent
baa23a8d43
commit
6599bd5517
@ -180,16 +180,39 @@ static void set_tracefs_inode_owner(struct inode *inode)
|
||||
{
|
||||
struct tracefs_inode *ti = get_tracefs(inode);
|
||||
struct inode *root_inode = ti->private;
|
||||
kuid_t uid;
|
||||
kgid_t gid;
|
||||
|
||||
uid = root_inode->i_uid;
|
||||
gid = root_inode->i_gid;
|
||||
|
||||
/*
|
||||
* If the root is not the mount point, then check the root's
|
||||
* permissions. If it was never set, then default to the
|
||||
* mount point.
|
||||
*/
|
||||
if (root_inode != d_inode(root_inode->i_sb->s_root)) {
|
||||
struct tracefs_inode *rti;
|
||||
|
||||
rti = get_tracefs(root_inode);
|
||||
root_inode = d_inode(root_inode->i_sb->s_root);
|
||||
|
||||
if (!(rti->flags & TRACEFS_UID_PERM_SET))
|
||||
uid = root_inode->i_uid;
|
||||
|
||||
if (!(rti->flags & TRACEFS_GID_PERM_SET))
|
||||
gid = root_inode->i_gid;
|
||||
}
|
||||
|
||||
/*
|
||||
* If this inode has never been referenced, then update
|
||||
* the permissions to the superblock.
|
||||
*/
|
||||
if (!(ti->flags & TRACEFS_UID_PERM_SET))
|
||||
inode->i_uid = root_inode->i_uid;
|
||||
inode->i_uid = uid;
|
||||
|
||||
if (!(ti->flags & TRACEFS_GID_PERM_SET))
|
||||
inode->i_gid = root_inode->i_gid;
|
||||
inode->i_gid = gid;
|
||||
}
|
||||
|
||||
static int tracefs_permission(struct mnt_idmap *idmap,
|
||||
|
Loading…
Reference in New Issue
Block a user