From mboxrd@z Thu Jan 1 00:00:00 1970 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 D91E644367; Tue, 28 Nov 2023 21:07:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="p0QQzIz8" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 85605C433CA; Tue, 28 Nov 2023 21:07:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1701205651; bh=NZTUjgALiPLwrAMWsEPQcegs3qq/KyxR2XaZBz8ElsM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=p0QQzIz8FpEYGTh3oBhUStNoisS9QBKSOPc1SqP60S4hzZeS4I3/f+mgwHvwvY5yR PsFAg6L7lZgYUdnSTUor5O1Uqe/ktA2R2G/nVgGmQqbOMv2c4RZhOUCCqgJVCKeuX2 GM4o5o30gg6FyFXNj071XRzD+IykrO3xeJuvXwktY78oBbTfXvFa3fERkXSRRltbqp uCq/K/E1/99yzRpBb0mVHxUCOVEHEvwQk8G3BbpBDnlqub5oCFhbDnAxAr0Zu6tRLr xBt8GrKCGlrO0nJV34O4EJlQrE2JADAFsd8U3qywfKW/8ZxBxdeFIGauaBSUc1jMyk QRtd+VeBRZKyw== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: "Steven Rostedt (Google)" , Masami Hiramatsu , Mark Rutland , Andrew Morton , Josef Bacik , Sasha Levin , linux-trace-kernel@vger.kernel.org Subject: [PATCH AUTOSEL 6.6 35/40] eventfs: Do not allow NULL parent to eventfs_start_creating() Date: Tue, 28 Nov 2023 16:05:41 -0500 Message-ID: <20231128210615.875085-35-sashal@kernel.org> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231128210615.875085-1-sashal@kernel.org> References: <20231128210615.875085-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore X-stable-base: Linux 6.6.3 Content-Transfer-Encoding: 8bit From: "Steven Rostedt (Google)" [ Upstream commit fc4561226feaad5fcdcb55646c348d77b8ee69c5 ] The eventfs directory is dynamically created via the meta data supplied by the existing trace events. All files and directories in eventfs has a parent. Do not allow NULL to be passed into eventfs_start_creating() as the parent because that should never happen. Warn if it does. Link: https://lkml.kernel.org/r/20231121231112.693841807@goodmis.org Cc: Masami Hiramatsu Cc: Mark Rutland Cc: Andrew Morton Reviewed-by: Josef Bacik Signed-off-by: Steven Rostedt (Google) Signed-off-by: Sasha Levin --- fs/tracefs/inode.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/fs/tracefs/inode.c b/fs/tracefs/inode.c index 891653ba9cf35..0292c6a2bed9f 100644 --- a/fs/tracefs/inode.c +++ b/fs/tracefs/inode.c @@ -509,20 +509,15 @@ struct dentry *eventfs_start_creating(const char *name, struct dentry *parent) struct dentry *dentry; int error; + /* Must always have a parent. */ + if (WARN_ON_ONCE(!parent)) + return ERR_PTR(-EINVAL); + error = simple_pin_fs(&trace_fs_type, &tracefs_mount, &tracefs_mount_count); if (error) return ERR_PTR(error); - /* - * If the parent is not specified, we create it in the root. - * We need the root dentry to do this, which is in the super - * block. A pointer to that is in the struct vfsmount that we - * have around. - */ - if (!parent) - parent = tracefs_mount->mnt_root; - if (unlikely(IS_DEADDIR(parent->d_inode))) dentry = ERR_PTR(-ENOENT); else -- 2.42.0