diff options
author | peter <peter@FreeBSD.org> | 1999-12-28 07:32:34 +0000 |
---|---|---|
committer | peter <peter@FreeBSD.org> | 1999-12-28 07:32:34 +0000 |
commit | 901351ff0de17a88861ad2abdd63aed4644eea3a (patch) | |
tree | 4c5e49990c40e4615f89236f12da322affaac7e7 | |
parent | 38a9421a1e400014ef261a0d4de1fe80e5817d0c (diff) | |
download | FreeBSD-src-901351ff0de17a88861ad2abdd63aed4644eea3a.zip FreeBSD-src-901351ff0de17a88861ad2abdd63aed4644eea3a.tar.gz |
Fix a panic when doing non-multiples of PAGE_SIZE or misaligned transfers
to a swap backed vn device.
OK'ed by: dillon
-rw-r--r-- | sys/dev/vn/vn.c | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/sys/dev/vn/vn.c b/sys/dev/vn/vn.c index 0d8e9e3..49fa104 100644 --- a/sys/dev/vn/vn.c +++ b/sys/dev/vn/vn.c @@ -311,6 +311,18 @@ vnstrategy(struct buf *bp) int pbn; /* in sc_secsize chunks */ long sz; /* in sc_secsize chunks */ + /* + * Check for required alignment. Transfers must be a valid + * multiple of the sector size. + */ + if (bp->b_bcount % vn->sc_secsize != 0 || + bp->b_blkno % (vn->sc_secsize / DEV_BSIZE) != 0) { + bp->b_error = EINVAL; + bp->b_flags |= B_ERROR | B_INVAL; + biodone(bp); + return; + } + pbn = bp->b_blkno / (vn->sc_secsize / DEV_BSIZE); sz = howmany(bp->b_bcount, vn->sc_secsize); @@ -390,7 +402,7 @@ vnstrategy(struct buf *bp) * Note: if we pre-reserved swap, B_FREEBUF is disabled */ KASSERT((bp->b_bufsize & (vn->sc_secsize - 1)) == 0, - ("vnstrategy: buffer %p to small for physio", bp)); + ("vnstrategy: buffer %p too small for physio", bp)); if ((bp->b_flags & B_FREEBUF) && TESTOPT(vn, VN_RESERVE)) { biodone(bp); |