Re: [PATCH] Changing RT priority in kernel 2.6 without CAP_SYS_NICE

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH] Changing RT priority in kernel 2.6 without CAP_SYS_NICE

Andrew Morton-8
Ingo Molnar <[hidden email]> 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 [hidden email]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH] Changing RT priority in kernel 2.6 without CAP_SYS_NICE

ocroquette
Hi!

The patch seems OK to me, I will try to test live in the next days.

Regards

Olivier
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [hidden email]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH] Changing RT priority in kernel 2.6 without CAP_SYS_NICE

Ingo Molnar-2
In reply to this post by Andrew Morton-8

* Andrew Morton <[hidden email]> wrote:

> Ingo Molnar <[hidden email]> 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.

the massaging looks ok - and i agree that we should merge the rt-rlimits
patch.

        Ingo
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [hidden email]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/