Skip to contentSkip to conversation

Make sure interleave masks have at least one node set

PATCH New Andi Kleen 1 participant 1 message Jan 2, 2006

Subsystems (2)
lore
Share & tools
lore

Andi Kleen

author
#0 lore raw

PATCH 1/1 Make sure interleave masks have at least one node set

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)

mm/mempolicy.c +4 -0
Index: linux-2.6.15rc7-work/mm/mempolicy.c
===================================================================
@@ -161,6 +161,10 @@ static struct mempolicy *mpol_new(int mo
 	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);