public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] sched: allow unsetting SCHED_RESET_ON_FORK when new policy is not realtime
@ 2012-10-17 21:18 Maarten Lankhorst
  2012-10-17 21:41 ` Maarten Lankhorst
  0 siblings, 1 reply; 2+ messages in thread
From: Maarten Lankhorst @ 2012-10-17 21:18 UTC (permalink / raw)
  To: Lennart Poettering; +Cc: LKML

When implementing SIGXCPU handling for a thread boosted with rtkit to realtime
priority, I noticed that sched_setscheduler(somepid, SCHED_OTHER) would return
-EPERM because the thread was previously SCHED_RR | SCHED_RESET_ON_FORK,
and looking from the code that flag cannot be reset without sufficient rights.

sched_setscheduler(somepid, SCHED_OTHER | SCHED_RESET_ON_FORK) which worked,
and seems to be the only way to remove realtime priority set by rtkit on all
kernels since the patch was introduced.

This patch allows SCHED_RESET_ON_FORK to be removed when the user sets a new
policy on itself without realtime.

Cc: Stable <stable@vger.kernel.org> [v2.6.32+]
Signed-off-by: Maarten Lankhorst <maarten.lankhorst@canonical.com>

diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index 2d8927f..4c0712a 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -3757,6 +3757,12 @@ recheck:
 			if (param->sched_priority > p->rt_priority &&
 			    param->sched_priority > rlim_rtprio)
 				return -EPERM;
+
+			/* Normal users shall not reset the
+			 * sched_reset_on_fork flag
+			 */
+			if (p->sched_reset_on_fork && !reset_on_fork)
+				return -EPERM;
 		}
 
 		/*
@@ -3771,10 +3777,6 @@ recheck:
 		/* can't change other user's priorities */
 		if (!check_same_owner(p))
 			return -EPERM;
-
-		/* Normal users shall not reset the sched_reset_on_fork flag */
-		if (p->sched_reset_on_fork && !reset_on_fork)
-			return -EPERM;
 	}
 
 	if (user) {


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] sched: allow unsetting SCHED_RESET_ON_FORK when new policy is not realtime
  2012-10-17 21:18 [PATCH] sched: allow unsetting SCHED_RESET_ON_FORK when new policy is not realtime Maarten Lankhorst
@ 2012-10-17 21:41 ` Maarten Lankhorst
  0 siblings, 0 replies; 2+ messages in thread
From: Maarten Lankhorst @ 2012-10-17 21:41 UTC (permalink / raw)
  To: Lennart Poettering; +Cc: LKML

Op 17-10-12 23:18, Maarten Lankhorst schreef:
> When implementing SIGXCPU handling for a thread boosted with rtkit to realtime
> priority, I noticed that sched_setscheduler(somepid, SCHED_OTHER) would return
> -EPERM because the thread was previously SCHED_RR | SCHED_RESET_ON_FORK,
> and looking from the code that flag cannot be reset without sufficient rights.
>
Argh must not send patches right before going to bed, this leaves open a hole
if current policy is sched_idle and when nice level is at a privileged level still..

Not that I've ever seen nice level do anything. Will resend after I've had some sleep.

~Maarten

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2012-10-17 21:41 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-10-17 21:18 [PATCH] sched: allow unsetting SCHED_RESET_ON_FORK when new policy is not realtime Maarten Lankhorst
2012-10-17 21:41 ` Maarten Lankhorst

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox