summaryrefslogtreecommitdiffstats
path: root/sys/kern
diff options
context:
space:
mode:
authorphk <phk@FreeBSD.org>1999-08-21 06:48:16 +0000
committerphk <phk@FreeBSD.org>1999-08-21 06:48:16 +0000
commit2a4a60dfae5b4436f3f3beb6d425bc4ad0f8c61c (patch)
treedb81b9006f5a9e2a9078bb3d80db00961c6867f7 /sys/kern
parentb51f157bff8b959d943b0836a1c57f065b9318d5 (diff)
downloadFreeBSD-src-2a4a60dfae5b4436f3f3beb6d425bc4ad0f8c61c.zip
FreeBSD-src-2a4a60dfae5b4436f3f3beb6d425bc4ad0f8c61c.tar.gz
Detect if the the offset used to read from a raw device loose bits
when converted to block number.
Diffstat (limited to 'sys/kern')
-rw-r--r--sys/kern/kern_physio.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/sys/kern/kern_physio.c b/sys/kern/kern_physio.c
index 3455f99..aae8ee9 100644
--- a/sys/kern/kern_physio.c
+++ b/sys/kern/kern_physio.c
@@ -16,7 +16,7 @@
* 4. Modifications may be freely made to this file if the above conditions
* are met.
*
- * $Id: kern_physio.c,v 1.35 1999/06/26 02:46:02 mckusick Exp $
+ * $Id: kern_physio.c,v 1.36 1999/08/14 11:40:42 phk Exp $
*/
#include <sys/param.h>
@@ -57,6 +57,7 @@ physio(bp, dev, rw, minp, uio)
int error;
int spl;
caddr_t sa;
+ off_t blockno;
int bp_alloc = (bp == 0);
struct buf *bpa;
@@ -95,7 +96,12 @@ physio(bp, dev, rw, minp, uio)
* for the temporary kernel mapping.
*/
bp->b_saveaddr = sa;
- bp->b_blkno = btodb(uio->uio_offset);
+ blockno = uio->uio_offset >> DEV_BSHIFT;
+ bp->b_blkno = blockno;
+ if (bp->b_blkno != blockno) {
+ error = EINVAL;
+ goto doerror;
+ }
bp->b_offset = uio->uio_offset;
if (uio->uio_segflg == UIO_USERSPACE) {
OpenPOWER on IntegriCloud