]> git.baikalelectronics.ru Git - kernel.git/commitdiff
netfilter: nft_fwd_netdev: validate family and chain type
authorPablo Neira Ayuso <pablo@netfilter.org>
Mon, 23 Mar 2020 13:27:16 +0000 (14:27 +0100)
committerPablo Neira Ayuso <pablo@netfilter.org>
Tue, 24 Mar 2020 18:59:38 +0000 (19:59 +0100)
Make sure the forward action is only used from ingress.

Fixes: 4c02705254c8 ("netfilter: nf_tables: add forward expression to the netdev family")
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
net/netfilter/nft_fwd_netdev.c

index aba11c2333f34e532fec3dc3ff72ba476187251a..ddd28de810b67e3a2bb9472f7a95e4a822881d50 100644 (file)
@@ -190,6 +190,13 @@ nla_put_failure:
        return -1;
 }
 
+static int nft_fwd_validate(const struct nft_ctx *ctx,
+                           const struct nft_expr *expr,
+                           const struct nft_data **data)
+{
+       return nft_chain_validate_hooks(ctx->chain, (1 << NF_NETDEV_INGRESS));
+}
+
 static struct nft_expr_type nft_fwd_netdev_type;
 static const struct nft_expr_ops nft_fwd_neigh_netdev_ops = {
        .type           = &nft_fwd_netdev_type,
@@ -197,6 +204,7 @@ static const struct nft_expr_ops nft_fwd_neigh_netdev_ops = {
        .eval           = nft_fwd_neigh_eval,
        .init           = nft_fwd_neigh_init,
        .dump           = nft_fwd_neigh_dump,
+       .validate       = nft_fwd_validate,
 };
 
 static const struct nft_expr_ops nft_fwd_netdev_ops = {
@@ -205,6 +213,7 @@ static const struct nft_expr_ops nft_fwd_netdev_ops = {
        .eval           = nft_fwd_netdev_eval,
        .init           = nft_fwd_netdev_init,
        .dump           = nft_fwd_netdev_dump,
+       .validate       = nft_fwd_validate,
        .offload        = nft_fwd_netdev_offload,
 };