summaryrefslogtreecommitdiffstats
path: root/sys/kern/sys_pipe.c
diff options
context:
space:
mode:
authorkib <kib@FreeBSD.org>2012-02-21 01:05:12 +0000
committerkib <kib@FreeBSD.org>2012-02-21 01:05:12 +0000
commit80ae8fe82cdaa69f78dc90fa27bc9e79863de0ea (patch)
treed0d078391c4959fc08545db4ab619daadd9cf1d9 /sys/kern/sys_pipe.c
parent31a24bc1664a822f3d06595f42063719e6902ff1 (diff)
downloadFreeBSD-src-80ae8fe82cdaa69f78dc90fa27bc9e79863de0ea.zip
FreeBSD-src-80ae8fe82cdaa69f78dc90fa27bc9e79863de0ea.tar.gz
Fix found places where uio_resid is truncated to int.
Add the sysctl debug.iosize_max_clamp, enabled by default. Setting the sysctl to zero allows to perform the SSIZE_MAX-sized i/o requests from the usermode. Discussed with: bde, das (previous versions) MFC after: 1 month
Diffstat (limited to 'sys/kern/sys_pipe.c')
-rw-r--r--sys/kern/sys_pipe.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/sys/kern/sys_pipe.c b/sys/kern/sys_pipe.c
index 9edcb74..0cb4fce 100644
--- a/sys/kern/sys_pipe.c
+++ b/sys/kern/sys_pipe.c
@@ -617,7 +617,7 @@ pipe_read(fp, uio, active_cred, flags, td)
size = rpipe->pipe_buffer.size - rpipe->pipe_buffer.out;
if (size > rpipe->pipe_buffer.cnt)
size = rpipe->pipe_buffer.cnt;
- if (size > (u_int) uio->uio_resid)
+ if (size > uio->uio_resid)
size = (u_int) uio->uio_resid;
PIPE_UNLOCK(rpipe);
@@ -650,7 +650,7 @@ pipe_read(fp, uio, active_cred, flags, td)
*/
} else if ((size = rpipe->pipe_map.cnt) &&
(rpipe->pipe_state & PIPE_DIRECTW)) {
- if (size > (u_int) uio->uio_resid)
+ if (size > uio->uio_resid)
size = (u_int) uio->uio_resid;
PIPE_UNLOCK(rpipe);
@@ -764,9 +764,10 @@ pipe_build_write_buffer(wpipe, uio)
KASSERT(wpipe->pipe_state & PIPE_DIRECTW,
("Clone attempt on non-direct write pipe!"));
- size = (u_int) uio->uio_iov->iov_len;
- if (size > wpipe->pipe_buffer.size)
- size = wpipe->pipe_buffer.size;
+ if (uio->uio_iov->iov_len > wpipe->pipe_buffer.size)
+ size = wpipe->pipe_buffer.size;
+ else
+ size = uio->uio_iov->iov_len;
if ((i = vm_fault_quick_hold_pages(&curproc->p_vmspace->vm_map,
(vm_offset_t)uio->uio_iov->iov_base, size, VM_PROT_READ,
@@ -960,7 +961,7 @@ pipe_write(fp, uio, active_cred, flags, td)
int flags;
{
int error = 0;
- int desiredsize, orig_resid;
+ size_t desiredsize, orig_resid;
struct pipe *wpipe, *rpipe;
rpipe = fp->f_data;
OpenPOWER on IntegriCloud