/* SPDX-License-Identifier: GPL-2.0 */ /* * mov_ss_trap.c: Exercise the bizarre side effects of a watchpoint on MOV SS * * This does MOV SS from a watchpointed address followed by various * types of kernel entries. A MOV SS that hits a watchpoint will queue * up a #DB trap but will not actually deliver that trap. The trap * will be delivered after the next instruction instead. The CPU's logic * seems to be: * * - Any fault: drop the pending #DB trap. * - INT $N, INT3, INTO, SYSCALL, SYSENTER: enter the kernel and then * deliver #DB. * - ICEBP: enter the kernel but do not deliver the watchpoint trap * - breakpoint: only one #DB is delivered (phew!) * * There are plenty of ways for a kernel to handle this incorrectly. This * test tries to exercise all the cases. * * This should mostly cover CVE-2018-1087 and CVE-2018-8897.
*/ #define _GNU_SOURCE
/* * INT $1: if #DB has DPL=3 and there isn't special handling, * then the kernel will die.
*/ if (sigsetjmp(jmpbuf, 1) == 0) {
printf("[RUN]\tMOV SS; INT 1\n");
sethandler(SIGSEGV, handle_and_longjmp, SA_RESETHAND); asmvolatile ("mov %[ss], %%ss; int $1" :: [ss] "m" (ss));
}
#ifdef __x86_64__ /* * In principle, we should test 32-bit SYSCALL as well, but * the calling convention is so unpredictable that it's * not obviously worth the effort.
*/ if (sigsetjmp(jmpbuf, 1) == 0) {
printf("[RUN]\tMOV SS; SYSCALL\n");
sethandler(SIGILL, handle_and_longjmp, SA_RESETHAND);
nr = SYS_getpid; /* * Toggle the high bit of RSP to make it noncanonical to * strengthen this test on non-SMAP systems.
*/ asmvolatile ("btc $63, %%rsp\n\t" "mov %[ss], %%ss; syscall\n\t" "btc $63, %%rsp"
: "+a" (nr) : [ss] "m" (ss)
: "rcx" #ifdef __x86_64__
, "r11" #endif
);
} #endif
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.