From nobody Tue Dec 23 14:20:48 2025 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 ACBE8BA2C; Fri, 2 Feb 2024 02:30:04 +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=1706841004; cv=none; b=HSYF7+cYrKo4w3n0RthivfVzaJNt2caOc3sB2i6YFjZcA8me2vjVd0BBMj7KzBgY2NMuCs2KWpt7Z9Jr6Pk7PHHQciCxbN01jP4RWQnEBYLPXzA5yJABeVGLMx9iLXtba12SACsJDjLMCrMXExCgJ9lr3o5+bGij6sZpbmBBrT8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706841004; c=relaxed/simple; bh=3adZE3XRvsxSdhBsQIqBjy7xLEJW/dok2uD8qBYZMss=; h=Message-ID:Date:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=J5pt1w7VAeyOqlSkP+/m+pCL9FNQPkwscLJ5mX3tK3L5SPuul7TyKkuJ+tgGofwHb+Qe9HVaWcXx5PCnx6eVd5lEkYpyX+fhlWdWTZyI9X+M69+aOT7sjjrS1KJSts4PK00k/ZAC2CMn+t2CjU7ah+oWoOCZThE+bWe9kEduC2g= 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 52AEFC433A6; Fri, 2 Feb 2024 02:30:04 +0000 (UTC) Received: from rostedt by gandalf with local (Exim 4.97) (envelope-from ) id 1rVjJu-00000005k6e-1YVm; Thu, 01 Feb 2024 21:30:22 -0500 Message-ID: <20240202023022.238836873@goodmis.org> User-Agent: quilt/0.67 Date: Thu, 01 Feb 2024 21:30:01 -0500 From: Steven Rostedt To: linux-kernel@vger.kernel.org Cc: Masami Hiramatsu , Mark Rutland , Mathieu Desnoyers , Andrew Morton , stable@vger.kernel.org, Christian Brauner , Al Viro , Ajay Kaher , Greg Kroah-Hartman , kernel test robot , Linus Torvalds Subject: [for-linus][PATCH 02/13] tracefs: Zero out the tracefs_inode when allocating it References: <20240202022959.515961549@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)" 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 to access to ti->private. The assignment still needs to be made before the dentry is instantiated. Link: https://lore.kernel.org/linux-trace-kernel/20240131185512.315825944@g= oodmis.org Cc: stable@vger.kernel.org Cc: Masami Hiramatsu Cc: Mark Rutland Cc: Mathieu Desnoyers Cc: Christian Brauner Cc: Al Viro Cc: Ajay Kaher Cc: Greg Kroah-Hartman Fixes: 5790b1fb3d672 ("eventfs: Remove eventfs_file and just use eventfs_in= ode") Reported-by: kernel test robot Closes: https://lore.kernel.org/oe-lkp/202401291043.e62e89dc-oliver.sang@in= tel.com Suggested-by: Linus Torvalds Signed-off-by: Steven Rostedt (Google) --- fs/tracefs/inode.c | 6 ++++-- fs/tracefs/internal.h | 3 ++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/fs/tracefs/inode.c b/fs/tracefs/inode.c index e1b172c0e091..888e42087847 100644 --- a/fs/tracefs/inode.c +++ b/fs/tracefs/inode.c @@ -38,8 +38,6 @@ static struct inode *tracefs_alloc_inode(struct super_blo= ck *sb) if (!ti) return NULL; =20 - ti->flags =3D 0; - return &ti->vfs_inode; } =20 @@ -779,7 +777,11 @@ static void init_once(void *foo) { struct tracefs_inode *ti =3D (struct tracefs_inode *) foo; =20 + /* inode_init_once() calls memset() on the vfs_inode portion */ inode_init_once(&ti->vfs_inode); + + /* Zero out the rest */ + memset_after(ti, 0, vfs_inode); } =20 static int __init tracefs_init(void) diff --git a/fs/tracefs/internal.h b/fs/tracefs/internal.h index 91c2bf0b91d9..7d84349ade87 100644 --- a/fs/tracefs/internal.h +++ b/fs/tracefs/internal.h @@ -11,9 +11,10 @@ enum { }; =20 struct tracefs_inode { + struct inode vfs_inode; + /* The below gets initialized with memset_after(ti, 0, vfs_inode) */ unsigned long flags; void *private; - struct inode vfs_inode; }; =20 /* --=20 2.43.0