From patchwork Tue Feb 6 12:09:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Rostedt X-Patchwork-Id: 197389 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:168b:b0:106:860b:bbdd with SMTP id ma11csp1496817dyb; Tue, 6 Feb 2024 04:18:57 -0800 (PST) X-Google-Smtp-Source: AGHT+IHs5QkauF8YVQraXArb8G83o8ZQaAHqM23DBbeapbSo0eRTEKuWOhWFebv15ndMArudHEi2 X-Received: by 2002:ac8:44d4:0:b0:42a:cdb9:5d9f with SMTP id b20-20020ac844d4000000b0042acdb95d9fmr1917380qto.17.1707221937373; Tue, 06 Feb 2024 04:18:57 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707221937; cv=pass; d=google.com; s=arc-20160816; b=HsbQF6tLuGyUAG6ccNP1qbIq3zO+UuTVPSGCBNJCDj7mjhci2zV2mu8wAr77xdSMmX A4VnuKmWyIKZlewMOubZZgJL94oF7cFJ6P40qTjQrzT3rov08ShH13civBbrpnEJA9dJ xOv+JIfFfOQtrIjVP4jTBdhbYXMCvFsu7H+dCzRCZFGuTeyTcU8blkANWC0EySMvQWBB ChoFOZXVoAf5HLcj68IVVO0eanLjugSc8n8vNfGwAKFniaAPSvirPVFR1WTLvgKonRLm 4/T6oGxisdA/Us1+BOBLcqs0HvW2fO1NaU3s6hSTXy5plzmgnIEUb11gC8VzCeLD2PJ8 +mBg== 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=ZlGoeyKLS0nVE4T8xfdj7NnUNORmtQA9/juv1ILReAQ=; fh=zz0Se07kAtH2vw7RhkVStRGlxv+1orb3A9VCOgyerrQ=; b=o8PR5HQXyPtHPHtaLqv5CjQbAhs6Wy5WtRvNFjdbZDBZ+bozalYHbC9N4vGN44rjbt vPDQYX2bT2T6+q4awxeWZXppqH0LxYz3qdZs/pK8Fo/6VSbiva5k0edOY58qBjpBVBq0 8fw7S9l5OfQUH699gqW9LLpwK/ckGXhdg/+K7sb1KNfcd1uriHCKyVCLPf73ZkkNMppC apAzm8qw2XwEUgvc+QeCUjxBnxrP89ASyaXgXqMKMIDs1ZLOvZrDMvaDU7nery23U693 FEbrXf62W+ssPTlRR94COJEtbS/ioPBiWZ9yS323aBw5Zvm53R/D8KmLRuxeRl2+QoiH 0QQw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel+bounces-54887-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-54887-ouuuleilei=gmail.com@vger.kernel.org" X-Forwarded-Encrypted: i=1; AJvYcCVI4/0sSo15nvYfFuk66E3kSCHlQ5eU8S3dx3/XwtWPQVP9R+SblXag96xfB2mV319kMur3UxStR1hanJ/M46OzNvfSrg== Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id b9-20020ac85bc9000000b0042c0b21c031si2228967qtb.183.2024.02.06.04.18.57 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Feb 2024 04:18:57 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-54887-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel+bounces-54887-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-54887-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 25F261C216E1 for ; Tue, 6 Feb 2024 12:18:57 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 43F6B1386D6; Tue, 6 Feb 2024 12:09:26 +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 5AD8F135A49; Tue, 6 Feb 2024 12:09:20 +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=1707221360; cv=none; b=gqWOfjL7NhsNP8hYNCXR9rwmmBI76v5TKWVYX6uBiEPpZyrZMoMLMdwav1w89AqpsKFI9slXiluAfYajuzu14ih2jdWtfO7n1UyegZhUcLsTGVwLouKCP4qCK8lht+1yF0Sn8Kmtgwb4AT1plXX+8b4sYGYoqnQBp1zpBt1eqAo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707221360; c=relaxed/simple; bh=ag23ZLNHvKwtbUtFEFGHSFqm7C64xgRkm1HvLw4xCCI=; h=Message-ID:Date:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=ud4DNtBHsIUPXjWVUDE3IdsvGNTccqYyZaIuYAZWjjiDv/T07Ee6vNp3CQtwFvbnM2+SNYQeJQFISeHnGy4kpnHPwewbl6Jn7PdURJ0+6YN/V+1faMuYSvbVqqq80l2FeScdOpoJvzksNTNLe3C/eZc+rexYnkK93L/YRRCzGmE= 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 0A394C433C7; Tue, 6 Feb 2024 12:09:20 +0000 (UTC) Received: from rostedt by gandalf with local (Exim 4.97) (envelope-from ) id 1rXKGq-00000006b7K-1zWt; Tue, 06 Feb 2024 07:09:48 -0500 Message-ID: <20240206120948.331907337@rostedt.homelinux.com> User-Agent: quilt/0.67 Date: Tue, 06 Feb 2024 07:09:17 -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 Subject: [v6.6][PATCH 12/57] eventfs: Fix WARN_ON() in create_file_dentry() References: <20240206120905.570408983@rostedt.homelinux.com> 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: 1790151950018602370 X-GMAIL-MSGID: 1790151950018602370 From: "Steven Rostedt (Google)" As the comment right above a WARN_ON() in create_file_dentry() states: * Note, with the mutex held, the e_dentry cannot have content * and the ei->is_freed be true at the same time. But the WARN_ON() only has: WARN_ON_ONCE(ei->is_free); Where to match the comment (and what it should actually do) is: dentry = *e_dentry; WARN_ON_ONCE(dentry && ei->is_free) Also in that case, set dentry to NULL (although it should never happen). Link: https://lore.kernel.org/linux-trace-kernel/20231024123628.62b88755@gandalf.local.home Cc: Masami Hiramatsu Cc: Mark Rutland Fixes: 5790b1fb3d672 ("eventfs: Remove eventfs_file and just use eventfs_inode") Signed-off-by: Steven Rostedt (Google) (cherry picked from commit a9de4eb15ad430fe45747c211e367da745a90093) --- fs/tracefs/event_inode.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/fs/tracefs/event_inode.c b/fs/tracefs/event_inode.c index 09ab93357957..4d2da7480e5f 100644 --- a/fs/tracefs/event_inode.c +++ b/fs/tracefs/event_inode.c @@ -264,8 +264,9 @@ create_file_dentry(struct eventfs_inode *ei, struct dentry **e_dentry, * Note, with the mutex held, the e_dentry cannot have content * and the ei->is_freed be true at the same time. */ - WARN_ON_ONCE(ei->is_freed); dentry = *e_dentry; + if (WARN_ON_ONCE(dentry && ei->is_freed)) + dentry = NULL; /* The lookup does not need to up the dentry refcount */ if (dentry && !lookup) dget(dentry);