summaryrefslogtreecommitdiffstats
path: root/sys
diff options
context:
space:
mode:
authoralfred <alfred@FreeBSD.org>2002-02-27 18:49:58 +0000
committeralfred <alfred@FreeBSD.org>2002-02-27 18:49:58 +0000
commitfc10081bae1648ec0fa3822a744459b64ec72aa8 (patch)
tree67352eb954f326ce62fb29e4ea96f7aedf260747 /sys
parent590885c10ff569ba21888a960fbc5c3560998327 (diff)
downloadFreeBSD-src-fc10081bae1648ec0fa3822a744459b64ec72aa8.zip
FreeBSD-src-fc10081bae1648ec0fa3822a744459b64ec72aa8.tar.gz
add assertions in the places where giant is required to catch when
the pipe is locked and shouldn't be. initialize pipe->pipe_mtxp to NULL when creating pipes in order not to trip the above assertions. swap pipe lock with giant around calls to pipe_destroy_write_buffer() pipe_destroy_write_buffer issue noticed by: jhb
Diffstat (limited to 'sys')
-rw-r--r--sys/kern/sys_pipe.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/sys/kern/sys_pipe.c b/sys/kern/sys_pipe.c
index ce9fde7..204f1f7 100644
--- a/sys/kern/sys_pipe.c
+++ b/sys/kern/sys_pipe.c
@@ -277,6 +277,8 @@ pipespace(cpipe, size)
int npages, error;
GIANT_REQUIRED;
+ KASSERT(cpipe->pipe_mtxp == NULL || !mtx_owned(PIPE_MTX(cpipe)),
+ ("pipespace: pipe mutex locked"));
npages = round_page(size)/PAGE_SIZE;
/*
@@ -354,6 +356,7 @@ pipe_create(cpipep)
/* cpipe->pipe_map.ms[] = invalid */
#endif
+ cpipe->pipe_mtxp = NULL; /* avoid pipespace assertion */
error = pipespace(cpipe, PIPE_SIZE);
if (error)
return (error);
@@ -590,6 +593,7 @@ pipe_build_write_buffer(wpipe, uio)
vm_offset_t addr, endaddr, paddr;
GIANT_REQUIRED;
+ PIPE_LOCK_ASSERT(wpipe, MA_NOTOWNED);
size = (u_int) uio->uio_iov->iov_len;
if (size > wpipe->pipe_buffer.size)
@@ -660,6 +664,7 @@ pipe_destroy_write_buffer(wpipe)
int i;
GIANT_REQUIRED;
+ PIPE_LOCK_ASSERT(wpipe, MA_NOTOWNED);
if (wpipe->pipe_map.kva) {
pmap_qremove(wpipe->pipe_map.kva, wpipe->pipe_map.npages);
@@ -699,7 +704,9 @@ pipe_clone_write_buffer(wpipe)
wpipe->pipe_buffer.cnt = size;
wpipe->pipe_state &= ~PIPE_DIRECTW;
+ PIPE_GET_GIANT(wpipe);
pipe_destroy_write_buffer(wpipe);
+ PIPE_DROP_GIANT(wpipe);
}
/*
@@ -791,7 +798,9 @@ retry:
*/
pipe_clone_write_buffer(wpipe);
} else {
+ PIPE_GET_GIANT(wpipe);
pipe_destroy_write_buffer(wpipe);
+ PIPE_DROP_GIANT(wpipe);
}
pipeunlock(wpipe);
return (error);
@@ -1231,7 +1240,10 @@ static void
pipe_free_kmem(cpipe)
struct pipe *cpipe;
{
+
GIANT_REQUIRED;
+ KASSERT(cpipe->pipe_mtxp == NULL || !mtx_owned(PIPE_MTX(cpipe)),
+ ("pipespace: pipe mutex locked"));
if (cpipe->pipe_buffer.buffer != NULL) {
if (cpipe->pipe_buffer.size > PIPE_SIZE)
OpenPOWER on IntegriCloud