From 0a66e5633c9f2c9e45b5aeaa3444a314c2d12ea9 Mon Sep 17 00:00:00 2001 From: Jan Macku Date: Wed, 18 Dec 2024 13:29:15 +0100 Subject: [PATCH] avoid consuming 100% CPU when running traceroute in loop Resolves: RHEL-71510 --- ...eroute-2.1.1-return-back-more-robust.patch | 44 +++++++++++++++++++ traceroute.spec | 6 ++- 2 files changed, 49 insertions(+), 1 deletion(-) create mode 100644 002-traceroute-2.1.1-return-back-more-robust.patch diff --git a/002-traceroute-2.1.1-return-back-more-robust.patch b/002-traceroute-2.1.1-return-back-more-robust.patch new file mode 100644 index 0000000..bebcc8a --- /dev/null +++ b/002-traceroute-2.1.1-return-back-more-robust.patch @@ -0,0 +1,44 @@ +diff --color -u -r traceroute-2.1.0/traceroute/poll.c traceroute-2.1.1/traceroute/poll.c +--- traceroute-2.1.0/traceroute/poll.c 2016-03-07 17:20:56.000000000 +0100 ++++ traceroute-2.1.1/traceroute/poll.c 2022-12-27 01:00:18.000000000 +0100 +@@ -64,28 +64,23 @@ + + + void do_poll (double timeout, void (*callback) (int fd, int revents)) { +- int nfds; +- int msecs = ceil (timeout * 1000); ++ int nfds, n, i; + +- while ((nfds = cleanup_polls ()) > 0) { +- int i, n; ++ nfds = cleanup_polls (); + +- n = poll (pfd, nfds, msecs); ++ if (!nfds) return; + +- if (n <= 0) { +- if (n == 0 || errno == EINTR) +- return; +- error ("poll"); +- } ++ n = poll (pfd, nfds, ceil(timeout * 1000)); ++ if (n < 0) { ++ if (errno == EINTR) return; ++ error ("poll"); ++ } + +- for (i = 0; n && i < num_polls; i++) { +- if (pfd[i].revents) { +- callback (pfd[i].fd, pfd[i].revents); +- n--; +- } ++ for (i = 0; n && i < num_polls; i++) { ++ if (pfd[i].revents) { ++ callback (pfd[i].fd, pfd[i].revents); ++ n--; + } +- +- msecs = 0; /* no more wait, just eat all the pending */ + } + + return; diff --git a/traceroute.spec b/traceroute.spec index a190e7c..4a7c723 100644 --- a/traceroute.spec +++ b/traceroute.spec @@ -2,13 +2,14 @@ Summary: Traces the route taken by packets over an IPv4/IPv6 network Name: traceroute Epoch: 3 Version: 2.1.0 -Release: 8%{?dist} +Release: 9%{?dist} Group: Applications/Internet License: GPLv2+ URL: http://traceroute.sourceforge.net Source0: http://downloads.sourceforge.net/project/traceroute/traceroute/traceroute-%{version}/traceroute-%{version}.tar.gz Patch001: 001-traceroute-CVE-2023-46316.patch +Patch002: 002-traceroute-2.1.1-return-back-more-robust.patch Provides: tcptraceroute = 1.5-1 Obsoletes: tcptraceroute < 1.5-1 @@ -61,6 +62,9 @@ popd %changelog +* Wed Dec 18 2024 Jan Macku - 3:2.1.0-9 +- avoid consuming 100% CPU when running traceroute in loop (RHEL-71510) + * Mon Nov 27 2023 Jan Macku - 3:2.1.0-8 - add gating.yaml