Current-Users archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: kauth and sched_{get,set}param



> Index: sys_sched.c
> ===================================================================
> RCS file: /cvsroot/src/sys/kern/sys_sched.c,v
> retrieving revision 1.9
> diff -u -p -r1.9 sys_sched.c
> --- sys_sched.c       31 Jan 2008 01:21:17 -0000      1.9
> +++ sys_sched.c       31 Jan 2008 14:38:59 -0000
> @@ -117,15 +117,29 @@ sys__sched_setparam(struct lwp *l, const
>       pri_t pri;
>       int error;
>  
> -     /* Available only for super-user */
> -     if (kauth_authorize_process(l->l_cred, KAUTH_PROCESS_SCHEDULER,
> -         KAUTH_ARG(KAUTH_REQ_PROCESS_SCHEDULER_SETPARAM), NULL, NULL, NULL))
> -             return EPERM;
> +     if (SCARG(uap, pid) != 0) {
> +             /* Find the process */
> +             p = p_find(SCARG(uap, pid), PFIND_UNLOCK_FAIL);
> +             if (p == NULL)
> +                     return ESRCH;
> +             mutex_enter(&p->p_smutex);
> +             mutex_exit(&proclist_lock);
> +             /* Disallow modification of system processes */
> +             if (p->p_flag & PK_SYSTEM) {
> +                     mutex_exit(&p->p_smutex);
> +                     return EPERM;
> +             }
> +     } else {
> +             /* Use the calling process */
> +             p = l->l_proc;
> +             mutex_enter(&p->p_smutex);
> +     }
>  
>       /* Get the parameters from the user-space */
>       sp = kmem_zalloc(sizeof(struct sched_param), KM_SLEEP);
>       error = copyin(SCARG(uap, params), sp, sizeof(struct sched_param));

you should not sleep with a spin mutex held.  see mutex(9).

YAMAMOTO Takashi



Home | Main Index | Thread Index | Old Index