Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp5456702pxb; Wed, 26 Jan 2022 12:24:24 -0800 (PST) X-Google-Smtp-Source: ABdhPJwjx5diWEvWyakUgmUi8c+CHG7pP9WWQfP2kQGE4HtLxX8x2z9eVpDKctv1jp8Ci0lRDFVm X-Received: by 2002:a17:902:9689:: with SMTP id n9mr331976plp.33.1643228664128; Wed, 26 Jan 2022 12:24:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643228664; cv=none; d=google.com; s=arc-20160816; b=pIVZoUOpfp5EPTlQpSHBmp1Z8rOpjl+pH+rgtt9ARfRH8H/Nnjd2aALyB/zn23Sxeg OpZ5jGM6ka5iqt8Nvu2gXvtk0ofZ8BPq7OyWIu9bMS8xqGGyKZjUhdabw688efUk4wqf Gefqmtds3Q8DehAGnmYevErH9Sc+ZpruJ3cnez0LWfYIL/UopKzNlW978tFqFhK9tdqp /wwMnKzlgXl7KfNZnExmu2Jv9f/xEsrECzPvSVnhACvX+zyKCW1TTW17NhfnJkbKXRQG b1xclvfJNmoyYJXgZE2xMbhBhHHEOF33Gqot81tEyxpMb9BWGzbLJLFH9KRmKuF6jS32 CyBA== 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:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id; bh=aZHlx9qIeIR6w8rtwP7/sK/c5/SCHjByHOobuSvR2M0=; b=J1rtYxMpKWb47hYbxMMrseAdxJKdSitBsqylUftUZCr2PP52Zig3LagT9dOrJYC/3H p7wCEOx5KK0nDyN+EuiljwRfhN+4/r3jWfLudWyOB/nF2LufCxGGqihMJFg1AJm+RoF0 YnN219IPBnwN1KWgenljrx+c39k0u+Q5GCqYQJGtS7R1x9xUwJwb4KJzMK6/FIl/HPFQ OBVN0RzR67MgBDyytduuOYH4Oo7QMOUb01ByAIOYtG+fGYKoXgeDuRkemq3r3pYW0183 ja3UMAgMiX0OishzsnoW50TMwg7KtxPMzRVLVMsHUk7erS2BYJ9J3Dk3rtJn5SkbVaqN L38A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v23si225146pfm.65.2022.01.26.12.24.12; Wed, 26 Jan 2022 12:24:24 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237969AbiAZHlt (ORCPT + 99 others); Wed, 26 Jan 2022 02:41:49 -0500 Received: from szxga03-in.huawei.com ([45.249.212.189]:32121 "EHLO szxga03-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229676AbiAZHls (ORCPT ); Wed, 26 Jan 2022 02:41:48 -0500 Received: from dggpemm500024.china.huawei.com (unknown [172.30.72.57]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4JkFvs29zrz8wdR; Wed, 26 Jan 2022 15:38:49 +0800 (CST) Received: from [10.67.110.173] (10.67.110.173) by dggpemm500024.china.huawei.com (7.185.36.203) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.21; Wed, 26 Jan 2022 15:41:46 +0800 Message-ID: <97142483-d7e7-e310-0cb0-30a81414cb57@huawei.com> Date: Wed, 26 Jan 2022 15:41:45 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.4.0 Subject: Re: [RESEND][PATCH] Documentation: added order requirement for ima_hash= Content-Language: en-US To: Mimi Zohar , CC: , , , , , References: <20220125090237.120357-1-guozihua@huawei.com> <36b6058f2cdf6bead917c06ecc6e8769bb88130c.camel@linux.ibm.com> <3933adf5-4e9d-6b22-2e46-55643c504f52@huawei.com> <71508a72b042da330d07a624cf499561c46195f0.camel@linux.ibm.com> From: "Guozihua (Scott)" In-Reply-To: <71508a72b042da330d07a624cf499561c46195f0.camel@linux.ibm.com> Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [10.67.110.173] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To dggpemm500024.china.huawei.com (7.185.36.203) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2022/1/26 12:37, Mimi Zohar wrote: > On Wed, 2022-01-26 at 10:28 +0800, Guozihua (Scott) wrote: >> >> On 2022/1/26 9:07, Mimi Zohar wrote: >>> On Tue, 2022-01-25 at 17:02 +0800, GUO Zihua wrote: >>>> From: Guo Zihua >>>> >>>> Commandline parameter ima_hash= and ima_template= has order requirement >>>> for them to work correctly together. Namely ima_hash= must be >>>> specified after ima_template=, otherwise ima_template= will be ignored. >>>> >>>> The reason is that when handling ima_hash=, ima template would be set to >>>> the default value if it has not been initialized already, and that value >>>> cannot be changed afterwards by ima_template=. >>>> >>>> This patch adds this limitation to the documentation. >>>> >>>> Reviewed-by: Roberto Sassu >>>> Signed-off-by: Guo Zihua >>> >>> This issue should be limited to the original "ima" template format, >>> which only supports hash algorithms of 20 bytes or less. The "ima_ng" >>> template has been the default since larger digests and templates were >>> upstreamed back in Linux 3.13[1]. Do you really still have kernels >>> built with the original "ima" template? >>> >>> [1] Refer to commit 4286587dccd4 ("ima: add Kconfig default measurement >>> list template"). >> >> Hi Mimi, >> >> The issue is that if ima_hash is specified before ima_template, >> ima_template will not work. Built-in default only affects which template >> will be loaded eventually. >> >> For example, if the built-in default template is ima-ng and user would >> like to change it to ima-sig with sha512 by specifying "ima_hash=sha512 >> ima_template=ima-sig" in command line, the result will be ima-ng with >> sha512, not ima-sig with sha512. > > Ok. Once the template name is set, ima_template_setup() doesn't allow > it to be reset. This was probably done to set the template name to the > first occurance of "ima_template=" on the boot command line. This > concern could be addressed by defining a static local variable in > ima_template_setup(). > > So either documenting the ordering requirement, as you've done, or > allowing the template_name to be reset are fine. > > thanks, > > Mimi > > . The main issue lies in ima_template_desc_current called by hash_setup, which does not just read ima_template global variable, but also tries to set it if that hasn't been done already. Causing ima_template_setup to quit. -- Best GUO Zihua