From nobody Wed Dec 17 22:44:08 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 88997C61D85 for ; Tue, 21 Nov 2023 23:11:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234896AbjKUXLI (ORCPT ); Tue, 21 Nov 2023 18:11:08 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54964 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229695AbjKUXLA (ORCPT ); Tue, 21 Nov 2023 18:11:00 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 347C2191 for ; Tue, 21 Nov 2023 15:10:57 -0800 (PST) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8D1B0C433CA; Tue, 21 Nov 2023 23:10:56 +0000 (UTC) Received: from rostedt by gandalf with local (Exim 4.97-RC3) (envelope-from ) id 1r5Ztg-00000002dEb-3Uvn; Tue, 21 Nov 2023 18:11:12 -0500 Message-ID: <20231121231112.693841807@goodmis.org> User-Agent: quilt/0.67 Date: Tue, 21 Nov 2023 18:10:06 -0500 From: Steven Rostedt To: linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org Cc: Masami Hiramatsu , Mark Rutland , Andrew Morton Subject: [PATCH 3/4] eventfs: Do not allow NULL parent to eventfs_start_creating() References: <20231121231003.516999942@goodmis.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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. Signed-off-by: Steven Rostedt (Google) --- 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 5b54948514fe..ae648deed019 100644 --- a/fs/tracefs/inode.c +++ b/fs/tracefs/inode.c @@ -509,20 +509,15 @@ struct dentry *eventfs_start_creating(const char *nam= e, struct dentry *parent) struct dentry *dentry; int error; =20 + /* Must always have a parent. */ + if (WARN_ON_ONCE(!parent)) + return ERR_PTR(-EINVAL); + error =3D simple_pin_fs(&trace_fs_type, &tracefs_mount, &tracefs_mount_count); if (error) return ERR_PTR(error); =20 - /* - * 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 =3D tracefs_mount->mnt_root; - if (unlikely(IS_DEADDIR(parent->d_inode))) dentry =3D ERR_PTR(-ENOENT); else --=20 2.42.0