[RFC][PATCH] Restore LSM hook calls to setpriority and setpgid

Stephen D. Smalley (sds@epoch.ncsc.mil)
Tue, 14 Jan 2003 16:44:51 -0500 (EST)


This patch restores the LSM hook calls in setpriority and setpgid to
2.5.58. These hooks were previously added as of 2.5.27, but the hook
calls were subsequently lost as a result of other changes to the code
as of 2.5.37.

If anyone has any objections to these changes, please let me know.

sys.c | 21 ++++++++++++++++-----
1 files changed, 16 insertions(+), 5 deletions(-)
-----

===== kernel/sys.c 1.38 vs edited =====
--- 1.38/kernel/sys.c Thu Dec 5 21:56:43 2002
+++ edited/kernel/sys.c Tue Jan 14 16:02:15 2003
@@ -212,18 +212,25 @@

static int set_one_prio(struct task_struct *p, int niceval, int error)
{
+ int no_nice;
+
if (p->uid != current->euid &&
p->uid != current->uid && !capable(CAP_SYS_NICE)) {
error = -EPERM;
goto out;
}
-
+ if (niceval < task_nice(p) && !capable(CAP_SYS_NICE)) {
+ error = -EACCES;
+ goto out;
+ }
+ no_nice = security_task_setnice(p, niceval);
+ if (no_nice) {
+ error = no_nice;
+ goto out;
+ }
if (error == -ESRCH)
error = 0;
- if (niceval < task_nice(p) && !capable(CAP_SYS_NICE))
- error = -EACCES;
- else
- set_user_nice(p, niceval);
+ set_user_nice(p, niceval);
out:
return error;
}
@@ -944,6 +951,10 @@
}

ok_pgid:
+ err = security_task_setpgid(p, pgid);
+ if (err)
+ goto out;
+
if (p->pgrp != pgid) {
detach_pid(p, PIDTYPE_PGID);
p->pgrp = pgid;

--
Stephen Smalley, NSA
sds@epoch.ncsc.mil

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