diff options
author | 2011-05-31 17:35:35 +0000 | |
---|---|---|
committer | 2011-05-31 17:35:35 +0000 | |
commit | a2f17f2e2ddfd86923342c54aa3dd691f8e08b91 (patch) | |
tree | 1d9bb0c5f04c49ea9c717c90c1d268add0f57bc2 | |
parent | fix typos in comment (diff) | |
download | wireguard-openbsd-a2f17f2e2ddfd86923342c54aa3dd691f8e08b91.tar.xz wireguard-openbsd-a2f17f2e2ddfd86923342c54aa3dd691f8e08b91.zip |
Change a few of the more common disk drivers (sd, cd, wd, rd, and vnd)
to return EBUSY if the user tries to modify an open partition's offset
or size. Only sadness can result if a user tries this, and rejecting
it prevents a race between sdstart() and sdstrategy().
Curiously, there was already code in the kernel and in disklabel(8) to
detect/handle this, but it was effectively disabled because the disk
drivers always used something like "/* sc->sc_dk.dk_openmask */ 0",
and this commented out code has existed since even r1.1 in NetBSD.
I had no problems building a release and messing around with
disklabel(8) for a bit with this diff. Canarying the more common MI
disk drivers until we gain confidence that there aren't any
regressions, then we can switch the remaining drivers.
"I am surprised you got me convinced that this stuff is safe" deraadt@
ok krw@
-rw-r--r-- | sys/dev/ata/wd.c | 4 | ||||
-rw-r--r-- | sys/dev/ramdisk.c | 4 | ||||
-rw-r--r-- | sys/dev/vnd.c | 4 | ||||
-rw-r--r-- | sys/scsi/cd.c | 4 | ||||
-rw-r--r-- | sys/scsi/sd.c | 4 |
5 files changed, 10 insertions, 10 deletions
diff --git a/sys/dev/ata/wd.c b/sys/dev/ata/wd.c index bf473917e88..aafa13128a1 100644 --- a/sys/dev/ata/wd.c +++ b/sys/dev/ata/wd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: wd.c,v 1.100 2011/04/18 04:16:13 deraadt Exp $ */ +/* $OpenBSD: wd.c,v 1.101 2011/05/31 17:35:35 matthew Exp $ */ /* $NetBSD: wd.c,v 1.193 1999/02/28 17:15:27 explorer Exp $ */ /* @@ -873,7 +873,7 @@ wdioctl(dev_t dev, u_long xfer, caddr_t addr, int flag, struct proc *p) wd->sc_flags |= WDF_LABELLING; error = setdisklabel(wd->sc_dk.dk_label, - (struct disklabel *)addr, /*wd->sc_dk.dk_openmask : */0); + (struct disklabel *)addr, wd->sc_dk.dk_openmask); if (error == 0) { if (wd->drvp->state > RECAL) wd->drvp->drive_flags |= DRIVE_RESET; diff --git a/sys/dev/ramdisk.c b/sys/dev/ramdisk.c index 9a5df12c920..ec9de3da28d 100644 --- a/sys/dev/ramdisk.c +++ b/sys/dev/ramdisk.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ramdisk.c,v 1.50 2010/09/22 01:18:57 matthew Exp $ */ +/* $OpenBSD: ramdisk.c,v 1.51 2011/05/31 17:35:35 matthew Exp $ */ /* $NetBSD: ramdisk.c,v 1.8 1996/04/12 08:30:09 leo Exp $ */ /* @@ -434,7 +434,7 @@ rdioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct proc *proc) return (EBADF); error = setdisklabel(sc->sc_dk.dk_label, - (struct disklabel *)data, /*sd->sc_dk.dk_openmask : */0); + (struct disklabel *)data, sc->sc_dk.dk_openmask); if (error == 0) { if (cmd == DIOCWDINFO) error = writedisklabel(DISKLABELDEV(dev), diff --git a/sys/dev/vnd.c b/sys/dev/vnd.c index 258bd2ec99f..9aac667a038 100644 --- a/sys/dev/vnd.c +++ b/sys/dev/vnd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vnd.c,v 1.115 2011/05/30 21:15:03 oga Exp $ */ +/* $OpenBSD: vnd.c,v 1.116 2011/05/31 17:35:35 matthew Exp $ */ /* $NetBSD: vnd.c,v 1.26 1996/03/30 23:06:11 christos Exp $ */ /* @@ -722,7 +722,7 @@ vndioctl(dev_t dev, u_long cmd, caddr_t addr, int flag, struct proc *p) vnd->sc_flags |= VNF_LABELLING; error = setdisklabel(vnd->sc_dk.dk_label, - (struct disklabel *)addr, /*vnd->sc_dk.dk_openmask : */0); + (struct disklabel *)addr, vnd->sc_dk.dk_openmask); if (error == 0) { if (cmd == DIOCWDINFO) error = writedisklabel(VNDLABELDEV(dev), diff --git a/sys/scsi/cd.c b/sys/scsi/cd.c index 24432963952..0325b93c54e 100644 --- a/sys/scsi/cd.c +++ b/sys/scsi/cd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cd.c,v 1.198 2011/03/17 21:30:24 deraadt Exp $ */ +/* $OpenBSD: cd.c,v 1.199 2011/05/31 17:35:35 matthew Exp $ */ /* $NetBSD: cd.c,v 1.100 1997/04/02 02:29:30 mycroft Exp $ */ /* @@ -884,7 +884,7 @@ cdioctl(dev_t dev, u_long cmd, caddr_t addr, int flag, struct proc *p) sc->sc_flags |= CDF_LABELLING; error = setdisklabel(sc->sc_dk.dk_label, - (struct disklabel *)addr, /*cd->sc_dk.dk_openmask : */0); + (struct disklabel *)addr, sc->sc_dk.dk_openmask); if (error == 0) { } diff --git a/sys/scsi/sd.c b/sys/scsi/sd.c index 848d0a04a8c..03fd0487e2c 100644 --- a/sys/scsi/sd.c +++ b/sys/scsi/sd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sd.c,v 1.225 2011/04/08 10:37:39 krw Exp $ */ +/* $OpenBSD: sd.c,v 1.226 2011/05/31 17:35:35 matthew Exp $ */ /* $NetBSD: sd.c,v 1.111 1997/04/02 02:29:41 mycroft Exp $ */ /*- @@ -935,7 +935,7 @@ sdioctl(dev_t dev, u_long cmd, caddr_t addr, int flag, struct proc *p) sc->flags |= SDF_LABELLING; error = setdisklabel(sc->sc_dk.dk_label, - (struct disklabel *)addr, /*sd->sc_dk.dk_openmask : */0); + (struct disklabel *)addr, sc->sc_dk.dk_openmask); if (error == 0) { if (cmd == DIOCWDINFO) error = writedisklabel(DISKLABELDEV(dev), |