From mboxrd@z Thu Jan 1 00:00:00 1970 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 83DDACE79D0 for ; Wed, 20 Sep 2023 12:42:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236005AbjITMnA (ORCPT ); Wed, 20 Sep 2023 08:43:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38420 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236191AbjITMm7 (ORCPT ); Wed, 20 Sep 2023 08:42:59 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DCCF192 for ; Wed, 20 Sep 2023 05:42:53 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 323F4C433C8; Wed, 20 Sep 2023 12:42:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1695213773; bh=yohrV4EAy4CGZonk3omscBa69N1Z0rnBoO7NGZO7hWE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=n+kiqTI+vnBxnJQGVpZ+P/NxozTvk/kXBQOmwCJVZHfvNwcyvwWCMQUrYn1GS1wRz h8uLsvwNxsMtGP3R5972AcrYh2zMG7qbxoVB8zYqlaa8AGryxKLa/qU6WsxuZLtSAv OzuIBlKEy042QkYb9HarUbPNGeJumKMEroncgefA= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Masami Hiramatsu , Mark Rutland , Andrew Morton , Ajay Kaher , Ching-lin Yu , kernel test robot , "Steven Rostedt (Google)" Subject: [PATCH 5.4 361/367] tracefs: Add missing lockdown check to tracefs_create_dir() Date: Wed, 20 Sep 2023 13:32:18 +0200 Message-ID: <20230920112907.831794795@linuxfoundation.org> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20230920112858.471730572@linuxfoundation.org> References: <20230920112858.471730572@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org 5.4-stable review patch. If anyone has any objections, please let me know. ------------------ From: Steven Rostedt (Google) commit 51aab5ffceb43e05119eb059048fd75765d2bc21 upstream. The function tracefs_create_dir() was missing a lockdown check and was called by the RV code. This gave an inconsistent behavior of this function returning success while other tracefs functions failed. This caused the inode being freed by the wrong kmem_cache. Link: https://lkml.kernel.org/r/20230905182711.692687042@goodmis.org Link: https://lore.kernel.org/all/202309050916.58201dc6-oliver.sang@intel.com/ Cc: stable@vger.kernel.org Cc: Masami Hiramatsu Cc: Mark Rutland Cc: Andrew Morton Cc: Ajay Kaher Cc: Ching-lin Yu Fixes: bf8e602186ec4 ("tracing: Do not create tracefs files if tracefs lockdown is in effect") Reported-by: kernel test robot Signed-off-by: Steven Rostedt (Google) Signed-off-by: Greg Kroah-Hartman --- fs/tracefs/inode.c | 3 +++ 1 file changed, 3 insertions(+) --- a/fs/tracefs/inode.c +++ b/fs/tracefs/inode.c @@ -551,6 +551,9 @@ static struct dentry *__create_dir(const */ struct dentry *tracefs_create_dir(const char *name, struct dentry *parent) { + if (security_locked_down(LOCKDOWN_TRACEFS)) + return NULL; + return __create_dir(name, parent, &simple_dir_inode_operations); }