From: Jiayuan Chen <jiayuan.chen@linux.dev>
To: Florian Westphal <fw@strlen.de>
Cc: netfilter-devel@vger.kernel.org
Subject: Re: [PATCH nf] netfilter: nft_ct: fix OOB in NFT_CT_SRC/DST eval
Date: Thu, 28 May 2026 15:02:14 +0800 [thread overview]
Message-ID: <88abc4d7-8316-4c9e-aca0-351fe0ecb2b0@linux.dev> (raw)
In-Reply-To: <ahfV6K6KrG0akLUZ@strlen.de>
On 5/28/26 1:43 PM, Florian Westphal wrote:
> Florian Westphal <fw@strlen.de> wrote:
>>> which makes nf_ct_l3num(ct) be 0
>> How?
Yes, it's the template ct path. The triggering rule is e.g.:
table ip t {
chain pre {
type filter hook prerouting priority raw;
ct zone set 1
ct original saddr 1.2.3.4 accept
}
}
> Wild guess:
>
> diff --git a/net/netfilter/nft_ct.c b/net/netfilter/nft_ct.c
> --- a/net/netfilter/nft_ct.c
> +++ b/net/netfilter/nft_ct.c
> @@ -78,7 +78,7 @@ static void nft_ct_get_eval(const struct nft_expr *expr,
> break;
> }
>
> - if (ct == NULL)
> + if (!ct || nf_ct_is_template(ct))
> goto err;
>
> switch (priv->key) {
> diff --git a/net/netfilter/nft_ct_fast.c b/net/netfilter/nft_ct_fast.c
> --- a/net/netfilter/nft_ct_fast.c
> +++ b/net/netfilter/nft_ct_fast.c
> @@ -30,7 +30,7 @@ void nft_ct_get_fast_eval(const struct nft_expr *expr,
> break;
> }
>
> - if (!ct) {
> + if (!ct || nf_ct_is_template(ct)) {
> regs->verdict.code = NFT_BREAK;
> return;
> }
>
It looks more general and also covers the other GET keys that would
equally misbehave on a template.
> .... might also make sense to invert
> nf_ct_l3num(ct) == NFPROTO_IPV4 ? 4 : 16), i.e.:
> nf_ct_l3num(ct) == NFPROTO_IPV6 ? 16 : 4);
As defense-in-depth, IIUC?
next prev parent reply other threads:[~2026-05-28 7:02 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-28 4:26 [PATCH nf] netfilter: nft_ct: fix OOB in NFT_CT_SRC/DST eval Jiayuan Chen
2026-05-28 5:19 ` Florian Westphal
2026-05-28 5:43 ` Florian Westphal
2026-05-28 7:02 ` Jiayuan Chen [this message]
2026-05-28 7:10 ` Florian Westphal
2026-05-28 7:27 ` Jiayuan Chen
2026-05-28 8:01 ` Florian Westphal
2026-05-28 8:25 ` Jiayuan Chen
2026-05-28 9:31 ` Florian Westphal
2026-05-28 10:03 ` Pablo Neira Ayuso
2026-05-28 10:24 ` Florian Westphal
2026-05-28 10:26 ` Jiayuan Chen
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=88abc4d7-8316-4c9e-aca0-351fe0ecb2b0@linux.dev \
--to=jiayuan.chen@linux.dev \
--cc=fw@strlen.de \
--cc=netfilter-devel@vger.kernel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.