mirror of
https://git.hardenedbsd.org/hardenedbsd/HardenedBSD.git
synced 2024-11-16 23:57:54 +01:00
Fixed an overflowing multiplication in vnstrategy() by replacing it with
the standard macro dbtob(). The non-B_PAGING case now works well enough to run newfs on a 32GB virtual drive. Fixed numerous bogus variable types and one overflowing multiplication in the B_PAGING case of vnstrategy(). Swapping to virtual drives larger than 2GB might work now.
This commit is contained in:
parent
04ecd93b2a
commit
337def8963
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=13427
@ -232,7 +232,7 @@ vnstrategy(struct buf *bp)
|
||||
register struct vn_softc *vn = vn_softc[unit];
|
||||
register daddr_t bn;
|
||||
int error;
|
||||
int sz;
|
||||
long sz;
|
||||
struct uio auio;
|
||||
struct iovec aiov;
|
||||
|
||||
@ -272,7 +272,7 @@ vnstrategy(struct buf *bp)
|
||||
aiov.iov_len = bp->b_bcount;
|
||||
auio.uio_iov = &aiov;
|
||||
auio.uio_iovcnt = 1;
|
||||
auio.uio_offset = bn*DEV_BSIZE;
|
||||
auio.uio_offset = dbtob(bn);
|
||||
auio.uio_segflg = UIO_SYSSPACE;
|
||||
if( bp->b_flags & B_READ)
|
||||
auio.uio_rw = UIO_READ;
|
||||
@ -291,15 +291,14 @@ vnstrategy(struct buf *bp)
|
||||
bp->b_flags |= B_ERROR;
|
||||
biodone(bp);
|
||||
} else {
|
||||
daddr_t bsize;
|
||||
int flags, resid;
|
||||
long bsize, resid;
|
||||
off_t byten;
|
||||
int flags;
|
||||
caddr_t addr;
|
||||
|
||||
struct buf *nbp;
|
||||
|
||||
nbp = getvnbuf();
|
||||
|
||||
bn = dbtob(bn);
|
||||
byten = dbtob(bn);
|
||||
bsize = vn->sc_vp->v_mount->mnt_stat.f_iosize;
|
||||
addr = bp->b_data;
|
||||
flags = bp->b_flags | B_CALL;
|
||||
@ -309,14 +308,15 @@ vnstrategy(struct buf *bp)
|
||||
int off, s, nra;
|
||||
|
||||
nra = 0;
|
||||
error = VOP_BMAP(vn->sc_vp, bn / bsize, &vp, &nbn, &nra, NULL);
|
||||
if (error == 0 && (long)nbn == -1)
|
||||
error = VOP_BMAP(vn->sc_vp, (daddr_t)(byten / bsize),
|
||||
&vp, &nbn, &nra, NULL);
|
||||
if (error == 0 && nbn == -1)
|
||||
error = EIO;
|
||||
|
||||
IFOPT(vn, VN_DONTCLUSTER)
|
||||
nra = 0;
|
||||
|
||||
off = bn % bsize;
|
||||
off = byten % bsize;
|
||||
if (off)
|
||||
sz = bsize - off;
|
||||
else
|
||||
@ -333,8 +333,11 @@ vnstrategy(struct buf *bp)
|
||||
}
|
||||
|
||||
IFOPT(vn,VN_IO)
|
||||
printf("vnstrategy: vp %p/%p bn 0x%lx/0x%lx sz 0x%x\n",
|
||||
vn->sc_vp, vp, bn, nbn, sz);
|
||||
printf(
|
||||
/* XXX no %qx in kernel. Synthesize it. */
|
||||
"vnstrategy: vp %p/%p bn 0x%lx%08lx/0x%lx sz 0x%x\n",
|
||||
vn->sc_vp, vp, (long)(byten >> 32),
|
||||
(u_long)byten, nbn, sz);
|
||||
|
||||
nbp->b_flags = flags;
|
||||
nbp->b_bcount = sz;
|
||||
@ -376,7 +379,7 @@ vnstrategy(struct buf *bp)
|
||||
return;
|
||||
}
|
||||
|
||||
bn += sz;
|
||||
byten += sz;
|
||||
addr += sz;
|
||||
resid -= sz;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user