⬢ DragonFlyBSD Kernel Audit
DF-4423 / fix.diff
← back to finding ↓ download raw
--- a/sys/dev/virtual/virtio/block/virtio_blk.c
+++ b/sys/dev/virtual/virtio/block/virtio_blk.c
@@ -1199,9 +1199,20 @@ vtblk_free_requests(struct vtblk_softc *sc)
 static void
 vtblk_finish_bio(struct bio *bio, int error)
 {
+	struct buf *bp;
+
+	/*
+	 * DF-4423: the error argument was silently dropped; biodone()
+	 * without B_ERROR reports the transfer as successful even though
+	 * it was never performed (drained at detach / ENXIO strategy path).
+	 */
+	if (error != 0) {
+		bp = bio->bio_buf;
+		bp->b_flags |= B_ERROR;
+		if (bp->b_error == 0)
+			bp->b_error = error;
+		bp->b_resid = bp->b_bcount;
+	}
 
 	biodone(bio);
 }