lkml.org 
[lkml]   [2005]   [Apr]   [26]   [last100]   RSS Feed
Views: [more markup]   [less markup]   [headers]   [forward]  
 
Messages in this thread
Patch in this message
/
DateMon, 25 Apr 2005 22:00:40 -0700
FromAndrew Morton <>
SubjectRe: [PATCH] Changing RT priority in kernel 2.6 without CAP_SYS_NICE
Ingo Molnar <mingo@elte.hu> wrote:
>
>  Presently, a process without the capability CAP_SYS_NICE can not change 
>  its own policy, which is OK.
> 
>  But it can also not decrease its RT priority (if scheduled with policy 
>  SCHED_RR or SCHED_FIFO), which is what this patch changes.

This patch needed some massaging to copt with the changes in
nice-and-rt-prio-rlimits.patch - please check.

I guess we should merge nice-and-rt-prio-rlimits.patch.

--- 25/kernel/sched.c~sched-changing-rt-priority-without-cap_sys_nice	2005-04-25 21:54:48.572295312 -0700
+++ 25-akpm/kernel/sched.c	2005-04-25 21:59:18.160311704 -0700
@@ -3445,13 +3445,24 @@ recheck:
 	if ((policy == SCHED_NORMAL) != (param->sched_priority == 0))
 		return -EINVAL;
 
-	if ((policy == SCHED_FIFO || policy == SCHED_RR) &&
-	    param->sched_priority > p->signal->rlim[RLIMIT_RTPRIO].rlim_cur &&
-	    !capable(CAP_SYS_NICE))
-		return -EPERM;
-	if ((current->euid != p->euid) && (current->euid != p->uid) &&
-	    !capable(CAP_SYS_NICE))
-		return -EPERM;
+	/*
+	 * Allow unprivileged RT tasks to decrease priority:
+	 */
+	if (!capable(CAP_SYS_NICE)) {
+		/* can't change policy */
+		if (policy != p->policy)
+			return -EPERM;
+		/* can't increase priority */
+		if (policy != SCHED_NORMAL &&
+		    param->sched_priority > p->rt_priority &&
+		    param->sched_priority >
+				p->signal->rlim[RLIMIT_RTPRIO].rlim_cur)
+			return -EPERM;
+		/* can't change other user's priorities */
+		if ((current->euid != p->euid) &&
+		    (current->euid != p->uid))
+			return -EPERM;
+	}
 
 	retval = security_task_setscheduler(p, policy, param);
 	if (retval)
_
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-04-26 05:06    [W:10.382 / U:0.150 seconds]
©2003-2008 Jasper Spaans