From: Andrew Morton <akpm@linux-foundation.org>
To: Thorsten Blum <blum@kernel.org>
Cc: Thomas Gleixner <tglx@kernel.org>, Ingo Molnar <mingo@redhat.com>,
Borislav Petkov <bp@alien8.de>,
Dave Hansen <dave.hansen@linux.intel.com>,
x86@kernel.org, "H. Peter Anvin" <hpa@zytor.com>,
"Ahmed S. Darwish" <darwi@linutronix.de>,
Kevin Brodsky <kevin.brodsky@arm.com>,
Andreas Larsson <andreas@gaisler.com>,
Yeoreum Yun <yeoreum.yun@arm.com>,
Tom Lendacky <thomas.lendacky@amd.com>,
"Ritesh Harjani (IBM)" <ritesh.list@gmail.com>,
Ingo Molnar <mingo@kernel.org>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH RESEND] x86/boot: Fix off-by-one error in sme_clear_pgd()
Date: Fri, 30 Oct 2026 18:46:42 -0700 [thread overview]
Message-ID: <20261030184642.3ec0215c9b47e3f3e0dbdbdd@linux-foundation.org> (raw)
In-Reply-To: <20260918142714.242711-2-blum@kernel.org>
On Fri, 18 Sep 2026 16:27:13 +0200 Thorsten Blum <blum@kernel.org> wrote:
> The mapping helpers __sme_map_range_pmd() and __sme_map_range_pte(), and
> therefore sme_encrypt_kernel(), use exclusive end addresses and stop
> before vaddr reaches vaddr_end.
>
> However, sme_clear_pgd() treats vaddr_end as inclusive when calculating
> the last PGD entry to clear. If vaddr_end is PGD-aligned, the first PGD
> entry outside the range is cleared too.
>
> Use vaddr_end - 1 to calculate the last PGD entry within the range.
When fixing a bug, please always fully describe the worst-case
userspace-visible runtime effects of that bug.
I'm guessing "none known, this is from code inspection"?
Thanks.
> --- a/arch/x86/boot/startup/sme.c
> +++ b/arch/x86/boot/startup/sme.c
> @@ -99,7 +99,7 @@ static void __init sme_clear_pgd(struct sme_populate_pgd_data *ppd)
> pgd_t *pgd_p;
>
> pgd_start = ppd->vaddr & PGDIR_MASK;
> - pgd_end = ppd->vaddr_end & PGDIR_MASK;
> + pgd_end = (ppd->vaddr_end - 1) & PGDIR_MASK;
>
> pgd_size = (((pgd_end - pgd_start) / PGDIR_SIZE) + 1) * sizeof(pgd_t);
>
prev parent reply other threads:[~2026-10-31 1:46 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-18 14:27 Thorsten Blum
2026-10-31 1:46 ` Andrew Morton [this message]
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=20261030184642.3ec0215c9b47e3f3e0dbdbdd@linux-foundation.org \
--to=akpm@linux-foundation.org \
--cc=andreas@gaisler.com \
--cc=blum@kernel.org \
--cc=bp@alien8.de \
--cc=darwi@linutronix.de \
--cc=dave.hansen@linux.intel.com \
--cc=hpa@zytor.com \
--cc=kevin.brodsky@arm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=mingo@redhat.com \
--cc=ritesh.list@gmail.com \
--cc=tglx@kernel.org \
--cc=thomas.lendacky@amd.com \
--cc=x86@kernel.org \
--cc=yeoreum.yun@arm.com \
/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®