Skip to content

Commit 6933c11

Browse files
seehearfeelchenhuacai
authored andcommitted
LoongArch: Do not kill the task in die() if notify_die() returns NOTIFY_STOP
If notify_die() returns NOTIFY_STOP, honor the return value from the handler chain invocation in die() and return without killing the task as, through a debugger, the fault may have been fixed. It makes sense even if ignoring the event will make the system unstable: by allowing access through a debugger it has been compromised already anyway. It makes our port consistent with x86, arm64, riscv and csky. Commit 20c0d2d ("[PATCH] i386: pass proper trap numbers to die chain handlers") may be the earliest of similar changes. Link: https://lore.kernel.org/r/43DDF02E.76F0.0078.0@novell.com/ Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn> Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
1 parent a746ceb commit 6933c11

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

arch/loongarch/include/asm/ptrace.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ static inline void regs_set_return_value(struct pt_regs *regs, unsigned long val
162162
#define instruction_pointer(regs) ((regs)->csr_era)
163163
#define profile_pc(regs) instruction_pointer(regs)
164164

165-
extern void die(const char *, struct pt_regs *) __noreturn;
165+
extern void die(const char *, struct pt_regs *);
166166

167167
static inline void die_if_kernel(const char *str, struct pt_regs *regs)
168168
{

arch/loongarch/kernel/traps.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -383,16 +383,15 @@ void show_registers(struct pt_regs *regs)
383383

384384
static DEFINE_RAW_SPINLOCK(die_lock);
385385

386-
void __noreturn die(const char *str, struct pt_regs *regs)
386+
void die(const char *str, struct pt_regs *regs)
387387
{
388+
int ret;
388389
static int die_counter;
389-
int sig = SIGSEGV;
390390

391391
oops_enter();
392392

393-
if (notify_die(DIE_OOPS, str, regs, 0, current->thread.trap_nr,
394-
SIGSEGV) == NOTIFY_STOP)
395-
sig = 0;
393+
ret = notify_die(DIE_OOPS, str, regs, 0,
394+
current->thread.trap_nr, SIGSEGV);
396395

397396
console_verbose();
398397
raw_spin_lock_irq(&die_lock);
@@ -414,7 +413,8 @@ void __noreturn die(const char *str, struct pt_regs *regs)
414413
if (panic_on_oops)
415414
panic("Fatal exception");
416415

417-
make_task_dead(sig);
416+
if (ret != NOTIFY_STOP)
417+
make_task_dead(SIGSEGV);
418418
}
419419

420420
static inline void setup_vint_size(unsigned int size)

0 commit comments

Comments
 (0)