aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Quigley <dpquigl@tycho.nsa.gov>2006-06-23 05:04:01 -0400
committerLinus Torvalds <torvalds@g5.osdl.org>2006-06-23 10:42:54 -0400
commit35601547baf92d984b6e59cf3583649da04baea5 (patch)
treea392501e6e004ed33789dbf3f7a9fe43295439e1
parent22fb52dd736a62e24c44c50739007496265dc38c (diff)
[PATCH] SELinux: add task_movememory hook
This patch adds new security hook, task_movememory, to be called when memory owened by a task is to be moved (e.g. when migrating pages to a this hook is identical to the setscheduler implementation, but a separate hook introduced to allow this check to be specialized in the future if necessary. Since the last posting, the hook has been renamed following feedback from Christoph Lameter. Signed-off-by: David Quigley <dpquigl@tycho.nsa.gov> Acked-by: Stephen Smalley <sds@tycho.nsa.gov> Signed-off-by: James Morris <jmorris@namei.org> Cc: Christoph Lameter <clameter@sgi.com> Cc: Andi Kleen <ak@muc.de> Acked-by: Chris Wright <chrisw@sous-sol.org> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
-rw-r--r--include/linux/security.h15
-rw-r--r--security/dummy.c6
-rw-r--r--security/selinux/hooks.c6
3 files changed, 27 insertions, 0 deletions
diff --git a/include/linux/security.h b/include/linux/security.h
index 65b32a0c6207..d2c17bd91a29 100644
--- a/include/linux/security.h
+++ b/include/linux/security.h
@@ -601,6 +601,10 @@ struct swap_info_struct;
601 * @p. 601 * @p.
602 * @p contains the task_struct for process. 602 * @p contains the task_struct for process.
603 * Return 0 if permission is granted. 603 * Return 0 if permission is granted.
604 * @task_movememory
605 * Check permission before moving memory owned by process @p.
606 * @p contains the task_struct for process.
607 * Return 0 if permission is granted.
604 * @task_kill: 608 * @task_kill:
605 * Check permission before sending signal @sig to @p. @info can be NULL, 609 * Check permission before sending signal @sig to @p. @info can be NULL,
606 * the constant 1, or a pointer to a siginfo structure. If @info is 1 or 610 * the constant 1, or a pointer to a siginfo structure. If @info is 1 or
@@ -1220,6 +1224,7 @@ struct security_operations {
1220 int (*task_setscheduler) (struct task_struct * p, int policy, 1224 int (*task_setscheduler) (struct task_struct * p, int policy,
1221 struct sched_param * lp); 1225 struct sched_param * lp);
1222 int (*task_getscheduler) (struct task_struct * p); 1226 int (*task_getscheduler) (struct task_struct * p);
1227 int (*task_movememory) (struct task_struct * p);
1223 int (*task_kill) (struct task_struct * p, 1228 int (*task_kill) (struct task_struct * p,
1224 struct siginfo * info, int sig); 1229 struct siginfo * info, int sig);
1225 int (*task_wait) (struct task_struct * p); 1230 int (*task_wait) (struct task_struct * p);
@@ -1865,6 +1870,11 @@ static inline int security_task_getscheduler (struct task_struct *p)
1865 return security_ops->task_getscheduler (p); 1870 return security_ops->task_getscheduler (p);
1866} 1871}
1867 1872
1873static inline int security_task_movememory (struct task_struct *p)
1874{
1875 return security_ops->task_movememory (p);
1876}
1877
1868static inline int security_task_kill (struct task_struct *p, 1878static inline int security_task_kill (struct task_struct *p,
1869 struct siginfo *info, int sig) 1879 struct siginfo *info, int sig)
1870{ 1880{
@@ -2512,6 +2522,11 @@ static inline int security_task_getscheduler (struct task_struct *p)
2512 return 0; 2522 return 0;
2513} 2523}
2514 2524
2525static inline int security_task_movememory (struct task_struct *p)
2526{
2527 return 0;
2528}
2529
2515static inline int security_task_kill (struct task_struct *p, 2530static inline int security_task_kill (struct task_struct *p,
2516 struct siginfo *info, int sig) 2531 struct siginfo *info, int sig)
2517{ 2532{
diff --git a/security/dummy.c b/security/dummy.c
index 879a98523b1b..c3c5493581e2 100644
--- a/security/dummy.c
+++ b/security/dummy.c
@@ -537,6 +537,11 @@ static int dummy_task_getscheduler (struct task_struct *p)
537 return 0; 537 return 0;
538} 538}
539 539
540static int dummy_task_movememory (struct task_struct *p)
541{
542 return 0;
543}
544
540static int dummy_task_wait (struct task_struct *p) 545static int dummy_task_wait (struct task_struct *p)
541{ 546{
542 return 0; 547 return 0;
@@ -981,6 +986,7 @@ void security_fixup_ops (struct security_operations *ops)
981 set_to_dummy_if_null(ops, task_setrlimit); 986 set_to_dummy_if_null(ops, task_setrlimit);
982 set_to_dummy_if_null(ops, task_setscheduler); 987 set_to_dummy_if_null(ops, task_setscheduler);
983 set_to_dummy_if_null(ops, task_getscheduler); 988 set_to_dummy_if_null(ops, task_getscheduler);
989 set_to_dummy_if_null(ops, task_movememory);
984 set_to_dummy_if_null(ops, task_wait); 990 set_to_dummy_if_null(ops, task_wait);
985 set_to_dummy_if_null(ops, task_kill); 991 set_to_dummy_if_null(ops, task_kill);
986 set_to_dummy_if_null(ops, task_prctl); 992 set_to_dummy_if_null(ops, task_prctl);
diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c
index 9dcf298921d4..79c16e31c884 100644
--- a/security/selinux/hooks.c
+++ b/security/selinux/hooks.c
@@ -2679,6 +2679,11 @@ static int selinux_task_getscheduler(struct task_struct *p)
2679 return task_has_perm(current, p, PROCESS__GETSCHED); 2679 return task_has_perm(current, p, PROCESS__GETSCHED);
2680} 2680}
2681 2681
2682static int selinux_task_movememory(struct task_struct *p)
2683{
2684 return task_has_perm(current, p, PROCESS__SETSCHED);
2685}
2686
2682static int selinux_task_kill(struct task_struct *p, struct siginfo *info, int sig) 2687static int selinux_task_kill(struct task_struct *p, struct siginfo *info, int sig)
2683{ 2688{
2684 u32 perm; 2689 u32 perm;
@@ -4392,6 +4397,7 @@ static struct security_operations selinux_ops = {
4392 .task_setrlimit = selinux_task_setrlimit, 4397 .task_setrlimit = selinux_task_setrlimit,
4393 .task_setscheduler = selinux_task_setscheduler, 4398 .task_setscheduler = selinux_task_setscheduler,
4394 .task_getscheduler = selinux_task_getscheduler, 4399 .task_getscheduler = selinux_task_getscheduler,
4400 .task_movememory = selinux_task_movememory,
4395 .task_kill = selinux_task_kill, 4401 .task_kill = selinux_task_kill,
4396 .task_wait = selinux_task_wait, 4402 .task_wait = selinux_task_wait,
4397 .task_prctl = selinux_task_prctl, 4403 .task_prctl = selinux_task_prctl,