From patchwork Sun Feb 4 01:16:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Rostedt X-Patchwork-Id: 196391 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:168b:b0:106:860b:bbdd with SMTP id ma11csp147992dyb; Sat, 3 Feb 2024 17:22:05 -0800 (PST) X-Google-Smtp-Source: AGHT+IEaIGk9YPUAmNIJaBBTCb+1yGR2OGhIZpKOF0mx6WUpnAwUi5rBpCwgnajFqCPEtF+L1Wu4 X-Received: by 2002:a92:ce4f:0:b0:363:c305:1032 with SMTP id a15-20020a92ce4f000000b00363c3051032mr1266796ilr.19.1707009725546; Sat, 03 Feb 2024 17:22:05 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707009725; cv=pass; d=google.com; s=arc-20160816; b=VtfzVYC9+7Sbr3FdoHRNqz8jcdGa3Yf9Cab/E9OJEesjnaV8wpE6t4exNXrv4t1pgA RFosAxC6J3Ca3lYjVYfPG271HHtXuskbAqZOcOQoySgaHrSdGbdN9ubAAtCgskbPN+2I rOUy9ZD4ieFs4TZVheD0uCyz2eGkD+zBsjlosqcQ0SIONffbTKI+u07GBjLPwrmWHS7a m7WkWlBi9E0jB/VL7R9+bvHz7wWqR4NUzHDT55bMNqYd0g1wn0/a2g/Ru1bdZ0JvO3ff bnFA3ulcSQu7uPJ5SCt75FCkHnq5+UmQM1h1QzP8cmxtmbZ5DUnSls9TcypJa7Vphpy+ +vgQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :references:subject:cc:to:from:date:user-agent:message-id; bh=9a6mlKxBAB+nG1o/FkoaS+LuUNdfuJ0NPVKe/J3/wfQ=; fh=iHEdDgS3o4pcBBJDecpITgeTklN0PS7zqd498i0z4q4=; b=klbKmPePZWhgn+tZZaynNztn+Tkb8sRah5uwDLG/oUcmZwWjRl27tMdSOqgyDuy2VQ UsXlveQYUWdYPY0OLN3fZzaLT7uJ0lZtrKWVXvLCPjM+MBAivs9gcS0nt9i3N2Abdx4u I4bKXrVjpP4pFGq93zQ1/13sk/ZCDHpJh+SdwrcQA9r0047K4ITfs0QfqRK4ozZhSdwN NMJLpwl2raAwN4RVpK0oU0I4tyXAqRD1iGrcuHNwvTwBzmBvWJ6fx/ph3wEoCKKH5CKZ dNgZdfzh38MmAWPZ0p1AK8X5IPhDSoF1cM0B8hisSGxEkYsEXBj3fU6dPaYgZNMJp5c1 opEw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel+bounces-51350-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-51350-ouuuleilei=gmail.com@vger.kernel.org" X-Forwarded-Encrypted: i=1; AJvYcCVTlwyBEvU1lYm28U/Yz4K6SgKFpOUfJLfXmF/tW5U8pM1v31bItRiT7UNc8NtOP+exskHLWHQOPPsg780WCMY6mgsZeg== Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id l19-20020a635b53000000b005d8e38097ffsi3749578pgm.715.2024.02.03.17.22.05 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 03 Feb 2024 17:22:05 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-51350-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel+bounces-51350-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-51350-ouuuleilei=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 50380285BAC for ; Sun, 4 Feb 2024 01:22:05 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 06D3E171AC; Sun, 4 Feb 2024 01:18:11 +0000 (UTC) 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 4DA1AB654; Sun, 4 Feb 2024 01:18:07 +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=1707009487; cv=none; b=Na4nM/pjeQwVasU9jqD2rinphziaZZ8/Ed+Yia5ChwDZ9u9Yarmz4qs34PNsh6TrDZpVH55FWgt4R4gE6hjr8zRRYxAfHHVRHmVhaHoJkgNGexCqOrCAP/tPl/UlwFPW/iad8ByIXRdYd4vYB91sXXVgG66gaUvs1bSA+9MEjFg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707009487; c=relaxed/simple; bh=3adZE3XRvsxSdhBsQIqBjy7xLEJW/dok2uD8qBYZMss=; h=Message-ID:Date:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=GInzBFKRQE0+viDe0f/tRVUB9NcdtQpJizeH2zONviJRj1+2feSJZY3NLUfAjVdzAxKQTbePJ3+kLn9hDNMoc6lCaK455mT/QMSsX2wFwWHgf98iIViywwbnO3NCVgjGnAbb7RYxVJ7ARn48YqllFx4/EE7i3UiiQFEmzBTm3sg= 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 7DA0CC4AF75; Sun, 4 Feb 2024 01:18:06 +0000 (UTC) Received: from rostedt by gandalf with local (Exim 4.97) (envelope-from ) id 1rWR9R-00000006Oqs-0cRt; Sat, 03 Feb 2024 20:18:29 -0500 Message-ID: <20240204011829.008666210@goodmis.org> User-Agent: quilt/0.67 Date: Sat, 03 Feb 2024 20:16:28 -0500 From: Steven Rostedt To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Linus Torvalds , Greg Kroah-Hartman , Sasha Levin , Masami Hiramatsu , Mark Rutland , Mathieu Desnoyers , Andrew Morton , Christian Brauner , Al Viro , Ajay Kaher , kernel test robot Subject: [v6.7][PATCH 13/23] tracefs: Zero out the tracefs_inode when allocating it References: <20240204011615.703023949@goodmis.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789929429957581686 X-GMAIL-MSGID: 1789929429957581686 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@goodmis.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_inode") Reported-by: kernel test robot Closes: https://lore.kernel.org/oe-lkp/202401291043.e62e89dc-oliver.sang@intel.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_block *sb) if (!ti) return NULL; - ti->flags = 0; - return &ti->vfs_inode; } @@ -779,7 +777,11 @@ static void init_once(void *foo) { struct tracefs_inode *ti = (struct tracefs_inode *) foo; + /* 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); } 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 { }; 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; }; /*