Received: by 2002:ac0:e34a:0:0:0:0:0 with SMTP id g10csp481779imn; Wed, 27 Jul 2022 11:25:19 -0700 (PDT) X-Google-Smtp-Source: AGRyM1s6eL+8c+bIpleBRSXM4vGj0H1+k4dHaEof8LcDiaQenM0tEKrTySzx9BHo/O5vTKvoNgGX X-Received: by 2002:a17:907:3f92:b0:72b:5af8:b87d with SMTP id hr18-20020a1709073f9200b0072b5af8b87dmr18001333ejc.416.1658946318896; Wed, 27 Jul 2022 11:25:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658946318; cv=none; d=google.com; s=arc-20160816; b=olo6d1qITm9qxKn88h7x2k/6mBMvM8zMO1xeeSdrXwtNdAi2PClcjcbBTKcuFfCz0L WGhJuF6UO3z2A9QXeYSu5Kg9Bk+0Qei6VUpAv6PWeYRdOVELToH/qk5jHOXUDv4YWvoB c69on7PeXFG8I0FTXnCZotppa8Cdi9UDTxsCFXiaGh0fEcPWQoNYdIApv6nlxg710zqH mF8ZYrgPZmCin3tpSygkaQyQviSodEiy3hsTMVQeS20tJ7Ufjlc44A3NNzsZfL7u2R79 D5dJnaT/dZ+NJXsvIibm5RSwU/KZJLAWSLQs/iaO/EzdUo+MSIr7jZuTk58fpJ3trL46 o2iQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=LUtCstr98pohmgPyHtk1QXSOYPPF1y8N7/+N+47xLNE=; b=Avq5NwA1DfUIgEXMTgsfptEFPSsVluF7AhZ4jQttEVLRctEbehkBPg57eRzJ/oetzi kzT66CGuuRirNiHHkPWMPGrYUNJJOvM0vzUPlb5tOE/SFpYR3cMj53GJWn9Q9r/+UypW foe/GZ+01IB6RlxTz5aHZ1o8YKPYFNEB1ZMkoVdF2oAAcc3QiduNmB12j7Ve+Oi2HPU+ FfcraZMF2dPAAWIKXH1J4G0oFqLgX5ogdYoWUFLunjEHOEROJqHzulyX9oD4MhEyuO5N 4JThx4vukbCHhIzBix6J9sWc+pPyhFcr6tGvZu56Kqz39I00dxXnX+FGRCScLyLKqvif tSYw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=CnegrMT+; 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=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s26-20020a05640217da00b0043aa8412569si15861654edy.315.2022.07.27.11.24.53; Wed, 27 Jul 2022 11:25:18 -0700 (PDT) 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=@linuxfoundation.org header.s=korg header.b=CnegrMT+; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237823AbiG0Qfz (ORCPT + 99 others); Wed, 27 Jul 2022 12:35:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47320 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238246AbiG0QeN (ORCPT ); Wed, 27 Jul 2022 12:34:13 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CFD394F194; Wed, 27 Jul 2022 09:26:58 -0700 (PDT) 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 DD03D619C0; Wed, 27 Jul 2022 16:26:27 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E7DA4C433D7; Wed, 27 Jul 2022 16:26:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658939187; bh=sKEh1h1g2EloXlRno4EC8xmmU1FOwVQwFsLKDWV/Ugg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CnegrMT+n6sIhcq5izHJH4bpeixzCkzyMZX8Tzn8Yve1c1uqWWAEoLeJ2c7Q/V7qx blYMar44WQFfmq9py4j+HUR7SHAFYsJ95omuv44hsx4Oz9rbd1fLP+ixJmW6/fZnjI EyawGpUg6/GguYOMCcGu3XHVEXCEfrBDFHqMIY3g= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, GUO Zihua , Stable@vger.kernel.org, Mimi Zohar , Sasha Levin Subject: [PATCH 4.19 43/62] ima: remove the IMA_TEMPLATE Kconfig option Date: Wed, 27 Jul 2022 18:10:52 +0200 Message-Id: <20220727161005.855488592@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220727161004.175638564@linuxfoundation.org> References: <20220727161004.175638564@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.7 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 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 From: GUO Zihua [ Upstream commit 891163adf180bc369b2f11c9dfce6d2758d2a5bd ] The original 'ima' measurement list template contains a hash, defined as 20 bytes, and a null terminated pathname, limited to 255 characters. Other measurement list templates permit both larger hashes and longer pathnames. When the "ima" template is configured as the default, a new measurement list template (ima_template=) must be specified before specifying a larger hash algorithm (ima_hash=) on the boot command line. To avoid this boot command line ordering issue, remove the legacy "ima" template configuration option, allowing it to still be specified on the boot command line. The root cause of this issue is that during the processing of ima_hash, we would try to check whether the hash algorithm is compatible with the template. If the template is not set at the moment we do the check, we check the algorithm against the configured default template. If the default template is "ima", then we reject any hash algorithm other than sha1 and md5. For example, if the compiled default template is "ima", and the default algorithm is sha1 (which is the current default). In the cmdline, we put in "ima_hash=sha256 ima_template=ima-ng". The expected behavior would be that ima starts with ima-ng as the template and sha256 as the hash algorithm. However, during the processing of "ima_hash=", "ima_template=" has not been processed yet, and hash_setup would check the configured hash algorithm against the compiled default: ima, and reject sha256. So at the end, the hash algorithm that is actually used will be sha1. With template "ima" removed from the configured default, we ensure that the default tempalte would at least be "ima-ng" which allows for basically any hash algorithm. This change would not break the algorithm compatibility checks for IMA. Fixes: 4286587dccd43 ("ima: add Kconfig default measurement list template") Signed-off-by: GUO Zihua Cc: Signed-off-by: Mimi Zohar Signed-off-by: Sasha Levin --- security/integrity/ima/Kconfig | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/security/integrity/ima/Kconfig b/security/integrity/ima/Kconfig index 5095b2e8fcee..3ec45028a8c5 100644 --- a/security/integrity/ima/Kconfig +++ b/security/integrity/ima/Kconfig @@ -68,10 +68,9 @@ choice hash, defined as 20 bytes, and a null terminated pathname, limited to 255 characters. The 'ima-ng' measurement list template permits both larger hash digests and longer - pathnames. + pathnames. The configured default template can be replaced + by specifying "ima_template=" on the boot command line. - config IMA_TEMPLATE - bool "ima" config IMA_NG_TEMPLATE bool "ima-ng (default)" config IMA_SIG_TEMPLATE @@ -81,7 +80,6 @@ endchoice config IMA_DEFAULT_TEMPLATE string depends on IMA - default "ima" if IMA_TEMPLATE default "ima-ng" if IMA_NG_TEMPLATE default "ima-sig" if IMA_SIG_TEMPLATE @@ -101,15 +99,15 @@ choice config IMA_DEFAULT_HASH_SHA256 bool "SHA256" - depends on CRYPTO_SHA256=y && !IMA_TEMPLATE + depends on CRYPTO_SHA256=y config IMA_DEFAULT_HASH_SHA512 bool "SHA512" - depends on CRYPTO_SHA512=y && !IMA_TEMPLATE + depends on CRYPTO_SHA512=y config IMA_DEFAULT_HASH_WP512 bool "WP512" - depends on CRYPTO_WP512=y && !IMA_TEMPLATE + depends on CRYPTO_WP512=y endchoice config IMA_DEFAULT_HASH -- 2.35.1