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 1D78D2DF9F; Tue, 20 Feb 2024 21:23:27 +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=1708464207; cv=none; b=PgLXiIR4yKIxc6GAcUBA65/6Sx5Tq2hEN+CeNPjpEVMK5lfklcKU/7Qz1eI32U5Bebje6SBz5HjFEr27Sy/xfmcdeJ0OFcCRDictFD9H4k8EUzdU1o0KIFinWmrOLArz+4jx76Hj+d02f9Uyjh75+261br8KsBWWMG2Io5qvbC4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708464207; c=relaxed/simple; bh=hvmYSMgzDwdQvKHA4cpHDramwzHbQ0wUwdq8nH3FWFs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=X7D/CY0z+LEgupx0Af8xInOWBeBCnMcf2wuU+QAjbploEDkFIaXVAj5XmfLt//QhGaxsf1bKxuKGjwftjVcbftmvHN0Gf2c+mqK76/uHq1Ys+dWzvq4NiO7Ken5YiNb/RNSTwc6uP904hUJVxi0RgiEiBvwRhQOlrTb4XZdjlsQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=Wey1Dc7c; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="Wey1Dc7c" Received: by smtp.kernel.org (Postfix) with ESMTPSA id A0237C433C7; Tue, 20 Feb 2024 21:23:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1708464207; bh=hvmYSMgzDwdQvKHA4cpHDramwzHbQ0wUwdq8nH3FWFs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Wey1Dc7c5Es75UWVD4ok4iskwtOiFugt1gc88nlZJZOjTGHegxmndqe168IW/KQRb FBcqZfOIODvOK5BKr/Wi4U66q+wILr4l51m+PkUo0INq/vNdMZrknIU16aq8I5dTK9 tVuHu4uRjEj820W20YLrGd0ZdklPXs/YrG06jDjU= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Masami Hiramatsu , Mark Rutland , Andrew Morton , Josef Bacik , "Steven Rostedt (Google)" Subject: [PATCH 6.6 285/331] eventfs: Do not allow NULL parent to eventfs_start_creating() Date: Tue, 20 Feb 2024 21:56:41 +0100 Message-ID: <20240220205646.924696590@linuxfoundation.org> X-Mailer: git-send-email 2.43.2 In-Reply-To: <20240220205637.572693592@linuxfoundation.org> References: <20240220205637.572693592@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: "Steven Rostedt (Google)" commit fc4561226feaad5fcdcb55646c348d77b8ee69c5 upstream. 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: Greg Kroah-Hartman --- fs/tracefs/inode.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) --- a/fs/tracefs/inode.c +++ b/fs/tracefs/inode.c @@ -509,20 +509,15 @@ struct dentry *eventfs_start_creating(co 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