From patchwork Tue Jan 30 20:17:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Rostedt X-Patchwork-Id: 194311 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2087:b0:106:209c:c626 with SMTP id gs7csp1473729dyb; Tue, 30 Jan 2024 12:17:45 -0800 (PST) X-Google-Smtp-Source: AGHT+IH+FPX/Zv8+4Z7iq03618vyuiTfYIDjYNNcuINEd8vKA9D9EPyk2M2F0eBxk8HbflPYHX1Q X-Received: by 2002:a17:903:2288:b0:1d8:ab46:c07 with SMTP id b8-20020a170903228800b001d8ab460c07mr11375143plh.25.1706645864947; Tue, 30 Jan 2024 12:17:44 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706645864; cv=pass; d=google.com; s=arc-20160816; b=Nfhq7ktgmWGCbB+3uknpstfBDcIxJEQi2DUzjvQIluQFQpvwkXPajUj6UD4SBvfuWt h5gJN++GjswDdgMrJw9s3lk/VPNKWU/8eQXu8OWQp5uO3Zgy9L7Ekl4OsUtQF1t10MwP y/3KXNop2mqHdo23zSeJObRYyKy6QtX+FwaTk6vITlbXE+3IpmVoQYAF0No38Q1ID75v JLYaUodMCu6fM9DkMXcdy5elTDlsf8V4lzqWThkhL7ZTyUMWufHG1aQk6gF1G66R8hNT 7LoPYO4iMJVJMuO5IaJLpckuCP3a9CVcQr0bK2/oI+9BuaaXEr3sv/9SiihMkZ8gVkQy oolw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:subject:cc:to:from :date; bh=6Hx4YE11qcSHfPaAbeLIu0vEMfCD8Zrl2XmgQIjdayk=; fh=pkZuECmCuiv8WzFlkti3JUBX5Rmz901QhZm88L2MtOI=; b=Zlxp6WaZI+zN70dVoaMUEOvukxjQ/nrBfRteo1p+9FNTF88XGDAdFUhu1JL1mp0zEA 6ffTXsIADB4mfaLZneFDcSHLLLEUQR99QqcAMFXO+bEo0Cf/wP90c9m6uZwqB7Xb7bNQ v/ZsN3vDVvTQ6zg03fjxqpFBpRbvSgxvp6P/p6hhYv+0RZacRse3SpB3WolO4oM6NVOW WiRh4I5n9sYQXPomZ3O2QNNq+xOy1DfTzlXm4g2kVAlgWT16QLCVHOzKA2U/pWazCJvg e81FHzVTec+R6gw2NIy+9M3rmGL/I71lznzBQY3lac4J97BcjW14sJ0TU0toJNStwlty 8vJA== ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel+bounces-45249-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-45249-ouuuleilei=gmail.com@vger.kernel.org" Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id bs131-20020a632889000000b005cdbeb8228dsi7681976pgb.433.2024.01.30.12.17.44 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Jan 2024 12:17:44 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-45249-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-45249-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-45249-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 7D9D528A070 for ; Tue, 30 Jan 2024 20:17:44 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3D4FE71B5B; Tue, 30 Jan 2024 20:17:28 +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 B75CE69E1E; Tue, 30 Jan 2024 20:17:26 +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=1706645846; cv=none; b=GYnQWJLTDB/LH/cLaTNtV6yArH1SuBPVnRO9ATvyxrPEwtYLYhbK41mkFpTiTwWmACTlweYf2AljMbSHkvHYW8r/7WYgxqLs0ShCDGQVNg5As86bGJjoSv+T92pWxnYAQbI0Wb6pqeWQkUQ4o5Bg9/5EmQr2CfhBChe1fvqNWpc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706645846; c=relaxed/simple; bh=zdUltoJAz28yULsd7S70/VZtc01SbxyEdOQCLH49gNE=; h=Date:From:To:Cc:Subject:Message-ID:MIME-Version:Content-Type; b=lkAy9EaHe5aJznb//oyUD5VOIoyAuZFWHWDGpdfBwCICMjqf1GicZyzioQH/dsPx2n/bzKv5tctQPOwr27ltyoeOITsFR0XhjuLm+s2FvMiqRjLjgzaDg5XiP4vtTQzRhKtmyvf26HgdW7XOQx9oXWgbBMGDG8da3VPEiOPwKBc= 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 7B67AC433F1; Tue, 30 Jan 2024 20:17:25 +0000 (UTC) Date: Tue, 30 Jan 2024 15:17:37 -0500 From: Steven Rostedt To: LKML , Linux Trace Kernel Cc: Linus Torvalds , Masami Hiramatsu , Mathieu Desnoyers , Christian Brauner , Al Viro Subject: [PATCH] tracefs: Zero out the tracefs_inode when allocating it Message-ID: <20240130151737.6e97ae00@gandalf.local.home> X-Mailer: Claws Mail 3.19.1 (GTK+ 2.24.33; x86_64-pc-linux-gnu) 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: 1789547894268472466 X-GMAIL-MSGID: 1789547894268472466 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 for accessing ti->private. The assignment still needs to be made before the dentry is instantiated. Cc: stable@vger.kernel.org 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 | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/fs/tracefs/inode.c b/fs/tracefs/inode.c index e1b172c0e091..f7cde61ff2fc 100644 --- a/fs/tracefs/inode.c +++ b/fs/tracefs/inode.c @@ -34,12 +34,10 @@ static struct inode *tracefs_alloc_inode(struct super_block *sb) { struct tracefs_inode *ti; - ti = kmem_cache_alloc(tracefs_inode_cachep, GFP_KERNEL); + ti = kmem_cache_alloc(tracefs_inode_cachep, GFP_KERNEL | __GFP_ZERO); if (!ti) return NULL; - ti->flags = 0; - return &ti->vfs_inode; }