From: "Steven Rostedt (Google)" <rost...@goodmis.org> eventfs uses the tracefs_inode and assumes that it's already initialized to zero. That is, it doesn't set fields to zero (like ti->private) after getting its tracefs_inode. This causes bugs due to stale values.
Just initialize the entire structure to zero on allocation so there isn't any more surprises. This is a partial fix for accessing ti->private. The assignment still needs to be made before the dentry is instantiated. Cc: sta...@vger.kernel.org Fixes: 5790b1fb3d672 ("eventfs: Remove eventfs_file and just use eventfs_inode") Reported-by: kernel test robot <oliver.s...@intel.com> Closes: https://lore.kernel.org/oe-lkp/202401291043.e62e89dc-oliver.s...@intel.com Suggested-by: Linus Torvalds <torva...@linux-foundation.org> Signed-off-by: Steven Rostedt (Google) <rost...@goodmis.org> --- Changes since v1: https://lore.kernel.org/all/20240130151737.6e97a...@gandalf.local.home/ - I didn't realize the slab had a constructor which prohibits __GFP_ZERO. Just use memset() in the constructor. I noticed the WARN_ON_ONCE that was triggering early in the boot process. fs/tracefs/inode.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/fs/tracefs/inode.c b/fs/tracefs/inode.c index e1b172c0e091..636180d45c62 100644 --- a/fs/tracefs/inode.c +++ b/fs/tracefs/inode.c @@ -38,8 +38,6 @@ static struct inode *tracefs_alloc_inode(struct super_block *sb) if (!ti) return NULL; - ti->flags = 0; - return &ti->vfs_inode; } @@ -779,6 +777,7 @@ static void init_once(void *foo) { struct tracefs_inode *ti = (struct tracefs_inode *) foo; + memset(ti, 0, sizeof(*ti)); inode_init_once(&ti->vfs_inode); } -- 2.43.0