Received: by 2002:a05:7412:3b8b:b0:fc:a2b0:25d7 with SMTP id nd11csp2774102rdb; Mon, 12 Feb 2024 16:54:15 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXkVffufGegka6vXahZCjss1JRq1F017SPz/eWvdx9gEgG8MQ7rNCc1IE7cmGtyfmXXED4sQLrUbUDHWRo+VfR/ilz8QZQFP2KnDIO9VQ== X-Google-Smtp-Source: AGHT+IH5GF8SYKd3n5fg8PZKcuoj6PurB9BpjJnMwikeu2r6nlP0JYmbHcKwLubYFqDkObIzpdry X-Received: by 2002:a17:906:ceca:b0:a3b:f3e4:e91b with SMTP id si10-20020a170906ceca00b00a3bf3e4e91bmr6761923ejb.42.1707785655274; Mon, 12 Feb 2024 16:54:15 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707785655; cv=pass; d=google.com; s=arc-20160816; b=pGW6DkROlk5FY6AJ7PUImdmiCJTgZGMnGOGj2wxhlZp8QGGalnWbfiLVItbnMa12oh GUejOaXcVzO8CW50dftXXDc3Wc5F/jpzlYuZ9MATP1asB21D0ceB0aUlsfw45O85JqwN kgDqKBA1oqaNVJdKXvuYXPkt7Q9qtCBGp0SFTUEl9P6ZQj1FGNUHGpqu9ztJcPYov6Zo CN+2IyrORU9RD/m+iCkjQa7Oe0waw0EjdzKyhnNF3QzW3CnmLQnHIN5etAwFFWd6o5w9 nL4ltm+HPMq1r3FksaT8F7jTrXh/pCFwyU9C2JoWYQq6o3SP3AFeQFrEObHBsI8OtyUK oDOA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=jrJ4xV5JvDX1wTOc1lhUoq/oVbc32wqSyxgS5+/t/ws=; fh=52d7sB3AWCwb5mhwV1IpBulyokjGPhUs01IxYToS+qk=; b=i6H5Rf4Fjn2NfZdmjFuGWnhoxLCSTKgsY73RnAS6JPy5Bj4wFzdm6KwsGKc7IhpLZ9 LZxa/gSAYB0+R5BLN8enpK3l0pwQWviBTefu/wlu3IcgO82qif8pzY/QqKq3QwvsiwSJ uaJbR0jl2aaXW+wXjl7wvTVN4IZkv9DoT8pu3DF7ILVAhkPQeiPJABI6Mpm131LkXKsz HMs8dUowXEJPwSGGpDjUYg4F/37X79trYerXZwKexnOVxtjzYh+BnZBUpGTzLyu3eb2K ke0VC12auyaITEHz91SJrgwx8PPyLuWfwLxeqWk5wg7NjET7s+xXnqXZ9uvBm6mAY+h2 30MQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=rTDfEL7w; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-62699-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-62699-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org X-Forwarded-Encrypted: i=2; AJvYcCWgfNxUUYtk2P1/a/9wfoFx2Q9baVoJm2NsZPT1baABPyfj+hlXI6BaMtV02hcXcnfAYWo9Nk/z/D5R9Fken7wIACPriRcJX/36v0ncRQ== Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id x2-20020a1709064a8200b00a3caa41bd8asi717018eju.82.2024.02.12.16.54.15 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Feb 2024 16:54:15 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-62699-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=rTDfEL7w; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-62699-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-62699-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 am.mirrors.kernel.org (Postfix) with ESMTPS id 0012E1F21FD9 for ; Tue, 13 Feb 2024 00:54:14 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2EB9D7D418; Tue, 13 Feb 2024 00:22:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="rTDfEL7w" 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 540187CF1D; Tue, 13 Feb 2024 00:22:56 +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=1707783776; cv=none; b=bEzAgWsM5jSeKFEO8D8kL23onKiLtP9eNxd+pr9NwwaEiZTY1+NsbwW5whQgstuoyNEV3oKY+18wpmiGa1efRpn68fHMGqvRqICJMV4G3fvb4TCaEO8/B6kW//OckbWPR7nolSrQkFieVAEM8pjy11uYKOGQ3i203wCynmsAqpE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707783776; c=relaxed/simple; bh=gentspeUg3lNv4PK8QA7OTi5omE8+hd7xEAFzJeXqTs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=QWocvs1RcvfqvuQxWRp5W/B/q0XRKK+YT4wL71UkAQA8gNyLr+VgJ4uYLM5ZAVpVUsVLhnbFGBeJI8OXfNP78Ehrr7wq61mF+Mdbc/sHqUleXjPi6YYY0Fii005hQoYKPKHU7ucI/ARr3VhuwGAAVr6FH5ZPAyeyEwUkkvPnNbI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=rTDfEL7w; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id A0B17C433C7; Tue, 13 Feb 2024 00:22:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1707783775; bh=gentspeUg3lNv4PK8QA7OTi5omE8+hd7xEAFzJeXqTs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rTDfEL7wbjvxaAPGofzRWncxs+63nv1vSg5CHL2IOW6HShcOIgo9kKULo8TN85QXW UA519AR8uHFoaNSVvRWvj16vZ2EIeTO7R+JV5ip3o1YwRsuQ1i4XaDKgUJkbRJcx+d 58JLNz+z9U9gTddiiEpXRyPObswdaqOFdmy/LtHYMcV80zhCqim5i421x8qM3rtpVN xCpVCaAqE3oQ90jWUlgHd5vr60lE7iBYs1nuADK2yhzxvaDcnU2ZMQEpUhyw8H07Pj ipyGvia2p0bYCysmfARliDkVIf/BZy5rMhAnRYyAtNDtiMa5Q0hss527/S7zV0D3cw ag0pDOf10heFA== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Andrew Bresticker , Ard Biesheuvel , Sasha Levin , paul.walmsley@sifive.com, palmer@dabbelt.com, aou@eecs.berkeley.edu, linux-efi@vger.kernel.org, linux-riscv@lists.infradead.org Subject: [PATCH AUTOSEL 6.1 15/28] efi: runtime: Fix potential overflow of soft-reserved region size Date: Mon, 12 Feb 2024 19:22:13 -0500 Message-ID: <20240213002235.671934-15-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240213002235.671934-1-sashal@kernel.org> References: <20240213002235.671934-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore X-stable-base: Linux 6.1.77 Content-Transfer-Encoding: 8bit From: Andrew Bresticker [ Upstream commit de1034b38a346ef6be25fe8792f5d1e0684d5ff4 ] md_size will have been narrowed if we have >= 4GB worth of pages in a soft-reserved region. Signed-off-by: Andrew Bresticker Signed-off-by: Ard Biesheuvel Signed-off-by: Sasha Levin --- 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 7c48c380d722..1995f0a2e0fc 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; + u64 md_size = md->num_pages << EFI_PAGE_SHIFT; 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 d0daacd2c903..6b142aa35389 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; + u64 md_size = md->num_pages << EFI_PAGE_SHIFT; struct resource *res; if (!(md->attribute & EFI_MEMORY_SP)) -- 2.43.0