From: Hangbin Liu <hangbin.liu@linux.dev>
To: Juan Agustin Niccolini <juanagusnicco@gmail.com>
Cc: Gabriel Goller <g.goller@proxmox.com>,
Andrea Mayer <andrea.mayer@uniroma2.it>,
"David S . Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@kernel.org>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Willem de Bruijn <willemb@google.com>,
netdev@vger.kernel.org, Simon Horman <horms@kernel.org>,
David Ahern <dsahern@kernel.org>,
Julien Massonneau <julien.massonneau@6wind.com>
Subject: Re: [PATCH net] seg6: check segments_left in the pulled SRH to fix an out-of-bounds read
Date: Wed, 2 Dec 2026 16:03:23 +0800 [thread overview]
Message-ID: <aw_Qy2_PQiznfu1v@fedora> (raw)
In-Reply-To: <CACQ4AchSLwD_k+uHp27kT9bsqkUchkoJhfctDHBsQM9pYQT1tQ@mail.gmail.com>
Hi Juan and Gabriel,
On Wed, Dec 02, 2026 at 01:30:54AM -0500, Juan Agustin Niccolini wrote:
> On Tue, Dec 01, 2026 at 11:43:23AM +0100, Gabriel Goller wrote:
> > On 01.12.2026 13:27, Hangbin Liu wrote:
> > > If the user can write the segments_left field, can it write to other fields?
> >
> > Yes, but from a quick glance, no other field can make advance_nextseg() read
> > past the segment list.
>
> Right. The sender can write to any byte that is still in the fragment,
> but the other fields are only trusted after the pull: seg6_get_srh()
> pulls the whole SRH into the linear area and then calls
> seg6_validate_srh() on that copy. That checks type, hdrlen,
> first_segment and the TLVs, and that segments_left <= first_segment + 1.
>
> The only value that passes this validation and that advance_nextseg()
> cannot handle is segments_left == 0, and that one was checked only by
> ipv6_find_hdr(), before the pull.
>
> > > And we put the check in get_and_validate_srh, what if it changed later
> > > and before or after advance_nextseg()?
> >
> > I don't think it can be changed, because at that point we use the linearized
> > copy.
>
> Yes. After seg6_get_srh() returns, srh points into the linear area of
> the skb, which is kernel memory that the sender has no mapping of. The
> new check and advance_nextseg() both read that copy.
>
> > I'd add a code comment here, otherwise this will be removed again :)
>
> Will do in v2, so that the check does not look redundant with
> IP6_FH_F_SKIP_RH. Thanks for the review.
Thanks for the explanations. I will review the v2 patch.
Hangbin
prev parent reply other threads:[~2026-12-02 8:03 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-30 3:16 [PATCH net] seg6: check segments_left in the pulled SRH to fix an out-of-bounds read Juan Agustin Niccolini
2026-12-01 5:27 ` Hangbin Liu
2026-12-01 10:43 ` Gabriel Goller
2026-12-02 6:30 ` Juan Agustin Niccolini
2026-12-02 8:03 ` Hangbin Liu [this message]
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=aw_Qy2_PQiznfu1v@fedora \
--to=hangbin.liu@linux.dev \
--cc=andrea.mayer@uniroma2.it \
--cc=davem@davemloft.net \
--cc=dsahern@kernel.org \
--cc=edumazet@kernel.org \
--cc=g.goller@proxmox.com \
--cc=horms@kernel.org \
--cc=juanagusnicco@gmail.com \
--cc=julien.massonneau@6wind.com \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=willemb@google.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