git: d6473780b8d9 - main - traceroute: do not use a stale or NULL quoted header with -E
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Tue, 17 Nov 2026 20:39:38 UTC
The branch main has been updated by maxim:
URL: https://cgit.FreeBSD.org/src/commit/?id=d6473780b8d9d7ac4a3ed40a455fae6302df708e
commit d6473780b8d9d7ac4a3ed40a455fae6302df708e
Author: Maxim Konovalov <maxim@FreeBSD.org>
AuthorDate: 2026-11-16 00:28:47 +0000
Commit: Maxim Konovalov <maxim@FreeBSD.org>
CommitDate: 2026-11-17 20:32:52 +0000
traceroute: do not use a stale or NULL quoted header with -E
packet_ok() points the global hip at the IP header quoted by an ICMP
error message and nothing resets it afterwards. The destination
answers an ICMP probe (-I) with an echo reply, which repeats the ICMP
data of the probe but not its IP header, so for that reply the main
loop used whatever an earlier packet had left in hip.
With -E the ECN report for the destination was therefore read from
the payload of the echo reply. If no ICMP error had been received
before, because the destination is one hop away, the first hops are
skipped with -f or the routers on the path are silent, hip was still
NULL and traceroute crashed:
$ traceroute -E -I 127.0.0.1
traceroute to 127.0.0.1 (127.0.0.1), 64 hops max, 48 byte packets
Segmentation fault
With -D the stale quote was compared with the probe.
Reset hip and hiplen for every received packet and print the ECN
report only when there is a quoted header. Document that there is no
ECN report for an echo reply.
Reviewed by: jlduran, Kevin Day
Fixes: 8aafae66394f ("traceroute: Implement ECN bleaching detection")
MFC after: 2 weeks
Co-Authored-By: Claude Opus 5.5
Differential Revision: https://reviews.freebsd.org/D61606
---
usr.sbin/traceroute/traceroute.8 | 5 ++++-
usr.sbin/traceroute/traceroute.c | 5 ++++-
2 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/usr.sbin/traceroute/traceroute.8 b/usr.sbin/traceroute/traceroute.8
index f36d473f2727..a5d102968fbf 100644
--- a/usr.sbin/traceroute/traceroute.8
+++ b/usr.sbin/traceroute/traceroute.8
@@ -18,7 +18,7 @@
.\"
.\" $Id: traceroute.8,v 1.19 2000/09/21 08:44:19 leres Exp $
.\"
-.Dd May 14, 2025
+.Dd November 15, 2026
.Dt TRACEROUTE 8
.Os
.Sh NAME
@@ -91,6 +91,9 @@ or mangled
them, or if it is experiencing congestion
.Pq Dv 11 .
Otherwise, report that it passed the bits appropriately.
+The report is taken from the probe header quoted in the ICMP error message
+sent by the hop, so there is none for a destination which answers an ICMP
+probe with an echo reply.
If
.Fl t
is also specified, the corresponding ECN bits will be replaced.
diff --git a/usr.sbin/traceroute/traceroute.c b/usr.sbin/traceroute/traceroute.c
index be14c40b8d7b..74e78c16c81b 100644
--- a/usr.sbin/traceroute/traceroute.c
+++ b/usr.sbin/traceroute/traceroute.c
@@ -1058,7 +1058,7 @@ main(int argc, char **argv)
#endif
precis = 3;
Printf(" %.*f ms", precis, T);
- if (ecnflag) {
+ if (ecnflag && hip != NULL) {
u_char ecn = hip->ip_tos & IPTOS_ECN_MASK;
switch (ecn) {
case IPTOS_ECN_ECT1:
@@ -1374,6 +1374,9 @@ packet_ok(register u_char *buf, int cc, register struct sockaddr_in *from,
#endif
type = icp->icmp_type;
code = icp->icmp_code;
+ /* Forget the header quoted by the previous packet. */
+ hip = NULL;
+ hiplen = 0;
/* Path MTU Discovery (RFC1191) */
if (code != ICMP_UNREACH_NEEDFRAG)
pmtu = 0;