Re: [PATCH net] net: icmp: avoid invalid transport header access in icmp_send tracepoint
flat view
From: Steven Rostedt <rostedt@goodmis.org>
Date: 2026-08-25 12:50:14
On Tue, 25 Aug 2026 08:45:51 +0000 Eric Dumazet [off-list ref] wrote:
quoted hunk ↗ jump to hunk
diff --git a/include/trace/events/icmp.h b/include/trace/events/icmp.h index 09ae115099dfe25616b6c74d5b92be1af4acff55..6937b778ae54dbf4442b127957a017da3551aaff 100644 --- a/include/trace/events/icmp.h +++ b/include/trace/events/icmp.h@@ -27,17 +27,20 @@ TRACE_EVENT(icmp_send, TP_fast_assign( struct iphdr *iph = ip_hdr(skb); - struct udphdr *uh = udp_hdr(skb); - int proto_4 = iph->protocol; + struct udphdr _uh, *uh = NULL; __be32 *p32; __entry->skbaddr = skb; __entry->type = type; __entry->code = code; - if (proto_4 != IPPROTO_UDP || (u8 *)uh < skb->head || - (u8 *)uh + sizeof(struct udphdr) - > skb_tail_pointer(skb)) { + if (iph->protocol == IPPROTO_UDP) + uh = skb_header_pointer(skb, + skb_network_offset(skb) + + (iph->ihl << 2), + sizeof(_uh), &_uh);
I don't know if networking has different rules about this, but we usually suggest using brackets around the if block for any multi line code. Not just multi commands. If the line needs to be broken due to length, we suggest brackets. -- Steve
quoted hunk ↗ jump to hunk
+ + if (!uh) { __entry->sport = 0; __entry->dport = 0; __entry->ulen = 0;