Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch/amd64/include Define PTRACE_ILLEGAL_ASM for NetBSD/...



details:   https://anonhg.NetBSD.org/src/rev/8ac9b74eeffe
branches:  trunk
changeset: 448677:8ac9b74eeffe
user:      kamil <kamil%NetBSD.org@localhost>
date:      Thu Feb 07 00:19:54 2019 +0000

description:
Define PTRACE_ILLEGAL_ASM for NetBSD/amd64 in ptrace.h

Use ud2 instruction that is guaranteed to raise an invalid instruction
exception (through SIGILL).

On NetBSD and FreeBSD this instruction raises ILL_PRVOPC, on Linux
ILL_ILLOPN. It's not clear which opion is better "Privileged opcode" vs
"Illegal operand", because ud2 doesn't seem to be a privileged operation
and it doesn't take any operand.

Assume in future changes that this opcode will raise ILL_PRVOPC and keep
it purely for testing purposes of the SIGILL crash type.

diffstat:

 sys/arch/amd64/include/ptrace.h |  4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diffs (18 lines):

diff -r feee2b2c9595 -r 8ac9b74eeffe sys/arch/amd64/include/ptrace.h
--- a/sys/arch/amd64/include/ptrace.h   Thu Feb 07 00:04:56 2019 +0000
+++ b/sys/arch/amd64/include/ptrace.h   Thu Feb 07 00:19:54 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ptrace.h,v 1.12 2017/04/12 18:17:59 kamil Exp $        */
+/*     $NetBSD: ptrace.h,v 1.13 2019/02/07 00:19:54 kamil Exp $        */
 
 /*
  * Copyright (c) 1993 Christopher G. Demetriou
@@ -63,6 +63,8 @@
 #define PTRACE_REG_SP(r)       (r)->regs[_REG_RSP]
 #define PTRACE_REG_INTRV(r)    (r)->regs[_REG_RAX]
 
+#define PTRACE_ILLEGAL_ASM     __asm __volatile ("ud2" : : : "memory")
+
 #define PTRACE_BREAKPOINT      ((const uint8_t[]) { 0xcc })
 #define PTRACE_BREAKPOINT_ASM  __asm __volatile ("int3" : : : "memory")
 #define PTRACE_BREAKPOINT_SIZE 1



Home | Main Index | Thread Index | Old Index