Module Name: src
Committed By: reinoud
Date: Mon Jun 11 19:23:21 UTC 2018
Modified Files:
src/sys/arch/usermode/usermode: trap.c
Log Message:
Prevent nested SIGIOs ruining the system stack
To generate a diff of this commit:
cvs rdiff -u -r1.67 -r1.68 src/sys/arch/usermode/usermode/trap.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/arch/usermode/usermode/trap.c
diff -u src/sys/arch/usermode/usermode/trap.c:1.67 src/sys/arch/usermode/usermode/trap.c:1.68
--- src/sys/arch/usermode/usermode/trap.c:1.67 Fri May 18 20:24:16 2018
+++ src/sys/arch/usermode/usermode/trap.c Mon Jun 11 19:23:21 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: trap.c,v 1.67 2018/05/18 20:24:16 reinoud Exp $ */
+/* $NetBSD: trap.c,v 1.68 2018/06/11 19:23:21 reinoud Exp $ */
/*-
* Copyright (c) 2011 Reinoud Zandijk <[email protected]>
@@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.67 2018/05/18 20:24:16 reinoud Exp $");
+__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.68 2018/06/11 19:23:21 reinoud Exp $");
#include <sys/types.h>
#include <sys/param.h>
@@ -335,7 +335,9 @@ handle_signal(int sig, siginfo_t *info,
if (sig == SIGILL)
print_illegal_instruction_siginfo(sig, info, ctx, pc, va, sp);
- /* if we're running on a stack of our own, use the system stack */
+ /* currently running on the dedicated signal stack */
+
+ /* if we're running on a userland stack, switch to the system stack */
from_userland = 0;
if ((sp < (vaddr_t) pcb->sys_stack) ||
(sp > (vaddr_t) pcb->sys_stack_top)) {
@@ -361,7 +363,11 @@ handle_signal(int sig, siginfo_t *info,
jump_ucp.uc_stack.ss_size = sp - (vaddr_t) pcb->sys_stack;
jump_ucp.uc_link = (void *) fp; /* link to old frame on stack */
- thunk_sigemptyset(&jump_ucp.uc_sigmask);
+ /* prevent multiple nested SIGIOs */
+ if (sig == SIGIO)
+ thunk_sigfillset(&jump_ucp.uc_sigmask);
+ else
+ thunk_sigemptyset(&jump_ucp.uc_sigmask);
jump_ucp.uc_flags = _UC_STACK | _UC_CPU | _UC_SIGMASK;
thunk_makecontext(&jump_ucp,