Skip to contentSkip to conversation

netfilter: nft_exthdr: fix register tracking for F_PRESENT flag

PATCH Florian Westphal 1 participant 1 message Jun 2 2 messages not in the archive

Subsystems (2)
lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

A message that is not in the archive (sent off-list or not yet received): ah6XqhKkEvMOlU-4@chamomile

Florian Westphal

author maintainer
#2 lore raw
Quoted 1 line · Pablo Neira Ayuso

On Tue, Jun 02, 2026 at 07:40:29AM +0000, Ji'an Zhou wrote:

Adding netfilter-devel@, there is no need to keep this 'secret'. We have some many bugs security@ is overwhelmed anyway.

fib seems to have same issue.
Probably this, please test & submit.

net/netfilter/nft_exthdr.c +3 -0
@@ -532,6 +532,9 @@ static int nft_exthdr_init(const struct nft_ctx *ctx,
                        return err;
        }
 
+       if ((flags & NFT_EXTHDR_F_PRESENT) && len != 1)
+               return -EINVAL;
+
        priv->type   = nla_get_u8(tb[NFTA_EXTHDR_TYPE]);
        priv->offset = offset;
        priv->len    = len;
net/netfilter/nft_fib.c +3 -0
@@ -107,6 +107,9 @@ int nft_fib_init(const struct nft_ctx *ctx, const struct nft_expr *expr,
                return -EINVAL;
        }
 
+       if (priv->flags & NFTA_FIB_F_PRESENT)
+               len = sizeof(u8);
+
        err = nft_parse_register_store(ctx, tb[NFTA_FIB_DREG], &priv->dreg,
                                       NULL, NFT_DATA_VALUE, len);