--- kernel/sched.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) Index: linux-2.6.22-rc3-ck2/kernel/sched.c =================================================================== --- linux-2.6.22-rc3-ck2.orig/kernel/sched.c 2007-06-05 20:39:44.000000000 +1000 +++ linux-2.6.22-rc3-ck2/kernel/sched.c 2007-06-05 20:48:36.000000000 +1000 @@ -4510,12 +4510,21 @@ int sched_setscheduler(struct task_struc { struct sched_param zero_param = { .sched_priority = 0 }; int queued, retval, oldprio, oldpolicy = -1; + unsigned long rlim_rtprio = 0; unsigned long flags; struct rq *rq; /* may grab non-irq protected spin_locks */ BUG_ON(in_interrupt()); if (is_rt_policy(policy) && !capable(CAP_SYS_NICE)) { + unsigned long lflags; + + if (!lock_task_sighand(p, &lflags)) + return -ESRCH; + rlim_rtprio = p->signal->rlim[RLIMIT_RTPRIO].rlim_cur; + unlock_task_sighand(p, &lflags); + if (rlim_rtprio) + goto recheck; /* * If the caller requested an RT policy without having the * necessary rights, we downgrade the policy to SCHED_ISO. @@ -4547,14 +4556,6 @@ recheck: */ if (!capable(CAP_SYS_NICE)) { if (is_rt_policy(policy)) { - unsigned long rlim_rtprio; - unsigned long flags; - - if (!lock_task_sighand(p, &flags)) - return -ESRCH; - rlim_rtprio = p->signal->rlim[RLIMIT_RTPRIO].rlim_cur; - unlock_task_sighand(p, &flags); - /* can't set/change the rt policy */ if (policy != p->policy && !rlim_rtprio) return -EPERM;