From patchwork Tue Feb 6 12:09:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Rostedt X-Patchwork-Id: 197400 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:168b:b0:106:860b:bbdd with SMTP id ma11csp1498868dyb; Tue, 6 Feb 2024 04:22:39 -0800 (PST) X-Google-Smtp-Source: AGHT+IFcceqs9b+FK/2xvbz5a6A13J0gbamfO7AIMWlpBhIZUXznqvzl6nbGkQzeTdaTdPgrdoWX X-Received: by 2002:a05:6808:d52:b0:3bf:e5ad:8eed with SMTP id w18-20020a0568080d5200b003bfe5ad8eedmr1202376oik.24.1707222159679; Tue, 06 Feb 2024 04:22:39 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707222159; cv=pass; d=google.com; s=arc-20160816; b=Nz5/kYef16DWvYoCtq/jFxtUpVp9IBjm16BzhW4zr4UYDjh9kVWNNun1l9f/NylNYR J+HM60qLLjcYwC2Hc2xhfQxiDnZxvQpvuE+VU/TOPOE+yhHYWyQrt/pcy5p1UxlRdTU0 5STs6gPYUL3iT+P8fbP2R9BqYGR4vYsc2NmYJO0FPH6+nZCeb7+1d6tOMY06+kkpXoUl ZZo+66rrmFlkpfIi9GirAc2ftt/wwEBBTPFQhbBLcPjzGCv3rtJYH85GlNT4FHFlr77P VZstzIGgLOBchOBsOsX5BT0cIoqTExi0R5lT53sRYVjsaedZVT2YuX/SSYMrgrCEvo5H goWA== 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=oHIE+QhcfaEk3owANw1ceP5hrYjvQW+yTWtSbLfxGbM=; fh=XVvSBTmH9USg0MkWY6ZbCcDws9rFdYq851AqmX8/LLw=; b=F45Y+d95GsysSY3xa8XF7hIP8xuQdgCw/TX3GYonbw+9o2shpbBHTlFjeVsHvuvzLY wkaJ0BoUjnTkvrboBnWgNI2UfxgYpW5r3elbX2tlMT/csTRP29Np+UfL42jzwqSaAkUT AN2ZkRG5G1y2RqRr9HkCHuXk1B4rtlV0AYQbYr0Xqoe3rDOI1gz76y117jV03xolGlUU Kzbz2DXXm4Dq5I+qSp61U7m/i+CZN/e5eUiUlAVmbZYPJUQfPqYriM6AjQLVRYRrC73/ 2A78Yl7CeF4wjHEhZ1wRvKm6gYfFL2yQMVCbWPEsIvXnWcLWfdTuEuIns5lgqrWELZRp hFEA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel+bounces-54901-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-54901-ouuuleilei=gmail.com@vger.kernel.org" X-Forwarded-Encrypted: i=1; AJvYcCXw6OQhBcufaoLyGnS5m+Qs9Vaxb7SUb9Egz35kCjS6Uhw09VLcVrS1uoBI5giTVF6X6WlybxlBZrnmbVKlH5qhINRjAw== Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id u12-20020a05622a010c00b0042c3a87c09esi192325qtw.162.2024.02.06.04.22.39 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Feb 2024 04:22:39 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-54901-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-54901-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-54901-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 685491C239D4 for ; Tue, 6 Feb 2024 12:22:39 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 66EFD145350; Tue, 6 Feb 2024 12:09:32 +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 72662137C5C; Tue, 6 Feb 2024 12:09:22 +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=1707221362; cv=none; b=ppSRaLASj5elmipnamstQanNqnqFDpgUrJ5AQlwnhR5gj1Vj8hRCopzLwfnit2FVKSblBhjn1YUF3T8HSuFUhXG843lrIuXONn9RD4Za1nZRvQGd+S1FtTkCROc8pRe+qGWiYPBqAqpDys/ZY7OKWDBrBa1Mrfg4NIR2khaHwio= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707221362; c=relaxed/simple; bh=zEAElJsFmiyF2k5GDTno69bAq8vWad8f06dz1WGJBYo=; h=Message-ID:Date:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=KOcGJJgj7tn1KzqiUiFauouZc/8OC8t1HczsTXMinbrj0MyNiWx/ut/23cjL0FRPczquUHTot1eOtEHeXb1Nkh9qMqPIvfVpeL1bgaTRuDwO20velV+kS5Nql5f77YG4AJ/HDX/RV+nmvfz5LfYAkcBt2Vt7Z+a4bCacs7bcOT0= 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 236CAC433B2; Tue, 6 Feb 2024 12:09:22 +0000 (UTC) Received: from rostedt by gandalf with local (Exim 4.97) (envelope-from ) id 1rXKGs-00000006bDq-2TH9; Tue, 06 Feb 2024 07:09:50 -0500 Message-ID: <20240206120950.446963304@rostedt.homelinux.com> User-Agent: quilt/0.67 Date: Tue, 06 Feb 2024 07:09:30 -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 , Naresh Kamboju , Linux Kernel Functional Testing Subject: [v6.6][PATCH 25/57] eventfs: Do not invalidate dentry in create_file/dir_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: 1790152183079930393 X-GMAIL-MSGID: 1790152183079930393 From: "Steven Rostedt (Google)" With the call to simple_recursive_removal() on the entire eventfs sub system when the directory is removed, it performs the d_invalidate on all the dentries when it is removed. There's no need to do clean ups when a dentry is being created while the directory is being deleted. As dentries are cleaned up by the simpler_recursive_removal(), trying to do d_invalidate() in these functions will cause the dentry to be invalidated twice, and crash the kernel. Link: https://lore.kernel.org/all/20231116123016.140576-1-naresh.kamboju@linaro.org/ Link: https://lkml.kernel.org/r/20231120235154.422970988@goodmis.org Cc: Masami Hiramatsu Cc: Andrew Morton Fixes: 407c6726ca71 ("eventfs: Use simple_recursive_removal() to clean up dentries") Reported-by: Mark Rutland Reported-by: Naresh Kamboju Reported-by: Linux Kernel Functional Testing Signed-off-by: Steven Rostedt (Google) (cherry picked from commit 71cade82f2b553a74d046c015c986f2df165696f) --- fs/tracefs/event_inode.c | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/fs/tracefs/event_inode.c b/fs/tracefs/event_inode.c index f239b2b507a4..3eb6c622a74d 100644 --- a/fs/tracefs/event_inode.c +++ b/fs/tracefs/event_inode.c @@ -326,7 +326,6 @@ create_file_dentry(struct eventfs_inode *ei, int idx, struct eventfs_attr *attr = NULL; struct dentry **e_dentry = &ei->d_children[idx]; struct dentry *dentry; - bool invalidate = false; mutex_lock(&eventfs_mutex); if (ei->is_freed) { @@ -389,17 +388,14 @@ create_file_dentry(struct eventfs_inode *ei, int idx, * Otherwise it means two dentries exist with the same name. */ WARN_ON_ONCE(!ei->is_freed); - invalidate = true; + dentry = NULL; } mutex_unlock(&eventfs_mutex); - if (invalidate) - d_invalidate(dentry); - - if (lookup || invalidate) + if (lookup) dput(dentry); - return invalidate ? NULL : dentry; + return dentry; } /** @@ -439,7 +435,6 @@ static struct dentry * create_dir_dentry(struct eventfs_inode *pei, struct eventfs_inode *ei, struct dentry *parent, bool lookup) { - bool invalidate = false; struct dentry *dentry = NULL; mutex_lock(&eventfs_mutex); @@ -495,16 +490,14 @@ create_dir_dentry(struct eventfs_inode *pei, struct eventfs_inode *ei, * Otherwise it means two dentries exist with the same name. */ WARN_ON_ONCE(!ei->is_freed); - invalidate = true; + dentry = NULL; } mutex_unlock(&eventfs_mutex); - if (invalidate) - d_invalidate(dentry); - if (lookup || invalidate) + if (lookup) dput(dentry); - return invalidate ? NULL : dentry; + return dentry; } /**