Change the types of vn_rdwr_inchunks()'s len and aresid arguments to
size_t and size_t *, respectively. Update callers for the new interface. This is a better fix for overflows that occurred when dumping segments larger than 2GB to core files.
This commit is contained in:
parent
2b471bc616
commit
f99619a0dc
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=130101
@ -214,14 +214,14 @@ pecoff_coredump(register struct thread * td, register struct vnode * vp,
|
||||
error = vn_rdwr_inchunks(UIO_WRITE, vp, vm->vm_daddr,
|
||||
(int)ctob(vm->vm_dsize),
|
||||
(off_t)ctob((uarea_pages + kstack_pages)),
|
||||
UIO_USERSPACE, IO_UNIT, cred, NOCRED, (int *)NULL, td);
|
||||
UIO_USERSPACE, IO_UNIT, cred, NOCRED, NULL, td);
|
||||
if (error == 0)
|
||||
error = vn_rdwr_inchunks(UIO_WRITE, vp,
|
||||
(caddr_t)trunc_page(USRSTACK - ctob(vm->vm_ssize)),
|
||||
round_page(ctob(vm->vm_ssize)),
|
||||
(off_t)ctob((uarea_pages + kstack_pages)) +
|
||||
ctob(vm->vm_dsize),
|
||||
UIO_USERSPACE, IO_UNIT, cred, NOCRED, (int *)NULL, td);
|
||||
UIO_USERSPACE, IO_UNIT, cred, NOCRED, NULL, td);
|
||||
return (error);
|
||||
|
||||
}
|
||||
|
@ -769,7 +769,7 @@ linux_aout_coredump(struct thread *td, struct vnode *vp, off_t limit)
|
||||
round_page(ctob(vm->vm_ssize)),
|
||||
(off_t)ctob(uarea_pages + kstack_pages) +
|
||||
ctob(vm->vm_dsize), UIO_USERSPACE,
|
||||
IO_UNIT | IO_DIRECT, cred, NOCRED, (int *) NULL, td);
|
||||
IO_UNIT | IO_DIRECT, cred, NOCRED, NULL, td);
|
||||
return (error);
|
||||
}
|
||||
/*
|
||||
|
@ -307,7 +307,7 @@ aout_coredump(td, vp, limit)
|
||||
ctob(vm->vm_ssize)), round_page(ctob(vm->vm_ssize)),
|
||||
(off_t)ctob(uarea_pages + kstack_pages) +
|
||||
ctob(vm->vm_dsize), UIO_USERSPACE,
|
||||
IO_UNIT | IO_DIRECT, cred, NOCRED, (int *) NULL, td);
|
||||
IO_UNIT | IO_DIRECT, cred, NOCRED, NULL, td);
|
||||
return (error);
|
||||
}
|
||||
|
||||
|
@ -970,7 +970,7 @@ __elfN(coredump)(td, vp, limit)
|
||||
error = vn_rdwr_inchunks(UIO_WRITE, vp,
|
||||
(caddr_t)(uintptr_t)php->p_vaddr,
|
||||
php->p_filesz, offset, UIO_USERSPACE,
|
||||
IO_UNIT | IO_DIRECT, cred, NOCRED, (int *)NULL,
|
||||
IO_UNIT | IO_DIRECT, cred, NOCRED, NULL,
|
||||
curthread); /* XXXKSE */
|
||||
if (error != 0)
|
||||
break;
|
||||
|
@ -461,16 +461,17 @@ vn_rdwr_inchunks(rw, vp, base, len, offset, segflg, ioflg, active_cred,
|
||||
enum uio_rw rw;
|
||||
struct vnode *vp;
|
||||
caddr_t base;
|
||||
int len;
|
||||
size_t len;
|
||||
off_t offset;
|
||||
enum uio_seg segflg;
|
||||
int ioflg;
|
||||
struct ucred *active_cred;
|
||||
struct ucred *file_cred;
|
||||
int *aresid;
|
||||
size_t *aresid;
|
||||
struct thread *td;
|
||||
{
|
||||
int error = 0;
|
||||
int iaresid;
|
||||
|
||||
do {
|
||||
int chunk;
|
||||
@ -487,8 +488,9 @@ vn_rdwr_inchunks(rw, vp, base, len, offset, segflg, ioflg, active_cred,
|
||||
chunk = len;
|
||||
if (rw != UIO_READ && vp->v_type == VREG)
|
||||
bwillwrite();
|
||||
iaresid = 0;
|
||||
error = vn_rdwr(rw, vp, base, chunk, offset, segflg,
|
||||
ioflg, active_cred, file_cred, aresid, td);
|
||||
ioflg, active_cred, file_cred, &iaresid, td);
|
||||
len -= chunk; /* aresid calc already includes length */
|
||||
if (error)
|
||||
break;
|
||||
@ -497,7 +499,7 @@ vn_rdwr_inchunks(rw, vp, base, len, offset, segflg, ioflg, active_cred,
|
||||
uio_yield();
|
||||
} while (len);
|
||||
if (aresid)
|
||||
*aresid += len;
|
||||
*aresid = len + iaresid;
|
||||
return (error);
|
||||
}
|
||||
|
||||
|
@ -662,8 +662,8 @@ int vn_rdwr(enum uio_rw rw, struct vnode *vp, caddr_t base,
|
||||
struct ucred *active_cred, struct ucred *file_cred, int *aresid,
|
||||
struct thread *td);
|
||||
int vn_rdwr_inchunks(enum uio_rw rw, struct vnode *vp, caddr_t base,
|
||||
int len, off_t offset, enum uio_seg segflg, int ioflg,
|
||||
struct ucred *active_cred, struct ucred *file_cred, int *aresid,
|
||||
size_t len, off_t offset, enum uio_seg segflg, int ioflg,
|
||||
struct ucred *active_cred, struct ucred *file_cred, size_t *aresid,
|
||||
struct thread *td);
|
||||
int vn_stat(struct vnode *vp, struct stat *sb, struct ucred *active_cred,
|
||||
struct ucred *file_cred, struct thread *td);
|
||||
|
Loading…
Reference in New Issue
Block a user