summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorMatthew Dempsky <matthew@cvs.openbsd.org>2011-07-05 09:46:12 +0000
committerMatthew Dempsky <matthew@cvs.openbsd.org>2011-07-05 09:46:12 +0000
commit7f84241bbef9fa3398f457770fee47c3d19ced26 (patch)
tree5384d533f0d903736587f1bdc658b4d649e6bc3b /sys
parentb5c5b1736f593d0efe7633a3a33087c41fd27d5a (diff)
Enforce that raw disk I/O is only initiated on block boundaries in
physio(). ok deraadt@
Diffstat (limited to 'sys')
-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;