summaryrefslogtreecommitdiffstats
path: root/sys/kern/subr_diskslice.c
diff options
context:
space:
mode:
authorbde <bde@FreeBSD.org>1998-02-15 05:41:31 +0000
committerbde <bde@FreeBSD.org>1998-02-15 05:41:31 +0000
commit1743f0cdeec1d777babce816f8e5b54fab3e0a7e (patch)
tree0eb9f89f9ea6e4dfe10916d4709eed62da3498bb /sys/kern/subr_diskslice.c
parentfbe6fe8df622ec2f41d4c28cf3cb1849007a8239 (diff)
downloadFreeBSD-src-1743f0cdeec1d777babce816f8e5b54fab3e0a7e.zip
FreeBSD-src-1743f0cdeec1d777babce816f8e5b54fab3e0a7e.tar.gz
Fixed an aliasing bug. It was too easy to defeat the check for moving
or shrinking an open partition (by changing the label for a compatibility slice while partitions on the corresponding real slice are open, or vice versa).
Diffstat (limited to 'sys/kern/subr_diskslice.c')
-rw-r--r--sys/kern/subr_diskslice.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/sys/kern/subr_diskslice.c b/sys/kern/subr_diskslice.c
index 371ec900..5ffb5db 100644
--- a/sys/kern/subr_diskslice.c
+++ b/sys/kern/subr_diskslice.c
@@ -43,7 +43,7 @@
* from: wd.c,v 1.55 1994/10/22 01:57:12 phk Exp $
* from: @(#)ufs_disksubr.c 7.16 (Berkeley) 5/4/91
* from: ufs_disksubr.c,v 1.8 1994/06/07 01:21:39 phk Exp $
- * $Id: subr_diskslice.c,v 1.40 1997/12/06 14:27:30 bde Exp $
+ * $Id: subr_diskslice.c,v 1.41 1998/01/24 02:54:34 eivind Exp $
*/
#include "opt_devfs.h"
@@ -366,9 +366,19 @@ dsioctl(dname, dev, cmd, data, flags, sspp, strat, setgeom)
bzero(lp, sizeof *lp);
else
bcopy(sp->ds_label, lp, sizeof *lp);
+ if (sp->ds_label == NULL)
+ openmask = 0;
+ else {
+ openmask = sp->ds_openmask;
+ if (slice == COMPATIBILITY_SLICE)
+ openmask |= ssp->dss_slices[
+ ssp->dss_first_bsd_slice].ds_openmask;
+ else if (slice == ssp->dss_first_bsd_slice)
+ openmask |= ssp->dss_slices[
+ COMPATIBILITY_SLICE].ds_openmask;
+ }
error = setdisklabel(lp, (struct disklabel *)data,
- sp->ds_label != NULL
- ? sp->ds_openmask : (u_long)0);
+ (u_long)openmask);
/* XXX why doesn't setdisklabel() check this? */
if (error == 0 && lp->d_partitions[RAW_PART].p_offset != 0)
error = EINVAL;
OpenPOWER on IntegriCloud