Skip to contentSkip to conversation

eventfs: Check for NULL ef in eventfs_set_attr()

PATCH In review Steven Rostedt 3 participants 4 messages Nov 12, 2023 – Nov 13, 2023

Subsystems (2)
lore
Share & tools
lore

Steven Rostedt

author maintainer
#0 lore raw

PATCH 1/1 eventfs: Check for NULL ef in eventfs_set_attr()

From: "Steven Rostedt (Google)" <[email protected]>

The top level events directory dentry does not have a d_fsdata set to a eventfs_file pointer. This dentry is still passed to eventfs_set_attr(). It can not assume that the d_fsdata is set. Check for that.

Fixes 9aaee3eebc91 ("eventfs: Save ownership and mode")

---

Note: This only affects 6.6 as the code in 6.7 here was rewritten.
I tested 6.7 and it does not have this bug.

 fs/tracefs/event_inode.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
fs/tracefs/event_inode.c +2 -2
index 5fcfb634fec2..efbdc47c74dc 100644
@@ -113,14 +113,14 @@ static int eventfs_set_attr(struct mnt_idmap *idmap, struct dentry *dentry,
 
 	mutex_lock(&eventfs_mutex);
 	ef = dentry->d_fsdata;
-	if (ef->is_freed) {
+	if (ef && ef->is_freed) {
 		/* Do not allow changes if the event is about to be removed. */
 		mutex_unlock(&eventfs_mutex);
 		return -ENODEV;
 	}
 
 	ret = simple_setattr(idmap, dentry, iattr);
-	if (!ret)
+	if (!ret && ef)
 		update_attr(ef, iattr);
 	mutex_unlock(&eventfs_mutex);
 	return ret;
Signature · 1 line
2.42.0
#1 lore raw
FYI: kernel test robot notices the stable kernel rule is not satisfied.

Hi,

Thanks for your patch.

FYI: kernel test robot notices the stable kernel rule is not satisfied.

The check is based on https://www.kernel.org/doc/html/latest/process/stable-kernel-rules.html#option-1

Rule: add the tag "Cc: [email protected]" in the sign-off area to have the patch automatically included in the stable tree.
Subject: [v6.6][PATCH] eventfs: Check for NULL ef in eventfs_set_attr()

Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
author maintainer
#2 lore raw
In reply to Steven Rostedt
Quoted 11 lines · On Sun, 12 Nov 2023 12:18:17 -0500 Steven Rostedt <[email protected]> wrote:

From: "Steven Rostedt (Google)" <[email protected]>

The top level events directory dentry does not have a d_fsdata set to a eventfs_file pointer. This dentry is still passed to eventfs_set_attr(). It can not assume that the d_fsdata is set. Check for that.

Fixes 9aaee3eebc91 ("eventfs: Save ownership and mode")

I guess I should have included the "Cc: stable" tag. This is a bit different patch since it's not going to land in upstream, as the bug doesn't exist there.

I can resend if needed.

-- Steve

Tested-by on v1 1/1
#3 lore raw
In reply to Steven Rostedt
Quoted 8 lines · On Sonntag, 12. November 2023 18:18:17 CET Steven Rostedt wrote:

From: "Steven Rostedt (Google)" <[email protected]>

The top level events directory dentry does not have a d_fsdata set to a eventfs_file pointer. This dentry is still passed to eventfs_set_attr(). It can not assume that the d_fsdata is set. Check for that.

Link:
https://lore.kernel.org/all/[email protected]/

Thanks you Steven,

this works like a charm.

Quoted 16 lines
Fixes 9aaee3eebc91 ("eventfs: Save ownership and mode")

---

Note: This only affects 6.6 as the code in 6.7 here was rewritten.
I tested 6.7 and it does not have this bug.

 fs/tracefs/event_inode.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
fs/tracefs/event_inode.c +0 -0
index 5fcfb634fec2..efbdc47c74dc 100644

fs/tracefs/event_inode.c static int eventfs_set_attr(struct mnt_idmap *idmap, · line 118

Quoted 7 lines
fs/tracefs/event_inode.c +1 -1
@@ -113,14 +113,14 @@ static int eventfs_set_attr(struct mnt_idmap *idmap,
 struct dentry *dentry,
 
 	mutex_lock(&eventfs_mutex);
 	ef = dentry->d_fsdata;
-	if (ef->is_freed) {
+	if (ef && ef->is_freed) {
 		/* Do not allow changes if the event is about to be 

removed. */

Quoted 10 lines
fs/tracefs/event_inode.c +1 -1
 		mutex_unlock(&eventfs_mutex);
 		return -ENODEV;
 	}
 
 	ret = simple_setattr(idmap, dentry, iattr);
-	if (!ret)
+	if (!ret && ef)
 		update_attr(ef, iattr);
 	mutex_unlock(&eventfs_mutex);

return ret;

Signature · 4 lines
Milian Wolff | [email protected] | Senior Software Engineer
KDAB (Deutschland) GmbH, a KDAB Group company
Tel: +49-30-521325470
KDAB - The Qt, C++ and OpenGL Experts