lkml.org 
[lkml]   [2023]   [Dec]   [15]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 1/2] um: do not panic on kernel mode faults
Date
From: Petr Tesarik <petr.tesarik1@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@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

\
 
 \ /
  Last update: 2023-12-15 13:32    [W:0.080 / U:0.132 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site