From mboxrd@z Thu Jan 1 00:00:00 1970 From: AKASHI Takahiro Date: Wed, 8 Jul 2020 10:12:38 +0900 Subject: [PATCH v2 08/17] efi_loader: signature: fix a size check against revocation list In-Reply-To: <84643027-6db0-db8e-f9bf-f9c21817f680@gmx.de> References: <20200609050947.17861-1-takahiro.akashi@linaro.org> <20200609050947.17861-9-takahiro.akashi@linaro.org> <84643027-6db0-db8e-f9bf-f9c21817f680@gmx.de> Message-ID: <20200708011238.GA16575@laputa> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de On Fri, Jul 03, 2020 at 01:00:21PM +0200, Heinrich Schuchardt wrote: > On 09.06.20 07:09, AKASHI Takahiro wrote: > > Since the size check against an entry in efi_search_siglist() is > > incorrect, this function will never find out a to-be-matched certificate > > and its associated revocation time in the signature list. > > > > Signed-off-by: AKASHI Takahiro > > --- > > lib/efi_loader/efi_signature.c | 5 +++-- > > 1 file changed, 3 insertions(+), 2 deletions(-) > > > > diff --git a/lib/efi_loader/efi_signature.c b/lib/efi_loader/efi_signature.c > > index a05c75472721..f22dc151971f 100644 > > --- a/lib/efi_loader/efi_signature.c > > +++ b/lib/efi_loader/efi_signature.c > > @@ -434,10 +434,11 @@ static bool efi_search_siglist(struct x509_certificate *cert, > > * time64_t revocation_time; > > * }; > > */ > > - if ((sig_data->size == SHA256_SUM_LEN) && > > - !memcmp(sig_data->data, hash, SHA256_SUM_LEN)) { > > + if ((sig_data->size >= SHA256_SUM_LEN + sizeof(time64_t)) && > > + !memcmp(sig_data->data, msg, SHA256_SUM_LEN)) { > > memcpy(revoc_time, sig_data->data + SHA256_SUM_LEN, > > sizeof(*revoc_time)); > > + EFI_PRINT("revocation time: %llu\n", *revoc_time); > > *revoc_time is of type __s64. So this must be %lld. Cf. > > include/linux/time.h:156 I know that because I added the definition. Interestingly, linux added another type, timeu64_t, later on to avoid an overflow in some calculation. While I don't think the current format is harmful, I will change it. -Takahiro Akashi > Best regards > > Heinrich > > > found = true; > > goto out; > > } > > >