Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp4631213ybl; Mon, 26 Aug 2019 13:23:59 -0700 (PDT) X-Google-Smtp-Source: APXvYqxozH7bcRKowMhqOA7lXqOztCurLczFxAd6FTIxO0hi/kBqIlFKEVHjEaVCDCDdG2kYB9V8 X-Received: by 2002:a63:4404:: with SMTP id r4mr17751963pga.245.1566851039420; Mon, 26 Aug 2019 13:23:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566851039; cv=none; d=google.com; s=arc-20160816; b=l2D2QY2QZHzPtMOxY8jpbQEtQTSVJsIZkAmGsyZMZhHLo0aVSEiCNhFrfKJSV4l2XZ BDI4QNTwGmg24Wxg1su0ACw8sitNv3lUYYhGtMx/91OMLRgtaNG3Nf53VROvp4N9p2we PG+CsfKO6rIWq9hinHEA+MQctZjMgzkGe51Uht2WDhNCX4TZGwxfKS3gB+NVJbpdbwKQ G69NSBDNPadf124kbhftCNN4Xb1Ma6v7ygu/CG3YxxKaXzRMDjekHMSvNLKse26MoDRi l3Xzyxjo0MuEE9gn628BqsEw06ZTg0yzlKhwKPPGvVnw2X64B7GJunsPXZgTe9cAJ452 jaHg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=pU42gGw1gVlVUlF/wW/uAiCaAt/FVvOc/4u8XYPtZ6Q=; b=rbtqUWDpUjr5yd1Pkm99LkG5WuNkPgpTDuxu3UUyNPb0ZEFpEU6fgu+pksZuJpbs1L S/6f2c0IQI5B1E6yJ7vRo+binEAlNMNiRCw3WpuzZ85jmG1CRAZeI7+AzSY2ZHJMMFYW ZIcQ127UTfKY6/9RT6YCG3pcK5kQ9+6Yf1GaphpfWE/WK820YhgLT6t1s5anznHj/U59 rekqDjlNqOI343+ibBuZhUMpxWKcWwJOxm8etA1BQO7bmM4RH1FVmUc5wFrbQDLXGz1J HZzW8Y7ufmU+FY5TkFGLvkCG6IWKC+j32qwfNPwa1l2LWGDLs42wixwHUtXCK6f5oiG5 uubQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b="m/a0mTn8"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b30si10318240pla.368.2019.08.26.13.23.41; Mon, 26 Aug 2019 13:23:59 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b="m/a0mTn8"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387468AbfHZRps (ORCPT + 99 others); Mon, 26 Aug 2019 13:45:48 -0400 Received: from mail-io1-f66.google.com ([209.85.166.66]:46559 "EHLO mail-io1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387458AbfHZRpr (ORCPT ); Mon, 26 Aug 2019 13:45:47 -0400 Received: by mail-io1-f66.google.com with SMTP id x4so39205006iog.13 for ; Mon, 26 Aug 2019 10:45:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=pU42gGw1gVlVUlF/wW/uAiCaAt/FVvOc/4u8XYPtZ6Q=; b=m/a0mTn8JIle2t4XwbClGaKckf9LvOCHpdQOtGkzUU0rgUZ8S22KXFW8g1bzXRTigd LRdxz5zugcj/G1i+OuzEkIRhO17zMitYulMruQy5JkXpHCG89RN1LywMhCPsUGuVD/rf 0tUvUnBlKrwHT+X2zmLr3/8lQaz7tJQwVrjgZhGdJ36x8/MvvefYoliDLf3Memx7VrkB TyVgQnHkRw5PAIlEsUU8ds+God+tLcZl29vHHkKyDVjspcuYQG6bwL0xGUFNpRy9E+dg PW5adaRX7JBso0vpertu9Oi9ZrkqAkUo6QmK67BhqPOMrN+eg/S5CPh7mMH7o3c0e2G7 XTyg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=pU42gGw1gVlVUlF/wW/uAiCaAt/FVvOc/4u8XYPtZ6Q=; b=AdcxAaAtTIEUvBoSsPTmlNgzOCQOnmVK6tXDn1cB6Q1iyYryMKaKqiUhbyxFsMwIJ1 1WeIzsRFhybRO/RyFp5qefCSNZyc6yl0q2WbEwW/b5qroPRsWPi/YTd0uYXCwCUs5+K6 EMPqHD5HioC/mD7s/JzHVt+5PexdskMM3oPeq6v+P1WBJHfAgdswUnwVzcBw5iwaqqfi FceO2Sr2nj5SotTX7aGXUO8XPqo2jhB4wrLqqvAPZuuFuBNe3o7QLwEjd0zOuwPjD6eQ ixpyR0cAgt11nNOgpXXyUoYdDV6x7nTeHSneqYYbD3Kv+QxydWgCx0Y2hFAlVZ2n0f6u aYEQ== X-Gm-Message-State: APjAAAUL2gAc3Ztbuv/bIxz9O8V6Coyz68e4slWqzNXe4/TPqFcVTmBn 0wSU/dRBVJO7VBFOaQi2DBwqK9nDg5yNq4sjXOnfYg== X-Received: by 2002:a6b:c94c:: with SMTP id z73mr27054283iof.84.1566841546578; Mon, 26 Aug 2019 10:45:46 -0700 (PDT) MIME-Version: 1.0 References: <20190826153028.32639-1-pjones@redhat.com> <20190826153028.32639-2-pjones@redhat.com> <20190826163020.e7sahr3irqwwneey@linux.intel.com> In-Reply-To: <20190826163020.e7sahr3irqwwneey@linux.intel.com> From: Matthew Garrett Date: Mon, 26 Aug 2019 10:45:35 -0700 Message-ID: Subject: Re: [PATCH 2/2] efi+tpm: don't traverse an event log with no events To: Jarkko Sakkinen Cc: Peter Jones , Ard Biesheuvel , Roberto Sassu , Bartosz Szczepanek , Lyude Paul , linux-efi , Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Aug 26, 2019 at 9:30 AM Jarkko Sakkinen wrote: > > On Mon, Aug 26, 2019 at 11:30:28AM -0400, Peter Jones wrote: > > When there are no entries to put into the final event log, some machines > > will return the template they would have populated anyway. In this case > > the nr_events field is 0, but the rest of the log is just garbage. > > > > This patch stops us from trying to iterate the table with > > __calc_tpm2_event_size() when the number of events in the table is 0. > > > > Signed-off-by: Peter Jones > > Tested-by: Lyude Paul > > --- > > drivers/firmware/efi/tpm.c | 14 +++++++++----- > > 1 file changed, 9 insertions(+), 5 deletions(-) > > > > diff --git a/drivers/firmware/efi/tpm.c b/drivers/firmware/efi/tpm.c > > index 1d3f5ca3eaa..be51ed17c6e 100644 > > --- a/drivers/firmware/efi/tpm.c > > +++ b/drivers/firmware/efi/tpm.c > > @@ -75,11 +75,15 @@ int __init efi_tpm_eventlog_init(void) > > goto out; > > } > > > > - tbl_size = tpm2_calc_event_log_size((void *)efi.tpm_final_log > > - + sizeof(final_tbl->version) > > - + sizeof(final_tbl->nr_events), > > - final_tbl->nr_events, > > - log_tbl->log); > > + tbl_size = 0; > > + if (final_tbl->nr_events != 0) { > > + void *events = (void *)efi.tpm_final_log > > + + sizeof(final_tbl->version) > > + + sizeof(final_tbl->nr_events); > > + tbl_size = tpm2_calc_event_log_size(events, > > + final_tbl->nr_events, > > + log_tbl->log); > > + } > > Reviewed-by: Jarkko Sakkinen Acked-by: Matthew Garrett