Skip to content

Commit 76a109f

Browse files
committed
netfilter: nft_fwd_netdev: validate family and chain type
Make sure the forward action is only used from ingress. Fixes: 39e6dea ("netfilter: nf_tables: add forward expression to the netdev family") Signed-off-by: Pablo Neira Ayuso <[email protected]>
1 parent 7c84d41 commit 76a109f

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

net/netfilter/nft_fwd_netdev.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,13 +190,21 @@ static int nft_fwd_neigh_dump(struct sk_buff *skb, const struct nft_expr *expr)
190190
return -1;
191191
}
192192

193+
static int nft_fwd_validate(const struct nft_ctx *ctx,
194+
const struct nft_expr *expr,
195+
const struct nft_data **data)
196+
{
197+
return nft_chain_validate_hooks(ctx->chain, (1 << NF_NETDEV_INGRESS));
198+
}
199+
193200
static struct nft_expr_type nft_fwd_netdev_type;
194201
static const struct nft_expr_ops nft_fwd_neigh_netdev_ops = {
195202
.type = &nft_fwd_netdev_type,
196203
.size = NFT_EXPR_SIZE(sizeof(struct nft_fwd_neigh)),
197204
.eval = nft_fwd_neigh_eval,
198205
.init = nft_fwd_neigh_init,
199206
.dump = nft_fwd_neigh_dump,
207+
.validate = nft_fwd_validate,
200208
};
201209

202210
static const struct nft_expr_ops nft_fwd_netdev_ops = {
@@ -205,6 +213,7 @@ static const struct nft_expr_ops nft_fwd_netdev_ops = {
205213
.eval = nft_fwd_netdev_eval,
206214
.init = nft_fwd_netdev_init,
207215
.dump = nft_fwd_netdev_dump,
216+
.validate = nft_fwd_validate,
208217
.offload = nft_fwd_netdev_offload,
209218
};
210219

0 commit comments

Comments
 (0)