Bläddra i källkod

netfilter: nf_tables: check for overflow of rule dlen field

Check that the space required for the expressions doesn't exceed the
size of the dlen field, which would lead to the iterators crashing.

Signed-off-by: Patrick McHardy <kaber@trash.net>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Patrick McHardy 10 år sedan
förälder
incheckning
9889840f59
1 ändrade filer med 4 tillägg och 0 borttagningar
  1. 4 0
      net/netfilter/nf_tables_api.c

+ 4 - 0
net/netfilter/nf_tables_api.c

@@ -1968,6 +1968,10 @@ static int nf_tables_newrule(struct sock *nlsk, struct sk_buff *skb,
 			n++;
 			n++;
 		}
 		}
 	}
 	}
+	/* Check for overflow of dlen field */
+	err = -EFBIG;
+	if (size >= 1 << 12)
+		goto err1;
 
 
 	if (nla[NFTA_RULE_USERDATA])
 	if (nla[NFTA_RULE_USERDATA])
 		ulen = nla_len(nla[NFTA_RULE_USERDATA]);
 		ulen = nla_len(nla[NFTA_RULE_USERDATA]);