Skip to contentSkip to conversation

2.6.13rc3: RLIMIT_RTPRIO broken

PATCH In review Andreas Steinmetz 4 participants 7 messages Jul 23, 2005 – Jul 26, 2005

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 2.6.13rc3: RLIMIT_RTPRIO broken

RLIMIT_RTPRIO is supposed to grant non privileged users the right to use SCHED_FIFO/SCHED_RR scheduling policies with priorites bounded by the RLIMIT_RTPRIO value via sched_setscheduler(). This is usually used by audio users.

Unfortunately this is broken in 2.6.13rc3 as you can see in the excerpt from sched_setscheduler below:

        /*
         * Allow unprivileged RT tasks to decrease priority:
         */
        if (!capable(CAP_SYS_NICE)) {
                /* can't change policy */
                if (policy != p->policy)
                        return -EPERM;

After the above unconditional test which causes sched_setscheduler to fail with no regard to the RLIMIT_RTPRIO value the following check is made:

               /* 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;

Thus I do believe that the RLIMIT_RTPRIO value must be taken into account for the policy check, especially as the RLIMIT_RTPRIO limit is of no use without this change.

The attached patch fixes this problem. I would appreciate it if the fix would make it into 2.6.13.

Signature · 1 line
Andreas Steinmetz                       SPAMmers use [email protected]
kernel/sched.c +2 -1
@@ -3528,7 +3528,8 @@
 	 */
 	if (!capable(CAP_SYS_NICE)) {
 		/* can't change policy */
-		if (policy != p->policy)
+		if (policy != p->policy &&
+			!p->signal->rlim[RLIMIT_RTPRIO].rlim_cur)
 			return -EPERM;
 		/* can't increase priority */
 		if (policy != SCHED_NORMAL &&
#1 lore raw
Quoted 7 lines · Andreas Steinmetz

RLIMIT_RTPRIO is supposed to grant non privileged users the right to use SCHED_FIFO/SCHED_RR scheduling policies with priorites bounded by the RLIMIT_RTPRIO value via sched_setscheduler(). This is usually used by audio users.

Unfortunately this is broken in 2.6.13rc3 as you can see in the excerpt from sched_setscheduler below:

Please provide the Signed-Off-By line. Also I have cc'ed Matt Mackall, the original author of the patch.

This should definitely make it in 2.6.13.

Lee

#2 lore raw
Quoted 7 lines · Lee Revell
Quoted 5 lines · Andreas Steinmetz

RLIMIT_RTPRIO is supposed to grant non privileged users the right to use SCHED_FIFO/SCHED_RR scheduling policies with priorites bounded by the RLIMIT_RTPRIO value via sched_setscheduler(). This is usually used by audio users.

Quoted 6 lines
Quoted 2 lines

Unfortunately this is broken in 2.6.13rc3 as you can see in the excerpt from sched_setscheduler below:

Please provide the Signed-Off-By line. Also I have cc'ed Matt Mackall, the original author of the patch.

Sorry, I do forget this all the time...

Signature · 1 line
Andreas Steinmetz                       SPAMmers use [email protected]
Acked-by on v1 1/1
#3 lore raw
In reply to Andreas Steinmetz
Quoted 26 lines · Andreas Steinmetz

RLIMIT_RTPRIO is supposed to grant non privileged users the right to use SCHED_FIFO/SCHED_RR scheduling policies with priorites bounded by the RLIMIT_RTPRIO value via sched_setscheduler(). This is usually used by audio users.

Unfortunately this is broken in 2.6.13rc3 as you can see in the excerpt from sched_setscheduler below:

        /*
         * Allow unprivileged RT tasks to decrease priority:
         */
        if (!capable(CAP_SYS_NICE)) {
                /* can't change policy */
                if (policy != p->policy)
                        return -EPERM;

After the above unconditional test which causes sched_setscheduler to fail with no regard to the RLIMIT_RTPRIO value the following check is made:

               /* 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;
Quoted 6 lines

Thus I do believe that the RLIMIT_RTPRIO value must be taken into account for the policy check, especially as the RLIMIT_RTPRIO limit is of no use without this change.

The attached patch fixes this problem. I would appreciate it if the fix would make it into 2.6.13.

[back from KS/OLS]

indeed. The effect of the bug is that RLIMIT_RTPRIO is completely non-functional in 2.6.12.

Ingo

#4 lore raw

2005/7/26, Ingo Molnar <[email protected]>:
[...]

Quoted 6 lines

[back from KS/OLS]

indeed. The effect of the bug is that RLIMIT_RTPRIO is completely non-functional in 2.6.12.

Ingo, Lee, Andreas,
the patch seems to be quite simple and is a fix for a regression. Is anybody going to FW it to the stable team ?

Signature · 2 lines
paoloc.blogspot.com
paoloc.mindsay.com
#5 lore raw
Quoted 4 lines · Paolo Ciarrocchi

2005/7/26, Ingo Molnar <[email protected]>:
[...]

Quoted 2 lines

[back from KS/OLS]

Quoted 8 lines
Quoted 4 lines

indeed. The effect of the bug is that RLIMIT_RTPRIO is completely non-functional in 2.6.12.

Ingo, Lee, Andreas,
the patch seems to be quite simple and is a fix for a regression. Is anybody going to FW it to the stable team ?

i'd not put it into stable just yet - the fact that it has not been tested in 2.6.12 _at all_ up until very recently means there's little QA feedback. Yes, it's simple, but it also triggers something we never did before. 2.6.13 ought to be released soon, that should be good enough.

Ingo

#6 lore raw
Quoted 5 lines · Ingo Molnar

i'd not put it into stable just yet - the fact that it has not been tested in 2.6.12 _at all_ up until very recently means there's little QA feedback. Yes, it's simple, but it also triggers something we never did before. 2.6.13 ought to be released soon, that should be good enough.

Also, no distro is shipping the updated PAM, glibc, and bash packages needed to use the new feature yet, even in their development releases. So there would be very little point in putting this in -stable.

Lee