From: David van Moolenbroek Date: Wed, 15 Aug 2012 08:50:30 +0000 (+0000) Subject: Kernel: use okendpt() to resolve stored endpoints X-Git-Tag: v3.2.1~370 X-Git-Url: http://zhaoyanbai.com/repos/%22http:/www.isc.org/icons/mult.png?a=commitdiff_plain;h=0b5c2a058c601a2370e4894e33886170c3d0b85c;p=minix.git Kernel: use okendpt() to resolve stored endpoints This adds an integrity check at very little cost, and should stop Coverity from flagging array overruns on the result. --- diff --git a/kernel/arch/i386/do_iopenable.c b/kernel/arch/i386/do_iopenable.c index 2c27c2de0..680be3b86 100644 --- a/kernel/arch/i386/do_iopenable.c +++ b/kernel/arch/i386/do_iopenable.c @@ -23,7 +23,7 @@ int do_iopenable(struct proc * caller, message * m_ptr) #if 1 /* ENABLE_USERPRIV && ENABLE_USERIOPL */ if (m_ptr->IOP_ENDPT == SELF) { - proc_nr = _ENDPOINT_P(caller->p_endpoint); + okendpt(caller->p_endpoint, &proc_nr); } else if(!isokendpt(m_ptr->IOP_ENDPT, &proc_nr)) return(EINVAL); enable_iop(proc_addr(proc_nr)); diff --git a/kernel/arch/i386/do_sdevio.c b/kernel/arch/i386/do_sdevio.c index d71056bea..23ea4fa24 100644 --- a/kernel/arch/i386/do_sdevio.c +++ b/kernel/arch/i386/do_sdevio.c @@ -54,7 +54,7 @@ int do_sdevio(struct proc * caller, message *m_ptr) * that initiated the device I/O. Kernel processes, of course, are denied. */ if (proc_nr_e == SELF) - proc_nr = _ENDPOINT_P(caller->p_endpoint); + okendpt(caller->p_endpoint, &proc_nr); else if(!isokendpt(proc_nr_e, &proc_nr)) return(EINVAL); diff --git a/kernel/system/do_privctl.c b/kernel/system/do_privctl.c index d99598632..d4014dfb9 100644 --- a/kernel/system/do_privctl.c +++ b/kernel/system/do_privctl.c @@ -44,7 +44,7 @@ int do_privctl(struct proc * caller, message * m_ptr) * forks. */ if (! (priv(caller)->s_flags & SYS_PROC)) return(EPERM); - if(m_ptr->CTL_ENDPT == SELF) proc_nr = _ENDPOINT_P(caller->p_endpoint); + if(m_ptr->CTL_ENDPT == SELF) okendpt(caller->p_endpoint, &proc_nr); else if(!isokendpt(m_ptr->CTL_ENDPT, &proc_nr)) return(EINVAL); rp = proc_addr(proc_nr); diff --git a/kernel/system/do_schedule.c b/kernel/system/do_schedule.c index f5cf335a4..799f8064f 100644 --- a/kernel/system/do_schedule.c +++ b/kernel/system/do_schedule.c @@ -14,7 +14,7 @@ int do_schedule(struct proc * caller, message * m_ptr) if (!isokendpt(m_ptr->SCHEDULING_ENDPOINT, &proc_nr)) return EINVAL; - p = proc_addr(_ENDPOINT_P(m_ptr->SCHEDULING_ENDPOINT)); + p = proc_addr(proc_nr); /* Only this process' scheduler can schedule it */ if (caller != p->p_scheduler) diff --git a/kernel/system/do_umap_remote.c b/kernel/system/do_umap_remote.c index 57dad9af6..9d0b4065e 100644 --- a/kernel/system/do_umap_remote.c +++ b/kernel/system/do_umap_remote.c @@ -38,7 +38,7 @@ int do_umap_remote(struct proc * caller, message * m_ptr) /* Verify process number. */ if (endpt == SELF) - proc_nr = _ENDPOINT_P(caller->p_endpoint); + okendpt(caller->p_endpoint, &proc_nr); else if (! isokendpt(endpt, &proc_nr)) return(EINVAL);