Skip to contentSkip to conversation

netfilter: fix out-of-bounds access in nat addr selection

PATCH Applied Florian Westphal 2 participants 2 messages Sep 5, 2012 – Sep 10, 2012

Subsystems (2)
lore
Share & tools
lore

Florian Westphal

author maintainer
#0 lore raw

PATCH 1/1 netfilter: fix out-of-bounds access in nat addr selection

include/linux/jhash.h:138:16: warning: array subscript is above array bounds [jhash2() expects the number of u32 in the key]

---
Only affects -next.
note that I also get same warning for hash_by_src(); but hash = jhash2((u32 *)&tuple->src, sizeof(tuple->src) / sizeof(u32),

	      tuple->dst.protonum ^ zone ^ nf_conntrack_hash_rnd);

looks correct to me.

net/netfilter/nf_nat_core.c +1 -1
index 29d4452..1816ad3 100644
@@ -255,7 +255,7 @@ find_best_ips_proto(u16 zone, struct nf_conntrack_tuple *tuple,
 	 * client coming from the same IP (some Internet Banking sites
 	 * like this), even across reboots.
 	 */
-	j = jhash2((u32 *)&tuple->src.u3, sizeof(tuple->src.u3),
+	j = jhash2((u32 *)&tuple->src.u3, sizeof(tuple->src.u3) / sizeof(u32),
 		   range->flags & NF_NAT_RANGE_PERSISTENT ?
 			0 : (__force u32)tuple->dst.u3.all[max] ^ zone);
 
Signature · 1 line
1.7.8.6
maintainer Applied
#1 lore raw
Quoted 2 lines · Florian Westphal

include/linux/jhash.h:138:16: warning: array subscript is above array bounds [jhash2() expects the number of u32 in the key]

Applied to -next, thanks Florian.

Quoted 7 lines

---
Only affects -next.
note that I also get same warning for hash_by_src(); but hash = jhash2((u32 *)&tuple->src, sizeof(tuple->src) / sizeof(u32),

	      tuple->dst.protonum ^ zone ^ nf_conntrack_hash_rnd);

looks correct to me.

It also seems correct to me, that tuple->src is 5*4 bytes long.

I'm not hitting any warning with gcc-4.7 though.