From nobody Fri Feb 13 16:36:00 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CA370127E0F; Thu, 23 May 2024 21:23:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716499400; cv=none; b=i2Gu2nHgwo7zkwBVyLHVUg1VbmYQBPwHtvqxU+CjalUrIiaxYxRE12+wc7JxSYX3JrkA9Eb3WEI1MQaR1sf5UvYbkOk+qbyWzfDCDUqhVSQxU4JehZHsZUwcwIl72PCngFfyk8pIN03bY8VTPYkH4EU9fIHU6wWAODPOfcQPUpo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716499400; c=relaxed/simple; bh=MgR7PcM1cd8fILj4Kljcp2I/+ntdD1HauSiyYWV8qas=; h=Message-ID:Date:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=iIrwQGdWfn0Zf935yizFktQnfdl1ivDj7BjvXfl23wiM846af1fZ1omLhxQV50PbiMe5/xjk1q9Tk/Ait8+9vEsOvF/eqve6XhHtceUvM3kCslz4ObhIqM3qymrp4Sg509MIrblUTC2+Us2sz4/sMu3zvAsEOPkJiLkqYOPoNgs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 73D5EC3277B; Thu, 23 May 2024 21:23:20 +0000 (UTC) Received: from rostedt by gandalf with local (Exim 4.97) (envelope-from ) id 1sAFuw-00000006l8E-0yrZ; Thu, 23 May 2024 17:24:06 -0400 Message-ID: <20240523212406.097200804@goodmis.org> User-Agent: quilt/0.68 Date: Thu, 23 May 2024 17:22:59 -0400 From: Steven Rostedt To: linux-kernel@vger.kernel.org Cc: Masami Hiramatsu , Mark Rutland , Mathieu Desnoyers , Andrew Morton , Masahiro Yamada , stable@vger.kernel.org Subject: [for-linus][PATCH 1/8] eventfs: Keep the directories from having the same inode number as files References: <20240523212258.883756004@goodmis.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: "Steven Rostedt (Google)" The directories require unique inode numbers but all the eventfs files have the same inode number. Prevent the directories from having the same inode numbers as the files as that can confuse some tooling. Link: https://lore.kernel.org/linux-trace-kernel/20240523051539.428826685@g= oodmis.org Cc: stable@vger.kernel.org Cc: Masami Hiramatsu Cc: Mark Rutland Cc: Mathieu Desnoyers Cc: Andrew Morton Cc: Masahiro Yamada Fixes: 834bf76add3e6 ("eventfs: Save directory inodes in the eventfs_inode = structure") Signed-off-by: Steven Rostedt (Google) --- fs/tracefs/event_inode.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/fs/tracefs/event_inode.c b/fs/tracefs/event_inode.c index 0256afdd4acf..55a40a730b10 100644 --- a/fs/tracefs/event_inode.c +++ b/fs/tracefs/event_inode.c @@ -50,8 +50,12 @@ static struct eventfs_root_inode *get_root_inode(struct = eventfs_inode *ei) /* Just try to make something consistent and unique */ static int eventfs_dir_ino(struct eventfs_inode *ei) { - if (!ei->ino) + if (!ei->ino) { ei->ino =3D get_next_ino(); + /* Must not have the file inode number */ + if (ei->ino =3D=3D EVENTFS_FILE_INODE_INO) + ei->ino =3D get_next_ino(); + } =20 return ei->ino; } --=20 2.43.0 From nobody Fri Feb 13 16:36:00 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CA2E384A22; Thu, 23 May 2024 21:23:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716499400; cv=none; b=SDRevRk63UcvejOfWhHds6QITR/knASd5sNfC6UffLrNcc3flplGjUv0B3GGB8HPkeR0h3JiHknzP/SHJ/8tl23+h8/CWGY2K2HsubHqqOE37jz+9BL7foOXCYES48hTKRjrxw3JnbaxFX4fKEcspwBGbyr9G/nS542eNybeK6E= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716499400; c=relaxed/simple; bh=XM0hUwOffQtWwO0Qz54AvVXTV1kQJiBoCu2GXssYZaE=; h=Message-ID:Date:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=aFwNDQkm1F4GZ7bRBfvQcKpK6LIypUPxW9u28OUXXYjlZmRiqjcbG6Sh/7zx06BZGjjwk/lvJBTm5f63rtTYii/4d4gP57X27+X45JRFiA1pWA9bCVV0vscMnE1mMmmOrLhDvO+6Vq2i9HdQTqR+CS/fAfMqsLvnivnt8joWhOY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 88465C4AF09; Thu, 23 May 2024 21:23:20 +0000 (UTC) Received: from rostedt by gandalf with local (Exim 4.97) (envelope-from ) id 1sAFuw-00000006l8j-1ene; Thu, 23 May 2024 17:24:06 -0400 Message-ID: <20240523212406.254317554@goodmis.org> User-Agent: quilt/0.68 Date: Thu, 23 May 2024 17:23:00 -0400 From: Steven Rostedt To: linux-kernel@vger.kernel.org Cc: Masami Hiramatsu , Mark Rutland , Mathieu Desnoyers , Andrew Morton , Masahiro Yamada , stable@vger.kernel.org Subject: [for-linus][PATCH 2/8] tracefs: Update inode permissions on remount References: <20240523212258.883756004@goodmis.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: "Steven Rostedt (Google)" When a remount happens, if a gid or uid is specified update the inodes to have the same gid and uid. This will allow the simplification of the permissions logic for the dynamically created files and directories. Link: https://lore.kernel.org/linux-trace-kernel/20240523051539.592429986@g= oodmis.org Cc: stable@vger.kernel.org Cc: Masami Hiramatsu Cc: Mark Rutland Cc: Mathieu Desnoyers Cc: Andrew Morton Cc: Masahiro Yamada Fixes: baa23a8d4360d ("tracefs: Reset permissions on remount if permissions= are options") Signed-off-by: Steven Rostedt (Google) --- fs/tracefs/event_inode.c | 17 +++++++++++++---- fs/tracefs/inode.c | 15 ++++++++++++--- 2 files changed, 25 insertions(+), 7 deletions(-) diff --git a/fs/tracefs/event_inode.c b/fs/tracefs/event_inode.c index 55a40a730b10..5dfb1ccd56ea 100644 --- a/fs/tracefs/event_inode.c +++ b/fs/tracefs/event_inode.c @@ -317,20 +317,29 @@ void eventfs_remount(struct tracefs_inode *ti, bool u= pdate_uid, bool update_gid) if (!ei) return; =20 - if (update_uid) + if (update_uid) { ei->attr.mode &=3D ~EVENTFS_SAVE_UID; + ei->attr.uid =3D ti->vfs_inode.i_uid; + } + =20 - if (update_gid) + if (update_gid) { ei->attr.mode &=3D ~EVENTFS_SAVE_GID; + ei->attr.gid =3D ti->vfs_inode.i_gid; + } =20 if (!ei->entry_attrs) return; =20 for (int i =3D 0; i < ei->nr_entries; i++) { - if (update_uid) + if (update_uid) { ei->entry_attrs[i].mode &=3D ~EVENTFS_SAVE_UID; - if (update_gid) + ei->entry_attrs[i].uid =3D ti->vfs_inode.i_uid; + } + if (update_gid) { ei->entry_attrs[i].mode &=3D ~EVENTFS_SAVE_GID; + ei->entry_attrs[i].gid =3D ti->vfs_inode.i_gid; + } } } =20 diff --git a/fs/tracefs/inode.c b/fs/tracefs/inode.c index a827f6a716c4..9252e0d78ea2 100644 --- a/fs/tracefs/inode.c +++ b/fs/tracefs/inode.c @@ -373,12 +373,21 @@ static int tracefs_apply_options(struct super_block *= sb, bool remount) =20 rcu_read_lock(); list_for_each_entry_rcu(ti, &tracefs_inodes, list) { - if (update_uid) + if (update_uid) { ti->flags &=3D ~TRACEFS_UID_PERM_SET; + ti->vfs_inode.i_uid =3D fsi->uid; + } =20 - if (update_gid) + if (update_gid) { ti->flags &=3D ~TRACEFS_GID_PERM_SET; - + ti->vfs_inode.i_gid =3D fsi->gid; + } + + /* + * Note, the above ti->vfs_inode updates are + * used in eventfs_remount() so they must come + * before calling it. + */ if (ti->flags & TRACEFS_EVENT_INODE) eventfs_remount(ti, update_uid, update_gid); } --=20 2.43.0 From nobody Fri Feb 13 16:36:00 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 27090127E37; Thu, 23 May 2024 21:23:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716499401; cv=none; b=UVvCbmKpv9HGpNK80uJZ6bKAYGoSBaMVHBYNXlj4IAq1+qPszqNllQ8QZaVDDAd4GgarCPjlyXO4fV/n3bNkYb1hc/7jjrTXo+q/L2GsP+VeGXb9fIaKpY+zuuhVsKbfVHnGyziN9S2aNk/8wu5j1b7m0sE/HaIUAN9NYLcqaGU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716499401; c=relaxed/simple; bh=bJ2R3MSjdttfi5d4JxJUeNoOGiEyHkNCTslsz8LEmK0=; h=Message-ID:Date:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=kIo3MBB8g4dAPlOLjidyk7HIgWnKDDNF8fhqXBWyska+Urph6wBUfFY36tOLxNKnFXoeonEL+DvRsfkR5afjLpLPiwRimTN8eVyw7zXy6MZHxxTjW+5JWP8bhbWHEefyAmvAASIZKOwke8hwVRRJdbXiDjZByQZKW/SSKTI37sI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id A7BD2C4AF0A; Thu, 23 May 2024 21:23:20 +0000 (UTC) Received: from rostedt by gandalf with local (Exim 4.97) (envelope-from ) id 1sAFuw-00000006l9D-2KmT; Thu, 23 May 2024 17:24:06 -0400 Message-ID: <20240523212406.414851880@goodmis.org> User-Agent: quilt/0.68 Date: Thu, 23 May 2024 17:23:01 -0400 From: Steven Rostedt To: linux-kernel@vger.kernel.org Cc: Masami Hiramatsu , Mark Rutland , Mathieu Desnoyers , Andrew Morton , Masahiro Yamada , stable@vger.kernel.org Subject: [for-linus][PATCH 3/8] eventfs: Update all the eventfs_inodes from the events descriptor References: <20240523212258.883756004@goodmis.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: "Steven Rostedt (Google)" The change to update the permissions of the eventfs_inode had the misconception that using the tracefs_inode would find all the eventfs_inodes that have been updated and reset them on remount. The problem with this approach is that the eventfs_inodes are freed when they are no longer used (basically the reason the eventfs system exists). When they are freed, the updated eventfs_inodes are not reset on a remount because their tracefs_inodes have been freed. Instead, since the events directory eventfs_inode always has a tracefs_inode pointing to it (it is not freed when finished), and the events directory has a link to all its children, have the eventfs_remount() function only operate on the events eventfs_inode and have it descend into its children updating their uid and gids. Link: https://lore.kernel.org/all/CAK7LNARXgaWw3kH9JgrnH4vK6fr8LDkNKf3wq8Nh= MWJrVwJyVQ@mail.gmail.com/ Link: https://lore.kernel.org/linux-trace-kernel/20240523051539.754424703@g= oodmis.org Cc: stable@vger.kernel.org Cc: Masami Hiramatsu Cc: Mark Rutland Cc: Mathieu Desnoyers Cc: Andrew Morton Fixes: baa23a8d4360d ("tracefs: Reset permissions on remount if permissions= are options") Reported-by: Masahiro Yamada Signed-off-by: Steven Rostedt (Google) --- fs/tracefs/event_inode.c | 44 ++++++++++++++++++++++++++++------------ 1 file changed, 31 insertions(+), 13 deletions(-) diff --git a/fs/tracefs/event_inode.c b/fs/tracefs/event_inode.c index 5dfb1ccd56ea..129d0f54ba62 100644 --- a/fs/tracefs/event_inode.c +++ b/fs/tracefs/event_inode.c @@ -305,27 +305,27 @@ static const struct file_operations eventfs_file_oper= ations =3D { .llseek =3D generic_file_llseek, }; =20 -/* - * On a remount of tracefs, if UID or GID options are set, then - * the mount point inode permissions should be used. - * Reset the saved permission flags appropriately. - */ -void eventfs_remount(struct tracefs_inode *ti, bool update_uid, bool updat= e_gid) +static void eventfs_set_attrs(struct eventfs_inode *ei, bool update_uid, k= uid_t uid, + bool update_gid, kgid_t gid, int level) { - struct eventfs_inode *ei =3D ti->private; + struct eventfs_inode *ei_child; =20 - if (!ei) + /* Update events// */ + if (WARN_ON_ONCE(level > 3)) return; =20 if (update_uid) { ei->attr.mode &=3D ~EVENTFS_SAVE_UID; - ei->attr.uid =3D ti->vfs_inode.i_uid; + ei->attr.uid =3D uid; } =20 - if (update_gid) { ei->attr.mode &=3D ~EVENTFS_SAVE_GID; - ei->attr.gid =3D ti->vfs_inode.i_gid; + ei->attr.gid =3D gid; + } + + list_for_each_entry(ei_child, &ei->children, list) { + eventfs_set_attrs(ei_child, update_uid, uid, update_gid, gid, level + 1); } =20 if (!ei->entry_attrs) @@ -334,13 +334,31 @@ void eventfs_remount(struct tracefs_inode *ti, bool u= pdate_uid, bool update_gid) for (int i =3D 0; i < ei->nr_entries; i++) { if (update_uid) { ei->entry_attrs[i].mode &=3D ~EVENTFS_SAVE_UID; - ei->entry_attrs[i].uid =3D ti->vfs_inode.i_uid; + ei->entry_attrs[i].uid =3D uid; } if (update_gid) { ei->entry_attrs[i].mode &=3D ~EVENTFS_SAVE_GID; - ei->entry_attrs[i].gid =3D ti->vfs_inode.i_gid; + ei->entry_attrs[i].gid =3D gid; } } + +} + +/* + * On a remount of tracefs, if UID or GID options are set, then + * the mount point inode permissions should be used. + * Reset the saved permission flags appropriately. + */ +void eventfs_remount(struct tracefs_inode *ti, bool update_uid, bool updat= e_gid) +{ + struct eventfs_inode *ei =3D ti->private; + + /* Only the events directory does the updates */ + if (!ei || !ei->is_events || ei->is_freed) + return; + + eventfs_set_attrs(ei, update_uid, ti->vfs_inode.i_uid, + update_gid, ti->vfs_inode.i_gid, 0); } =20 /* Return the evenfs_inode of the "events" directory */ --=20 2.43.0 From nobody Fri Feb 13 16:36:00 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 501E1128365; Thu, 23 May 2024 21:23:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716499401; cv=none; b=mUjoUCtOZarZHbpKbwfLR9cNLK8/gL600VtBexyZxhFzn9f8aOtIGaEhbiD4YaVIY/sialBMk4fNpDwd2ipEzM9nTzzWFX1bTTQHJ7SASQnSss6tFEHHWb1ziQw8vYRMUVjCivshXzl7HNGiFPipT7G9VT/7wGJFbzDPiK/f7JI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716499401; c=relaxed/simple; bh=1Wy8rfVh+tcDx6TeVrWroMHMwycF9RAXCxOu1SCaAl4=; h=Message-ID:Date:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=eE3HlPPlD3S0DoFqHij/xvwEQoZc6fTJQfo7Es2hRlWC3B79KaCn73rWiwW38yBkPqFuj+hCv6V/nzaWYk9iRUpxJMiGbiMjvngRIjyBURQLyuOe7nrv12oSwQCL+zrz0OpdRXaHbmqzez23NF8FfrOawrq0C9JdqmmrrPnybe4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id E8211C2BD10; Thu, 23 May 2024 21:23:20 +0000 (UTC) Received: from rostedt by gandalf with local (Exim 4.97) (envelope-from ) id 1sAFuw-00000006l9h-308p; Thu, 23 May 2024 17:24:06 -0400 Message-ID: <20240523212406.575903016@goodmis.org> User-Agent: quilt/0.68 Date: Thu, 23 May 2024 17:23:02 -0400 From: Steven Rostedt To: linux-kernel@vger.kernel.org Cc: Masami Hiramatsu , Mark Rutland , Mathieu Desnoyers , Andrew Morton , Masahiro Yamada , stable@vger.kernel.org Subject: [for-linus][PATCH 4/8] tracefs: Clear EVENT_INODE flag in tracefs_drop_inode() References: <20240523212258.883756004@goodmis.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: "Steven Rostedt (Google)" When the inode is being dropped from the dentry, the TRACEFS_EVENT_INODE flag needs to be cleared to prevent a remount from calling eventfs_remount() on the tracefs_inode private data. There's a race between the inode is dropped (and the dentry freed) to where the inode is actually freed. If a remount happens between the two, the eventfs_inode could be accessed after it is freed (only the dentry keeps a ref count on it). Currently the TRACEFS_EVENT_INODE flag is cleared from the dentry iput() function. But this is incorrect, as it is possible that the inode has another reference to it. The flag should only be cleared when the inode is really being dropped and has no more references. That happens in the drop_inode callback of the inode, as that gets called when the last reference of the inode is released. Remove the tracefs_d_iput() function and move its logic to the more appropriate tracefs_drop_inode() callback function. Link: https://lore.kernel.org/linux-trace-kernel/20240523051539.908205106@g= oodmis.org Cc: stable@vger.kernel.org Cc: Masami Hiramatsu Cc: Mark Rutland Cc: Mathieu Desnoyers Cc: Andrew Morton Cc: Masahiro Yamada Fixes: baa23a8d4360d ("tracefs: Reset permissions on remount if permissions= are options") Signed-off-by: Steven Rostedt (Google) --- fs/tracefs/inode.c | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/fs/tracefs/inode.c b/fs/tracefs/inode.c index 9252e0d78ea2..7c29f4afc23d 100644 --- a/fs/tracefs/inode.c +++ b/fs/tracefs/inode.c @@ -426,10 +426,26 @@ static int tracefs_show_options(struct seq_file *m, s= truct dentry *root) return 0; } =20 +static int tracefs_drop_inode(struct inode *inode) +{ + struct tracefs_inode *ti =3D get_tracefs(inode); + + /* + * This inode is being freed and cannot be used for + * eventfs. Clear the flag so that it doesn't call into + * eventfs during the remount flag updates. The eventfs_inode + * gets freed after an RCU cycle, so the content will still + * be safe if the iteration is going on now. + */ + ti->flags &=3D ~TRACEFS_EVENT_INODE; + + return 1; +} + static const struct super_operations tracefs_super_operations =3D { .alloc_inode =3D tracefs_alloc_inode, .free_inode =3D tracefs_free_inode, - .drop_inode =3D generic_delete_inode, + .drop_inode =3D tracefs_drop_inode, .statfs =3D simple_statfs, .show_options =3D tracefs_show_options, }; @@ -455,22 +471,7 @@ static int tracefs_d_revalidate(struct dentry *dentry,= unsigned int flags) return !(ei && ei->is_freed); } =20 -static void tracefs_d_iput(struct dentry *dentry, struct inode *inode) -{ - struct tracefs_inode *ti =3D get_tracefs(inode); - - /* - * This inode is being freed and cannot be used for - * eventfs. Clear the flag so that it doesn't call into - * eventfs during the remount flag updates. The eventfs_inode - * gets freed after an RCU cycle, so the content will still - * be safe if the iteration is going on now. - */ - ti->flags &=3D ~TRACEFS_EVENT_INODE; -} - static const struct dentry_operations tracefs_dentry_operations =3D { - .d_iput =3D tracefs_d_iput, .d_revalidate =3D tracefs_d_revalidate, .d_release =3D tracefs_d_release, }; --=20 2.43.0 From nobody Fri Feb 13 16:36:00 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5023C128366 for ; Thu, 23 May 2024 21:23:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716499401; cv=none; b=s756IR6gBTeJvYYHZ21IfvaorYnhcleHG6T1agkc29t3dZtyCZOFoGFWpzqa5ah3t7vHF0sB5kRvAHDsI5yFqW9ookewl4JAHR3mWcLujedWQPSLF3QPJ2F1JGXLuJgMhMCokL5I4Y4zOzl3+DsBhjgpvD4ZX+HryFDpYrHqcKk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716499401; c=relaxed/simple; bh=+siZ2Hk8ib7KD+12oMbnGGoyuW6XrOeayeGP5/JEG+8=; h=Message-ID:Date:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=qG1Bk7pin0aOeIlvU8mMWKyPVK0AO4iJ8RRp2olavCF7NNEWD7Kw9MGQyfAa53LD4c4aliRrtaRYcaOFc/Rv/nHe7MfI2KWC1Nd9puAxr+RwcuAD1ta8yWqh3jlQEb+V4GjiQGPO2ZPf9FL5N+g3quWynkIlYACEy8qywXuXnI0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 01FC0C32789; Thu, 23 May 2024 21:23:21 +0000 (UTC) Received: from rostedt by gandalf with local (Exim 4.97) (envelope-from ) id 1sAFuw-00000006lAB-3g8s; Thu, 23 May 2024 17:24:06 -0400 Message-ID: <20240523212406.736741267@goodmis.org> User-Agent: quilt/0.68 Date: Thu, 23 May 2024 17:23:03 -0400 From: Steven Rostedt To: linux-kernel@vger.kernel.org Cc: Masami Hiramatsu , Mark Rutland , Mathieu Desnoyers , Andrew Morton , Masahiro Yamada , Linus Torvalds Subject: [for-linus][PATCH 5/8] eventfs: Consolidate the eventfs_inode update in eventfs_get_inode() References: <20240523212258.883756004@goodmis.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: "Steven Rostedt (Google)" To simplify the code, create a eventfs_get_inode() that is used when an eventfs file or directory is created. Have the internal tracefs_inode updated the appropriate flags in this function and update the inode's mode as well. Link: https://lore.kernel.org/lkml/20240522165031.624864160@goodmis.org Cc: Linus Torvalds Cc: Masami Hiramatsu Cc: Mark Rutland Cc: Mathieu Desnoyers Cc: Andrew Morton Signed-off-by: Steven Rostedt (Google) --- fs/tracefs/event_inode.c | 42 ++++++++++++++++++++++------------------ 1 file changed, 23 insertions(+), 19 deletions(-) diff --git a/fs/tracefs/event_inode.c b/fs/tracefs/event_inode.c index 129d0f54ba62..92987b5c8d9d 100644 --- a/fs/tracefs/event_inode.c +++ b/fs/tracefs/event_inode.c @@ -412,6 +412,25 @@ static void update_inode_attr(struct dentry *dentry, s= truct inode *inode, inode->i_gid =3D attr->gid; } =20 +static struct inode *eventfs_get_inode(struct dentry *dentry, struct event= fs_attr *attr, + umode_t mode, struct eventfs_inode *ei) +{ + struct tracefs_inode *ti; + struct inode *inode; + + inode =3D tracefs_get_inode(dentry->d_sb); + if (!inode) + return NULL; + + ti =3D get_tracefs(inode); + ti->private =3D ei; + ti->flags |=3D TRACEFS_EVENT_INODE; + + update_inode_attr(dentry, inode, attr, mode); + + return inode; +} + /** * lookup_file - look up a file in the tracefs filesystem * @parent_ei: Pointer to the eventfs_inode that represents parent of the = file @@ -432,7 +451,6 @@ static struct dentry *lookup_file(struct eventfs_inode = *parent_ei, void *data, const struct file_operations *fop) { - struct tracefs_inode *ti; struct inode *inode; =20 if (!(mode & S_IFMT)) @@ -441,13 +459,11 @@ static struct dentry *lookup_file(struct eventfs_inod= e *parent_ei, if (WARN_ON_ONCE(!S_ISREG(mode))) return ERR_PTR(-EIO); =20 - inode =3D tracefs_get_inode(dentry->d_sb); + /* Only directories have ti->private set to an ei, not files */ + inode =3D eventfs_get_inode(dentry, attr, mode, NULL); if (unlikely(!inode)) return ERR_PTR(-ENOMEM); =20 - /* If the user updated the directory's attributes, use them */ - update_inode_attr(dentry, inode, attr, mode); - inode->i_op =3D &eventfs_file_inode_operations; inode->i_fop =3D fop; inode->i_private =3D data; @@ -455,9 +471,6 @@ static struct dentry *lookup_file(struct eventfs_inode = *parent_ei, /* All files will have the same inode number */ inode->i_ino =3D EVENTFS_FILE_INODE_INO; =20 - ti =3D get_tracefs(inode); - ti->flags |=3D TRACEFS_EVENT_INODE; - // Files have their parent's ei as their fsdata dentry->d_fsdata =3D get_ei(parent_ei); =20 @@ -477,28 +490,19 @@ static struct dentry *lookup_file(struct eventfs_inod= e *parent_ei, static struct dentry *lookup_dir_entry(struct dentry *dentry, struct eventfs_inode *pei, struct eventfs_inode *ei) { - struct tracefs_inode *ti; struct inode *inode; + umode_t mode =3D S_IFDIR | S_IRWXU | S_IRUGO | S_IXUGO; =20 - inode =3D tracefs_get_inode(dentry->d_sb); + inode =3D eventfs_get_inode(dentry, &ei->attr, mode, ei); if (unlikely(!inode)) return ERR_PTR(-ENOMEM); =20 - /* If the user updated the directory's attributes, use them */ - update_inode_attr(dentry, inode, &ei->attr, - S_IFDIR | S_IRWXU | S_IRUGO | S_IXUGO); - inode->i_op =3D &eventfs_dir_inode_operations; inode->i_fop =3D &eventfs_file_operations; =20 /* All directories will have the same inode number */ inode->i_ino =3D eventfs_dir_ino(ei); =20 - ti =3D get_tracefs(inode); - ti->flags |=3D TRACEFS_EVENT_INODE; - /* Only directories have ti->private set to an ei, not files */ - ti->private =3D ei; - dentry->d_fsdata =3D get_ei(ei); =20 d_add(dentry, inode); --=20 2.43.0 From nobody Fri Feb 13 16:36:00 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9E07C12838F for ; Thu, 23 May 2024 21:23:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716499401; cv=none; b=Ph2gUP8XV6bFM0FI9KSU5Y/npPuIxE5uapsw/gBYydQex6t+wTdUswsrf4sl5CRoB7Sdv53Ls36NOCtx7k62JSv7DZ27wz+R6GjcOzlfg1A6vXJZ8+eNIcIpfJPqNKg19wQkR67dfVtmfwmueEuC0UuZkj9eHH3zLj5r/YQe93g= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716499401; c=relaxed/simple; bh=krRDAMZ6xTgFMUtD/RVVOB1jD17MwEJGX9YoC2sERuQ=; h=Message-ID:Date:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=C3MTLLUYQnCHwY8EIvqyw7W7j3HA4jDFk2aPiOaE6tm3IYGPwElglXd8LjJ9JPfdjS9pZ9enk12HpaeWxrwuHYXNZuqEJmyui00aSR7YxtTqOQkZKSv+5R33nkhGVO5wvcBouI/gtXLj6stYaawTrf56NC/EKcD5nOc0IG2jWYY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 496FBC4AF4D; Thu, 23 May 2024 21:23:21 +0000 (UTC) Received: from rostedt by gandalf with local (Exim 4.97) (envelope-from ) id 1sAFux-00000006lAf-08iV; Thu, 23 May 2024 17:24:07 -0400 Message-ID: <20240523212406.897870866@goodmis.org> User-Agent: quilt/0.68 Date: Thu, 23 May 2024 17:23:04 -0400 From: Steven Rostedt To: linux-kernel@vger.kernel.org Cc: Masami Hiramatsu , Mark Rutland , Mathieu Desnoyers , Andrew Morton , Masahiro Yamada , Linus Torvalds Subject: [for-linus][PATCH 6/8] eventfs: Remove getattr and permission callbacks References: <20240523212258.883756004@goodmis.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: "Steven Rostedt (Google)" Now that inodes have their permissions updated on remount, the only other places to update the inode permissions are when they are created and in the setattr callback. The getattr and permission callbacks are not needed as the inodes should already be set at their proper settings. Remove the callbacks, as it not only simplifies the code, but also allows more flexibility to fix the inconsistencies with various corner cases (like changing the permission of an instance directory). Link: https://lore.kernel.org/lkml/20240522165031.782066021@goodmis.org Cc: Linus Torvalds Cc: Masami Hiramatsu Cc: Mark Rutland Cc: Mathieu Desnoyers Cc: Andrew Morton Signed-off-by: Steven Rostedt (Google) --- fs/tracefs/event_inode.c | 40 ---------------------------------------- 1 file changed, 40 deletions(-) diff --git a/fs/tracefs/event_inode.c b/fs/tracefs/event_inode.c index 92987b5c8d9d..f32c6f7eb29f 100644 --- a/fs/tracefs/event_inode.c +++ b/fs/tracefs/event_inode.c @@ -250,49 +250,9 @@ static void update_events_attr(struct eventfs_inode *e= i, struct super_block *sb) ei->attr.gid =3D parent->i_gid; } =20 -static void set_top_events_ownership(struct inode *inode) -{ - struct tracefs_inode *ti =3D get_tracefs(inode); - struct eventfs_inode *ei =3D ti->private; - - /* The top events directory doesn't get automatically updated */ - if (!ei || !ei->is_events) - return; - - update_events_attr(ei, inode->i_sb); - - if (!(ei->attr.mode & EVENTFS_SAVE_UID)) - inode->i_uid =3D ei->attr.uid; - - if (!(ei->attr.mode & EVENTFS_SAVE_GID)) - inode->i_gid =3D ei->attr.gid; -} - -static int eventfs_get_attr(struct mnt_idmap *idmap, - const struct path *path, struct kstat *stat, - u32 request_mask, unsigned int flags) -{ - struct dentry *dentry =3D path->dentry; - struct inode *inode =3D d_backing_inode(dentry); - - set_top_events_ownership(inode); - - generic_fillattr(idmap, request_mask, inode, stat); - return 0; -} - -static int eventfs_permission(struct mnt_idmap *idmap, - struct inode *inode, int mask) -{ - set_top_events_ownership(inode); - return generic_permission(idmap, inode, mask); -} - static const struct inode_operations eventfs_dir_inode_operations =3D { .lookup =3D eventfs_root_lookup, .setattr =3D eventfs_set_attr, - .getattr =3D eventfs_get_attr, - .permission =3D eventfs_permission, }; =20 static const struct inode_operations eventfs_file_inode_operations =3D { --=20 2.43.0 From nobody Fri Feb 13 16:36:00 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 64EB912836E for ; Thu, 23 May 2024 21:23:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716499401; cv=none; b=aRQu8WE64kNUyYbX5gzS7OOvefXSlXYZMnJzaKQmLkwPbMrqW/HcMOoreILZDVGn6npAndndF+QnJATANr53QB+E1qjJ7lGYy1zOvb61SkfMsHPqjACTfWEVLaY+gvhve/doGjgcMEnkVJeZ/5ZlMbmE+PdC2tMLHWPuUVYBFUk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716499401; c=relaxed/simple; bh=b2rFVhUNdELSgple//yRUVKiuIFpt3ZKpCvrhw8yifE=; h=Message-ID:Date:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=tKqqqBcj5HIRxK3dwxnYciAYDpOhMu3WKeAdhdpiopfvDpVP3w6h5cUKBrM3wKbBqDq4chXRDhCFNYp5Txe7gIopMfRVm2l1WEfPqN9tCKKmMX5KJFOIyeCPxs83c77Q3MH/vWiQntH6BagdHwYxrju7WzIp3Zwn6rH8axFcr4E= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 47848C4AF1D; Thu, 23 May 2024 21:23:21 +0000 (UTC) Received: from rostedt by gandalf with local (Exim 4.97) (envelope-from ) id 1sAFux-00000006lB9-0nme; Thu, 23 May 2024 17:24:07 -0400 Message-ID: <20240523212407.052080067@goodmis.org> User-Agent: quilt/0.68 Date: Thu, 23 May 2024 17:23:05 -0400 From: Steven Rostedt To: linux-kernel@vger.kernel.org Cc: Masami Hiramatsu , Mark Rutland , Mathieu Desnoyers , Andrew Morton , Masahiro Yamada , Linus Torvalds Subject: [for-linus][PATCH 7/8] eventfs: Cleanup permissions in creation of inodes References: <20240523212258.883756004@goodmis.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: "Steven Rostedt (Google)" The permissions being set during the creation of the inodes was updating eventfs_inode attributes as well. Those attributes should only be touched by the setattr or remount operations, not during the creation of inodes. The eventfs_inode attributes should only be used to set the inodes and should not be modified during the inode creation. Simplify the code and fix the situation by: 1) Removing the eventfs_find_events() and doing a simple lookup for the events descriptor in eventfs_get_inode() 2) Remove update_events_attr() as the attributes should only be used to update the inode and should not be modified here. 3) Add update_inode_attr() that uses the attributes to determine what the inode permissions should be. 4) As the parent_inode of the eventfs_root_inode structure is no longer needed, remove it. Now on creation, the inode gets the proper permissions without causing side effects to the ei->attr field. Link: https://lore.kernel.org/lkml/20240522165031.944088388@goodmis.org Cc: Linus Torvalds Cc: Masami Hiramatsu Cc: Mark Rutland Cc: Mathieu Desnoyers Cc: Andrew Morton Signed-off-by: Steven Rostedt (Google) --- fs/tracefs/event_inode.c | 90 ++++++++++------------------------------ 1 file changed, 23 insertions(+), 67 deletions(-) diff --git a/fs/tracefs/event_inode.c b/fs/tracefs/event_inode.c index f32c6f7eb29f..320e49056d3a 100644 --- a/fs/tracefs/event_inode.c +++ b/fs/tracefs/event_inode.c @@ -37,7 +37,6 @@ static DEFINE_MUTEX(eventfs_mutex); =20 struct eventfs_root_inode { struct eventfs_inode ei; - struct inode *parent_inode; struct dentry *events_dir; }; =20 @@ -229,27 +228,6 @@ static int eventfs_set_attr(struct mnt_idmap *idmap, s= truct dentry *dentry, return ret; } =20 -static void update_events_attr(struct eventfs_inode *ei, struct super_bloc= k *sb) -{ - struct eventfs_root_inode *rei; - struct inode *parent; - - rei =3D get_root_inode(ei); - - /* Use the parent inode permissions unless root set its permissions */ - parent =3D rei->parent_inode; - - if (rei->ei.attr.mode & EVENTFS_SAVE_UID) - ei->attr.uid =3D rei->ei.attr.uid; - else - ei->attr.uid =3D parent->i_uid; - - if (rei->ei.attr.mode & EVENTFS_SAVE_GID) - ei->attr.gid =3D rei->ei.attr.gid; - else - ei->attr.gid =3D parent->i_gid; -} - static const struct inode_operations eventfs_dir_inode_operations =3D { .lookup =3D eventfs_root_lookup, .setattr =3D eventfs_set_attr, @@ -321,60 +299,30 @@ void eventfs_remount(struct tracefs_inode *ti, bool u= pdate_uid, bool update_gid) update_gid, ti->vfs_inode.i_gid, 0); } =20 -/* Return the evenfs_inode of the "events" directory */ -static struct eventfs_inode *eventfs_find_events(struct dentry *dentry) +static void update_inode_attr(struct inode *inode, umode_t mode, + struct eventfs_attr *attr, struct eventfs_root_inode *rei) { - struct eventfs_inode *ei; - - do { - // The parent is stable because we do not do renames - dentry =3D dentry->d_parent; - // ... and directories always have d_fsdata - ei =3D dentry->d_fsdata; - - /* - * If the ei is being freed, the ownership of the children - * doesn't matter. - */ - if (ei->is_freed) - return NULL; - - // Walk upwards until you find the events inode - } while (!ei->is_events); - - update_events_attr(ei, dentry->d_sb); - - return ei; -} - -static void update_inode_attr(struct dentry *dentry, struct inode *inode, - struct eventfs_attr *attr, umode_t mode) -{ - struct eventfs_inode *events_ei =3D eventfs_find_events(dentry); - - if (!events_ei) - return; - - inode->i_mode =3D mode; - inode->i_uid =3D events_ei->attr.uid; - inode->i_gid =3D events_ei->attr.gid; - - if (!attr) - return; - - if (attr->mode & EVENTFS_SAVE_MODE) + if (attr && attr->mode & EVENTFS_SAVE_MODE) inode->i_mode =3D attr->mode & EVENTFS_MODE_MASK; + else + inode->i_mode =3D mode; =20 - if (attr->mode & EVENTFS_SAVE_UID) + if (attr && attr->mode & EVENTFS_SAVE_UID) inode->i_uid =3D attr->uid; + else + inode->i_uid =3D rei->ei.attr.uid; =20 - if (attr->mode & EVENTFS_SAVE_GID) + if (attr && attr->mode & EVENTFS_SAVE_GID) inode->i_gid =3D attr->gid; + else + inode->i_gid =3D rei->ei.attr.gid; } =20 static struct inode *eventfs_get_inode(struct dentry *dentry, struct event= fs_attr *attr, umode_t mode, struct eventfs_inode *ei) { + struct eventfs_root_inode *rei; + struct eventfs_inode *pei; struct tracefs_inode *ti; struct inode *inode; =20 @@ -386,7 +334,16 @@ static struct inode *eventfs_get_inode(struct dentry *= dentry, struct eventfs_att ti->private =3D ei; ti->flags |=3D TRACEFS_EVENT_INODE; =20 - update_inode_attr(dentry, inode, attr, mode); + /* Find the top dentry that holds the "events" directory */ + do { + dentry =3D dentry->d_parent; + /* Directories always have d_fsdata */ + pei =3D dentry->d_fsdata; + } while (!pei->is_events); + + rei =3D get_root_inode(pei); + + update_inode_attr(inode, mode, attr, rei); =20 return inode; } @@ -823,7 +780,6 @@ struct eventfs_inode *eventfs_create_events_dir(const c= har *name, struct dentry // Note: we have a ref to the dentry from tracefs_start_creating() rei =3D get_root_inode(ei); rei->events_dir =3D dentry; - rei->parent_inode =3D d_inode(dentry->d_sb->s_root); =20 ei->entries =3D entries; ei->nr_entries =3D size; --=20 2.43.0 From nobody Fri Feb 13 16:36:00 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 90474128386 for ; Thu, 23 May 2024 21:23:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716499401; cv=none; b=PYxrCJYT2ilrro4wJ7SF2O5ooFkMKMJ9AJ9qrEEIkmC+P++g6rn8Rhg3SxJvm4Gkr/R6zI2gnBbFgnTLF6s/xRPnYW3CIKNP6YCLV3ypOpk4fiZ1NEkgMCooEkydBGz2/F/fBs3vfbPy8hCRzU5h6S3qtMVwit9mcLxk53KFOvA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716499401; c=relaxed/simple; bh=85e7mQH4jt2WvuzuVD0ye023imHegS2wclDhhyvGB8A=; h=Message-ID:Date:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=IFu6DCOPgjmfiQCPzLwG2fyeN2ywGz2plO+tlOes1kYetY2ajeM7esVOp3u4xjkuipaSAj6ynA+DPOCM3GpUQGeQjvzdyf6A8Qxj2M0uRgeBKez1IgHeP31lgektriMF8yieA9wUdjYPX9nWt4Fou+b1573JX9QMI3Z70uc1cpw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7AD2CC4AF0F; Thu, 23 May 2024 21:23:21 +0000 (UTC) Received: from rostedt by gandalf with local (Exim 4.97) (envelope-from ) id 1sAFux-00000006lBd-1U2P; Thu, 23 May 2024 17:24:07 -0400 Message-ID: <20240523212407.210966757@goodmis.org> User-Agent: quilt/0.68 Date: Thu, 23 May 2024 17:23:06 -0400 From: Steven Rostedt To: linux-kernel@vger.kernel.org Cc: Masami Hiramatsu , Mark Rutland , Mathieu Desnoyers , Andrew Morton , Masahiro Yamada , Linus Torvalds Subject: [for-linus][PATCH 8/8] eventfs: Do not use attributes for events directory References: <20240523212258.883756004@goodmis.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: "Steven Rostedt (Google)" 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/20240522165032.104981011@goodmis.org Cc: Linus Torvalds Cc: Masami Hiramatsu Cc: Mark Rutland Cc: Mathieu Desnoyers Cc: Andrew Morton Signed-off-by: Steven Rostedt (Google) --- fs/tracefs/event_inode.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/fs/tracefs/event_inode.c b/fs/tracefs/event_inode.c index 320e49056d3a..5d88c184f0fc 100644 --- a/fs/tracefs/event_inode.c +++ b/fs/tracefs/event_inode.c @@ -210,7 +210,9 @@ static int eventfs_set_attr(struct mnt_idmap *idmap, st= ruct dentry *dentry, * determined by the parent directory. */ if (dentry->d_inode->i_mode & S_IFDIR) { - update_attr(&ei->attr, iattr); + /* Just use the inode permissions for the events directory */ + if (!ei->is_events) + update_attr(&ei->attr, iattr); =20 } else { name =3D dentry->d_name.name; @@ -789,14 +791,12 @@ struct eventfs_inode *eventfs_create_events_dir(const= char *name, struct dentry uid =3D d_inode(dentry->d_parent)->i_uid; gid =3D d_inode(dentry->d_parent)->i_gid; =20 - ei->attr.uid =3D uid; - ei->attr.gid =3D gid; - /* - * When the "events" directory is created, it takes on the - * permissions of its parent. But can be reset on remount. + * The ei->attr will be used as the default values for the + * files beneath this directory. */ - ei->attr.mode |=3D EVENTFS_SAVE_UID | EVENTFS_SAVE_GID; + ei->attr.uid =3D uid; + ei->attr.gid =3D gid; =20 INIT_LIST_HEAD(&ei->children); INIT_LIST_HEAD(&ei->list); --=20 2.43.0