From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 54C5BC04FE1 for ; Thu, 27 Jul 2023 08:22:33 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id DB7D086784; Thu, 27 Jul 2023 10:22:30 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="LoJR4QYN"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 9C7798677D; Thu, 27 Jul 2023 10:22:27 +0200 (CEST) Received: from mail-wm1-x32c.google.com (mail-wm1-x32c.google.com [IPv6:2a00:1450:4864:20::32c]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 08E128680E for ; Thu, 27 Jul 2023 10:22:19 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=ilias.apalodimas@linaro.org Received: by mail-wm1-x32c.google.com with SMTP id 5b1f17b1804b1-3fbc77e76abso6898745e9.1 for ; Thu, 27 Jul 2023 01:22:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1690446138; x=1691050938; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=2vkFXYaphd9C3n38erlwfgt4bF6RVuCWNtPURTrZXaA=; b=LoJR4QYNny9Pi/j7vbZBjuiWvAY4x9hYeR6EsK2+wV0OHc5QExQpyfBePAMEVtoUGo ivhtlKY7zizzta0nIatB2RNwe8EYv2q3mJSF/iGAMzPFm+2r9vvsMvljcTwgx9Nrbov6 nDenGMmviE/eEXMbZNEHKKqqahtkA6FXOcJ2/5szB4rTHg6YZFbSKn5iYW/OaIaG5Cr0 EaoDsXrdtX3M0rlXybboZzQ94kdLp/KQ5Gx/tA9F8cEz9ZEFBg3NvVugHtlXssvpY6gG ZaUYj39z5ljq7cr3Rnxd48sgQ/F2fjRmeEMG3cG1AQnx04mddMSUPBLdJwaDW2OHvBm1 IHJA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690446138; x=1691050938; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=2vkFXYaphd9C3n38erlwfgt4bF6RVuCWNtPURTrZXaA=; b=gr5jPWYuPmDeDXtswn31dT2dSgwmaLTrPbYz/TIXhU19Fj/SWnEE/USagK4MqdLwOZ U1P1DM45bkbaEC/qB805Nr2YQnmQrHeeprMBRQUj7Weeyf5+f10S7AKHfwrDb9G++hGS KLAg0mmDes/wnc3KcQNMOxWyxEqxfMcXJ7xKvYZqpnF8ZLOjttSR6q6qnRFD5FzTxAPI 2UD1eEdkY/eLWvCSYpSpBvwThqIWqG2N5te6ysiGGtv+SMvYq6l7WqpicWeRgNNNNl55 9/4yvIVviwhOYaKMj8jArHnzqhbjhp7MWzQYlqGsh8cDwv1pgTjvYyWnO/n/5M1RAdg5 KWPw== X-Gm-Message-State: ABy/qLbjkwL9LWPhD5JlNeW8kBmkW5riy1uDnl7dCnXOHJ/byG5DHUgt muqb7mcQi0+K+Z+dKVRNIPfEYw== X-Google-Smtp-Source: APBJJlH+r/2q+fXNGPMb5AAxYCEOFDT7ydOoMM9ax9jwOXX58DzVVK2bbc6pZ6W7THTZgj4r9EfGcg== X-Received: by 2002:a05:600c:2058:b0:3fb:739d:27b2 with SMTP id p24-20020a05600c205800b003fb739d27b2mr1216833wmg.8.1690446138372; Thu, 27 Jul 2023 01:22:18 -0700 (PDT) Received: from hades (ppp089210088142.access.hol.gr. [89.210.88.142]) by smtp.gmail.com with ESMTPSA id z3-20020a1c4c03000000b003fd2eba5a9esm3979268wmf.5.2023.07.27.01.22.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Jul 2023 01:22:18 -0700 (PDT) Date: Thu, 27 Jul 2023 11:22:15 +0300 From: Ilias Apalodimas To: Dan Carpenter Cc: Heinrich Schuchardt , u-boot@lists.denx.de Subject: Re: [PATCH v2] efi_loader: Fix memory corruption on 32bit systems Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean Hi Dan, [...] > @@ -313,7 +313,7 @@ static int cmp_pe_section(const void *arg1, const void *arg2) > * > * Return: valid pointer to a image, return NULL if allocation fails. > */ > -void *efi_prepare_aligned_image(void *efi, u64 *efi_size) > +void *efi_prepare_aligned_image(void *efi, size_t *efi_size) > { > size_t new_efi_size; > void *new_efi; > @@ -600,7 +600,7 @@ static bool efi_image_authenticate(void *efi, size_t efi_size) > if (!efi_secure_boot_enabled()) > return true; > > - new_efi = efi_prepare_aligned_image(efi, (u64 *)&efi_size); > + new_efi = efi_prepare_aligned_image(efi, &efi_size); > if (!new_efi) > return false; > > diff --git a/lib/efi_loader/efi_tcg2.c b/lib/efi_loader/efi_tcg2.c > index 49f8a5e77cbf..d57afd0c498b 100644 > --- a/lib/efi_loader/efi_tcg2.c > +++ b/lib/efi_loader/efi_tcg2.c > @@ -882,7 +882,7 @@ out: > * > * Return: status code > */ > -static efi_status_t tcg2_hash_pe_image(void *efi, u64 efi_size, > +static efi_status_t tcg2_hash_pe_image(void *efi, size_t efi_size, > struct tpml_digest_values *digest_list) Unfortunately the rabbit hole is a bit deeper with this one. tcg2_hash_pe_image() is called in - tcg2_measure_pe_image(). This one is called in efi_load_pe() and the type is indeed a size_t there, so that's fine - efi_tcg2_hash_log_extend_event(), this one is different... The function is described by the EFI spec [0] which mandates a u64... I think that was the reason efi_prepare_aligned_image() is using a u64 to begin with. This one uses the size only though not the pointer, but in a 32bit platform it would truncate s size > UINT_MAX. [0] https://trustedcomputinggroup.org/wp-content/uploads/EFI-Protocol-Specification-rev13-160330final.pdf Regards /Ilias > { > WIN_CERTIFICATE *wincerts = NULL; > -- > 2.39.2 >