summaryrefslogtreecommitdiff
path: root/scripts/basic
diff options
context:
space:
mode:
authorChris Mason <mason@kernel.org>2026-11-01 19:05:26 +0000
committerAlexei Starovoitov <ast@kernel.org>2026-11-02 00:10:40 +0000
commitac159f39b252971141c49b68a27de0b637debfad (patch)
tree5e0865edc6105baefc8fb9f63cf962ed38f35b51 /scripts/basic
parentc1ca06e48e8848743fd876a1dc6b0f57bc76d23e (diff)
downloadlinux-ac159f39b252971141c49b68a27de0b637debfad.tar.gz
linux-ac159f39b252971141c49b68a27de0b637debfad.zip
bpf: Limit the SRH length in bpf_lwt_seg6_adjust_srh()
bpf_lwt_seg6_adjust_srh() lets an End.BPF prog change the size of the TLVs in the SRH. The helper keeps the SRH length in srh_state->hdrlen, in bytes and without the first 8 bytes. Later seg6_bpf_has_valid_srh() writes it to srh->hdrlen, an 8-bit field in units of 8 bytes. But srh_state->hdrlen has no upper limit, and the cast to u8 can truncate it. After that, seg6_validate_srh() gets the SRH length from srh->hdrlen, and thus it can accept the SRH. Then srh->hdrlen is too small, and a parser reads TLVs as the subsequent header. Return -EFAULT when the new srh_state->hdrlen is larger than 2040, the largest length that srh->hdrlen can hold. To replace a TLV in the largest SRH, a prog can no longer add bytes first. It must remove bytes first. Fixes: fe94cc290f53 ("bpf: Add IPv6 Segment Routing helpers") Signed-off-by: Chris Mason <mason@kernel.org> Signed-off-by: Alexei Starovoitov <ast@kernel.org> Link: https://patch.msgid.link/20261101190535.1454146-19-alexei.starovoitov@gmail.com
Diffstat (limited to 'scripts/basic')
0 files changed, 0 insertions, 0 deletions