Contents of /trunk/kernel26-tinyalx/patches-2.6.21-r14/0007-2.6.21-sched-limit_policy_changes.patch
Parent Directory | Revision Log
Revision 453 -
(show annotations)
(download)
Fri Jan 25 23:34:48 2008 UTC (16 years, 9 months ago) by niro
File size: 1532 byte(s)
Fri Jan 25 23:34:48 2008 UTC (16 years, 9 months ago) by niro
File size: 1532 byte(s)
-tiny-alx 2.6.21-tinyalx-r14
1 | Many applications explicitly set SCHED_NORMAL on threads thus undoing the |
2 | usefulness of the SCHED_ISO, SCHED_BATCH and SCHED_IDLEPRIO policies. |
3 | |
4 | For unprivileged users: |
5 | |
6 | Only allow non realtime policies to be downgraded from ISO->BATCH->IDLEPRIO |
7 | but not back to NORMAL. |
8 | |
9 | Signed-off-by: Con Kolivas <kernel@kolivas.org> |
10 | |
11 | --- |
12 | kernel/sched.c | 26 ++++++++++++++++++++++++++ |
13 | 1 file changed, 26 insertions(+) |
14 | |
15 | Index: linux-2.6.21-ck2/kernel/sched.c |
16 | =================================================================== |
17 | --- linux-2.6.21-ck2.orig/kernel/sched.c 2007-05-14 19:30:31.000000000 +1000 |
18 | +++ linux-2.6.21-ck2/kernel/sched.c 2007-05-14 19:30:31.000000000 +1000 |
19 | @@ -4295,6 +4295,31 @@ recheck: |
20 | if (param->sched_priority > p->rt_priority && |
21 | param->sched_priority > rlim_rtprio) |
22 | return -EPERM; |
23 | + } else { |
24 | + switch (p->policy) { |
25 | + /* |
26 | + * Can only downgrade policies but not back to |
27 | + * SCHED_NORMAL |
28 | + */ |
29 | + case SCHED_ISO: |
30 | + if (policy == SCHED_ISO) |
31 | + goto out; |
32 | + if (policy == SCHED_NORMAL) |
33 | + return -EPERM; |
34 | + break; |
35 | + case SCHED_BATCH: |
36 | + if (policy == SCHED_BATCH) |
37 | + goto out; |
38 | + if (policy != SCHED_IDLEPRIO) |
39 | + return -EPERM; |
40 | + break; |
41 | + case SCHED_IDLEPRIO: |
42 | + if (policy == SCHED_IDLEPRIO) |
43 | + goto out; |
44 | + return -EPERM; |
45 | + default: |
46 | + break; |
47 | + } |
48 | } |
49 | |
50 | /* can't change other user's priorities */ |
51 | @@ -4351,6 +4376,7 @@ recheck: |
52 | |
53 | rt_mutex_adjust_pi(p); |
54 | |
55 | +out: |
56 | return 0; |
57 | } |
58 | EXPORT_SYMBOL_GPL(sched_setscheduler); |