summaryrefslogtreecommitdiffstats
path: root/sys/kern/kern_physio.c
diff options
context:
space:
mode:
authormatthew <matthew@openbsd.org>2011-07-05 09:46:11 +0000
committermatthew <matthew@openbsd.org>2011-07-05 09:46:11 +0000
commitbe49dc26b540d02cffa3f13b47badcb69e318b06 (patch)
tree56b7770ee50ac5b4f5fcd446297803b61660f28a /sys/kern/kern_physio.c
parentmsync has some code that is based on *old* bsd behaviour where (diff)
downloadwireguard-openbsd-be49dc26b540d02cffa3f13b47badcb69e318b06.tar.xz
wireguard-openbsd-be49dc26b540d02cffa3f13b47badcb69e318b06.zip
Enforce that raw disk I/O is only initiated on block boundaries in
physio(). ok deraadt@
Diffstat (limited to 'sys/kern/kern_physio.c')
-rw-r--r--sys/kern/kern_physio.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/sys/kern/kern_physio.c b/sys/kern/kern_physio.c
index b4207821360..11975ed4044 100644
--- a/sys/kern/kern_physio.c
+++ b/sys/kern/kern_physio.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kern_physio.c,v 1.33 2011/05/08 09:07:06 dlg Exp $ */
+/* $OpenBSD: kern_physio.c,v 1.34 2011/07/05 09:46:11 matthew Exp $ */
/* $NetBSD: kern_physio.c,v 1.28 1997/05/19 10:43:28 pk Exp $ */
/*-
@@ -69,6 +69,9 @@ physio(void (*strategy)(struct buf *), dev_t dev, int flags,
int error, done, i, s, todo;
struct buf *bp;
+ if ((uio->uio_offset % DEV_BSIZE) != 0)
+ return (EINVAL);
+
error = 0;
flags &= B_READ | B_WRITE;
@@ -199,6 +202,8 @@ after_unlock:
panic("done < 0; strategy broken");
if (done > todo)
panic("done > todo; strategy broken");
+ if ((done % DEV_BSIZE) != 0)
+ panic("(done % DEV_BSIZE) != 0; strategy broken");
#endif
iovp->iov_len -= done;
iovp->iov_base = (caddr_t)iovp->iov_base + done;