]> pilppa.com Git - linux-2.6-omap-h63xx.git/commitdiff
[PATCH] Make sure interleave masks have at least one node set
authorAndi Kleen <ak@suse.de>
Mon, 2 Jan 2006 23:07:28 +0000 (00:07 +0100)
committerLinus Torvalds <torvalds@g5.osdl.org>
Tue, 3 Jan 2006 01:01:42 +0000 (17:01 -0800)
Otherwise a bad mem policy system call can confuse the interleaving
code into referencing undefined nodes.

Originally reported by Doug Chapman

I was told it's CVE-2005-3358
(one has to love these security people - they make everything sound important)

Signed-off-by: Andi Kleen <ak@suse.de>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
mm/mempolicy.c

index bec88c81244e0d4f9541f4098f5f8c8409ba455b..72f402cc9c9af77f6d6c765c166e35d0bb4764ae 100644 (file)
@@ -161,6 +161,10 @@ static struct mempolicy *mpol_new(int mode, nodemask_t *nodes)
        switch (mode) {
        case MPOL_INTERLEAVE:
                policy->v.nodes = *nodes;
+               if (nodes_weight(*nodes) == 0) {
+                       kmem_cache_free(policy_cache, policy);
+                       return ERR_PTR(-EINVAL);
+               }
                break;
        case MPOL_PREFERRED:
                policy->v.preferred_node = first_node(*nodes);