netfilter: nft_payload: rebuild vlan header when needed
authorPablo Neira Ayuso <pablo@netfilter.org>
Tue, 6 Jun 2023 07:38:42 +0000 (09:38 +0200)
committerPablo Neira Ayuso <pablo@netfilter.org>
Mon, 26 Jun 2023 06:05:45 +0000 (08:05 +0200)
Skip rebuilding the vlan header when accessing destination and source
mac address.

Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
net/netfilter/nft_payload.c

index 3a3c774..8cb8009 100644 (file)
@@ -171,7 +171,8 @@ void nft_payload_eval(const struct nft_expr *expr,
                if (!skb_mac_header_was_set(skb))
                        goto err;
 
-               if (skb_vlan_tag_present(skb)) {
+               if (skb_vlan_tag_present(skb) &&
+                   priv->offset >= offsetof(struct ethhdr, h_proto)) {
                        if (!nft_payload_copy_vlan(dest, skb,
                                                   priv->offset, priv->len))
                                goto err;