Skip to content

Commit

Permalink
Fixed a potential kernel panic when calculating ICMPv6 packet checksum.
Browse files Browse the repository at this point in the history
  • Loading branch information
SongXiaoXi committed Aug 16, 2023
1 parent c0dee6d commit 24e9689
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions AppleIGC/AppleIGC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1177,15 +1177,20 @@ static void igc_tx_csum(struct igc_ring *tx_ring, struct igc_tx_buffer *first,

/* Set the ether header length */
packet = (u8*)mbuf_data(skb) + ehdrlen;
size_t len = mbuf_len(skb);

if(checksumDemanded & DEMAND_IPv6){ // IPv6
struct ip6_hdr* ip6 = (struct ip6_hdr*)packet;
u_int8_t nexthdr;
do {
nexthdr = ip6->ip6_ctlun.ip6_un1.ip6_un1_nxt;
if ((u8*)&ip6->ip6_ctlun.ip6_un1.ip6_un1_nxt - packet < len) {
nexthdr = ip6->ip6_ctlun.ip6_un1.ip6_un1_nxt;
} else {
break;
}
ip6++;
} while(nexthdr != IPPROTO_TCP && nexthdr != IPPROTO_UDP);
ip_hlen = (u8*)ip6 - packet;
} while(nexthdr != IPPROTO_TCP && nexthdr != IPPROTO_UDP && nexthdr != IPPROTO_ICMPV6);
ip_hlen = (int)((u8*)ip6 - packet);
} else {
struct ip *ip = (struct ip *)packet;
ip_hlen = ip->ip_hl << 2;
Expand Down

0 comments on commit 24e9689

Please sign in to comment.