sys_generic.c (36846) | sys_generic.c (38517) |
---|---|
1/* 2 * Copyright (c) 1982, 1986, 1989, 1993 3 * The Regents of the University of California. All rights reserved. 4 * (c) UNIX System Laboratories, Inc. 5 * All or some portions of this file are derived from material licensed 6 * to the University of California by American Telephone and Telegraph 7 * Co. or Unix System Laboratories, Inc. and are reproduced herein with 8 * the permission of UNIX System Laboratories, Inc. --- 22 unchanged lines hidden (view full) --- 31 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 32 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 33 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 34 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 35 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 36 * SUCH DAMAGE. 37 * 38 * @(#)sys_generic.c 8.5 (Berkeley) 1/21/94 | 1/* 2 * Copyright (c) 1982, 1986, 1989, 1993 3 * The Regents of the University of California. All rights reserved. 4 * (c) UNIX System Laboratories, Inc. 5 * All or some portions of this file are derived from material licensed 6 * to the University of California by American Telephone and Telegraph 7 * Co. or Unix System Laboratories, Inc. and are reproduced herein with 8 * the permission of UNIX System Laboratories, Inc. --- 22 unchanged lines hidden (view full) --- 31 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 32 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 33 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 34 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 35 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 36 * SUCH DAMAGE. 37 * 38 * @(#)sys_generic.c 8.5 (Berkeley) 1/21/94 |
39 * $Id: sys_generic.c,v 1.38 1998/05/17 11:52:51 phk Exp $ | 39 * $Id: sys_generic.c,v 1.39 1998/06/10 10:29:31 dfr Exp $ |
40 */ 41 42#include "opt_ktrace.h" 43 44#include <sys/param.h> 45#include <sys/systm.h> 46#include <sys/sysproto.h> 47#include <sys/filedesc.h> --- 8 unchanged lines hidden (view full) --- 56#include <sys/kernel.h> 57#include <sys/malloc.h> 58#include <sys/poll.h> 59#include <sys/sysent.h> 60#ifdef KTRACE 61#include <sys/ktrace.h> 62#endif 63 | 40 */ 41 42#include "opt_ktrace.h" 43 44#include <sys/param.h> 45#include <sys/systm.h> 46#include <sys/sysproto.h> 47#include <sys/filedesc.h> --- 8 unchanged lines hidden (view full) --- 56#include <sys/kernel.h> 57#include <sys/malloc.h> 58#include <sys/poll.h> 59#include <sys/sysent.h> 60#ifdef KTRACE 61#include <sys/ktrace.h> 62#endif 63 |
64#include <machine/limits.h> 65 |
|
64static MALLOC_DEFINE(M_IOCTLOPS, "ioctlops", "ioctl data buffer"); 65static MALLOC_DEFINE(M_SELECT, "select", "select() buffer"); 66MALLOC_DEFINE(M_IOV, "iov", "large iov's"); 67 68static int pollscan __P((struct proc *, struct pollfd *, int)); 69static int selscan __P((struct proc *, fd_mask **, fd_mask **, int)); 70 71/* --- 25 unchanged lines hidden (view full) --- 97 (fp = fdp->fd_ofiles[uap->fd]) == NULL || 98 (fp->f_flag & FREAD) == 0) 99 return (EBADF); 100 aiov.iov_base = (caddr_t)uap->buf; 101 aiov.iov_len = uap->nbyte; 102 auio.uio_iov = &aiov; 103 auio.uio_iovcnt = 1; 104 auio.uio_offset = -1; | 66static MALLOC_DEFINE(M_IOCTLOPS, "ioctlops", "ioctl data buffer"); 67static MALLOC_DEFINE(M_SELECT, "select", "select() buffer"); 68MALLOC_DEFINE(M_IOV, "iov", "large iov's"); 69 70static int pollscan __P((struct proc *, struct pollfd *, int)); 71static int selscan __P((struct proc *, fd_mask **, fd_mask **, int)); 72 73/* --- 25 unchanged lines hidden (view full) --- 99 (fp = fdp->fd_ofiles[uap->fd]) == NULL || 100 (fp->f_flag & FREAD) == 0) 101 return (EBADF); 102 aiov.iov_base = (caddr_t)uap->buf; 103 aiov.iov_len = uap->nbyte; 104 auio.uio_iov = &aiov; 105 auio.uio_iovcnt = 1; 106 auio.uio_offset = -1; |
105 106 auio.uio_resid = uap->nbyte; 107 if (auio.uio_resid < 0) | 107 if (uap->nbyte > INT_MAX) |
108 return (EINVAL); | 108 return (EINVAL); |
109 | 109 auio.uio_resid = uap->nbyte; |
110 auio.uio_rw = UIO_READ; 111 auio.uio_segflg = UIO_USERSPACE; 112 auio.uio_procp = p; 113#ifdef KTRACE 114 /* 115 * if tracing, save a copy of iovec 116 */ 117 if (KTRPOINT(p, KTR_GENIO)) --- 60 unchanged lines hidden (view full) --- 178 auio.uio_rw = UIO_READ; 179 auio.uio_segflg = UIO_USERSPACE; 180 auio.uio_procp = p; 181 auio.uio_offset = -1; 182 if ((error = copyin((caddr_t)uap->iovp, (caddr_t)iov, iovlen))) 183 goto done; 184 auio.uio_resid = 0; 185 for (i = 0; i < uap->iovcnt; i++) { | 110 auio.uio_rw = UIO_READ; 111 auio.uio_segflg = UIO_USERSPACE; 112 auio.uio_procp = p; 113#ifdef KTRACE 114 /* 115 * if tracing, save a copy of iovec 116 */ 117 if (KTRPOINT(p, KTR_GENIO)) --- 60 unchanged lines hidden (view full) --- 178 auio.uio_rw = UIO_READ; 179 auio.uio_segflg = UIO_USERSPACE; 180 auio.uio_procp = p; 181 auio.uio_offset = -1; 182 if ((error = copyin((caddr_t)uap->iovp, (caddr_t)iov, iovlen))) 183 goto done; 184 auio.uio_resid = 0; 185 for (i = 0; i < uap->iovcnt; i++) { |
186 auio.uio_resid += iov->iov_len; 187 if (auio.uio_resid < 0) { | 186 if (iov->iov_len > INT_MAX - auio.uio_resid) { |
188 error = EINVAL; 189 goto done; 190 } | 187 error = EINVAL; 188 goto done; 189 } |
190 auio.uio_resid += iov->iov_len; |
|
191 iov++; 192 } 193#ifdef KTRACE 194 /* 195 * if tracing, save a copy of iovec 196 */ 197 if (KTRPOINT(p, KTR_GENIO)) { 198 MALLOC(ktriov, struct iovec *, iovlen, M_TEMP, M_WAITOK); --- 49 unchanged lines hidden (view full) --- 248 (fp = fdp->fd_ofiles[uap->fd]) == NULL || 249 (fp->f_flag & FWRITE) == 0) 250 return (EBADF); 251 aiov.iov_base = (caddr_t)uap->buf; 252 aiov.iov_len = uap->nbyte; 253 auio.uio_iov = &aiov; 254 auio.uio_iovcnt = 1; 255 auio.uio_offset = -1; | 191 iov++; 192 } 193#ifdef KTRACE 194 /* 195 * if tracing, save a copy of iovec 196 */ 197 if (KTRPOINT(p, KTR_GENIO)) { 198 MALLOC(ktriov, struct iovec *, iovlen, M_TEMP, M_WAITOK); --- 49 unchanged lines hidden (view full) --- 248 (fp = fdp->fd_ofiles[uap->fd]) == NULL || 249 (fp->f_flag & FWRITE) == 0) 250 return (EBADF); 251 aiov.iov_base = (caddr_t)uap->buf; 252 aiov.iov_len = uap->nbyte; 253 auio.uio_iov = &aiov; 254 auio.uio_iovcnt = 1; 255 auio.uio_offset = -1; |
256 if (uap->nbyte > INT_MAX) 257 return (EINVAL); |
|
256 auio.uio_resid = uap->nbyte; 257 auio.uio_rw = UIO_WRITE; 258 auio.uio_segflg = UIO_USERSPACE; 259 auio.uio_procp = p; 260#ifdef KTRACE 261 /* 262 * if tracing, save a copy of iovec 263 */ --- 65 unchanged lines hidden (view full) --- 329 auio.uio_rw = UIO_WRITE; 330 auio.uio_segflg = UIO_USERSPACE; 331 auio.uio_procp = p; 332 auio.uio_offset = -1; 333 if ((error = copyin((caddr_t)uap->iovp, (caddr_t)iov, iovlen))) 334 goto done; 335 auio.uio_resid = 0; 336 for (i = 0; i < uap->iovcnt; i++) { | 258 auio.uio_resid = uap->nbyte; 259 auio.uio_rw = UIO_WRITE; 260 auio.uio_segflg = UIO_USERSPACE; 261 auio.uio_procp = p; 262#ifdef KTRACE 263 /* 264 * if tracing, save a copy of iovec 265 */ --- 65 unchanged lines hidden (view full) --- 331 auio.uio_rw = UIO_WRITE; 332 auio.uio_segflg = UIO_USERSPACE; 333 auio.uio_procp = p; 334 auio.uio_offset = -1; 335 if ((error = copyin((caddr_t)uap->iovp, (caddr_t)iov, iovlen))) 336 goto done; 337 auio.uio_resid = 0; 338 for (i = 0; i < uap->iovcnt; i++) { |
337 auio.uio_resid += iov->iov_len; 338 if (auio.uio_resid < 0) { | 339 if (iov->iov_len > INT_MAX - auio.uio_resid) { |
339 error = EINVAL; 340 goto done; 341 } | 340 error = EINVAL; 341 goto done; 342 } |
343 auio.uio_resid += iov->iov_len; |
|
342 iov++; 343 } 344#ifdef KTRACE 345 /* 346 * if tracing, save a copy of iovec 347 */ 348 if (KTRPOINT(p, KTR_GENIO)) { 349 MALLOC(ktriov, struct iovec *, iovlen, M_TEMP, M_WAITOK); --- 25 unchanged lines hidden (view full) --- 375} 376 377/* 378 * Ioctl system call 379 */ 380#ifndef _SYS_SYSPROTO_H_ 381struct ioctl_args { 382 int fd; | 344 iov++; 345 } 346#ifdef KTRACE 347 /* 348 * if tracing, save a copy of iovec 349 */ 350 if (KTRPOINT(p, KTR_GENIO)) { 351 MALLOC(ktriov, struct iovec *, iovlen, M_TEMP, M_WAITOK); --- 25 unchanged lines hidden (view full) --- 377} 378 379/* 380 * Ioctl system call 381 */ 382#ifndef _SYS_SYSPROTO_H_ 383struct ioctl_args { 384 int fd; |
383 int com; | 385 u_long com; |
384 caddr_t data; 385}; 386#endif 387/* ARGSUSED */ 388int 389ioctl(p, uap) 390 struct proc *p; 391 register struct ioctl_args *uap; --- 508 unchanged lines hidden --- | 386 caddr_t data; 387}; 388#endif 389/* ARGSUSED */ 390int 391ioctl(p, uap) 392 struct proc *p; 393 register struct ioctl_args *uap; --- 508 unchanged lines hidden --- |