The non-first fragment early return is the only successful exit of ipv6_find_hdr() that leaves *offset untouched. IPVS used the initial offset as if it had been updated. For non-first fragments with target < 0, set *offset immediately after the Fragment header, at the start of the fragment payload. Callers must still account for the nonzero fragment offset. A NEXTHDR_FRAGMENT search continues to return the Fragment header's offset. Other target < 0 callers check the returned fragment offset or ignore *offset here. Suggested-by: Julian Anastasov Signed-off-by: Axel Mierczuk --- net/ipv6/exthdrs_core.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/net/ipv6/exthdrs_core.c b/net/ipv6/exthdrs_core.c index 4a9748338cf4..e27f5b8cc154 100644 --- a/net/ipv6/exthdrs_core.c +++ b/net/ipv6/exthdrs_core.c @@ -179,7 +179,10 @@ EXPORT_SYMBOL_GPL(ipv6_find_tlv); * * Note that non-1st fragment is special case that "the protocol number * of last header" is "next header" field in Fragment header. In this case, - * *offset is meaningless and fragment offset is stored in *fragoff if fragoff + * for target < 0, *offset points immediately after the Fragment header, + * at the start of the fragment payload. Callers must still account for + * the nonzero fragment offset before interpreting the payload. The + * fragment offset is stored in *fragoff if fragoff * isn't NULL. * * if flags is not NULL and it's a fragment, then the frag flag @@ -261,6 +264,7 @@ int ipv6_find_hdr(const struct sk_buff *skb, unsigned int *offset, hp->nexthdr == NEXTHDR_NONE)) { if (fragoff) *fragoff = _frag_off; + *offset = start + sizeof(struct frag_hdr); return hp->nexthdr; } if (!found) -- 2.43.0