Author: kib
Date: Mon May 23 00:58:52 2016
New Revision: 300441
URL: https://svnweb.freebsd.org/changeset/base/300441

Log:
  MFC r300305, r300332:
  Check for overflow and return EINVAL if detected.  Use unsigned index.

Modified:
  stable/10/sys/amd64/amd64/sys_machdep.c
  stable/10/sys/i386/i386/sys_machdep.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/amd64/amd64/sys_machdep.c
==============================================================================
--- stable/10/sys/amd64/amd64/sys_machdep.c     Sun May 22 23:28:23 2016        
(r300440)
+++ stable/10/sys/amd64/amd64/sys_machdep.c     Mon May 23 00:58:52 2016        
(r300441)
@@ -334,18 +334,20 @@ amd64_set_ioperm(td, uap)
        struct thread *td;
        struct i386_ioperm_args *uap;
 {
-       int i, error;
        char *iomap;
        struct amd64tss *tssp;
        struct system_segment_descriptor *tss_sd;
        u_long *addr;
        struct pcb *pcb;
+       u_int i;
+       int error;
 
        if ((error = priv_check(td, PRIV_IO)) != 0)
                return (error);
        if ((error = securelevel_gt(td->td_ucred, 0)) != 0)
                return (error);
-       if (uap->start + uap->length > IOPAGES * PAGE_SIZE * NBBY)
+       if (uap->start > uap->start + uap->length ||
+           uap->start + uap->length > IOPAGES * PAGE_SIZE * NBBY)
                return (EINVAL);
 
        /*

Modified: stable/10/sys/i386/i386/sys_machdep.c
==============================================================================
--- stable/10/sys/i386/i386/sys_machdep.c       Sun May 22 23:28:23 2016        
(r300440)
+++ stable/10/sys/i386/i386/sys_machdep.c       Mon May 23 00:58:52 2016        
(r300441)
@@ -344,8 +344,9 @@ i386_set_ioperm(td, uap)
        struct thread *td;
        struct i386_ioperm_args *uap;
 {
-       int i, error;
        char *iomap;
+       u_int i;
+       int error;
 
        if ((error = priv_check(td, PRIV_IO)) != 0)
                return (error);
@@ -363,7 +364,8 @@ i386_set_ioperm(td, uap)
                        return (error);
        iomap = (char *)td->td_pcb->pcb_ext->ext_iomap;
 
-       if (uap->start + uap->length > IOPAGES * PAGE_SIZE * NBBY)
+       if (uap->start > uap->start + uap->length ||
+           uap->start + uap->length > IOPAGES * PAGE_SIZE * NBBY)
                return (EINVAL);
 
        for (i = uap->start; i < uap->start + uap->length; i++) {
_______________________________________________
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to