Re: [PATCH net] net: icmp: avoid invalid transport header access in icmp_send tracepoint
flat view
From: Eric Dumazet <hidden>
Date: 2026-08-25 14:11:50
On Tue, Aug 25, 2026 at 2:50 PM Steven Rostedt [off-list ref] wrote:
On Tue, 25 Aug 2026 08:45:51 +0000 Eric Dumazet [off-list ref] wrote:quoted
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.
We do not have such rules in networking, and checkpatch is ok
(although I never use it)
scripts/checkpatch.pl -g HEAD
total: 0 errors, 0 warnings, 25 lines checked
Commit 27ce2cf2018e ("net: icmp: avoid invalid transport header access
in icmp_send tracepoint") has no obvious style problems and is ready
for submission.
Thanks.