From: Axel Mierczuk <axel.mierczuk@1password.com>
To: Julian Anastasov <ja@ssi.bg>, Simon Horman <horms@verge.net.au>
Cc: Pablo Neira Ayuso <pablo@netfilter.org>,
Florian Westphal <fw@strlen.de>, Phil Sutter <phil@nwl.cc>,
David Ahern <dsahern@kernel.org>,
Ido Schimmel <idosch@nvidia.com>,
Eric Dumazet <edumazet@google.com>,
netfilter-devel@vger.kernel.org, lvs-devel@vger.kernel.org,
coreteam@netfilter.org, netdev@vger.kernel.org,
Willy Tarreau <w@1wt.eu>,
Keith Hoodlet <keith.hoodlet@1password.com>,
Axel Mierczuk <axel.mierczuk@1password.com>
Subject: [PATCH nf 2/2] ipv6: update *offset for non-first fragments in ipv6_find_hdr()
Date: Fri, 25 Sep 2026 10:11:55 -0400 [thread overview]
Message-ID: <20260925141155.17603-3-axel.mierczuk@1password.com> (raw)
In-Reply-To: <20260925141155.17603-1-axel.mierczuk@1password.com>
The non-first fragment early return is the only successful exit of
ipv6_find_hdr() that leaves *offset untouched. IPVS used the initial
offset as if it had been updated.
For non-first fragments with target < 0, set *offset immediately
after the Fragment header, at the start of the fragment payload.
Callers must still account for the nonzero fragment offset. A
NEXTHDR_FRAGMENT search continues to return the Fragment header's
offset. Other target < 0 callers check the returned fragment offset
or ignore *offset here.
Suggested-by: Julian Anastasov <ja@ssi.bg>
Signed-off-by: Axel Mierczuk <axel.mierczuk@1password.com>
---
net/ipv6/exthdrs_core.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/net/ipv6/exthdrs_core.c b/net/ipv6/exthdrs_core.c
index 4a9748338cf4..e27f5b8cc154 100644
--- a/net/ipv6/exthdrs_core.c
+++ b/net/ipv6/exthdrs_core.c
@@ -179,7 +179,10 @@ EXPORT_SYMBOL_GPL(ipv6_find_tlv);
*
* Note that non-1st fragment is special case that "the protocol number
* of last header" is "next header" field in Fragment header. In this case,
- * *offset is meaningless and fragment offset is stored in *fragoff if fragoff
+ * for target < 0, *offset points immediately after the Fragment header,
+ * at the start of the fragment payload. Callers must still account for
+ * the nonzero fragment offset before interpreting the payload. The
+ * fragment offset is stored in *fragoff if fragoff
* isn't NULL.
*
* if flags is not NULL and it's a fragment, then the frag flag
@@ -261,6 +264,7 @@ int ipv6_find_hdr(const struct sk_buff *skb, unsigned int *offset,
hp->nexthdr == NEXTHDR_NONE)) {
if (fragoff)
*fragoff = _frag_off;
+ *offset = start + sizeof(struct frag_hdr);
return hp->nexthdr;
}
if (!found)
--
2.43.0
next prev parent reply other threads:[~2026-09-25 14:12 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-25 14:11 [PATCH nf 0/2] ipvs: fix OOB write when NATing ICMPv6 errors quoting non-first fragments Axel Mierczuk
2026-09-25 14:11 ` [PATCH nf 1/2] ipvs: avoid out-of-bounds write in ip_vs_nat_icmp_v6 Axel Mierczuk
2026-09-29 15:57 ` netdev-bot+sashiko
2026-09-25 14:11 ` Axel Mierczuk [this message]
2026-09-29 15:57 ` [PATCH nf 2/2] ipv6: update *offset for non-first fragments in ipv6_find_hdr() netdev-bot+sashiko
2026-09-25 17:50 ` [PATCH nf 0/2] ipvs: fix OOB write when NATing ICMPv6 errors quoting non-first fragments Julian Anastasov
2026-09-28 11:15 ` Ido Schimmel
2026-09-30 17:34 ` Julian Anastasov
2026-10-01 16:10 ` Ido Schimmel
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=20260925141155.17603-3-axel.mierczuk@1password.com \
--to=axel.mierczuk@1password.com \
--cc=coreteam@netfilter.org \
--cc=dsahern@kernel.org \
--cc=edumazet@google.com \
--cc=fw@strlen.de \
--cc=horms@verge.net.au \
--cc=idosch@nvidia.com \
--cc=ja@ssi.bg \
--cc=keith.hoodlet@1password.com \
--cc=lvs-devel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=netfilter-devel@vger.kernel.org \
--cc=pablo@netfilter.org \
--cc=phil@nwl.cc \
--cc=w@1wt.eu \
/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