DragonFlyBSD Kernel Audit
DF-0249 / fix.diff
← back to finding ↓ download raw
diff --git a/sys/kern/kern_physio.c b/sys/kern/kern_physio.c
--- a/sys/kern/kern_physio.c
+++ b/sys/kern/kern_physio.c
@@ -110,6 +110,8 @@
 			biowait(&bp->b_bio1, "physstr");
 
 			iolen = bp->b_bcount - bp->b_resid;
+			if (iolen < 0)	/* driver reported more resid than xfer'd */
+				iolen = 0;
 			if (uio->uio_segflg == UIO_USERSPACE) {
 				if (uio->uio_rw == UIO_READ && iolen) {
 					error = copyout(bp->b_data, ubase, iolen);