diff options
author | Matthew Dempsky <matthew@cvs.openbsd.org> | 2011-07-05 09:46:12 +0000 |
---|---|---|
committer | Matthew Dempsky <matthew@cvs.openbsd.org> | 2011-07-05 09:46:12 +0000 |
commit | 7f84241bbef9fa3398f457770fee47c3d19ced26 (patch) | |
tree | 5384d533f0d903736587f1bdc658b4d649e6bc3b /sys/kern | |
parent | b5c5b1736f593d0efe7633a3a33087c41fd27d5a (diff) |
Enforce that raw disk I/O is only initiated on block boundaries in
physio().
ok deraadt@
Diffstat (limited to 'sys/kern')
-rw-r--r-- | sys/kern/kern_physio.c | 7 |
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; |