summaryrefslogtreecommitdiffstats
path: root/sys/kern/kern_physio.c
diff options
context:
space:
mode:
authorkrw <krw@openbsd.org>2020-01-25 21:56:49 +0000
committerkrw <krw@openbsd.org>2020-01-25 21:56:49 +0000
commitd70f2b8afe0429d3e4f4834de39770786f68c8e7 (patch)
treeaccfb1f134147852cfa3c33420b25104bfba8182 /sys/kern/kern_physio.c
parentDrivers that implement their own *minphys() don't need to call the (diff)
downloadwireguard-openbsd-d70f2b8afe0429d3e4f4834de39770786f68c8e7.tar.xz
wireguard-openbsd-d70f2b8afe0429d3e4f4834de39770786f68c8e7.zip
physio() just needs to check for b_bcount overflow. Let the provided
minphys() function check for MAXPHYS. Feedback from tedu@ kettenis@ dlg@ ok cheloha@, robert@, jmatthew@ as part of larger diff
Diffstat (limited to 'sys/kern/kern_physio.c')
-rw-r--r--sys/kern/kern_physio.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/sys/kern/kern_physio.c b/sys/kern/kern_physio.c
index 47962ccf039..cbdb94184b7 100644
--- a/sys/kern/kern_physio.c
+++ b/sys/kern/kern_physio.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kern_physio.c,v 1.44 2019/12/19 17:40:11 mpi Exp $ */
+/* $OpenBSD: kern_physio.c,v 1.45 2020/01/25 21:56:49 krw Exp $ */
/* $NetBSD: kern_physio.c,v 1.28 1997/05/19 10:43:28 pk Exp $ */
/*-
@@ -110,12 +110,13 @@ physio(void (*strategy)(struct buf *), dev_t dev, int flags,
bp->b_blkno = btodb(uio->uio_offset);
/*
- * Because iov_len is unsigned but b_bcount is signed,
- * an overflow is possible. Therefore bound to MAXPHYS
- * before calling minphys.
+ * Because iov_len is size_t (unsigned) but b_bcount is
+ * long (signed), an overflow is possible. Therefore
+ * limit b_bcount to LONG_MAX before calling the provided
+ * minphys.
*/
- if (iovp->iov_len > MAXPHYS)
- bp->b_bcount = MAXPHYS;
+ if (iovp->iov_len > LONG_MAX)
+ bp->b_bcount = LONG_MAX;
else
bp->b_bcount = iovp->iov_len;