Skip to content

Commit b727a03

Browse files
azurelinux-securitykgodara912Kanishk Bansal
authored
[AutoPR- Security] Patch iputils for CVE-2025-48964, CVE-2025-47268 [MEDIUM] (#14444)
Signed-off-by: Kanishk Bansal <[email protected]> Co-authored-by: kgodara912 <[email protected]> Co-authored-by: Kanishk Bansal <[email protected]>
1 parent 0eca4fc commit b727a03

File tree

4 files changed

+245
-28
lines changed

4 files changed

+245
-28
lines changed

SPECS/iputils/CVE-2025-47268.patch

Lines changed: 137 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
1+
From 33ebd21ac99d3e6ab2d51b6581cbec7e9fba17b6 Mon Sep 17 00:00:00 2001
2+
From: Petr Vorel <[email protected]>
3+
Date: Mon, 5 May 2025 23:55:57 +0200
4+
Subject: [PATCH] ping: Fix signed 64-bit integer overflow in RTT calculation
5+
6+
Crafted ICMP Echo Reply packet can cause signed integer overflow in
7+
8+
1) triptime calculation:
9+
triptime = tv->tv_sec * 1000000 + tv->tv_usec;
10+
11+
2) tsum2 increment which uses triptime
12+
rts->tsum2 += (double)((long long)triptime * (long long)triptime);
13+
14+
3) final tmvar:
15+
tmvar = (rts->tsum2 / total) - (tmavg * tmavg)
16+
17+
$ export CFLAGS="-O1 -g -fsanitize=address,undefined -fno-omit-frame-pointer"
18+
$ export LDFLAGS="-fsanitize=address,undefined -fno-omit-frame-pointer"
19+
$ meson setup .. -Db_sanitize=address,undefined
20+
$ ninja
21+
$ ./ping/ping -c2 127.0.0.1
22+
23+
PING 127.0.0.1 (127.0.0.1) 56(84) bytes of data.
24+
64 bytes from 127.0.0.1: icmp_seq=1 ttl=64 time=0.061 ms
25+
../ping/ping_common.c:757:25: runtime error: signed integer overflow: -2513732689199106 * 1000000 cannot be represented in type 'long int'
26+
../ping/ping_common.c:757:12: runtime error: signed integer overflow: -4975495174606980224 + -6510615555425289427 cannot be represented in type 'long int'
27+
../ping/ping_common.c:769:47: runtime error: signed integer overflow: 6960633343677281965 * 6960633343677281965 cannot be represented in type 'long int'
28+
24 bytes from 127.0.0.1: icmp_seq=1 ttl=64 (truncated)
29+
./ping/ping: Warning: time of day goes back (-7256972569576721377us), taking countermeasures
30+
./ping/ping: Warning: time of day goes back (-7256972569576721232us), taking countermeasures
31+
24 bytes from 127.0.0.1: icmp_seq=1 ttl=64 (truncated)
32+
../ping/ping_common.c:265:16: runtime error: signed integer overflow: 6960633343677281965 * 2 cannot be represented in type 'long int'
33+
64 bytes from 127.0.0.1: icmp_seq=2 ttl=64 time=0.565 ms
34+
35+
--- 127.0.0.1 ping statistics ---
36+
2 packets transmitted, 2 received, +2 duplicates, 0% packet loss, time 1002ms
37+
../ping/ping_common.c:940:42: runtime error: signed integer overflow: 1740158335919320832 * 1740158335919320832 cannot be represented in type 'long int'
38+
rtt min/avg/max/mdev = 0.000/1740158335919320.832/6960633343677281.965/-1623514645242292.-224 ms
39+
40+
To fix the overflow check allowed ranges of struct timeval members:
41+
* tv_sec <0, LONG_MAX/1000000>
42+
* tv_usec <0, 999999>
43+
44+
Fix includes 2 new error messages (needs translation).
45+
Also existing message "time of day goes back ..." needed to be modified
46+
as it now prints tv->tv_sec which is a second (needs translation update).
47+
48+
After fix:
49+
50+
$ ./ping/ping -c2 127.0.0.1
51+
64 bytes from 127.0.0.1: icmp_seq=1 ttl=64 time=0.057 ms
52+
./ping/ping: Warning: invalid tv_usec -6510615555424928611 us
53+
./ping/ping: Warning: time of day goes back (-3985394643238914 s), taking countermeasures
54+
./ping/ping: Warning: invalid tv_usec -6510615555424928461 us
55+
./ping/ping: Warning: time of day goes back (-3985394643238914 s), taking countermeasures
56+
24 bytes from 127.0.0.1: icmp_seq=1 ttl=64 (truncated)
57+
./ping/ping: Warning: invalid tv_usec -6510615555425884541 us
58+
./ping/ping: Warning: time of day goes back (-4243165695442945 s), taking countermeasures
59+
24 bytes from 127.0.0.1: icmp_seq=1 ttl=64 (truncated)
60+
64 bytes from 127.0.0.1: icmp_seq=2 ttl=64 time=0.111 ms
61+
62+
--- 127.0.0.1 ping statistics ---
63+
2 packets transmitted, 2 received, +2 duplicates, 0% packet loss, time 101ms
64+
rtt min/avg/max/mdev = 0.000/0.042/0.111/0.046 ms
65+
66+
Fixes: https://github.com/iputils/iputils/issues/584
67+
Fixes: CVE-2025-472
68+
Link: https://github.com/Zephkek/ping-rtt-overflow/
69+
Co-developed-by: Cyril Hrubis <[email protected]>
70+
Reported-by: Mohamed Maatallah <[email protected]>
71+
Reviewed-by: Mohamed Maatallah <[email protected]>
72+
Reviewed-by: Cyril Hrubis <[email protected]>
73+
Signed-off-by: Petr Vorel <[email protected]>
74+
Signed-off-by: Azure Linux Security Servicing Account <[email protected]>
75+
Upstream-reference: https://github.com/iputils/iputils/pull/585/commits/b41e4a10ab1f749a9bd149c608213c9704c3147f.patch
76+
---
77+
iputils_common.h | 3 +++
78+
ping/ping_common.c | 22 +++++++++++++++++++---
79+
2 files changed, 22 insertions(+), 3 deletions(-)
80+
81+
diff --git a/iputils_common.h b/iputils_common.h
82+
index 49e790d..829a749 100644
83+
--- a/iputils_common.h
84+
+++ b/iputils_common.h
85+
@@ -10,6 +10,9 @@
86+
!!__builtin_types_compatible_p(__typeof__(arr), \
87+
__typeof__(&arr[0]))])) * 0)
88+
89+
+/* 1000001 = 1000000 tv_sec + 1 tv_usec */
90+
+#define TV_SEC_MAX_VAL (LONG_MAX/1000001)
91+
+
92+
#ifdef __GNUC__
93+
# define iputils_attribute_format(t, n, m) __attribute__((__format__ (t, n, m)))
94+
#else
95+
diff --git a/ping/ping_common.c b/ping/ping_common.c
96+
index 73da26c..f44b2c0 100644
97+
--- a/ping/ping_common.c
98+
+++ b/ping/ping_common.c
99+
@@ -744,16 +744,32 @@ int gather_statistics(struct ping_rts *rts, uint8_t *icmph, int icmplen,
100+
101+
restamp:
102+
tvsub(tv, &tmp_tv);
103+
- triptime = tv->tv_sec * 1000000 + tv->tv_usec;
104+
- if (triptime < 0) {
105+
- error(0, 0, _("Warning: time of day goes back (%ldus), taking countermeasures"), triptime);
106+
+
107+
+ if (tv->tv_usec >= 1000000) {
108+
+ error(0, 0, _("Warning: invalid tv_usec %ld us"), tv->tv_usec);
109+
+ tv->tv_usec = 999999;
110+
+ }
111+
+
112+
+ if (tv->tv_usec < 0) {
113+
+ error(0, 0, _("Warning: invalid tv_usec %ld us"), tv->tv_usec);
114+
+ tv->tv_usec = 0;
115+
+ }
116+
+
117+
+ if (tv->tv_sec > TV_SEC_MAX_VAL) {
118+
+ error(0, 0, _("Warning: invalid tv_sec %ld s"), tv->tv_sec);
119+
+ triptime = 0;
120+
+ } else if (tv->tv_sec < 0) {
121+
+ error(0, 0, _("Warning: time of day goes back (%ld s), taking countermeasures"), tv->tv_sec);
122+
triptime = 0;
123+
if (!rts->opt_latency) {
124+
gettimeofday(tv, NULL);
125+
rts->opt_latency = 1;
126+
goto restamp;
127+
}
128+
+ } else {
129+
+ triptime = tv->tv_sec * 1000000 + tv->tv_usec;
130+
}
131+
+
132+
if (!csfailed) {
133+
rts->tsum += triptime;
134+
rts->tsum2 += (double)((long long)triptime * (long long)triptime);
135+
--
136+
2.45.4
137+

SPECS/iputils/CVE-2025-48964.patch

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
From 339a67ae9f589b2e42c9b932066208b34f272d97 Mon Sep 17 00:00:00 2001
2+
From: Cyril Hrubis <[email protected]>
3+
Date: Fri, 16 May 2025 17:57:10 +0200
4+
Subject: [PATCH] ping: Fix moving average rtt calculation
5+
6+
The rts->rtt counts an exponential weight moving average in a fixed
7+
point, that means that even if we limit the triptime to fit into a 32bit
8+
number the average will overflow because because fixed point needs eight
9+
more bits.
10+
11+
We also have to limit the triptime to 32bit number because otherwise the
12+
moving average may stil overflow if we manage to produce a large enough
13+
triptime.
14+
15+
Fixes: CVE-2025-48964
16+
Fixes: https://bugzilla.suse.com/show_bug.cgi?id=1243772
17+
Closes: https://github.com/iputils/iputils-ghsa-25fr-jw29-74f9/pull/1
18+
Reported-by: Mohamed Maatallah <[email protected]>
19+
Reviewed-by: Petr Vorel <[email protected]>
20+
Tested-by: Petr Vorel <[email protected]>
21+
Reviewed-by: Michal Kubecek <[email protected]>
22+
Reviewed-by: Mohamed Maatallah <[email protected]>
23+
Signed-off-by: Cyril Hrubis <[email protected]>
24+
Signed-off-by: Azure Linux Security Servicing Account <[email protected]>
25+
Upstream-reference: https://github.com/iputils/iputils/commit/afa36390394a6e0cceba03b52b59b6d41710608c.patch
26+
---
27+
iputils_common.h | 2 +-
28+
ping/ping.h | 2 +-
29+
ping/ping_common.c | 8 ++++----
30+
3 files changed, 6 insertions(+), 6 deletions(-)
31+
32+
diff --git a/iputils_common.h b/iputils_common.h
33+
index 829a749..1296905 100644
34+
--- a/iputils_common.h
35+
+++ b/iputils_common.h
36+
@@ -11,7 +11,7 @@
37+
__typeof__(&arr[0]))])) * 0)
38+
39+
/* 1000001 = 1000000 tv_sec + 1 tv_usec */
40+
-#define TV_SEC_MAX_VAL (LONG_MAX/1000001)
41+
+#define TV_SEC_MAX_VAL (INT32_MAX/1000001)
42+
43+
#ifdef __GNUC__
44+
# define iputils_attribute_format(t, n, m) __attribute__((__format__ (t, n, m)))
45+
diff --git a/ping/ping.h b/ping/ping.h
46+
index a40c8f8..f5a5bb8 100644
47+
--- a/ping/ping.h
48+
+++ b/ping/ping.h
49+
@@ -191,7 +191,7 @@ struct ping_rts {
50+
long tmax; /* maximum round trip time */
51+
double tsum; /* sum of all times, for doing average */
52+
double tsum2;
53+
- int rtt;
54+
+ uint64_t rtt; /* Exponential weight moving average calculated in fixed point */
55+
int rtt_addend;
56+
uint16_t acked;
57+
int pipesize;
58+
diff --git a/ping/ping_common.c b/ping/ping_common.c
59+
index f44b2c0..013a007 100644
60+
--- a/ping/ping_common.c
61+
+++ b/ping/ping_common.c
62+
@@ -282,7 +282,7 @@ int __schedule_exit(int next)
63+
64+
static inline void update_interval(struct ping_rts *rts)
65+
{
66+
- int est = rts->rtt ? rts->rtt / 8 : rts->interval * 1000;
67+
+ int est = rts->rtt ? (int)(rts->rtt / 8) : rts->interval * 1000;
68+
69+
rts->interval = (est + rts->rtt_addend + 500) / 1000;
70+
if (rts->uid && rts->interval < MIN_USER_INTERVAL_MS)
71+
@@ -778,7 +778,7 @@ restamp:
72+
if (triptime > rts->tmax)
73+
rts->tmax = triptime;
74+
if (!rts->rtt)
75+
- rts->rtt = triptime * 8;
76+
+ rts->rtt = ((uint64_t)triptime) * 8;
77+
else
78+
rts->rtt += triptime - rts->rtt / 8;
79+
if (rts->opt_adaptive)
80+
@@ -948,7 +948,7 @@ int finish(struct ping_rts *rts)
81+
int ipg = (1000000 * (long long)tv.tv_sec + tv.tv_nsec / 1000) / (rts->ntransmitted - 1);
82+
83+
printf(_("%sipg/ewma %d.%03d/%d.%03d ms"),
84+
- comma, ipg / 1000, ipg % 1000, rts->rtt / 8000, (rts->rtt / 8) % 1000);
85+
+ comma, ipg / 1000, ipg % 1000, (int)(rts->rtt / 8000), (int)((rts->rtt / 8) % 1000));
86+
}
87+
putchar('\n');
88+
return (!rts->nreceived || (rts->deadline && rts->nreceived < rts->npackets));
89+
@@ -973,7 +973,7 @@ void status(struct ping_rts *rts)
90+
fprintf(stderr, _(", min/avg/ewma/max = %ld.%03ld/%lu.%03ld/%d.%03d/%ld.%03ld ms"),
91+
(long)rts->tmin / 1000, (long)rts->tmin % 1000,
92+
tavg / 1000, tavg % 1000,
93+
- rts->rtt / 8000, (rts->rtt / 8) % 1000, (long)rts->tmax / 1000, (long)rts->tmax % 1000);
94+
+ (int)(rts->rtt / 8000), (int)((rts->rtt / 8) % 1000), (long)rts->tmax / 1000, (long)rts->tmax % 1000);
95+
}
96+
fprintf(stderr, "\n");
97+
}
98+
--
99+
2.45.4
100+

SPECS/iputils/iputils.spec

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
Summary: Programs for basic networking
22
Name: iputils
33
Version: 20240117
4-
Release: 1%{?dist}
4+
Release: 2%{?dist}
55
License: BSD-3 AND GPLv2+ AND Rdisc
66
Vendor: Microsoft Corporation
77
Distribution: Azure Linux
88
Group: Applications/Communications
99
URL: https://github.com/iputils/iputils
1010
Source0: https://github.com/iputils/iputils/archive/20240117.tar.gz#/%{name}-%{version}.tar.gz
11-
Patch0: ping_test_ipv6_localhost.patch
11+
12+
Patch0: CVE-2025-47268.patch
13+
Patch1: CVE-2025-48964.patch
1214
BuildRequires: iproute
1315
BuildRequires: libcap-devel
1416
BuildRequires: libgcrypt-devel
@@ -64,6 +66,10 @@ mv -f RELNOTES.tmp RELNOTES.old
6466
%exclude %{_datadir}/locale/
6567

6668
%changelog
69+
* Wed Aug 06 2025 Azure Linux Security Servicing Account <[email protected]> - 20240117-2
70+
- Patch for CVE-2025-48964, CVE-2025-47268
71+
- Remove patch for ping_test_ipv6_localhost as it causes test failure
72+
6773
* Thu Feb 01 2024 Suresh Thelkar <[email protected]> - 20240117-1
6874
- Upgrade to 20240117
6975

SPECS/iputils/ping_test_ipv6_localhost.patch

Lines changed: 0 additions & 26 deletions
This file was deleted.

0 commit comments

Comments
 (0)