]> git.ipfire.org Git - thirdparty/kernel/stable.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)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 2 Apr 2020 13:28:19 +0000 (15:28 +0200)
commit 76a109fac206e158eb3c967af98c178cff738e6a upstream.

Make sure the forward action is only used from ingress.

Fixes: 39e6dea28adc ("netfilter: nf_tables: add forward expression to the netdev family")
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
net/netfilter/nft_fwd_netdev.c

index 8abb9891cdf22e26e2c17d4cadb4acba1a8dc14b..649edbe77a20596bd51eb84bd1e3342275ec78d7 100644 (file)
@@ -186,6 +186,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,
@@ -193,6 +200,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 = {
@@ -201,6 +209,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,
 };
 
 static const struct nft_expr_ops *