[PATCH 2/3] SELinux: add security_task_setmempolicy hooks to mm code

From: James Morris
Date: Wed Jun 21 2006 - 15:21:47 EST


From: David Quigley <dpquigl@xxxxxxxxxxxxx>

This patch inserts the security hook calls into the setmempolicy function
to enable security modules to mediate this operation between tasks.

This patch is aimed at 2.6.18 inclusion.

Please apply.

Signed-Off-By: David Quigley <dpquigl@xxxxxxxxxxxxx>
Acked-by: Stephen Smalley <sds@xxxxxxxxxxxxx>
Signed-off-by: James Morris <jmorris@xxxxxxxxx>

---

mempolicy.c | 5 +++++
migrate.c | 6 ++++++
2 files changed, 11 insertions(+)

diff -purN -X dontdiff linux-2.6.17-mm1.p/mm/mempolicy.c linux-2.6.17-mm1.w/mm/mempolicy.c
--- linux-2.6.17-mm1.p/mm/mempolicy.c 2006-06-21 13:09:22.000000000 -0400
+++ linux-2.6.17-mm1.w/mm/mempolicy.c 2006-06-21 13:10:09.000000000 -0400
@@ -88,6 +88,7 @@
#include <linux/proc_fs.h>
#include <linux/migrate.h>
#include <linux/rmap.h>
+#include <linux/security.h>

#include <asm/tlbflush.h>
#include <asm/uaccess.h>
@@ -946,6 +947,10 @@ asmlinkage long sys_migrate_pages(pid_t
goto out;
}

+ err = security_task_setmempolicy(task);
+ if (err)
+ goto out;
+
err = do_migrate_pages(mm, &old, &new,
capable(CAP_SYS_NICE) ? MPOL_MF_MOVE_ALL : MPOL_MF_MOVE);
out:
diff -purN -X dontdiff linux-2.6.17-mm1.p/mm/migrate.c linux-2.6.17-mm1.w/mm/migrate.c
--- linux-2.6.17-mm1.p/mm/migrate.c 2006-06-21 13:09:22.000000000 -0400
+++ linux-2.6.17-mm1.w/mm/migrate.c 2006-06-21 13:10:09.000000000 -0400
@@ -27,6 +27,7 @@
#include <linux/writeback.h>
#include <linux/mempolicy.h>
#include <linux/vmalloc.h>
+#include <linux/security.h>

#include "internal.h"

@@ -903,6 +904,11 @@ asmlinkage long sys_move_pages(pid_t pid
goto out2;
}

+ err = security_task_setmempolicy(task);
+ if (err)
+ goto out2;
+
+
task_nodes = cpuset_mems_allowed(task);

/* Limit nr_pages so that the multiplication may not overflow */
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/