From: Paolo Abeni <pabeni@redhat.com>
To: Xin Long <lucien.xin@gmail.com>, netdev-bot+sashiko@kernel.org
Cc: edumazet@kernel.org, davem@davemloft.net, kuba@kernel.org,
horms@kernel.org, dsahern@kernel.org, idosch@nvidia.com,
willemdebruijn.kernel@gmail.com, marcelo.leitner@gmail.com,
aconole@redhat.com, echaudro@redhat.com, i.maximets@ovn.org,
daniel@iogearbox.net, justin.iurman@gmail.com,
linus.luessing@c0d3.blue, sd@queasysnail.net, sbrivio@redhat.com,
imv4bel@gmail.com, netdev@vger.kernel.org,
linux-sctp@vger.kernel.org, dev@openvswitch.org,
stable@vger.kernel.org
Subject: Re: [PATCH net 4/5] sctp: use skb_set_transport_header_careful() in sctp_v6_err()
Date: Thu, 19 Nov 2026 13:10:04 +0100 [thread overview]
Message-ID: <a1b7a992-3bed-43ef-80bd-a76cc697f58f@redhat.com> (raw)
In-Reply-To: <CADvbK_dKiTF4gSjsRuVKUDVTJn-EVVvunmhOOEGyG7Bt6jjeVw@mail.gmail.com>
On 11/16/26 20:20, Xin Long wrote:
> On Mon, Nov 16, 2026 at 10:47 AM <netdev-bot+sashiko@kernel.org> wrote:
>> Thank you for your contribution! Sashiko AI review found 1 potential
>> issue(s) to consider.
>>
>> Critical: 0 · High: 0 · Medium: 1 · Low: 0
>>
>> If you believe none of the issues are legitimate, please reply to each
>> issue of Medium severity or higher and explain why the AI is wrong.
>> If any of them are legitimate and you plan to respin, please let patchwork
>> know by including "pw-bot: cr" as a separate line at the end of your reply
>> (one such reply per series is enough).
>>
>> - [Medium] The main part of this concern is fixed later in the series.
>>
>> --
>>
>> sctp: use skb_set_transport_header_careful() in sctp_v6_err()
>>
>> sctp_v6_err() now stores the ICMPv6 inner transport offset with
>> skb_set_transport_header_careful(). If the offset does not fit in the
>> 16-bit skb->transport_header field, the ICMPv6 error is ignored. Before,
>> the offset was silently truncated and sctp_err_lookup() read the SCTP
>> header from the wrong place.
>>
>>> diff --git a/net/sctp/ipv6.c b/net/sctp/ipv6.c
>>> index 97390569c4bdc..ad5c951efdf06 100644
>>> --- a/net/sctp/ipv6.c
>>> +++ b/net/sctp/ipv6.c
>>> @@ -170,8 +170,11 @@ static int sctp_v6_err(struct sk_buff *skb, struct inet6_skb_parm *opt,
>>> /* Fix up skb to look at the embedded net header. */
>>> saveip = skb->network_header;
>>> savesctp = skb->transport_header;
>>> + if (unlikely(!skb_set_transport_header_careful(skb, offset))) {
>>> + __ICMP6_INC_STATS(net, __in6_dev_get(skb->dev), ICMP6_MIB_INERRORS);
>>> + return -EINVAL;
>>> + }
>>> skb_reset_network_header(skb);
>>> - skb_set_transport_header(skb, offset);
>>> sk = sctp_err_lookup(net, AF_INET6, skb, sctp_hdr(skb), &asoc, &transport);
>>
>> [Severity: Medium]
>>
>> This covers native SCTP. Can the SCTP-over-UDPv6 handler in the same file
>> still hand a wrapped transport header to sctp_err_lookup()?
>>
>> sctp_udp_v6_err() is installed as encap_err_lookup. It still does an
>> unchecked 16-bit add:
>>
>> net/sctp/ipv6.c:sctp_udp_v6_err() {
>> ...
>> skb->transport_header += sizeof(struct udphdr);
>> sk = sctp_err_lookup(net, AF_INET6, skb, sctp_hdr(skb), &asoc, &t);
>> ...
>> }
>>
>> A later patch in this series ("udp: use skb_set_transport_header_careful()
>> in __udp6_lib_err_encap()") makes __udp6_lib_err_encap() store the UDP
>> header offset carefully. That check only makes sure the UDP header offset
>> itself fits and is not U16_MAX, so transport_header can still be as high
>> as 0xFFFE when sctp_udp_v6_err() runs.
>>
>> For a UDP header offset between 0xFFF7 and 0xFFFE, adding 8 gives a bad
>> value:
>>
>> - 0xFFF7 becomes 0xFFFF, the "not set" value. With CONFIG_DEBUG_NET this
>> trips the DEBUG_NET_WARN_ON_ONCE() in skb_transport_header().
>> - 0xFFF8 to 0xFFFE wrap to 0..6, so sctp_hdr(skb) points at
>> skb->head + 0..6.
>>
>> In the wrapped case, sctp_err_lookup() reads vtag from the wrong bytes.
>> sctp_v6_from_skb(), called through af->from_skb, also reads sh->source and
>> sh->dest from there for the association lookup. When vtag == 0, the INIT
>> chunk is read with skb_header_pointer() at a negative
>> skb_transport_offset().
>>
>> The commit message says "Should the value be truncated, sctp_err_lookup()
>> would read the SCTP header at the wrong place". Would it make sense to
>> also check, before the += in sctp_udp_v6_err(), that transport_header +
>> sizeof(struct udphdr) fits in 16 bits and is not U16_MAX? Another option
>> is for __udp6_lib_err_encap() to reserve room for the payload header.
>>
>> This needs the same large skb->data - skb->head precondition the series
>> describes, and there is no reproducer.
>>
>>> /* Put back, the original pointers. */
>>> skb->network_header = saveip;
>>
>> --
>> Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261113124625.4010206-1-edumazet%40kernel.org
>
> The new skb->transport_header is used by sctp_hdr(skb) in af->from_skb()
> in sctp_err_lookup(). I think it's better to avoid changing
> skb->transport_header by passing sctphdr to af->from_skb(), which also
> makes code cleaner.
>
> Hi Eric, you can either continue with the idea, or discard this patch and
> leave it to me.
The rework looks out-of-scope for a 'net' target. I think it should land
on net-next.
And I think the missing sctp over udp call-site could be a follow-up.
/P
next prev parent reply other threads:[~2026-11-19 12:10 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-13 12:46 [PATCH net 0/5] net: avoid truncated transport header offsets Eric Dumazet
2026-11-13 12:46 ` [PATCH net 1/5] ipv6: gro: limit the number of extension headers Eric Dumazet
2026-11-13 12:58 ` Hyunwoo Kim
2026-11-16 11:33 ` Ido Schimmel
2026-11-16 15:47 ` netdev-bot+sashiko
2026-11-19 0:48 ` Aaron Conole
2026-11-13 12:46 ` [PATCH net 2/5] ipv6: mcast: use skb_set_transport_header_careful() in ipv6_mc_check_exthdrs() Eric Dumazet
2026-11-16 11:45 ` Ido Schimmel
2026-11-13 12:46 ` [PATCH net 3/5] net: openvswitch: use skb_set_transport_header_careful() in parse_ipv6hdr() Eric Dumazet
2026-11-18 23:30 ` Ilya Maximets
2026-11-19 0:48 ` Aaron Conole
2026-11-13 12:46 ` [PATCH net 4/5] sctp: use skb_set_transport_header_careful() in sctp_v6_err() Eric Dumazet
2026-11-16 15:47 ` netdev-bot+sashiko
2026-11-16 19:20 ` Xin Long
2026-11-19 12:10 ` Paolo Abeni [this message]
2026-11-13 12:46 ` [PATCH net 5/5] udp: use skb_set_transport_header_careful() in __udp6_lib_err_encap() Eric Dumazet
2026-11-15 14:40 ` Stefano Brivio
2026-11-14 20:17 ` [PATCH net 0/5] net: avoid truncated transport header offsets Justin Iurman
2026-11-19 12:20 ` patchwork-bot+netdevbpf
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=a1b7a992-3bed-43ef-80bd-a76cc697f58f@redhat.com \
--to=pabeni@redhat.com \
--cc=aconole@redhat.com \
--cc=daniel@iogearbox.net \
--cc=davem@davemloft.net \
--cc=dev@openvswitch.org \
--cc=dsahern@kernel.org \
--cc=echaudro@redhat.com \
--cc=edumazet@kernel.org \
--cc=horms@kernel.org \
--cc=i.maximets@ovn.org \
--cc=idosch@nvidia.com \
--cc=imv4bel@gmail.com \
--cc=justin.iurman@gmail.com \
--cc=kuba@kernel.org \
--cc=linus.luessing@c0d3.blue \
--cc=linux-sctp@vger.kernel.org \
--cc=lucien.xin@gmail.com \
--cc=marcelo.leitner@gmail.com \
--cc=netdev-bot+sashiko@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=sbrivio@redhat.com \
--cc=sd@queasysnail.net \
--cc=stable@vger.kernel.org \
--cc=willemdebruijn.kernel@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