Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp929654ybt; Wed, 24 Jun 2020 15:07:23 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyUWL4DaGYsVkC4ToX5SABccxPOS6G5O26Fac1UCDDw31vnflP8nKIW60s8ie9ssfIVxSYO X-Received: by 2002:a17:906:168b:: with SMTP id s11mr11544911ejd.444.1593036443340; Wed, 24 Jun 2020 15:07:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593036443; cv=none; d=google.com; s=arc-20160816; b=zD1RLTL9gUYeGiupz8Q82W7QQHYNaZT6sLI9bYPzc9GhRkeyECKl1+fjPj+sefam67 JqYZKbWrFTET2PA9gj+IIdL7zOPn6lBTjGvo3d7qD9tN1UZpjYmAOb7z3zfGh9elNgbk +4iWSvf52QniM/fwvdD8Y/LX80q6WcYL9XOPJ4QrnDvk2+8YwYh74Bgj0PsDe74rqKCF qg4iMecvsr7yIvAuLpGGkc/4HCOT/lw8wPB6LsJ7/eMMVzpGoaeeHethCH8epbq6iKXZ oGMJ+gNzwc9kIqN7I8smmj8Van2C6csGcOWTqs6yPJnZ1lzeZuJ3uFPzJ2REjzj1sKzq GRxw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-disposition:in-reply-to :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=y7EcaWcwOVxs7xfTz82JvfiUivSbvgvT6tEmCQl4GAs=; b=nl5B3nROCGYFhAgK71dr0sFVKwI93RU+l0JI0K91SNUEqjU1/mcwkQMZHX8TErNW3H ZK7ct4FAb4voawZeRKGJJRHcMlcfbPq1yNznBmgBj6w2AOI4fY6keu5mEut0cVaXh0WM HOzhb0dK3esw4aF2UySobfKkD8+Q5lcXArQn59PolP5DTF7IzzBGsjQCfOZvUT/xV+1K D3tC6zoDNKT33MC5ockZtYzAy48UmddyPx7Ck+nM59TNgBOL915e4vepCeSFOvQXZvHg e//csmp1Vm9RZurgR6xL+uBJq2DelJoaorexJZj+m+OD+8SCwheExUaQQei/326L+22I nJOg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=VtsxTZbZ; 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=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b19si3182891edj.598.2020.06.24.15.06.59; Wed, 24 Jun 2020 15:07:23 -0700 (PDT) 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; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=VtsxTZbZ; 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=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2404252AbgFXVeA (ORCPT + 99 others); Wed, 24 Jun 2020 17:34:00 -0400 Received: from us-smtp-2.mimecast.com ([205.139.110.61]:40520 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2403906AbgFXVd7 (ORCPT ); Wed, 24 Jun 2020 17:33:59 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1593034437; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=y7EcaWcwOVxs7xfTz82JvfiUivSbvgvT6tEmCQl4GAs=; b=VtsxTZbZiT3ovV4jLQ4N511ZttDBiLP5eM7QC8C39d3z3VxQeUtvFillqPNiE1nT13GbiP zX9TFJnplYcONg2ZTcNfXXBAigzsd09l98nMrH7lnc2It7JjIMAaaKUAcGmQ3j+7xZ48u8 6n8vbKekLjl6YPJmyph5jSg9G4rjHk8= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-64-WoI1-yE6NoOYD6JWbB085g-1; Wed, 24 Jun 2020 17:33:49 -0400 X-MC-Unique: WoI1-yE6NoOYD6JWbB085g-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 944FF193F563; Wed, 24 Jun 2020 21:33:47 +0000 (UTC) Received: from localhost (ovpn-116-62.gru2.redhat.com [10.97.116.62]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6C04E2B4AE; Wed, 24 Jun 2020 21:33:46 +0000 (UTC) Date: Wed, 24 Jun 2020 18:33:45 -0300 From: Bruno Meneguele To: Stefan Berger Cc: Maurizio Drocco , zohar@linux.ibm.com, Silviu.Vlasceanu@huawei.com, dmitry.kasatkin@gmail.com, jejb@linux.ibm.com, jmorris@namei.org, linux-integrity@vger.kernel.org, linux-kernel@vger.kernel.org, linux-security-module@vger.kernel.org, mdrocco@linux.vnet.ibm.com, roberto.sassu@huawei.com, serge@hallyn.com Subject: Re: [PATCH v2] ima_evm_utils: extended calc_bootaggr to PCRs 8 - 9 Message-ID: <20200624213345.GB2639@glitch> References: <1592856871.4987.21.camel@linux.ibm.com> <20200623180122.209-1-maurizio.drocco@ibm.com> <20200623181357.GC4983@glitch> <92a0d170-8157-476b-8083-ae567b11f364@linux.ibm.com> MIME-Version: 1.0 In-Reply-To: <92a0d170-8157-476b-8083-ae567b11f364@linux.ibm.com> X-PGP-Key: http://keys.gnupg.net/pks/lookup?op=get&search=0x3823031E4660608D X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=bmeneg@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="pvezYHf7grwyp3Bc" Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --pvezYHf7grwyp3Bc Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Wed, Jun 24, 2020 at 05:17:52PM -0400, Stefan Berger wrote: > On 6/23/20 2:13 PM, Bruno Meneguele wrote: > > On Tue, Jun 23, 2020 at 02:01:22PM -0400, Maurizio Drocco wrote: > > > From: Maurizio > > >=20 > > > If PCRs 8 - 9 are set (i.e. not all-zeros), cal_bootaggr should inclu= de > > > them into the digest. >=20 >=20 > Wouldn't you have to check for not all-zeros in your code? >=20 boot_aggregate in kernel, after the following patch be applied: https://lkml.org/lkml/2020/6/23/833 is calculated regardless PCR 8 & 9 being zero or not. Thus evmctl is only reflecting the same behavior. I think it would be worth changing the commit log here. >=20 > =A0=A0 Stefan >=20 >=20 > > >=20 > > > Signed-off-by: Maurizio Drocco > > > --- > > > Changelog: > > > v2: > > > - Always include PCRs 8 & 9 to non-sha1 hashes > > > v1: > > > - Include non-zero PCRs 8 & 9 to boot aggregates > > >=20 > > > src/evmctl.c | 15 +++++++++++++-- > > > 1 file changed, 13 insertions(+), 2 deletions(-) > > >=20 > > > diff --git a/src/evmctl.c b/src/evmctl.c > > > index 1d065ce..46b7092 100644 > > > --- a/src/evmctl.c > > > +++ b/src/evmctl.c > > > @@ -1930,6 +1930,16 @@ static void calc_bootaggr(struct tpm_bank_info= *bank) > > > =09=09} > > > =09} > > > +=09if (strcmp(bank->algo_name, "sha1") !=3D 0) { > > > +=09=09for (i =3D 8; i < 10; i++) { > > > +=09=09=09err =3D EVP_DigestUpdate(pctx, bank->pcr[i], bank->digest_s= ize); > > > +=09=09=09if (!err) { > > > +=09=09=09=09log_err("EVP_DigestUpdate() failed\n"); > > > +=09=09=09=09return; > > > +=09=09=09} > > > +=09=09} > > > +=09} > > > + > > > =09err =3D EVP_DigestFinal(pctx, bank->digest, &mdlen); > > > =09if (!err) { > > > =09=09log_err("EVP_DigestFinal() failed\n"); > > > @@ -1972,8 +1982,9 @@ static int append_bootaggr(char *bootaggr, stru= ct tpm_bank_info *tpm_banks) > > > /* > > > * The IMA measurement list boot_aggregate is the link between the = preboot > > > * event log and the IMA measurement list. Read and calculate all = the > > > - * possible per TPM bank boot_aggregate digests based on the existin= g > > > - * PCRs 0 - 7 to validate against the IMA boot_aggregate record. > > > + * possible per TPM bank boot_aggregate digests based on the existin= g PCRs > > > + * 0 - 9 to validate against the IMA boot_aggregate record. If the d= igest > > > + * algorithm is SHA1, only PCRs 0 - 7 are considered to avoid ambigu= ity. > > > */ > > > static int cmd_ima_bootaggr(struct command *cmd) > > > { > > > --=20 > > > 2.17.1 > > >=20 > > Reviewed-by: Bruno Meneguele > >=20 >=20 --=20 bmeneg=20 PGP Key: http://bmeneg.com/pubkey.txt --pvezYHf7grwyp3Bc Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEzBAEBCAAdFiEEdWo6nTbnZdbDmXutYdRkFR+RokMFAl7zxrkACgkQYdRkFR+R okPYcQgAm6LTqZtL5mRjNJGbAAZw84aOAtH2k6SpA7DctDptfHi4GqFGsUQlUm20 qoj6O72gsg8KEAg2PCBD+Say3QRN4Z688divjN90eCmgtcP2m56t1dFrDxDxX2cg 6eTznSJ+wJtBhBOgQnm+ZzfVr+mcqlDQm9KkCgeGa3e+20bp1RZlIv7riJr7WEpb DikYbbv/rkixLrBKuwHylQiGw0VYs5n3tfCXd/EMPdlI1//QPzg8UT7m9TfB+sPS sHdLa1AgFZYuvZ2Zy5gZ31cI0+nqc2oikOyX+tBYcAuGVNU2IhLq9x20Ro0K18NN p0w6HJMC3pQK6zsZN2PZ9Om8qjGXCA== =3iq3 -----END PGP SIGNATURE----- --pvezYHf7grwyp3Bc--