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.
Agustin