Received: by 2002:a05:7412:bbc7:b0:fc:a2b0:25d7 with SMTP id kh7csp946051rdb; Fri, 2 Feb 2024 08:38:19 -0800 (PST) X-Google-Smtp-Source: AGHT+IH8K46NmK83N0RZk7+n6qiyll4enQfnHE8Jd9iG69ldsAbWC8l79/1+W5SXqEhUER3Lz2YR X-Received: by 2002:a05:622a:22a8:b0:42b:e342:6149 with SMTP id ay40-20020a05622a22a800b0042be3426149mr2663969qtb.39.1706891898906; Fri, 02 Feb 2024 08:38:18 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706891898; cv=pass; d=google.com; s=arc-20160816; b=0uLrSEZ6C0UMz3JujdfrtMghFB0/zQ2Z8FeVlN6WqB+q6r7btOxew/NsPtSpXmACIL HGtSW8r9OnFnLBf0wIVnW9n0rVS3xAMz0jWSolruOx2BeHIqPKIaRY4cp/44OA8Tt1jE 3K7eBfaAT/YUNWG3kAMnS56ObBg4UTc55ONk+bI+0/M1jg+X7qkgWszq6h612YGRKwm9 CMEnHs6WzZshY2Okjmu4Ly7Y9CqHAGeVJDHMuUWVOUtuln9BX0D/da7Wct+ZGbopToHm +UudzkREovb8OAsASO+qjJUBPG+uPx9QreVUFTcsv8i//+jpCNWEVg9jSmJMKfdeG/is 8Mhw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :dkim-signature; bh=sNHHZq0KP+zG4/eP6VQFrK73ExtZxuUHbRjHsBYlhj8=; fh=jSDJEqFCENWJCQ5SNNd8ZpaZMQwtzcH042O0S3JMIOk=; b=xCy9PJ8dhglXVD36lcZ4X+Dyi0TL75EyuvQWa/sGRec23NP5deFM4SLQXqpp0i6yGp zZPfvdG9DsIYKqs3N+23WbRpPpFeYaOJ8n3Wf94nhnSVaLXSqSYd6yQT05wu2TZH8NEV AXmb/7blst4tqzPATIP5c/1YBd1Aeqgj61Y1FxxqLTsRSYVWXN3T/sLR60nXfhcXohtB 2n3R9tc2vOWDm4wmgcTT0rQ3bmS4ngzQPkbmg7zNoM2Khf8raALUJ8QLaHzlC+iQC36L 1+q6Yhz9qimc7L0O9bMRY5vEF+wOKrWBs2mD1GRJzvaLGtJQ1QA9gmWE3EbRsK8TgSmy F4pA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=fXHS0fuy; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-50157-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-50157-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org X-Forwarded-Encrypted: i=1; AJvYcCVlpk6SK2shWmN39oAmEZ+0QoPmtKdBTqWsfEy7SqIiA5xGsA8i0fYmujAgLqRlVgFmaXPL5Tds+dF1GxIhRHp+zN2fxkDaLRoWChdyvA== Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id x7-20020a05622a000700b0042ab228f40dsi2240481qtw.451.2024.02.02.08.38.18 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Feb 2024 08:38:18 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-50157-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=fXHS0fuy; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-50157-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-50157-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id A11AA1C26864 for ; Fri, 2 Feb 2024 16:38:18 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id CD9721487E2; Fri, 2 Feb 2024 16:37:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="fXHS0fuy" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E989C14830B; Fri, 2 Feb 2024 16:37:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706891861; cv=none; b=bznc+aWZyo4KTlZBNtYNfZSGQCgIwVqfsS+cNngRNgCUx+8yuk4kw8x6OcZx9LybmXMyJEmI6beovbUN/0VkSB+H8iGkHWFQuDuTpZHOlKo/F6FJEK7klzRQKDSguv92qCh2EivED/nSdw1ydDqg4RK29QqiYJjBN0Oj3C5ZqVQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706891861; c=relaxed/simple; bh=Uwkd7nTQQrSccD545d3Y+lH6FQYzJbXBcM9/NkSdyEU=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=abHl6eBkfBtANzvGk/TKhv4AZl4en8hO2+1/J7ocZkXHBG+C2ZJUNaGHXRInC5+M6XukKG2QgckbvujfuAoN5oFFDjleErDDmWGZVtT1omfYmS6r4J1cS7/44Hh7NpUmfbZ/EqEabtbDxuFwvFJR6ms6F1xf0r30yguXDB9Wldo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=fXHS0fuy; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8B904C433F1; Fri, 2 Feb 2024 16:37:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1706891860; bh=Uwkd7nTQQrSccD545d3Y+lH6FQYzJbXBcM9/NkSdyEU=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=fXHS0fuyj/S03+wmk5ISzAXdQ8cMdABMx6ExToz8J4VtDmQbJ8hPFgjtzru1e8/Aw DLegNr7XswiSzak9whAzIsW+48P5LDZSbLuGEB31DJe6aKrSIkbhf1Di0GuD0R5KWR 9K/xj19XqXZLro3BoaW+43MvNTrvWnRPxmtN/+gYvTxpka5TxFtxKJaMDux/IszswB JRKDFSIVE+zmeEjhlkCDUxJf0J1LHTMFPsTcJr1AOJ0mM0MQiLFw666l9tZ29VLPu0 LizKmg8YJIsUwwlbbNL8WPUowEqVutqGy87WF3IdnnRKYx7fB8NRX/lflzu+MzYVFq cFuGogFLj8yEQ== Received: by mail-lj1-f178.google.com with SMTP id 38308e7fff4ca-2d093cb1ef3so1391161fa.3; Fri, 02 Feb 2024 08:37:40 -0800 (PST) X-Gm-Message-State: AOJu0Yx34rge4x4vJNdeeLbsHZCKVRaW/iJWQLAmWIurEMzIL885cLdE YnN/6dm+7lN99zZGmMM5hvk3+5ZlORDKlHWzDhIeceZ7hbhzOhJpLs19TVou0/cMDveHNBZTfyV P7mBb6WohcwllqoQuULC6N6WKurM= X-Received: by 2002:a2e:bc1b:0:b0:2d0:870e:b29d with SMTP id b27-20020a2ebc1b000000b002d0870eb29dmr1857693ljf.50.1706891858752; Fri, 02 Feb 2024 08:37:38 -0800 (PST) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240202163433.786581-1-abrestic@rivosinc.com> <20240202163433.786581-2-abrestic@rivosinc.com> In-Reply-To: <20240202163433.786581-2-abrestic@rivosinc.com> From: Ard Biesheuvel Date: Fri, 2 Feb 2024 17:37:24 +0100 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH 1/2] efi: runtime: Fix potential overflow of soft-reserved region size To: Andrew Bresticker Cc: Paul Walmsley , Palmer Dabbelt , Albert Ou , linux-efi@vger.kernel.org, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org Content-Type: text/plain; charset="UTF-8" Hi Andrew, On Fri, 2 Feb 2024 at 17:34, Andrew Bresticker wrote: > > md_size will have been narrowed if we have >= 4GB worth of pages in a > soft-reserved region. > > Signed-off-by: Andrew Bresticker > --- > drivers/firmware/efi/arm-runtime.c | 2 +- > drivers/firmware/efi/riscv-runtime.c | 2 +- > 2 files changed, 2 insertions(+), 2 deletions(-) > > diff --git a/drivers/firmware/efi/arm-runtime.c b/drivers/firmware/efi/arm-runtime.c > index 83f5bb57fa4c..f369256c7003 100644 > --- a/drivers/firmware/efi/arm-runtime.c > +++ b/drivers/firmware/efi/arm-runtime.c > @@ -107,7 +107,7 @@ static int __init arm_enable_runtime_services(void) > efi_memory_desc_t *md; > > for_each_efi_memory_desc(md) { > - int md_size = md->num_pages << EFI_PAGE_SHIFT; > + unsigned long md_size = md->num_pages << EFI_PAGE_SHIFT; Better use u64 here, and below as well. > struct resource *res; > > if (!(md->attribute & EFI_MEMORY_SP)) > diff --git a/drivers/firmware/efi/riscv-runtime.c b/drivers/firmware/efi/riscv-runtime.c > index 09525fb5c240..9da79b8169d2 100644 > --- a/drivers/firmware/efi/riscv-runtime.c > +++ b/drivers/firmware/efi/riscv-runtime.c > @@ -85,7 +85,7 @@ static int __init riscv_enable_runtime_services(void) > efi_memory_desc_t *md; > > for_each_efi_memory_desc(md) { > - int md_size = md->num_pages << EFI_PAGE_SHIFT; > + unsigned long md_size = md->num_pages << EFI_PAGE_SHIFT; > struct resource *res; > > if (!(md->attribute & EFI_MEMORY_SP)) > -- > 2.34.1 > >