Received: by 2002:a05:6a10:7420:0:0:0:0 with SMTP id hk32csp3598623pxb; Mon, 21 Feb 2022 01:25:26 -0800 (PST) X-Google-Smtp-Source: ABdhPJy6WJ7FuUa/fjqJEMRv210ciDTyhfFSSqoPVjOmbY2hkzli6tJIqSve0NmMKgvXwP2+rBMD X-Received: by 2002:a63:f42:0:b0:373:847:a17a with SMTP id 2-20020a630f42000000b003730847a17amr15396955pgp.390.1645435526271; Mon, 21 Feb 2022 01:25:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1645435526; cv=none; d=google.com; s=arc-20160816; b=ki4ZhATqJ1c0UNeM10RbEFRuaTxkqXvlWiKu58gfIuDnKsTq6sgF0Bpsm2xZ6n3Q53 nGwvG1LsMXrvxTDEadZe9fV8YbRyMPx6w/GC2JCHMMxQQ/XHAQdhG1F7zslsn1SYwxZP QEQ9GjcN0bAJ63BikTik6r1dCRyP3+xYt4p7dHCGPQZKs9PDLb4rUz5txPdxnKP00XYl K85TZjt9bkZRwpqolzvxX3P4JJ/dGmyfgmQ8xt7I8fpc7yEcoX314jmn7l3phOOn/JIG ZEoKQ7a9WJNtH7CfnH0Siz5pKYdhZAHi62RNKz1FG7RkG9d8pZds1dXn7WpFSJS1L6oY C2MA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=E9QnsM00kB/VRxqOMVyvaZGH20vUG/PvOGWwyJ4WPd0=; b=oB7oNd+f2qZvNYgDZyf7OfJMIzuoMwNdQAK+KtV19uOHQ9/m3fGXzMeJbIyX2r3H/z xCcFVHsir9moWVib3B/A3h03ztZPDF60wrbpSqdLGWnG9ihScTJwi8vEPLX0ICJqmZ8f 6WqGVGqItPCGoIH+aQl2B8Pf4UQdjsQMGjkQwX+vXvZhHi1bM9NZxvEnoiR5vgV10r5C VU1XL4C/yT/gRlgxxkffV544csupt665Rt5VCIRQzTl909xibIyc4iV4VVQr/XE1JqP0 axL8GjHRCfU9Mqeh8n8RK+XMSyyWmU0h5Pg2AKgrkRQGIrTLYLtoO7MFwaCylBCl5JMQ N3Rg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=smUdnBvC; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z17si9136886pfh.111.2022.02.21.01.25.12; Mon, 21 Feb 2022 01:25:26 -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; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=smUdnBvC; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235115AbiBTXFm (ORCPT + 99 others); Sun, 20 Feb 2022 18:05:42 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:45914 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229794AbiBTXFl (ORCPT ); Sun, 20 Feb 2022 18:05:41 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C39984477D; Sun, 20 Feb 2022 15:05:19 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 4FB4260FC8; Sun, 20 Feb 2022 23:05:19 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 19626C340E8; Sun, 20 Feb 2022 23:05:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1645398318; bh=WEigyHym8SL+eQLKpwgUOuryIp8HNx3u/9ThKQ85NWQ=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=smUdnBvCRQ8GbwYUMVhG0Y6/evChhHhjUWFahl8NgOPqMiAtynTA1YhHQGodjGJy1 oEnQtLxn53eQeh2JEb/NWETQ+9WpfMP/BvHiidU+TRXM+zmuisp043J4cfE6ul+cHa HOJUQteInnx4n4KwKsDDZaTntFIq++y3pQROpbExs9H0QKUvzBR+PRgrQ1z+ViUoKB 9HZ+tN7SUmL7pJQQitsvMZECSO4+imQ9yDzdoaGDqHKo2gJZtchRtt6MLI4uzL8vXZ 5tOS7iCa1RHiHCdCHSaR7lvVGXdBQ9vfgu7zz3wU0bSLS+8G/y9yOyCgbjt2pJHvV5 kkXVK18T55Pxw== Date: Mon, 21 Feb 2022 00:05:57 +0100 From: Jarkko Sakkinen To: Tong Zhang Cc: James Bottomley , 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 Subject: Re: [PATCH] KEYS: trusted: fix crash when TPM/TEE are built as module Message-ID: References: <20220204200342.48665-1-ztong0001@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220204200342.48665-1-ztong0001@gmail.com> X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham 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 On Fri, Feb 04, 2022 at 12:03:42PM -0800, 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. > > 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 > }; > -- > 2.25.1 > Reviewed-by: Jarkko Sakkinen BR, Jarkko