* [PATCH v2] x86/mm/pat: Don't leak reservations at the physical address limit
@ 2026-11-29 14:26 Chris Down
0 siblings, 0 replies; only message in thread
From: Chris Down @ 2026-11-29 14:26 UTC (permalink / raw)
To: Dave Hansen, Andy Lutomirski, Peter Zijlstra, Borislav Petkov, x86
Cc: Rik van Riel, Thomas Gleixner, Ingo Molnar, H. Peter Anvin,
Jeff Moyer, Dan Williams, David Hildenbrand, Xu Yilun,
linux-kernel, kernel-team
memtype_reserve() and memtype_free() pass their physical addresses
through sanitize_phys(). Both take an exclusive end address, but
sanitize_phys() expects an inclusive one. Commit aeef8b5089b7
("x86/pat: Pass valid address to sanitize_phys()") fixed this for
memtype_reserve(), but memtype_free() still passes the exclusive end.
So this has the effect that for a range that ends exactly at the top of
the physical address space, the mask turns the end into 0.
As a result the ISA range check succeeds and memtype_free() returns 0
without removing the reservation. A new reservation that overlaps
existing entries takes on their memory type, so the stale entry goes on
choosing the cache mode for that range.
Convert the end address in memtype_free() the same way as
memtype_reserve() does.
Fixes: 510ee090abc3 ("x86/mm/pat: Prepare {reserve, free}_memtype() for "decoy" addresses")
Cc: stable@vger.kernel.org
Signed-off-by: Chris Down <chris@chrisdown.name>
---
v1 at https://lore.kernel.org/r/avAH5XMCbIWvdD8R@chrisdown.name
v2:
- Reference aeef8b5089b7, which already fixed memtype_reserve(), and
point Fixes: at 510ee090abc3 instead (Yilun)
- Add the same comment as in memtype_reserve()
arch/x86/mm/pat/memtype.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/arch/x86/mm/pat/memtype.c b/arch/x86/mm/pat/memtype.c
index cf94fb561310..11e1bb1e7097 100644
--- a/arch/x86/mm/pat/memtype.c
+++ b/arch/x86/mm/pat/memtype.c
@@ -613,7 +613,12 @@ int memtype_free(u64 start, u64 end)
return 0;
start = sanitize_phys(start);
- end = sanitize_phys(end);
+
+ /*
+ * The end address passed into this function is exclusive, but
+ * sanitize_phys() expects an inclusive address.
+ */
+ end = sanitize_phys(end - 1) + 1;
/* Low ISA region is always mapped WB. No need to track */
if (x86_platform.is_untracked_pat_range(start, end))
base-commit: b1e6233ef68ff994c924fad46a728e7191175bef
--
2.56.1
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2026-11-29 14:26 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-29 14:26 [PATCH v2] x86/mm/pat: Don't leak reservations at the physical address limit Chris Down
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®