diff --git a/net/core/filter.c b/net/core/filter.c index 6f755cca452069..3b7398ae270aa3 100644 --- a/net/core/filter.c +++ b/net/core/filter.c @@ -322,6 +322,8 @@ unsigned int sk_run_filter(const struct sk_buff *skb, if (skb_is_nonlinear(skb)) return 0; + if (skb->len < sizeof(struct nlattr)) + return 0; if (A > skb->len - sizeof(struct nlattr)) return 0; @@ -338,11 +340,13 @@ unsigned int sk_run_filter(const struct sk_buff *skb, if (skb_is_nonlinear(skb)) return 0; + if (skb->len < sizeof(struct nlattr)) + return 0; if (A > skb->len - sizeof(struct nlattr)) return 0; nla = (struct nlattr *)&skb->data[A]; - if (nla->nla_len > A - skb->len) + if (nla->nla_len > skb->len - A) return 0; nla = nla_find_nested(nla, X);