linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3 0/3] KHO: kfence + KHO memory corruption fix
@ 2025-10-21  0:08 Pasha Tatashin
  2025-10-21  0:08 ` [PATCH v3 1/3] liveupdate: kho: warn and fail on metadata or preserved memory in scratch area Pasha Tatashin
                   ` (3 more replies)
  0 siblings, 4 replies; 22+ messages in thread
From: Pasha Tatashin @ 2025-10-21  0:08 UTC (permalink / raw)
  To: akpm, brauner, corbet, graf, jgg, linux-kernel, linux-kselftest,
	linux-mm, masahiroy, ojeda, pasha.tatashin, pratyush, rdunlap,
	rppt, tj, jasonmiu, dmatlack, skhawaja

This series fixes a memory corruption bug in KHO that occurs when KFENCE
is enabled.

The root cause is that KHO metadata, allocated via kzalloc(), can be
randomly serviced by kfence_alloc(). When a kernel boots via KHO, the
early memblock allocator is restricted to a "scratch area". This forces
the KFENCE pool to be allocated within this scratch area, creating a
conflict. If KHO metadata is subsequently placed in this pool, it gets
corrupted during the next kexec operation.

Patch 1/3 introduces a debug-only feature (CONFIG_KEXEC_HANDOVER_DEBUG)
that adds checks to detect and fail any operation that attempts to place
KHO metadata or preserved memory within the scratch area. This serves as
a validation and diagnostic tool to confirm the problem without
affecting production builds.

Patch 2/3 Increases bitmap to PAGE_SIZE, so buddy allocator can be used.

Patch 3/3 Provides the fix by modifying KHO to allocate its metadata
directly from the buddy allocator instead of slab. This bypasses the
KFENCE interception entirely.

Pasha Tatashin (3):
  liveupdate: kho: warn and fail on metadata or preserved memory in
    scratch area
  liveupdate: kho: Increase metadata bitmap size to PAGE_SIZE
  liveupdate: kho: allocate metadata directly from the buddy allocator

 include/linux/gfp.h              |  3 ++
 kernel/Kconfig.kexec             |  9 ++++
 kernel/Makefile                  |  1 +
 kernel/kexec_handover.c          | 72 ++++++++++++++++++++------------
 kernel/kexec_handover_debug.c    | 25 +++++++++++
 kernel/kexec_handover_internal.h | 16 +++++++
 6 files changed, 100 insertions(+), 26 deletions(-)
 create mode 100644 kernel/kexec_handover_debug.c
 create mode 100644 kernel/kexec_handover_internal.h


base-commit: 6548d364a3e850326831799d7e3ea2d7bb97ba08
-- 
2.51.0.869.ge66316f041-goog



^ permalink raw reply	[flat|nested] 22+ messages in thread

end of thread, other threads:[~2025-10-29  8:48 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-10-21  0:08 [PATCH v3 0/3] KHO: kfence + KHO memory corruption fix Pasha Tatashin
2025-10-21  0:08 ` [PATCH v3 1/3] liveupdate: kho: warn and fail on metadata or preserved memory in scratch area Pasha Tatashin
2025-10-22 10:22   ` Pratyush Yadav
2025-10-27 22:29   ` David Matlack
2025-10-28  0:01     ` Pasha Tatashin
2025-10-29  8:48   ` Mike Rapoport
2025-10-21  0:08 ` [PATCH v3 2/3] liveupdate: kho: Increase metadata bitmap size to PAGE_SIZE Pasha Tatashin
2025-10-22 10:25   ` Pratyush Yadav
2025-10-27 22:44   ` David Matlack
2025-10-27 22:56   ` David Matlack
2025-10-27 23:01     ` David Matlack
2025-10-28  0:03       ` Pasha Tatashin
2025-10-21  0:08 ` [PATCH v3 3/3] liveupdate: kho: allocate metadata directly from the buddy allocator Pasha Tatashin
2025-10-27 23:04   ` David Matlack
2025-10-28  0:03     ` Pasha Tatashin
2025-10-21  6:00 ` [PATCH v3 0/3] KHO: kfence + KHO memory corruption fix Mike Rapoport
2025-10-21 16:04   ` Pasha Tatashin
2025-10-21 20:53     ` Andrew Morton
2025-10-22  0:15       ` Pasha Tatashin
2025-10-22  5:48         ` Mike Rapoport
2025-10-22 18:24           ` Andrew Morton
2025-10-23  2:45         ` Andrew Morton

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).