[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20231215121431.680-2-petrtesarik@huaweicloud.com>
Date: Fri, 15 Dec 2023 13:14:30 +0100
From: Petr Tesarik <petrtesarik@...weicloud.com>
To: Richard Weinberger <richard@....at>,
Anton Ivanov <anton.ivanov@...bridgegreys.com>,
Johannes Berg <johannes@...solutions.net>,
linux-um@...ts.infradead.org (open list:USER-MODE LINUX (UML)),
linux-kernel@...r.kernel.org (open list)
Cc: Roberto Sassu <roberto.sassu@...weicloud.com>,
petr@...arici.cz,
Petr Tesarik <petr.tesarik1@...wei-partners.com>
Subject: [PATCH 1/2] um: do not panic on kernel mode faults
From: Petr Tesarik <petr.tesarik1@...wei-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@...wei-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
Powered by blists - more mailing lists