diff options
author | Philip Guenther <guenther@cvs.openbsd.org> | 2013-09-14 02:28:04 +0000 |
---|---|---|
committer | Philip Guenther <guenther@cvs.openbsd.org> | 2013-09-14 02:28:04 +0000 |
commit | 8980b4bc0e0964f3f84625f36ff46df354ec85f2 (patch) | |
tree | e829db0fb28d09e3ad2095b685326a8a8732b65c /sys/kern/kern_ktrace.c | |
parent | 7b115ba51011af0745a43200d86691551c932fd6 (diff) |
Correct the handling of I/O of >=2^32 bytes and the ktracing there of
by using size_t/ssize_t instead of int/u_int to handle I/O lengths in
uiomove(), vn_fsizechk(), and ktrgenio(). Eliminate the always-zero
'error' argument to ktrgenio() at the same time.
Diffstat (limited to 'sys/kern/kern_ktrace.c')
-rw-r--r-- | sys/kern/kern_ktrace.c | 29 |
1 files changed, 15 insertions, 14 deletions
diff --git a/sys/kern/kern_ktrace.c b/sys/kern/kern_ktrace.c index 7eb25f0498a..50e29d13398 100644 --- a/sys/kern/kern_ktrace.c +++ b/sys/kern/kern_ktrace.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_ktrace.c,v 1.60 2013/06/01 16:27:37 tedu Exp $ */ +/* $OpenBSD: kern_ktrace.c,v 1.61 2013/09/14 02:28:01 guenther Exp $ */ /* $NetBSD: kern_ktrace.c,v 1.23 1996/02/09 18:59:36 christos Exp $ */ /* @@ -159,7 +159,7 @@ ktrsyscall(struct proc *p, register_t code, size_t argsize, register_t args[]) * array because it is interesting. */ if (args[1] > 0) - nargs = min(args[1], CTL_MAXNAME); + nargs = lmin(args[1], CTL_MAXNAME); len += nargs * sizeof(int); } atomic_setbits_int(&p->p_flag, P_INKTR); @@ -225,21 +225,22 @@ ktremul(struct proc *p, char *emul) } void -ktrgenio(struct proc *p, int fd, enum uio_rw rw, struct iovec *iov, int len, - int error) +ktrgenio(struct proc *p, int fd, enum uio_rw rw, struct iovec *iov, + ssize_t len) { struct ktr_header kth; struct ktr_genio *ktp; caddr_t cp; - int resid = len, count; + int count; int buflen; - if (error) - return; - atomic_setbits_int(&p->p_flag, P_INKTR); - buflen = min(PAGE_SIZE, len + sizeof(struct ktr_genio)); + /* beware overflow */ + if (len > PAGE_SIZE - sizeof(struct ktr_genio)) + buflen = PAGE_SIZE; + else + buflen = len + sizeof(struct ktr_genio); ktrinitheader(&kth, p, KTR_GENIO); ktp = malloc(buflen, M_TEMP, M_WAITOK); @@ -249,7 +250,7 @@ ktrgenio(struct proc *p, int fd, enum uio_rw rw, struct iovec *iov, int len, cp = (caddr_t)((char *)ktp + sizeof (struct ktr_genio)); buflen -= sizeof(struct ktr_genio); - while (resid > 0) { + while (len > 0) { /* * Don't allow this process to hog the cpu when doing * huge I/O. @@ -257,9 +258,9 @@ ktrgenio(struct proc *p, int fd, enum uio_rw rw, struct iovec *iov, int len, if (curcpu()->ci_schedstate.spc_schedflags & SPCF_SHOULDYIELD) preempt(NULL); - count = min(iov->iov_len, buflen); - if (count > resid) - count = resid; + count = lmin(iov->iov_len, buflen); + if (count > len) + count = len; if (copyin(iov->iov_base, cp, count)) break; @@ -274,7 +275,7 @@ ktrgenio(struct proc *p, int fd, enum uio_rw rw, struct iovec *iov, int len, if (iov->iov_len == 0) iov++; - resid -= count; + len -= count; } free(ktp, M_TEMP); |