From patchwork Wed Jan 31 04:06:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Rostedt X-Patchwork-Id: 194483 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2087:b0:106:209c:c626 with SMTP id gs7csp1659835dyb; Tue, 30 Jan 2024 20:06:14 -0800 (PST) X-Google-Smtp-Source: AGHT+IH//yPHiVzUednOHjZAUHJhGkkjW9EO4SDtnHyqYjyLJ+4JwqLVR+qMyjJPJ0A5WzThDo5p X-Received: by 2002:a05:6358:2489:b0:178:94bc:7302 with SMTP id m9-20020a056358248900b0017894bc7302mr263531rwc.4.1706673974127; Tue, 30 Jan 2024 20:06:14 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706673974; cv=pass; d=google.com; s=arc-20160816; b=imqYFfPKTDPKibbi97e2oP5zoYGXrsXLolXVNDOXwOyTqpERBhlc4ZzLnaOHdyNhkb 0yEECEjFJHK83/JhD6My3fNZndCC35hK8B0BCCnRCv1Z0sYTznnoMEf7TKTaot3cSaQb fAtb6cVTjJvDZoWZ4ozQLObAI5RMgM2GNWW4xZVfu3bVzo2RWLIQ2fcfACMJN6xHuMeL w3TldLawanKHIygGAmR6Wo0Je1oz0mD5UuSOIA0DXWWgV0xAIjeyoN3izBZ+iqaLv39v 4nZtymzorGLmUmPJPf9aGsrhJ9IiQIhgWvMPTdeuuudlb/CMI/SWXfkyplcCtzlHRwWK DK1w== 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=Gogn/MUnYw5hFYDuq1kucYfTq0mImjGnk6sTn5MqHZA=; fh=r72FEMXuMOswpBLXmbCF/kauugm3NahMcjTXCq3nDBU=; b=bl7BEsrZmdydrrOG/IixkisvxlFg/ROIC/CS8ET2TKXsKb6WYZvnKPGZbAi/XCR8a9 p1kxSbjXkUFie+7SiZ2EpWGnbWQAqjncTEes09WVsNdlFgaVGFJKh87yAYKQNORBzx7C btzJ1yK13nJMMKSAI1GmkI22kSb70UHc2Skq5rxteFUefa287AWs5TpzuDeIsCeXH8jp wztJkmG6QmoCefyD9IBJhFFzcpVFZQrfegiRp5GgZYEQHoSF/TMvuEjhx302DGWINm1E kMnwPKd2m0IAluWlt0YKH59iFBEoGM2F1Uz/7Ur4foR7qBWZsY9TvXF26R/lkPsO8d+F EGDw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel+bounces-45730-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-45730-ouuuleilei=gmail.com@vger.kernel.org" X-Forwarded-Encrypted: i=1; AJvYcCXYDcYPXBUfC2Niyyf2xoK0xBWYvF0ivIeQ+iOBAHlmj62Z5hp4Jz02bq5MaTfgyme0MOv2BZxWD9KoOn6tdzAQo+Wi1w== Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id o25-20020a637e59000000b005cfb2c44526si8818734pgn.862.2024.01.30.20.06.13 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Jan 2024 20:06:14 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-45730-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-45730-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-45730-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 D6493288EC1 for ; Wed, 31 Jan 2024 04:06:13 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 41EA317BDB; Wed, 31 Jan 2024 04:06:02 +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 BC02D14A92; Wed, 31 Jan 2024 04:06:00 +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=1706673960; cv=none; b=tmoRJdDH/nbNWZdPCR6UCE8Ga2ZV72fGl0/KI1s+mwvgn7vjNj7ZzddWp6KzjsDAHjr/DohxKkpS6mBPjIgTj2nZIXb6T7Ywg7Ceg6fkLJrd9Ps/6kkXNO7Onky3W24NHiR/wG9niHOqo8dT/Wp5UUupGqqrgaf47QRu5WnCwOc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706673960; c=relaxed/simple; bh=E3NIQxoA8SMIzX9BXY7UqTvrppGF6a/PTIVPf1MjfcA=; h=Date:From:To:Cc:Subject:Message-ID:MIME-Version:Content-Type; b=ejUotKHDzaT4vfHA1AnNBwwRJT0xNu3TJXTV9/b/TC74kF6G9jaS0HKWAIxr9MGL0XpR/kGEkJTBG18LzG70y/+w1VHdckXXmOyKOzjGUYfp/5XgI90Fe148xEl94hH9+uNb48LWm/yJCVxkaI6mCIZTNg/LXe4mz/Nda9Z9BW4= 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 7553BC43399; Wed, 31 Jan 2024 04:05:59 +0000 (UTC) Date: Tue, 30 Jan 2024 23:06:12 -0500 From: Steven Rostedt To: LKML , Linux Trace Kernel Cc: Linus Torvalds , Al Viro , Masami Hiramatsu , Mathieu Desnoyers Subject: [PATCH v2] tracefs: Zero out the tracefs_inode when allocating it Message-ID: <20240130230612.377a1933@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: 1789577369045011039 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) --- Changes since v1: https://lore.kernel.org/all/20240130151737.6e97ae00@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); }