]> git.itanic.dy.fi Git - linux-stable/commitdiff
netfilter: nft_payload: fix wrong mac header matching
authorFlorian Westphal <fw@strlen.de>
Sun, 8 Oct 2023 17:36:53 +0000 (19:36 +0200)
committerFlorian Westphal <fw@strlen.de>
Thu, 12 Oct 2023 08:28:45 +0000 (10:28 +0200)
mcast packets get looped back to the local machine.
Such packets have a 0-length mac header, we should treat
this like "mac header not set" and abort rule evaluation.

As-is, we just copy data from the network header instead.

Fixes: 96518518cc41 ("netfilter: add nftables")
Reported-by: Blažej Krajňák <krajnak@levonet.sk>
Signed-off-by: Florian Westphal <fw@strlen.de>
net/netfilter/nft_payload.c

index 120f6d395b98b3ddf9d73d56ecbfb46e1e408bc0..0a689c8e0295dfed3511997abcac53fad4b56fd5 100644 (file)
@@ -179,7 +179,7 @@ void nft_payload_eval(const struct nft_expr *expr,
 
        switch (priv->base) {
        case NFT_PAYLOAD_LL_HEADER:
-               if (!skb_mac_header_was_set(skb))
+               if (!skb_mac_header_was_set(skb) || skb_mac_header_len(skb) == 0)
                        goto err;
 
                if (skb_vlan_tag_present(skb) &&