summaryrefslogtreecommitdiff
path: root/sys/kern
diff options
context:
space:
mode:
authorSebastien Marie <semarie@cvs.openbsd.org>2019-07-09 11:35:07 +0000
committerSebastien Marie <semarie@cvs.openbsd.org>2019-07-09 11:35:07 +0000
commitac9b4ecdfee4ba64777d8945268f2a426fd97aa8 (patch)
tree3ac66ff4e4feb05190660ef6ecef9a0cd0aa2fa8 /sys/kern
parent40a461e0f725a98fa76b8d56888479c0be6cc2e8 (diff)
unlock pipe(2) and pipe2(2) syscalls
initial work from mpi@ ok visa@ mpi@
Diffstat (limited to 'sys/kern')
-rw-r--r--sys/kern/sys_pipe.c17
-rw-r--r--sys/kern/syscalls.master6
2 files changed, 16 insertions, 7 deletions
diff --git a/sys/kern/sys_pipe.c b/sys/kern/sys_pipe.c
index 2d2c2210e5e..9d337f0622a 100644
--- a/sys/kern/sys_pipe.c
+++ b/sys/kern/sys_pipe.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sys_pipe.c,v 1.88 2019/06/22 06:48:25 semarie Exp $ */
+/* $OpenBSD: sys_pipe.c,v 1.89 2019/07/09 11:35:06 semarie Exp $ */
/*
* Copyright (c) 1996 John S. Dyson
@@ -198,6 +198,7 @@ free3:
free2:
fdpunlock(fdp);
free1:
+ /* fine without KERNEL_LOCK because just created */
pipeclose(wpipe);
pipeclose(rpipe);
return (error);
@@ -214,12 +215,18 @@ pipespace(struct pipe *cpipe, u_int size)
{
caddr_t buffer;
+ /* pipe should be uninitialized or locked */
+ KASSERT((cpipe->pipe_buffer.buffer == NULL) ||
+ (cpipe->pipe_state & PIPE_LOCK));
+
+ /* buffer should be empty */
+ KASSERT(cpipe->pipe_buffer.cnt == 0);
+
KERNEL_LOCK();
buffer = km_alloc(size, &kv_any, &kp_pageable, &kd_waitok);
KERNEL_UNLOCK();
- if (buffer == NULL) {
+ if (buffer == NULL)
return (ENOMEM);
- }
/* free old resources if we are resizing */
pipe_free_kmem(cpipe);
@@ -227,7 +234,6 @@ pipespace(struct pipe *cpipe, u_int size)
cpipe->pipe_buffer.size = size;
cpipe->pipe_buffer.in = 0;
cpipe->pipe_buffer.out = 0;
- cpipe->pipe_buffer.cnt = 0;
atomic_add_int(&amountpipekva, cpipe->pipe_buffer.size);
@@ -244,6 +250,8 @@ pipe_create(struct pipe *cpipe)
/* so pipe_free_kmem() doesn't follow junk pointer */
cpipe->pipe_buffer.buffer = NULL;
+ cpipe->pipe_buffer.cnt = 0;
+
/*
* protect so pipeclose() doesn't follow a junk pointer
* if pipespace() fails.
@@ -303,6 +311,7 @@ pipeselwakeup(struct pipe *cpipe)
selwakeup(&cpipe->pipe_sel);
} else
KNOTE(&cpipe->pipe_sel.si_note, 0);
+
if (cpipe->pipe_state & PIPE_ASYNC)
pgsigio(&cpipe->pipe_sigio, SIGIO, 0);
}
diff --git a/sys/kern/syscalls.master b/sys/kern/syscalls.master
index 70f84136dc3..778f8077a3a 100644
--- a/sys/kern/syscalls.master
+++ b/sys/kern/syscalls.master
@@ -1,4 +1,4 @@
-; $OpenBSD: syscalls.master,v 1.193 2019/06/24 12:49:54 visa Exp $
+; $OpenBSD: syscalls.master,v 1.194 2019/07/09 11:35:06 semarie Exp $
; $NetBSD: syscalls.master,v 1.32 1996/04/23 10:24:21 mycroft Exp $
; @(#)syscalls.master 8.2 (Berkeley) 1/13/94
@@ -216,7 +216,7 @@
socklen_t namelen); }
99 STD { int sys_getdents(int fd, void *buf, size_t buflen); }
100 STD { int sys_getpriority(int which, id_t who); }
-101 STD { int sys_pipe2(int *fdp, int flags); }
+101 STD NOLOCK { int sys_pipe2(int *fdp, int flags); }
102 STD { int sys_dup3(int from, int to, int flags); }
103 STD { int sys_sigreturn(struct sigcontext *sigcntxp); }
104 STD { int sys_bind(int s, const struct sockaddr *name, \
@@ -448,7 +448,7 @@
260 UNIMPL
261 UNIMPL
262 UNIMPL
-263 STD { int sys_pipe(int *fdp); }
+263 STD NOLOCK { int sys_pipe(int *fdp); }
264 STD { int sys_fhopen(const fhandle_t *fhp, int flags); }
265 UNIMPL
266 UNIMPL