Annotation of /trunk/kernel26-alx/patches-2.6.17-r5/0010-2.6.17-sched-limit_policy_changes.patch
Parent Directory | Revision Log
Revision 199 -
(hide annotations)
(download)
Fri May 18 11:04:36 2007 UTC (17 years, 4 months ago) by niro
File size: 2425 byte(s)
Fri May 18 11:04:36 2007 UTC (17 years, 4 months ago) by niro
File size: 2425 byte(s)
-import
1 | niro | 199 | 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 | 52 +++++++++++++++++++++++++++++++++++++++------------- | ||
13 | 1 files changed, 39 insertions(+), 13 deletions(-) | ||
14 | |||
15 | Index: linux-ck-dev/kernel/sched.c | ||
16 | =================================================================== | ||
17 | --- linux-ck-dev.orig/kernel/sched.c 2006-06-18 15:23:46.000000000 +1000 | ||
18 | +++ linux-ck-dev/kernel/sched.c 2006-06-18 15:23:49.000000000 +1000 | ||
19 | @@ -3700,19 +3700,44 @@ recheck: | ||
20 | * Allow unprivileged RT tasks to decrease priority: | ||
21 | */ | ||
22 | if (!capable(CAP_SYS_NICE)) { | ||
23 | - /* | ||
24 | - * can't change policy, except between SCHED_NORMAL | ||
25 | - * and SCHED_BATCH: | ||
26 | - */ | ||
27 | - if (SCHED_RT(policy) && policy != p->policy && | ||
28 | - !p->signal->rlim[RLIMIT_RTPRIO].rlim_cur) | ||
29 | - return -EPERM; | ||
30 | - /* can't increase priority */ | ||
31 | - if (SCHED_RT(policy) && | ||
32 | - param->sched_priority > p->rt_priority && | ||
33 | - param->sched_priority > | ||
34 | - p->signal->rlim[RLIMIT_RTPRIO].rlim_cur) | ||
35 | - return -EPERM; | ||
36 | + if (SCHED_RT(policy)) { | ||
37 | + /* | ||
38 | + * can't change policy to a realtime policy | ||
39 | + */ | ||
40 | + if (policy != p->policy && | ||
41 | + !p->signal->rlim[RLIMIT_RTPRIO].rlim_cur) | ||
42 | + return -EPERM; | ||
43 | + /* can't increase priority */ | ||
44 | + if (param->sched_priority > p->rt_priority && | ||
45 | + param->sched_priority > | ||
46 | + p->signal->rlim[RLIMIT_RTPRIO].rlim_cur) | ||
47 | + return -EPERM; | ||
48 | + } else { | ||
49 | + switch (p->policy) { | ||
50 | + /* | ||
51 | + * Can only downgrade policies but not back to | ||
52 | + * SCHED_NORMAL | ||
53 | + */ | ||
54 | + case SCHED_ISO: | ||
55 | + if (policy == SCHED_ISO) | ||
56 | + goto out; | ||
57 | + if (policy == SCHED_NORMAL) | ||
58 | + return -EPERM; | ||
59 | + break; | ||
60 | + case SCHED_BATCH: | ||
61 | + if (policy == SCHED_BATCH) | ||
62 | + goto out; | ||
63 | + if (policy != SCHED_IDLEPRIO) | ||
64 | + return -EPERM; | ||
65 | + break; | ||
66 | + case SCHED_IDLEPRIO: | ||
67 | + if (policy == SCHED_IDLEPRIO) | ||
68 | + goto out; | ||
69 | + return -EPERM; | ||
70 | + default: | ||
71 | + break; | ||
72 | + } | ||
73 | + } | ||
74 | /* can't change other user's priorities */ | ||
75 | if ((current->euid != p->euid) && | ||
76 | (current->euid != p->uid)) | ||
77 | @@ -3756,6 +3781,7 @@ recheck: | ||
78 | preempt(p, rq); | ||
79 | } | ||
80 | task_rq_unlock(rq, &flags); | ||
81 | +out: | ||
82 | return 0; | ||
83 | } | ||
84 | EXPORT_SYMBOL_GPL(sched_setscheduler); |