[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <05f00515-1400-2f39-0bdb-b963994bf882@amd.com>
Date: Fri, 18 Apr 2025 09:43:43 -0500
From: Tom Lendacky <thomas.lendacky@....com>
To: Dmytro Maluka <dmaluka@...omium.org>,
Dave Hansen <dave.hansen@...ux.intel.com>
Cc: Andy Lutomirski <luto@...nel.org>, Peter Zijlstra <peterz@...radead.org>,
Thomas Gleixner <tglx@...utronix.de>, Ingo Molnar <mingo@...hat.com>,
Borislav Petkov <bp@...en8.de>,
"maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT)" <x86@...nel.org>,
"H. Peter Anvin" <hpa@...or.com>,
"open list:X86 MM" <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] x86/ioremap: Fix off-by-one in e820 check in
memremap_should_map_decrypted()
On 4/18/25 08:59, Dmytro Maluka wrote:
> The end address in e820__get_entry_type() is exclusive, not inclusive.
>
> Note: untested, bug found by code inspection.
>
> Signed-off-by: Dmytro Maluka <dmaluka@...omium.org>
> ---
> arch/x86/mm/ioremap.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/arch/x86/mm/ioremap.c b/arch/x86/mm/ioremap.c
> index 331e101bf801..a44800a6196e 100644
> --- a/arch/x86/mm/ioremap.c
> +++ b/arch/x86/mm/ioremap.c
> @@ -578,7 +578,7 @@ static bool memremap_should_map_decrypted(resource_size_t phys_addr,
> }
>
> /* Check if the address is outside kernel usable area */
> - switch (e820__get_entry_type(phys_addr, phys_addr + size - 1)) {
> + switch (e820__get_entry_type(phys_addr, phys_addr + size)) {
I don't think removing the " - 1" is correct. For example, if you are
mapping a page-aligned value for page-size (4K), then not subtracting 1
will place you on the next page, which is incorrect, because you are not
mapping that page.
Thanks,
Tom
> case E820_TYPE_RESERVED:
> case E820_TYPE_ACPI:
> case E820_TYPE_NVS:
Powered by blists - more mailing lists