diff --git a/sys/geom/geom_io.c b/sys/geom/geom_io.c index 0b8e118..7e08640 100644 --- a/sys/geom/geom_io.c +++ b/sys/geom/geom_io.c @@ -358,6 +358,14 @@ g_io_check(struct bio *bp) return (EIO); if (bp->bio_offset > pp->mediasize) return (EIO); + /* Reject request with unaligned buffers */ + if (((bp->bio_flags & BIO_UNMAPPED) != 0 && + bp->bio_ma_offset % pp->sectorsize != 0) || + ((bp->bio_flags & BIO_UNMAPPED) == 0 && + (vm_offset_t)bp->bio_data % pp->sectorsize != 0)) { + printf("Rejecting bios with unaligned buffer\n"); + return (EINVAL); + } /* Truncate requests to the end of providers media. */ excess = bp->bio_offset + bp->bio_length;