From patchwork Tue Feb 6 12:09:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Rostedt X-Patchwork-Id: 197431 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:168b:b0:106:860b:bbdd with SMTP id ma11csp1503625dyb; Tue, 6 Feb 2024 04:31:29 -0800 (PST) X-Google-Smtp-Source: AGHT+IGvKXzJJAcqPW1dnEIZqb/GUEEZqTRpU9o+XRAg7sjJfUkHU1t9Jv0L9qE11f/Rbx9f/sgG X-Received: by 2002:a05:6a20:3ca2:b0:19e:4f18:b953 with SMTP id b34-20020a056a203ca200b0019e4f18b953mr1243174pzj.16.1707222689795; Tue, 06 Feb 2024 04:31:29 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707222689; cv=pass; d=google.com; s=arc-20160816; b=YKiTLCyTnJ/RdsNn/YNuwuwcsI8pFlVP3Q0UC3dmDQ0JFL4ESqDhKSVeZStif7+sh9 ie64Nola7VITdhTZqzQRQtcElVrlZz7Qx0ynrJocpNU98bBiG8p/pzrPfSLq5WVt6oU7 zDoLUc6N8Gk7VdQoTe40lJJkFb2oOQho9WIyFIHgztymUzGjjghX8YjaS7lSkWPIA3sA UY/47b0kzQ298uqxbw0UK7r6Eq02FjDO1xJDJ9Lg+q/3OdWAQlmuSgS6sQZ24DzGEO/6 itvY4RQiodzlTOOV82DrPQ8f2ehKOshNt9sa29ZjZ3tY9qMVyG20biCXrk/13CSNBd6m nSww== 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=Dsu+LcnJPUhPz5tbtdFla/KW2/YazHKd2WJZ6bKnGpw=; fh=LDmP2gU+Y0UBarqmhNFJZ0bJNCof8YrlQJoOHQenSco=; b=GaCRu5rf4YDZb6lmvAUy/B8YULj+ERuBgRqMjG266Cc1eFw+t0Sbu3DD4JVD6HGEnb 87yiLVEQeGvtFJdGdPidMSKttB/U5SPjpt+E0iA9Uft6XoVqjvibhFJsNpdptvRoPI2D IBSjgPWFCskfo6Dvx5fvS5Pm1qPrinz0Ec/9CN392GWggLPlXnuKT52HVsI4OVV6kDtQ LS4Ad9A74hYBpYTpoez5byoIqSohmCgjznXYxIssI+3Vk0Vq84MPb4pyGKJWA4eQC1kI 2Y3y+PwvF0Lr5gq77rB68rIswn60FtENKAQRUhyIIqOsVB1HSKqBffKPmGXQgiNn/4ri TD8g==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel+bounces-54903-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-54903-ouuuleilei=gmail.com@vger.kernel.org" X-Forwarded-Encrypted: i=1; AJvYcCVImyC3KizFbvfBPAFbtllikaQF/A9UHHyHNmiIppgPa6p5aAi94oh4Dl1+0r7x+W1hKlcv5JQjJsuyOj8gI2b29jDBhg== Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id q21-20020a170902c9d500b001d9607d5cc5si1568515pld.244.2024.02.06.04.31.29 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Feb 2024 04:31:29 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-54903-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel+bounces-54903-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-54903-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 44E38B21FA5 for ; Tue, 6 Feb 2024 12:23:07 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 40FFC14831F; Tue, 6 Feb 2024 12:09:33 +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 2716F1386A8; 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=1707221363; cv=none; b=EOtQi83F3qgbvKzZQal4n20UQbfWOkvxzcAkwMhPlkFpvl9oaQ3BSdmhSZGv1QpSyhQao7w5KVSyYx6nwxks7pRPDEZfSWSAo0fcwjff0D4DcHkRnWKt14E5LlADXnQHtY66Qd9/AybVVhcA7cwM6lid8XXG83SIG9+1m4Y6/gk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707221363; c=relaxed/simple; bh=bXsar5R8Z/J/4GcAeyNBhLTiQlp64pDEtOV6uUPgCcU=; h=Message-ID:Date:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=iwDdkAlUQr+Eu5VlJxUOYeuy9Wb+7XFlpGkbIBoXCmiPQidqM8K1Hj770LTw2s0MU8O1qBrwalrbKWykQIUOfq7n9g7acVkQhTvZOCM8NA6bSyhsjIcuhf/VZ4hl21EqFfqdxro817piU3auD8oajToz3PzNBhdwU6Olytw1Yww= 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 C479FC433C7; Tue, 6 Feb 2024 12:09:22 +0000 (UTC) Received: from rostedt by gandalf with local (Exim 4.97) (envelope-from ) id 1rXKGt-00000006bFq-0z3I; Tue, 06 Feb 2024 07:09:51 -0500 Message-ID: <20240206120951.095364893@rostedt.homelinux.com> User-Agent: quilt/0.67 Date: Tue, 06 Feb 2024 07:09:34 -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 , Josef Bacik Subject: [v6.6][PATCH 29/57] eventfs: Make sure that parent->d_inode is locked in creating files/dirs 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: 1790152739122060965 X-GMAIL-MSGID: 1790152739122060965 From: "Steven Rostedt (Google)" Since the locking of the parent->d_inode has been moved outside the creation of the files and directories (as it use to be locked via a conditional), add a WARN_ON_ONCE() to the case that it's not locked. Link: https://lkml.kernel.org/r/20231121231112.853962542@goodmis.org Cc: Masami Hiramatsu Cc: Mark Rutland Cc: Andrew Morton Reviewed-by: Josef Bacik Signed-off-by: Steven Rostedt (Google) (cherry picked from commit f49f950c217bfb40f11662bab39cb388d41e4cfb) --- fs/tracefs/event_inode.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/fs/tracefs/event_inode.c b/fs/tracefs/event_inode.c index 590e8176449b..0b90869fd805 100644 --- a/fs/tracefs/event_inode.c +++ b/fs/tracefs/event_inode.c @@ -327,6 +327,8 @@ create_file_dentry(struct eventfs_inode *ei, int idx, struct dentry **e_dentry = &ei->d_children[idx]; struct dentry *dentry; + WARN_ON_ONCE(!inode_is_locked(parent->d_inode)); + mutex_lock(&eventfs_mutex); if (ei->is_freed) { mutex_unlock(&eventfs_mutex); @@ -430,6 +432,8 @@ create_dir_dentry(struct eventfs_inode *pei, struct eventfs_inode *ei, { struct dentry *dentry = NULL; + WARN_ON_ONCE(!inode_is_locked(parent->d_inode)); + mutex_lock(&eventfs_mutex); if (pei->is_freed || ei->is_freed) { mutex_unlock(&eventfs_mutex);