summaryrefslogtreecommitdiff
path: root/sys/dev
diff options
context:
space:
mode:
authorKenneth R Westerback <krw@cvs.openbsd.org>2008-06-15 00:36:42 +0000
committerKenneth R Westerback <krw@cvs.openbsd.org>2008-06-15 00:36:42 +0000
commitc74544620cbb68ee5eeb151f8179b7b75a541845 (patch)
tree690e112486687a73d36279bd6260d0c784473b24 /sys/dev
parent663dcc3f9fd3820372803855330ae78840ef6eb3 (diff)
Don't bypass partition bounds check for RAW_PART. We now guarantee that
RAW_PART will always be 0 -> disksize, so the bounds check will always pass for i/o's to valid addresses. Now the i/o will be properly truncated if it goes past the end of the device. This prevents various adverse impacts of issuing i/o's for data past the end of the device. Repeatedly requested by todd@. ok weingart@ deraadt@
Diffstat (limited to 'sys/dev')
-rw-r--r--sys/dev/ata/wd.c5
-rw-r--r--sys/dev/ccd.c5
-rw-r--r--sys/dev/flash.c5
-rw-r--r--sys/dev/isa/mcd.c5
-rw-r--r--sys/dev/raidframe/rf_openbsdkintf.c15
-rw-r--r--sys/dev/ramdisk.c8
6 files changed, 18 insertions, 25 deletions
diff --git a/sys/dev/ata/wd.c b/sys/dev/ata/wd.c
index f1fafeaa9c1..e06563f1413 100644
--- a/sys/dev/ata/wd.c
+++ b/sys/dev/ata/wd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: wd.c,v 1.69 2008/02/07 12:58:30 sthen Exp $ */
+/* $OpenBSD: wd.c,v 1.70 2008/06/15 00:36:41 krw Exp $ */
/* $NetBSD: wd.c,v 1.193 1999/02/28 17:15:27 explorer Exp $ */
/*
@@ -481,8 +481,7 @@ wdstrategy(struct buf *bp)
* Do bounds checking, adjust transfer. if error, process.
* If end of partition, just return.
*/
- if (DISKPART(bp->b_dev) != RAW_PART &&
- bounds_check_with_label(bp, wd->sc_dk.dk_label,
+ if (bounds_check_with_label(bp, wd->sc_dk.dk_label,
(wd->sc_flags & (WDF_WLABEL|WDF_LABELLING)) != 0) <= 0)
goto done;
/* Queue transfer on drive, activate drive and controller if idle. */
diff --git a/sys/dev/ccd.c b/sys/dev/ccd.c
index 4a889a02a24..6729ec30c2d 100644
--- a/sys/dev/ccd.c
+++ b/sys/dev/ccd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ccd.c,v 1.83 2008/06/14 10:55:20 mk Exp $ */
+/* $OpenBSD: ccd.c,v 1.84 2008/06/15 00:36:40 krw Exp $ */
/* $NetBSD: ccd.c,v 1.33 1996/05/05 04:21:14 thorpej Exp $ */
/*-
@@ -680,8 +680,7 @@ ccdstrategy(struct buf *bp)
* error, the bounds check will flag that for us.
*/
wlabel = cs->sc_flags & (CCDF_WLABEL|CCDF_LABELLING);
- if (DISKPART(bp->b_dev) != RAW_PART &&
- bounds_check_with_label(bp, lp, wlabel) <= 0)
+ if (bounds_check_with_label(bp, lp, wlabel) <= 0)
goto done;
bp->b_resid = bp->b_bcount;
diff --git a/sys/dev/flash.c b/sys/dev/flash.c
index abce68b529f..c6ea5ccb26b 100644
--- a/sys/dev/flash.c
+++ b/sys/dev/flash.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: flash.c,v 1.8 2007/06/20 18:15:46 deraadt Exp $ */
+/* $OpenBSD: flash.c,v 1.9 2008/06/15 00:36:41 krw Exp $ */
/*
* Copyright (c) 2005 Uwe Stuehler <uwe@openbsd.org>
@@ -809,8 +809,7 @@ flashstrategy(struct buf *bp)
goto done;
/* Do bounds checking on partitions. */
- if (flashpart(bp->b_dev) != RAW_PART &&
- bounds_check_with_label(bp, sc->sc_dk.dk_label, 0) <= 0)
+ if (bounds_check_with_label(bp, sc->sc_dk.dk_label, 0) <= 0)
goto done;
/* Queue the transfer. */
diff --git a/sys/dev/isa/mcd.c b/sys/dev/isa/mcd.c
index 7e741776f77..427284806f5 100644
--- a/sys/dev/isa/mcd.c
+++ b/sys/dev/isa/mcd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mcd.c,v 1.49 2007/06/20 18:15:46 deraadt Exp $ */
+/* $OpenBSD: mcd.c,v 1.50 2008/06/15 00:36:41 krw Exp $ */
/* $NetBSD: mcd.c,v 1.60 1998/01/14 12:14:41 drochner Exp $ */
/*
@@ -507,8 +507,7 @@ mcdstrategy(bp)
* Do bounds checking, adjust transfer. if error, process.
* If end of partition, just return.
*/
- if (DISKPART(bp->b_dev) != RAW_PART &&
- bounds_check_with_label(bp, sc->sc_dk.dk_label,
+ if (bounds_check_with_label(bp, sc->sc_dk.dk_label,
(sc->flags & (MCDF_WLABEL|MCDF_LABELLING)) != 0) <= 0)
goto done;
diff --git a/sys/dev/raidframe/rf_openbsdkintf.c b/sys/dev/raidframe/rf_openbsdkintf.c
index 385a8c5f4f5..d691a0f84fa 100644
--- a/sys/dev/raidframe/rf_openbsdkintf.c
+++ b/sys/dev/raidframe/rf_openbsdkintf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rf_openbsdkintf.c,v 1.47 2008/03/26 00:48:54 krw Exp $ */
+/* $OpenBSD: rf_openbsdkintf.c,v 1.48 2008/06/15 00:36:41 krw Exp $ */
/* $NetBSD: rf_netbsdkintf.c,v 1.109 2001/07/27 03:30:07 oster Exp $ */
/*-
@@ -768,13 +768,12 @@ raidstrategy(struct buf *bp)
* error, the bounds check will flag that for us.
*/
wlabel = rs->sc_flags & (RAIDF_WLABEL | RAIDF_LABELLING);
- if (DISKPART(bp->b_dev) != RAW_PART)
- if (bounds_check_with_label(bp, lp, wlabel) <= 0) {
- db1_printf(("Bounds check failed!!:%d %d\n",
- (int)bp->b_blkno, (int)wlabel));
- biodone(bp);
- goto raidstrategy_end;
- }
+ if (bounds_check_with_label(bp, lp, wlabel) <= 0) {
+ db1_printf(("Bounds check failed!!:%d %d\n",
+ (int)bp->b_blkno, (int)wlabel));
+ biodone(bp);
+ goto raidstrategy_end;
+ }
bp->b_resid = 0;
diff --git a/sys/dev/ramdisk.c b/sys/dev/ramdisk.c
index c6f59632cf4..d8e6785d1f8 100644
--- a/sys/dev/ramdisk.c
+++ b/sys/dev/ramdisk.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ramdisk.c,v 1.41 2008/05/23 00:51:33 krw Exp $ */
+/* $OpenBSD: ramdisk.c,v 1.42 2008/06/15 00:36:41 krw Exp $ */
/* $NetBSD: ramdisk.c,v 1.8 1996/04/12 08:30:09 leo Exp $ */
/*
@@ -345,7 +345,7 @@ void
rdstrategy(bp)
struct buf *bp;
{
- int unit, part;
+ int unit;
struct rd_softc *sc;
caddr_t addr;
size_t off, xfer;
@@ -362,9 +362,7 @@ rdstrategy(bp)
}
/* Do not write on "no trespassing" areas... */
- part = DISKPART(bp->b_dev);
- if (part != RAW_PART &&
- bounds_check_with_label(bp, sc->sc_dkdev.dk_label, 1) <= 0)
+ if (bounds_check_with_label(bp, sc->sc_dkdev.dk_label, 1) <= 0)
goto bad;
switch (sc->sc_type) {