Skip to content

Commit 3de33e1

Browse files
sbrivio-rhdavem330
authored andcommitted
ipv6: accept 64k - 1 packet length in ip6_find_1stfragopt()
A packet length of exactly IPV6_MAXPLEN is allowed, we should refuse parsing options only if the size is 64KiB or more. While at it, remove one extra variable and one assignment which were also introduced by the commit that introduced the size check. Checking the sum 'offset + len' and only later adding 'len' to 'offset' doesn't provide any advantage over directly summing to 'offset' and checking it. Fixes: 6399f1f ("ipv6: avoid overflow of offset in ip6_find_1stfragopt") Signed-off-by: Stefano Brivio <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 6470812 commit 3de33e1

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

net/ipv6/output_core.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,6 @@ int ip6_find_1stfragopt(struct sk_buff *skb, u8 **nexthdr)
8686

8787
while (offset <= packet_len) {
8888
struct ipv6_opt_hdr *exthdr;
89-
unsigned int len;
9089

9190
switch (**nexthdr) {
9291

@@ -112,10 +111,9 @@ int ip6_find_1stfragopt(struct sk_buff *skb, u8 **nexthdr)
112111

113112
exthdr = (struct ipv6_opt_hdr *)(skb_network_header(skb) +
114113
offset);
115-
len = ipv6_optlen(exthdr);
116-
if (len + offset >= IPV6_MAXPLEN)
114+
offset += ipv6_optlen(exthdr);
115+
if (offset > IPV6_MAXPLEN)
117116
return -EINVAL;
118-
offset += len;
119117
*nexthdr = &exthdr->nexthdr;
120118
}
121119

0 commit comments

Comments
 (0)