From: Florian Westphal <fw@strlen.de>
To: Pablo Neira Ayuso <pablo@netfilter.org>
Cc: netfilter-devel@vger.kernel.org
Subject: Re: [PATCH nf] netfilter: nf_tables: validate NFPROTO_{IPV4,IPV6,INET} family
Date: Tue, 23 Jan 2024 18:10:21 +0100 [thread overview]
Message-ID: <20240123171021.GA31645@breakpoint.cc> (raw)
In-Reply-To: <20240123161333.39189-1-pablo@netfilter.org>
Pablo Neira Ayuso <pablo@netfilter.org> wrote:
> Several expressions explicitly refer to NF_INET_* hook definitions
> from expr->ops->validate, however, family is not validated.
>
> Bail out with EOPNOTSUPP in case they are used from unsupported
> families.
>
> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
> ---
> This is v1:
>
> NF_INET_* and NF_NETDEV_* hook definitions overlap, and .validate refers to
> hooks only in several expressions, not families.
>
> - synproxy refers to NFPROTO_BRIDGE from eval path, however, .validate does
> not refer to bridge hooks.
Probably those NFPROTO_BRIDGE should be removed then.
> diff --git a/net/netfilter/nft_compat.c b/net/netfilter/nft_compat.c
> index 5284cd2ad532..61f5498b73ef 100644
> --- a/net/netfilter/nft_compat.c
> +++ b/net/netfilter/nft_compat.c
> @@ -350,6 +350,11 @@ static int nft_target_validate(const struct nft_ctx *ctx,
> unsigned int hook_mask = 0;
> int ret;
>
> + if (ctx->family != NFPROTO_IPV4 &&
> + ctx->family != NFPROTO_IPV6 &&
> + ctx->family != NFPROTO_BRIDGE)
> + return -EOPNOTSUPP;
> +
> if (nft_is_base_chain(ctx->chain)) {
> const struct nft_base_chain *basechain =
> nft_base_chain(ctx->chain);
> @@ -595,6 +600,11 @@ static int nft_match_validate(const struct nft_ctx *ctx,
> unsigned int hook_mask = 0;
> int ret;
>
> + if (ctx->family != NFPROTO_IPV4 &&
> + ctx->family != NFPROTO_IPV6 &&
> + ctx->family != NFPROTO_BRIDGE)
> + return -EOPNOTSUPP;
> +
Both need to permit NFPROTO_ARP too.
LGTM otherwise.
prev parent reply other threads:[~2024-01-23 17:10 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-01-23 16:13 [PATCH nf] netfilter: nf_tables: validate NFPROTO_{IPV4,IPV6,INET} family Pablo Neira Ayuso
2024-01-23 17:10 ` Florian Westphal [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240123171021.GA31645@breakpoint.cc \
--to=fw@strlen.de \
--cc=netfilter-devel@vger.kernel.org \
--cc=pablo@netfilter.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).