Skip to contentSkip to conversation

nft: masq: fix uninitialized range in nft_masq_{ipv4,ipv6}_eval

PATCH Applied Daniel Borkmann 2 participants 2 messages Nov 7, 2014 – Nov 10, 2014

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 nft: masq: fix uninitialized range in nft_masq_{ipv4,ipv6}_eval

When transferring from the original range in nf_nat_masquerade_{ipv4,ipv6}() we copy over values from stack in from min_proto/max_proto due to uninitialized range variable in both, nft_masq_{ipv4,ipv6}_eval. As we only initialize flags at this time from nft_masq struct, just zero out the rest.

Fixes 9ba1f726bec09 ("netfilter: nf_tables: add new nft_masq expression")
---
 net/ipv4/netfilter/nft_masq_ipv4.c | 1 +
 net/ipv6/netfilter/nft_masq_ipv6.c | 1 +
 2 files changed, 2 insertions(+)
net/ipv4/netfilter/nft_masq_ipv4.c +1 -0
index c1023c4..665de06 100644
@@ -24,6 +24,7 @@ static void nft_masq_ipv4_eval(const struct nft_expr *expr,
 	struct nf_nat_range range;
 	unsigned int verdict;
 
+	memset(&range, 0, sizeof(range));
 	range.flags = priv->flags;
 
 	verdict = nf_nat_masquerade_ipv4(pkt->skb, pkt->ops->hooknum,
net/ipv6/netfilter/nft_masq_ipv6.c +1 -0
index 8a7ac68..529c119 100644
@@ -25,6 +25,7 @@ static void nft_masq_ipv6_eval(const struct nft_expr *expr,
 	struct nf_nat_range range;
 	unsigned int verdict;
 
+	memset(&range, 0, sizeof(range));
 	range.flags = priv->flags;
 
 	verdict = nf_nat_masquerade_ipv6(pkt->skb, &range, pkt->out);
Signature · 1 line
1.7.11.7
maintainer Applied
#1 lore raw
Quoted 4 lines · Daniel Borkmann

When transferring from the original range in nf_nat_masquerade_{ipv4,ipv6}() we copy over values from stack in from min_proto/max_proto due to uninitialized range variable in both, nft_masq_{ipv4,ipv6}_eval. As we only initialize flags at this time from nft_masq struct, just zero out the rest.

Applied, thanks Daniel!