diff options
author | Yi Zhao <yi.zhao@windriver.com> | 2025-05-14 16:13:59 +0800 |
---|---|---|
committer | Steve Sakoman <steve@sakoman.com> | 2025-05-28 08:46:32 -0700 |
commit | 7f043fb4bbe96cf6714938c494331bcdee29fb7c (patch) | |
tree | 1aaeed18717d8e9edd3f00a5a456f69a80a12ebf | |
parent | 0fa8a4465e1b653c102d425804fcf85d0d28977a (diff) | |
download | poky-7f043fb4bbe96cf6714938c494331bcdee29fb7c.tar.gz |
iputils: Security fix for CVE-2025-47268
CVE-2025-47268
ping in iputils through 20240905 allows a denial of service (application
error or incorrect data collection) via a crafted ICMP Echo Reply
packet, because of a signed 64-bit integer overflow in timestamp
multiplication.
Reference:
https://nvd.nist.gov/vuln/detail/CVE-2025-47268
Patch from:
https://github.com/iputils/iputils/commit/070cfacd7348386173231fb16fad4983d4e6ae40
(From OE-Core rev: a463c8e3950ccf58316d48241c2cd82484f25fda)
Signed-off-by: Yi Zhao <yi.zhao@windriver.com>
Signed-off-by: Steve Sakoman <steve@sakoman.com>
-rw-r--r-- | meta/recipes-extended/iputils/iputils/CVE-2025-47268.patch | 143 | ||||
-rw-r--r-- | meta/recipes-extended/iputils/iputils_20211215.bb | 1 |
2 files changed, 144 insertions, 0 deletions
diff --git a/meta/recipes-extended/iputils/iputils/CVE-2025-47268.patch b/meta/recipes-extended/iputils/iputils/CVE-2025-47268.patch new file mode 100644 index 0000000000..dd31b79031 --- /dev/null +++ b/meta/recipes-extended/iputils/iputils/CVE-2025-47268.patch | |||
@@ -0,0 +1,143 @@ | |||
1 | From 070cfacd7348386173231fb16fad4983d4e6ae40 Mon Sep 17 00:00:00 2001 | ||
2 | From: Petr Vorel <pvorel@suse.cz> | ||
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 <chrubis@suse.cz> | ||
70 | Reported-by: Mohamed Maatallah <hotelsmaatallahrecemail@gmail.com> | ||
71 | Reviewed-by: Mohamed Maatallah <hotelsmaatallahrecemail@gmail.com> | ||
72 | Reviewed-by: Cyril Hrubis <chrubis@suse.cz> | ||
73 | Reviewed-by: Noah Meyerhans <noahm@debian.org> | ||
74 | Signed-off-by: Petr Vorel <pvorel@suse.cz> | ||
75 | |||
76 | CVE: CVE-2025-47268 | ||
77 | |||
78 | Upstream-Status: Backport | ||
79 | [https://github.com/iputils/iputils/commit/070cfacd7348386173231fb16fad4983d4e6ae40] | ||
80 | |||
81 | Signed-off-by: Yi Zhao <yi.zhao@windriver.com> | ||
82 | --- | ||
83 | iputils_common.h | 3 +++ | ||
84 | ping/ping_common.c | 22 +++++++++++++++++++--- | ||
85 | 2 files changed, 22 insertions(+), 3 deletions(-) | ||
86 | |||
87 | diff --git a/iputils_common.h b/iputils_common.h | ||
88 | index 49e790d..829a749 100644 | ||
89 | --- a/iputils_common.h | ||
90 | +++ b/iputils_common.h | ||
91 | @@ -10,6 +10,9 @@ | ||
92 | !!__builtin_types_compatible_p(__typeof__(arr), \ | ||
93 | __typeof__(&arr[0]))])) * 0) | ||
94 | |||
95 | +/* 1000001 = 1000000 tv_sec + 1 tv_usec */ | ||
96 | +#define TV_SEC_MAX_VAL (LONG_MAX/1000001) | ||
97 | + | ||
98 | #ifdef __GNUC__ | ||
99 | # define iputils_attribute_format(t, n, m) __attribute__((__format__ (t, n, m))) | ||
100 | #else | ||
101 | diff --git a/ping/ping_common.c b/ping/ping_common.c | ||
102 | index dadd2a4..4e99d89 100644 | ||
103 | --- a/ping/ping_common.c | ||
104 | +++ b/ping/ping_common.c | ||
105 | @@ -754,16 +754,32 @@ int gather_statistics(struct ping_rts *rts, uint8_t *icmph, int icmplen, | ||
106 | |||
107 | restamp: | ||
108 | tvsub(tv, &tmp_tv); | ||
109 | - triptime = tv->tv_sec * 1000000 + tv->tv_usec; | ||
110 | - if (triptime < 0) { | ||
111 | - error(0, 0, _("Warning: time of day goes back (%ldus), taking countermeasures"), triptime); | ||
112 | + | ||
113 | + if (tv->tv_usec >= 1000000) { | ||
114 | + error(0, 0, _("Warning: invalid tv_usec %ld us"), tv->tv_usec); | ||
115 | + tv->tv_usec = 999999; | ||
116 | + } | ||
117 | + | ||
118 | + if (tv->tv_usec < 0) { | ||
119 | + error(0, 0, _("Warning: invalid tv_usec %ld us"), tv->tv_usec); | ||
120 | + tv->tv_usec = 0; | ||
121 | + } | ||
122 | + | ||
123 | + if (tv->tv_sec > TV_SEC_MAX_VAL) { | ||
124 | + error(0, 0, _("Warning: invalid tv_sec %ld s"), tv->tv_sec); | ||
125 | + triptime = 0; | ||
126 | + } else if (tv->tv_sec < 0) { | ||
127 | + error(0, 0, _("Warning: time of day goes back (%ld s), taking countermeasures"), tv->tv_sec); | ||
128 | triptime = 0; | ||
129 | if (!rts->opt_latency) { | ||
130 | gettimeofday(tv, NULL); | ||
131 | rts->opt_latency = 1; | ||
132 | goto restamp; | ||
133 | } | ||
134 | + } else { | ||
135 | + triptime = tv->tv_sec * 1000000 + tv->tv_usec; | ||
136 | } | ||
137 | + | ||
138 | if (!csfailed) { | ||
139 | rts->tsum += triptime; | ||
140 | rts->tsum2 += (double)((long long)triptime * (long long)triptime); | ||
141 | -- | ||
142 | 2.34.1 | ||
143 | |||
diff --git a/meta/recipes-extended/iputils/iputils_20211215.bb b/meta/recipes-extended/iputils/iputils_20211215.bb index 3ddce0be54..03dc97dcc8 100644 --- a/meta/recipes-extended/iputils/iputils_20211215.bb +++ b/meta/recipes-extended/iputils/iputils_20211215.bb | |||
@@ -12,6 +12,7 @@ DEPENDS = "gnutls" | |||
12 | 12 | ||
13 | SRC_URI = "git://github.com/iputils/iputils;branch=master;protocol=https \ | 13 | SRC_URI = "git://github.com/iputils/iputils;branch=master;protocol=https \ |
14 | file://0001-rarpd-rdisc-Drop-PrivateUsers.patch \ | 14 | file://0001-rarpd-rdisc-Drop-PrivateUsers.patch \ |
15 | file://CVE-2025-47268.patch \ | ||
15 | " | 16 | " |
16 | SRCREV = "1d1e7c43210d8af316a41cb2c53d612a4c16f34d" | 17 | SRCREV = "1d1e7c43210d8af316a41cb2c53d612a4c16f34d" |
17 | 18 | ||