From f5edbdc5910a35966903868133ff9b8c9e7e8353 Mon Sep 17 00:00:00 2001 From: guenther Date: Sun, 16 Apr 2023 06:38:50 +0000 Subject: [PATCH] Handle T_CP traps from userland by generating SIGILL, with code ILL_ILLOPC or ILL_BADSTK depending on the error from hardware lack of handling noted by deraadt@ ok jsg@ --- sys/arch/amd64/amd64/trap.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/sys/arch/amd64/amd64/trap.c b/sys/arch/amd64/amd64/trap.c index 783184b2b17..8c9abf64bd7 100644 --- a/sys/arch/amd64/amd64/trap.c +++ b/sys/arch/amd64/amd64/trap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: trap.c,v 1.98 2023/04/15 01:22:50 jsg Exp $ */ +/* $OpenBSD: trap.c,v 1.99 2023/04/16 06:38:50 guenther Exp $ */ /* $NetBSD: trap.c,v 1.2 2003/05/04 23:51:56 fvdl Exp $ */ /*- @@ -431,6 +431,11 @@ usertrap(struct trapframe *frame) sig = SIGTRAP; code = TRAP_BRKPT; break; + case T_CP: + sig = SIGILL; + code = (frame->tf_err & 0x7fff) < 4 ? ILL_ILLOPC + : ILL_BADSTK; + break; case T_PAGEFLT: /* page fault */ if (!uvm_map_inentry(p, &p->p_spinentry, PROC_STACK(p), -- 2.20.1