Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp5437556pxb; Mon, 7 Feb 2022 01:51:18 -0800 (PST) X-Google-Smtp-Source: ABdhPJxNjcXvD7fdTnUJSuTqQJsXKOVj6Wpyr4UkhbSiFcMKUunx/9hLXx4DxTrsGJb72svduaYF X-Received: by 2002:a63:fd14:: with SMTP id d20mr8713914pgh.369.1644227477862; Mon, 07 Feb 2022 01:51:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644227477; cv=none; d=google.com; s=arc-20160816; b=jVrAZz7GO5cBbdt4cSKOLKKmuf7ZGBxN3FkVAp+4hd3spBVc8c8j6O6bqkWI819JDd K3T7FldArX3QyYAjhT1cE6ohYrsVifzIsHwgQ5gFqowHXP+XAmR190hTtn5r+lTD+CxT 5JW+vyKC24tKCE/1GlIwRoHwYttEU38OmGczdTIUmzVVzD2zhWYFIrkFJRxXI3cqg8gZ Jv480i6kPIscS+nHW/eVSz6FtpFeqDn3vC10I3XvsVIeAx1Lb+pnRkjf0NNhrxGcyvUK iKgDzhdnFEwltvigWm3168wSk2y1f3epVho0M0rabrx3DwdZmThtzbM96SxpLv+V4dSW oinw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to :content-language:references:to:subject:from:user-agent:mime-version :date:message-id; bh=Qja/LrlyzlS61+FDfnDlKPLo/KAyZJ1MHN7865yD+1I=; b=FR9yoBDySoKdcNdeHJJlGLh9zM6saPBwLwbKkTgdgiscR3G1EN6ePhcBaQ5gF/aIAU UMe3Oi9gzc3VbZYL9KjykSOkX3lSyMFjbrpjQV+2SGmJ61LX0KIob7iyVnBN1ityqVd2 m33MvCYV0GPRhVyNwTgPW9Wh15YUOC80u5bGXSfJk9J3tBtvum1VdY5s9UGLLACWkics HeAQtrVCitdIrF+R+NpUAxOdlLw0EFtpSsj6ZxCosnGCluZRccVOE6/FjwTyJ7vuwiEH 03tuu/lFu+b7Xx1Py0BwRSsP/asSe0zDpCWW/oCicxgAMP4j5j1b3xBpM7C2PcmD4Yfq ExeA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id pf4si3204450pjb.77.2022.02.07.01.51.06; Mon, 07 Feb 2022 01:51:17 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233510AbiBFKhO (ORCPT + 99 others); Sun, 6 Feb 2022 05:37:14 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48768 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231180AbiBFKhM (ORCPT ); Sun, 6 Feb 2022 05:37:12 -0500 Received: from metis.ext.pengutronix.de (metis.ext.pengutronix.de [IPv6:2001:67c:670:201:290:27ff:fe1d:cc33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7247FC06109E for ; Sun, 6 Feb 2022 02:37:12 -0800 (PST) Received: from gallifrey.ext.pengutronix.de ([2001:67c:670:201:5054:ff:fe8d:eefb] helo=[127.0.0.1]) by metis.ext.pengutronix.de with esmtp (Exim 4.92) (envelope-from ) id 1nGeuc-0002la-07; Sun, 06 Feb 2022 11:36:54 +0100 Message-ID: Date: Sun, 6 Feb 2022 11:36:48 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.5.0 From: Ahmad Fatoum Subject: Re: [PATCH] KEYS: trusted: fix crash when TPM/TEE are built as module To: Tong Zhang , James Bottomley , Jarkko Sakkinen , Mimi Zohar , David Howells , James Morris , "Serge E. Hallyn" , Sumit Garg , linux-integrity@vger.kernel.org, keyrings@vger.kernel.org, linux-security-module@vger.kernel.org, linux-kernel@vger.kernel.org, Andreas Rammhold References: <20220204200342.48665-1-ztong0001@gmail.com> Content-Language: en-US In-Reply-To: <20220204200342.48665-1-ztong0001@gmail.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-SA-Exim-Connect-IP: 2001:67c:670:201:5054:ff:fe8d:eefb X-SA-Exim-Mail-From: a.fatoum@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,NICE_REPLY_A, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hello Tong, On 04.02.22 21:03, Tong Zhang wrote: > when TCG_TPM and TEE are built as module, trusted_key_sources will be an > empty array, loading it won't do what it is supposed to do and unloading > it will cause kernel crash. Jarkko reported picking up an equivalent fix two months ago: https://lkml.kernel.org/keyrings/YadRAWbl2aiapf8l@iki.fi/ But it seems to have never made it to Linus. Cheers, Ahmad > > To reproduce: > $ modprobe trusted > $ modprobe -r trusted > > [ 173.749423] Unable to handle kernel NULL pointer dereference at virtual address 00000000 > [ 173.755268] Backtrace: > [ 173.755378] cleanup_trusted [trusted] from sys_delete_module+0x15c/0x22c > [ 173.755589] sys_delete_module from ret_fast_syscall+0x0/0x1c > > To fix this issue, we also need to check CONFIG_TCG_TPM_MODULE and > CONFIG_TEE_MODULE. > > Fixes: 5d0682be3189 ("KEYS: trusted: Add generic trusted keys framework") > Signed-off-by: Tong Zhang > --- > security/keys/trusted-keys/trusted_core.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/security/keys/trusted-keys/trusted_core.c b/security/keys/trusted-keys/trusted_core.c > index d5c891d8d353..b3a3b2f2d4a4 100644 > --- a/security/keys/trusted-keys/trusted_core.c > +++ b/security/keys/trusted-keys/trusted_core.c > @@ -27,10 +27,10 @@ module_param_named(source, trusted_key_source, charp, 0); > MODULE_PARM_DESC(source, "Select trusted keys source (tpm or tee)"); > > static const struct trusted_key_source trusted_key_sources[] = { > -#if defined(CONFIG_TCG_TPM) > +#if defined(CONFIG_TCG_TPM) || defined(CONFIG_TCG_TPM_MODULE) > { "tpm", &trusted_key_tpm_ops }, > #endif > -#if defined(CONFIG_TEE) > +#if defined(CONFIG_TEE) || defined(CONFIG_TEE_MODULE) > { "tee", &trusted_key_tee_ops }, > #endif > }; -- Pengutronix e.K. | | Steuerwalder Str. 21 | http://www.pengutronix.de/ | 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |