From: Tom Lendacky <thomas.lendacky@amd.com>
To: Dmytro Maluka <dmaluka@chromium.org>,
Dave Hansen <dave.hansen@linux.intel.com>
Cc: Andy Lutomirski <luto@kernel.org>,
Peter Zijlstra <peterz@infradead.org>,
Thomas Gleixner <tglx@linutronix.de>,
Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>,
"maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT)"
<x86@kernel.org>, "H. Peter Anvin" <hpa@zytor.com>,
"open list:X86 MM" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] x86/ioremap: Fix off-by-one in e820 check in memremap_should_map_decrypted()
Date: Fri, 18 Apr 2025 09:43:43 -0500 [thread overview]
Message-ID: <05f00515-1400-2f39-0bdb-b963994bf882@amd.com> (raw)
In-Reply-To: <20250418135955.58190-1-dmaluka@chromium.org>
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@chromium.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:
next prev parent reply other threads:[~2025-04-18 14:43 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-18 13:59 Dmytro Maluka
2025-04-18 14:43 ` Tom Lendacky [this message]
2025-04-18 16:48 ` Dmytro Maluka
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=05f00515-1400-2f39-0bdb-b963994bf882@amd.com \
--to=thomas.lendacky@amd.com \
--cc=bp@alien8.de \
--cc=dave.hansen@linux.intel.com \
--cc=dmaluka@chromium.org \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=luto@kernel.org \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
--cc=tglx@linutronix.de \
--cc=x86@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®