mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v3 0/3] Address page fault in ima_restore_measurement_list()
@ 2025-12-31  6:16 Harshit Mogalapalli
  2025-12-31  6:16 ` [PATCH v3 1/3] ima: verify the previous kernel's IMA buffer lies in addressable RAM Harshit Mogalapalli
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Harshit Mogalapalli @ 2025-12-31  6:16 UTC (permalink / raw)
  To: zohar, akpm
  Cc: ardb, bp, dave.hansen, graf, guoweikang.kernel,
	harshit.m.mogalapalli, henry.willard, hpa, jbohac, joel.granados,
	linux-kernel, mingo, noodles, paul.x.webb, rppt, sohil.mehta,
	sourabhjain, stable, tglx, x86, yifei.l.liu

On x86_64:
When the second-stage kernel is booted via kexec with a limiting command
line such as "mem=<size>" we observe a pafe fault that happens.

    BUG: unable to handle page fault for address: ffff97793ff47000
    RIP: ima_restore_measurement_list+0xdc/0x45a
    #PF: error_code(0x0000) – not-present page

This happens on x86_64 only, as this is already fixed in aarch64 in
commit: cbf9c4b9617b ("of: check previous kernel's ima-kexec-buffer
against memory bounds")

V1: https://lore.kernel.org/all/20251112193005.3772542-1-harshit.m.mogalapalli@oracle.com/

V1 attempted to do a similar sanity check in x86_64. Borislav suggested
to add a generic helper ima_validate_range() which could then be used
for both OF based and x86_64.

Testing information:
--------------------
On x86_64: With latest 6.19-rc2 based, we could reproduce the issue, and
patched kernel works fine. (with mem=8G on a 16G memory machine)
Thanks to Yifei for finding enabling IMA_KEXEC is the cause.

Thanks for the reviews on V1.

V1 -> V2: 
 - Patch 1: Add a generic helper "ima_validate_range()"
 - Patch 2: Use this new helper in drivers/of/kexec.c -> No functional
   change.
 - Patch 3: Fix the page fault by doing sanity check with
   "ima_validate_range()"

V2: https://lore.kernel.org/all/20251229081523.622515-1-harshit.m.mogalapalli@oracle.com/

V2 -> V3:
 Update subject of Patch 1 to more appropriate one (Suggested by Mimi
Zohar)

Thanks,
Harshit

Harshit Mogalapalli (3):
  ima: verify the previous kernel's IMA buffer lies in addressable RAM
  of/kexec: refactor ima_get_kexec_buffer() to use ima_validate_range()
  x86/kexec: Add a sanity check on previous kernel's ima kexec buffer

 arch/x86/kernel/setup.c            |  6 +++++
 drivers/of/kexec.c                 | 15 +++----------
 include/linux/ima.h                |  1 +
 security/integrity/ima/ima_kexec.c | 35 ++++++++++++++++++++++++++++++
 4 files changed, 45 insertions(+), 12 deletions(-)

-- 
2.50.1


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

end of thread, other threads:[~2026-01-02 20:31 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-12-31  6:16 [PATCH v3 0/3] Address page fault in ima_restore_measurement_list() Harshit Mogalapalli
2025-12-31  6:16 ` [PATCH v3 1/3] ima: verify the previous kernel's IMA buffer lies in addressable RAM Harshit Mogalapalli
2026-01-02 20:30   ` Mimi Zohar
2025-12-31  6:16 ` [PATCH v3 2/3] of/kexec: refactor ima_get_kexec_buffer() to use ima_validate_range() Harshit Mogalapalli
2025-12-31  6:16 ` [PATCH v3 3/3] x86/kexec: Add a sanity check on previous kernel's ima kexec buffer Harshit Mogalapalli

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®