From: Florian Westphal <fw@strlen.de>
To: Siho Lee <25esihoya@gmail.com>
Cc: Pablo Neira Ayuso <pablo@netfilter.org>,
netfilter-devel@vger.kernel.org, netdev@vger.kernel.org,
stable@vger.kernel.org
Subject: Re: [PATCH v2 net] netfilter: nft_payload: validate offset for all csum_type paths
Date: Thu, 28 May 2026 18:08:20 +0200 [thread overview]
Message-ID: <ahhodI4Ou64n9HEq@strlen.de> (raw)
In-Reply-To: <CAOYEF6nkrD4o_Kw_gxbv7Vefxpp=E6N4X_s-3KEcS1f3Hb1uAg@mail.gmail.com>
Siho Lee <25esihoya@gmail.com> wrote:
> For NFT_PAYLOAD_LL_HEADER, offset is computed as:
> offset = skb_mac_header(skb) - skb->data - vlan_hlen
> which evaluates to -14 (or -18 with VLAN) after eth_type_trans()
> pulls the Ethernet header. This is a valid negative offset that
> refers to the Ethernet header area (used by bridge/vlan rules).
>
> However, without any bounds check in the csum=NONE path:
> - skb_ensure_writable(skb, max(offset + priv->len, 0)):
> max() converts negative values to 0, making it a no-op.
Are you sure?
> - skb_store_bits(skb, offset, src, priv->len):
> A negative offset that exceeds skb headroom writes out of bounds.
Sure, but how can that happen? This should be explained here,
because I am NOT seeing a bug in the first place.
> Add proper validation after the csum condition block:
> - Negative offsets: ensure they fall within skb_headroom(skb)
> (bridge/vlan rules legitimately access the Ethernet header)
> - Positive offsets: ensure offset + len does not exceed skb->len
Large offset/len should make skb_copy_bits return an error.
> Also remove the max() wrapper from skb_ensure_writable() since
> the new validation guarantees the offset is within range.
No, this patch still breaks test cases we have. Please figure out
if there is a bug in this code, and if there is, explain it in a way
that I can understand (e.g. provide broken example that triggers OOB).
Then, git clone https://git.netfilter.org/nftables and make sure the
tests pass.
> + if (skb_ensure_writable(skb, offset + priv->len) ||
ensure_writable has unsigned arg, so this -14 + 6 will asks for
4GB and this aborts here.
next prev parent reply other threads:[~2026-05-28 16:08 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-28 15:28 [PATCH v2 net] netfilter: nft_payload: validate offset for all csum_type paths Siho Lee
2026-05-28 16:08 ` Florian Westphal [this message]
-- strict thread matches above, loose matches on Subject: below --
2026-05-28 13:39 [PATCH net] netfilter: nft_payload: move offset bounds check outside csum condition Siho Lee
2026-05-28 14:12 ` Florian Westphal
2026-05-28 15:28 ` [PATCH v2 net] netfilter: nft_payload: validate offset for all csum_type paths Siho Lee
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=ahhodI4Ou64n9HEq@strlen.de \
--to=fw@strlen.de \
--cc=25esihoya@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=netfilter-devel@vger.kernel.org \
--cc=pablo@netfilter.org \
--cc=stable@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox