From: Pablo Neira Ayuso <pablo@netfilter.org>
To: Nikolaos Gkarlis <nickgarlis@gmail.com>
Cc: netfilter-devel@vger.kernel.org, fw@strlen.de
Subject: Re: [PATCH v2] netfilter: nft_ct: reject ambiguous conntrack expressions in inet tables
Date: Wed, 3 Sep 2025 12:31:20 +0200 [thread overview]
Message-ID: <aLgY-O5Oj-ZjhZJS@calendula> (raw)
In-Reply-To: <20250902215433.75568-1-nickgarlis@gmail.com>
On Tue, Sep 02, 2025 at 11:54:33PM +0200, Nikolaos Gkarlis wrote:
> The kernel allows netlink messages that use the legacy NFT_CT_SRC and
> NFT_CT_DST keys in inet tables without an accompanying nft_meta
> expression specifying NFT_META_NFPROTO. This results in ambiguous
> conntrack expressions that cannot be reliably evaluated during packet
> processing.
>
> When that happens, the register size calculation defaults to IPv6 (16
> bytes) regardless of the actual packet family.
>
> This causes two issues:
> 1. For IPv4 packets, only 4 bytes contain valid address data while 12
> bytes contain uninitialized memory during comparison.
> 2. nft userspace cannot properly display these rules ([invalid type]).
>
> The bug is not reproducible through standard nft commands, which use
> NFT_CT_SRC_IP(6) and NFT_CT_DST_IP(6) keys when NFT_META_NFPROTO is
> not defined.
>
> Fix by adding a pointer to the parent nft_rule in nft_expr, allowing
> iteration over preceding expressions to ensure that an nft_meta with
> NFT_META_NFPROTO has been defined.
I think it is easier to work around this from userspace by translating
NFT_CT_SRC to NFT_CT_SRC_{IPV4,IPV6} by peeking the datatype at the
rhs of the relational.
NFT_CT_{SRC,DST} only works with relational expression, they are
broken with sets, that's why NFT_CT_SRC_{IPV4,IPV6} was introduced
(which works with both relational expressions and sets).
IIRC, I removed documentation for this syntax time ago with the
expectation, it seems someone found it and it is buggy with
NFPROTO_INET as you describe.
next prev parent reply other threads:[~2025-09-03 10:31 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-29 6:50 [PATCH] netfilter: nft_ct: reject ambiguous conntrack expressions in inet tables Nikolaos Gkarlis
2025-08-29 15:08 ` Florian Westphal
2025-08-29 21:59 ` Nick Garlis
2025-09-02 21:54 ` [PATCH v2] " Nikolaos Gkarlis
2025-09-02 22:21 ` Florian Westphal
2025-09-03 9:12 ` Nick Garlis
2025-09-03 10:13 ` Florian Westphal
2025-09-03 10:34 ` Pablo Neira Ayuso
2025-09-03 11:51 ` Nikolaos Gkarlis
2025-09-03 10:31 ` Pablo Neira Ayuso [this message]
2025-09-03 13:18 ` kernel test robot
2025-09-03 17:47 ` [syzbot ci] " syzbot ci
2025-09-03 17:56 ` [PATCH v2] " kernel test robot
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=aLgY-O5Oj-ZjhZJS@calendula \
--to=pablo@netfilter.org \
--cc=fw@strlen.de \
--cc=netfilter-devel@vger.kernel.org \
--cc=nickgarlis@gmail.com \
/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).