⬢ DragonFlyBSD Kernel Audit
DF-4479 / fix.diff
← back to finding ↓ download raw
--- a/sys/dev/raid/vinum/vinumstate.c
+++ b/sys/dev/raid/vinum/vinumstate.c
@@ -1042,8 +1042,14 @@
 		ioctl_reply->error = EFAULT;
 		return;
 	    }
-	    set_sd_state(msg->index, sd_initialized, msg->force);
-	    if (sd->state != sd_initializing) {
+	    /*
+	     * DF-4479: judge success by the transition result, not by
+	     * comparing against sd_initializing (the state we came FROM);
+	     * update_plex_state() may legitimately promote the sd past
+	     * sd_initialized (forceup) before we look.
+	     */
+	    if (set_sd_state(msg->index, sd_initialized, msg->force) == 0 ||
+		sd->state == sd_initializing) {
 		strcpy(ioctl_reply->msg, "Can't set state");
 		ioctl_reply->error = EBUSY;
 	    } else