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 16:25:09 +0800 [thread overview]
Message-ID: <c1383a3a-6c76-411a-8ae3-1dfe90052fb7@linux.dev> (raw)
In-Reply-To: <ahf2XAmRnsjK0krp@strlen.de>
On 5/28/26 4:01 PM, Florian Westphal wrote:
> Jiayuan Chen <jiayuan.chen@linux.dev> wrote:
>>>>> nf_ct_l3num(ct) == NFPROTO_IPV6 ? 16 : 4);
>>>> As defense-in-depth, IIUC?
>>> Yes, alternatively merge your v1 with the template check. I don't see how
>>> we can ever have nf_ct_l3num(ct) != nft_pf(pkt) outside of the template
>>> bug.
>> I think the template check plus the family check (nf_ct_l3num(ct) !=
>> nft_pf(pkt)) is enough as defense-in-depth.
> Actually, I think we need to fix this to copy priv->len unconditionally.
> Or, alternatively, add a memcpy wrapper that zero-pads the remainder of
> the registers.
>
> https://sashiko.dev/#/patchset/20260528042620.263828-1-jiayuan.chen%40linux.dev
>
> "This is a pre-existing issue, but does copying only addr_len bytes when
> priv->len is larger leave the remainder of the register uninitialized?
> In nft_do_chain(), the register array is allocated on the kernel stack
> without zero-initialization. If priv->len is 16 and addr_len is 4, only
> the first 4 bytes are written."
I just spotted that too. I think copying priv->len unconditionally
is enough -- tuple->{src,dst} is zeroed in nf_ct_get_tuple() before the
protocol pkt_to_tuple callback fills in only the relevant leading bytes,
so the trailing bytes of tuple->{src,dst}.u3.all are well-defined zeros
and no wrapper is needed.
next prev parent reply other threads:[~2026-05-28 8:25 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
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 [this message]
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=c1383a3a-6c76-411a-8ae3-1dfe90052fb7@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.