summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoranton <anton@openbsd.org>2020-02-01 15:06:21 +0000
committeranton <anton@openbsd.org>2020-02-01 15:06:21 +0000
commitfec696e8b19f2ebeba1c5bca5b14987979b47d40 (patch)
tree60bb088bf07a83c5d05c1b74523c4b154fc84727
parentUse -rdomain to reset rdomain (diff)
downloadwireguard-openbsd-fec696e8b19f2ebeba1c5bca5b14987979b47d40.tar.xz
wireguard-openbsd-fec696e8b19f2ebeba1c5bca5b14987979b47d40.zip
Grab the kernel lock in pgsigio() as it's strictly needed while
operating on the process structure and issuing signals. This is similar to what sigio_setown() already does. With this in place, the pipe subsystem is no longer required to grab the kernel lock before calling pgsigio(). ok visa@
-rw-r--r--sys/kern/kern_sig.c4
-rw-r--r--sys/kern/sys_pipe.c9
2 files changed, 6 insertions, 7 deletions
diff --git a/sys/kern/kern_sig.c b/sys/kern/kern_sig.c
index f91e344ed8f..9400330d3a1 100644
--- a/sys/kern/kern_sig.c
+++ b/sys/kern/kern_sig.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kern_sig.c,v 1.243 2020/01/30 08:51:27 mpi Exp $ */
+/* $OpenBSD: kern_sig.c,v 1.244 2020/02/01 15:06:21 anton Exp $ */
/* $NetBSD: kern_sig.c,v 1.54 1996/04/22 01:38:32 christos Exp $ */
/*
@@ -740,6 +740,7 @@ pgsigio(struct sigio_ref *sir, int sig, int checkctty)
if (sir->sir_sigio == NULL)
return;
+ KERNEL_LOCK();
mtx_enter(&sigio_lock);
sigio = sir->sir_sigio;
if (sigio == NULL)
@@ -756,6 +757,7 @@ pgsigio(struct sigio_ref *sir, int sig, int checkctty)
}
out:
mtx_leave(&sigio_lock);
+ KERNEL_UNLOCK();
}
/*
diff --git a/sys/kern/sys_pipe.c b/sys/kern/sys_pipe.c
index ced9eb90005..59d519845ca 100644
--- a/sys/kern/sys_pipe.c
+++ b/sys/kern/sys_pipe.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sys_pipe.c,v 1.113 2020/01/12 09:18:39 anton Exp $ */
+/* $OpenBSD: sys_pipe.c,v 1.114 2020/02/01 15:06:21 anton Exp $ */
/*
* Copyright (c) 1996 John S. Dyson
@@ -372,20 +372,17 @@ pipeselwakeup(struct pipe *cpipe)
{
rw_assert_wrlock(cpipe->pipe_lock);
- KERNEL_LOCK();
-
/* Kernel lock needed in order to prevent race with kevent. */
+ KERNEL_LOCK();
if (cpipe->pipe_state & PIPE_SEL) {
cpipe->pipe_state &= ~PIPE_SEL;
selwakeup(&cpipe->pipe_sel);
} else
KNOTE(&cpipe->pipe_sel.si_note, NOTE_SUBMIT);
+ KERNEL_UNLOCK();
- /* Kernel lock needed since pgsigio() calls ptsignal(). */
if (cpipe->pipe_state & PIPE_ASYNC)
pgsigio(&cpipe->pipe_sigio, SIGIO, 0);
-
- KERNEL_UNLOCK();
}
int