pipe: keep uio_iovcnt consistent

In pipe_build_write_buffer we increment uio_iov but did not update
uio_iovcnt.  This would not cause an OOB read (thanks to to uio_resid)
but is inconsistent and could be an issue if other code changes are made
in the future.

Reported by:	Synacktiv
Reviewed by:	jhb, markj, brooks
Sponsored by:	The Alpha-Omega Project
Sponsored by:	The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D45999

(cherry picked from commit d8ff42e816)
This commit is contained in:
Ed Maste 2024-07-17 10:33:53 -04:00
parent 6fb0634bc4
commit cbbc8d6730

View file

@ -942,8 +942,10 @@ pipe_build_write_buffer(struct pipe *wpipe, struct uio *uio)
uio->uio_iov->iov_len -= size;
uio->uio_iov->iov_base = (char *)uio->uio_iov->iov_base + size;
if (uio->uio_iov->iov_len == 0)
if (uio->uio_iov->iov_len == 0) {
uio->uio_iov++;
uio->uio_iovcnt--;
}
uio->uio_resid -= size;
uio->uio_offset += size;
return (0);