diff --git a/net/core/filter.c b/net/core/filter.c index a69f6817e273..acd1e89351d6 100644 --- a/net/core/filter.c +++ b/net/core/filter.c @@ -7179,6 +7179,9 @@ BPF_CALL_3(bpf_lwt_seg6_adjust_srh, struct sk_buff *, skb, u32, offset, return -EFAULT; if (unlikely(len < 0 && (void *)((char *)ptr - len) > srh_end)) return -EFAULT; + /* The length field of the SRH has 8 bits, in units of 8 bytes. */ + if (unlikely(len > (U8_MAX << 3) - srh_state->hdrlen)) + return -EFAULT; if (len > 0) { ret = skb_cow_head(skb, len);