From patchwork Tue Feb 6 12:09:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Rostedt X-Patchwork-Id: 197404 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:168b:b0:106:860b:bbdd with SMTP id ma11csp1499342dyb; Tue, 6 Feb 2024 04:23:36 -0800 (PST) X-Google-Smtp-Source: AGHT+IGFEeZxao0Ko/ssJTkPFGsz8kXQGeLNrFYXsRZNnsfdjXf7vhHKEhh7Z0lMydoFo4sHonGb X-Received: by 2002:a05:6214:224d:b0:68c:9649:e2fb with SMTP id c13-20020a056214224d00b0068c9649e2fbmr2152319qvc.62.1707222216238; Tue, 06 Feb 2024 04:23:36 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707222216; cv=pass; d=google.com; s=arc-20160816; b=mLhBtidRfMixSogtuNvsIBEqZQ6Hf0eL3DfaYsSWs02LuYY5sNDBsCuOHUr0/uvl5B BRhgPxzxCIoBsQYI+uXp6fozxWb1twMNAyr+idIFdom5t90ibxVOF5sFMv+34m+ajL7E 34OriLjDnNOQgL3H+BWLTOiyST4WNoOJ9kO99t/q5wAm4vm6OC/9+OTlJ4DU5aCxTvoZ 10KM58t8y848AwiIXqfJNQ3wzLCVVyRZ4nl/FqsxNzuh/XlHvbxzlHxuOmLYomIMAs3G Jw9zxP97BoBoRa1hWt2EgD/pF0kupdUhiF7IuGAhF5YWdVGhtNFV4iAks+J9MgfgIYW4 3nXQ== 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=kt+Wx6rLiZ+dqZAOKpCt4s0UO7Nz6IeAXI0rrIUssT4=; fh=CJSBC+JyjrofGJCw5iO3QSJ6l+DzVbxtu+lcQK5SZuE=; b=IHvb0PYC0npujcxJRK9rv3/txpKa7TVeY1D5zCFZSU8yDQGtvgdTpcLkuJu398pZcc LsKSwD0VE7cRMM0xV9uL1M/IV1OE9A9eRehKKVPy+aPPtPCk7EM/g9fl28e7drHi4wyJ i5hvL1HUte91TAi7DeTEtD7c8SJ+Wr+gy/g1MwJYy5/I4imornFnmaXujRr5d9262F6G e+mJDtDLrDmU2zDrGQAYAm2ySHbmBV47SWA+AYQZ04ugY0rtpmotzHeqY4bdd3lmO5ZI mbjr+W0XJsuKFh5aFU5nVNV6TrMrXFQ+Y0Hq/Q6ujU0A0HYRBm2UJlSPF+XQsoxraQrR lMFw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel+bounces-54904-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-54904-ouuuleilei=gmail.com@vger.kernel.org" X-Forwarded-Encrypted: i=1; AJvYcCUXRpUTUOfuEBLQdfkjZkp2MXZlAOdP2BQTiNlKfOCNT/az9pnH3TkGZUI3J5qFneS1nHOdq4/bg/IHRX23unOwFpNBgw== Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id jo19-20020a056214501300b0068cafc7c1bdsi2054956qvb.237.2024.02.06.04.23.36 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Feb 2024 04:23:36 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-54904-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-54904-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-54904-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 0CB011C238A9 for ; Tue, 6 Feb 2024 12:23:36 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1C9D1133434; Tue, 6 Feb 2024 12:09:34 +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 EA6AD1384B1; 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=ggMc1hE9s3NFUWRBl15kA3ZW65H9sdirQecUcWyGdrwgh48eDy1w98yuPR0UtyA4aTQ6CtSj0IyBTfg9y6lBjZncwA7ES+EAKieVU56ROIDlwuMNcJc+CAwkiPPpx0LkT8XZpUXX+3r7JnkZtcTu4smEGN/h8QgM6WdyTuV2Kks= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707221363; c=relaxed/simple; bh=3SwXKn69jqhTzyrSfRqMAzadq7iwgEqhvz0y/eDGZkM=; h=Message-ID:Date:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=We/dMSdZ0RscfLli4/aLeah+CEeqHaI+M/YwDr3HzXhSr/2podkLi87AJR3lOqeNCMrKrSG/Ggm7TrjiOE8AlJxBuBvsJ4gT9yZ9qNl1nVx2t4AJWCTsrmkNEcLj7Zsel0bbdJD+BjNssGDOLq+7AO71OqLys8UX6ZTK30u7xos= 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 9779BC43390; Tue, 6 Feb 2024 12:09:22 +0000 (UTC) Received: from rostedt by gandalf with local (Exim 4.97) (envelope-from ) id 1rXKGt-00000006bFL-0JBS; Tue, 06 Feb 2024 07:09:51 -0500 Message-ID: <20240206120950.930155940@rostedt.homelinux.com> User-Agent: quilt/0.67 Date: Tue, 06 Feb 2024 07:09:33 -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 28/57] eventfs: Do not allow NULL parent to eventfs_start_creating() 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: 1790152242883125619 X-GMAIL-MSGID: 1790152242883125619 From: "Steven Rostedt (Google)" 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) (cherry picked from commit fc4561226feaad5fcdcb55646c348d77b8ee69c5) --- 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 34ffb2f8114e..b9ed8db4f6b9 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