mirror of
https://github.com/torvalds/linux.git
synced 2026-11-07 06:17:02 +01:00
netfilter: nf_conntrack: avoid truncating IPv6 nexthdr offset
find_prev_fhdr() returns the offset of the Next Header field before an
IPv6 Fragment header through an int pointer, but stores the offset in a
u8 local. An extension header chain can put this field beyond byte 255,
causing the offset to wrap before it is saved in the fragment queue.
Reassembly later uses the wrapped value to update the preceding Next
Header field. This overwrites another byte in the IPv6 header chain and
can make conntrack parse a different transport tuple from the one used
by IPv6 local delivery. A two-fragment packet can, for example, be
recorded as UDP destination port 53 while its payload is delivered to
UDP port 9999.
Use int for the working offset, matching the output argument and the
other offset variables in this path.
Fixes: 9fb9cbb108 ("[NETFILTER]: Add nf_conntrack subsystem.")
Assisted-by: Codex:gpt-5
Signed-off-by: Jérémy Jean <Jeremy.Jean@oss.cyber.gouv.fr>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
This commit is contained in:
parent
ab699d296e
commit
48d522b65f
|
|
@ -398,7 +398,7 @@ find_prev_fhdr(struct sk_buff *skb, u8 *prevhdrp, int *prevhoff, int *fhoff)
|
|||
{
|
||||
u8 nexthdr = ipv6_hdr(skb)->nexthdr;
|
||||
const int netoff = skb_network_offset(skb);
|
||||
u8 prev_nhoff = netoff + offsetof(struct ipv6hdr, nexthdr);
|
||||
int prev_nhoff = netoff + offsetof(struct ipv6hdr, nexthdr);
|
||||
int start = netoff + sizeof(struct ipv6hdr);
|
||||
int len = skb->len - start;
|
||||
u8 prevhdr = NEXTHDR_IPV6;
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user