[PATCH 1/2] um: do not panic on kernel mode faults
Petr Tesarik
petrtesarik at huaweicloud.com
Fri Dec 15 04:14:30 PST 2023
From: Petr Tesarik <petr.tesarik1 at huawei-partners.com>
Do not call panic() on unrecoverable page faults in kernel mode. Although
such page faults always indicate a bug in the kernel, other architectures
prefer to kill only the current process and continue.
The new behavior is useful for testing intentional kernel mode page faults
with KUnit.
Signed-off-by: Petr Tesarik <petr.tesarik1 at huawei-partners.com>
---
arch/um/kernel/trap.c | 15 ++++++++++-----
1 file changed, 10 insertions(+), 5 deletions(-)
diff --git a/arch/um/kernel/trap.c b/arch/um/kernel/trap.c
index 6d8ae86ae978..1124a382fd14 100644
--- a/arch/um/kernel/trap.c
+++ b/arch/um/kernel/trap.c
@@ -17,6 +17,14 @@
#include <os.h>
#include <skas.h>
+static void page_fault_oops(struct uml_pt_regs *regs, unsigned long address,
+ unsigned long ip)
+{
+ pr_alert("Kernel mode fault at addr 0x%lx, ip 0x%lx\n", address, ip);
+ show_regs(container_of(regs, struct pt_regs, regs));
+ make_task_dead(SIGKILL);
+}
+
/*
* Note this is constrained to return 0, -EFAULT, -EACCES, -ENOMEM by
* segv().
@@ -249,11 +257,8 @@ unsigned long segv(struct faultinfo fi, unsigned long ip, int is_user,
else if (!is_user && arch_fixup(ip, regs))
goto out;
- if (!is_user) {
- show_regs(container_of(regs, struct pt_regs, regs));
- panic("Kernel mode fault at addr 0x%lx, ip 0x%lx",
- address, ip);
- }
+ if (!is_user)
+ page_fault_oops(regs, address, ip);
show_segv_info(regs);
--
2.34.1
More information about the linux-um
mailing list