netfilter: nf_tables: improve nft payload fast eval
authorLiping Zhang <liping.zhang@spreadtrum.com>
Thu, 15 Sep 2016 13:29:08 +0000 (21:29 +0800)
committerPablo Neira Ayuso <pablo@netfilter.org>
Fri, 23 Sep 2016 07:30:16 +0000 (09:30 +0200)
There's an off-by-one issue in nft_payload_fast_eval, skb_tail_pointer
and ptr + priv->len all point to the last valid address plus 1. So if
they are equal, we can still fetch the valid data. It's unnecessary to
fall back to nft_payload_eval.

Signed-off-by: Liping Zhang <liping.zhang@spreadtrum.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
net/netfilter/nf_tables_core.c

index fb8b5892b5ffa8ec6b0cf35792991b9125f082eb..36ba4e55d84e7039caa0e404ef82835b96057270 100644 (file)
@@ -98,7 +98,7 @@ static bool nft_payload_fast_eval(const struct nft_expr *expr,
 
        ptr += priv->offset;
 
-       if (unlikely(ptr + priv->len >= skb_tail_pointer(skb)))
+       if (unlikely(ptr + priv->len > skb_tail_pointer(skb)))
                return false;
 
        *dest = 0;