summaryrefslogtreecommitdiffstats
path: root/meta-networking
diff options
context:
space:
mode:
authorAshish Sharma <asharma@mvista.com>2025-05-20 07:25:03 +0530
committerArmin Kuster <akuster808@gmail.com>2025-07-02 20:29:51 -0400
commit4a099116873cc7bd44fde320c9091ab369651c2e (patch)
treeb1db2a692bf396576bdcea33c4918705f4e7aadb /meta-networking
parent9063cb0d9f781cbe226a5ef5853005a733595978 (diff)
downloadmeta-openembedded-4a099116873cc7bd44fde320c9091ab369651c2e.tar.gz
tcpdump: patch CVE-2024-2397
Upstream-Status: Backport from https://github.com/the-tcpdump-group/tcpdump/commit/b9811ef5bb1b7d45a90e042f81f3aaf233c8bcb2 Signed-off-by: Ashish Sharma <asharma@mvista.com> Signed-off-by: Armin Kuster <akuster808@gmail.com>
Diffstat (limited to 'meta-networking')
-rw-r--r--meta-networking/recipes-support/tcpdump/tcpdump/CVE-2024-2397.patch126
-rw-r--r--meta-networking/recipes-support/tcpdump/tcpdump_4.99.4.bb1
2 files changed, 127 insertions, 0 deletions
diff --git a/meta-networking/recipes-support/tcpdump/tcpdump/CVE-2024-2397.patch b/meta-networking/recipes-support/tcpdump/tcpdump/CVE-2024-2397.patch
new file mode 100644
index 0000000000..169ec6be70
--- /dev/null
+++ b/meta-networking/recipes-support/tcpdump/tcpdump/CVE-2024-2397.patch
@@ -0,0 +1,126 @@
1From b9811ef5bb1b7d45a90e042f81f3aaf233c8bcb2 Mon Sep 17 00:00:00 2001
2From: Guy Harris <gharris@sonic.net>
3Date: Tue, 12 Mar 2024 00:37:23 -0700
4Subject: [PATCH] ppp: use the buffer stack for the de-escaping buffer.
5
6This both saves the buffer for freeing later and saves the packet
7pointer and snapend to be restored when packet processing is complete,
8even if an exception is thrown with longjmp.
9
10This means that the hex/ASCII printing in pretty_print_packet()
11processes the packet data as captured or read from the savefile, rather
12than as modified by the PPP printer, so that the bounds checking is
13correct.
14
15That fixes CVE-2024-2397, which was caused by an exception being thrown
16by the hex/ASCII printer (which should only happen if those routines are
17called by a packet printer, not if they're called for the -X/-x/-A
18flag), which jumps back to the setjmp() that surrounds the packet
19printer. Hilarity^Winfinite looping ensues.
20
21Also, restore ndo->ndo_packetp before calling the hex/ASCII printing
22routine, in case nd_pop_all_packet_info() didn't restore it.
23
24Upstream-Status: Backport [https://github.com/the-tcpdump-group/tcpdump/commit/b9811ef5bb1b7d45a90e042f81f3aaf233c8bcb2]
25CVE: CVE-2024-2397
26Signed-off-by: Ashish Sharma <asharma@mvista.com>
27
28 print-ppp.c | 31 +++++++++++++++++--------------
29 print.c | 8 ++++++--
30 2 files changed, 23 insertions(+), 16 deletions(-)
31
32diff --git a/print-ppp.c b/print-ppp.c
33index 2cf06c363..9aed23eb9 100644
34--- a/print-ppp.c
35+++ b/print-ppp.c
36@@ -37,6 +37,8 @@
37
38 #include "netdissect-stdinc.h"
39
40+#include <stdlib.h>
41+
42 #include "netdissect.h"
43 #include "extract.h"
44 #include "addrtoname.h"
45@@ -1358,7 +1360,6 @@ ppp_hdlc(netdissect_options *ndo,
46 u_char *b, *t, c;
47 const u_char *s;
48 u_int i, proto;
49- const void *sb, *se;
50
51 if (caplen == 0)
52 return;
53@@ -1366,9 +1367,11 @@ ppp_hdlc(netdissect_options *ndo,
54 if (length == 0)
55 return;
56
57- b = (u_char *)nd_malloc(ndo, caplen);
58- if (b == NULL)
59- return;
60+ b = (u_char *)malloc(caplen);
61+ if (b == NULL) {
62+ (*ndo->ndo_error)(ndo, S_ERR_ND_MEM_ALLOC,
63+ "%s: malloc", __func__);
64+ }
65
66 /*
67 * Unescape all the data into a temporary, private, buffer.
68@@ -1389,13 +1392,15 @@ ppp_hdlc(netdissect_options *ndo,
69 }
70
71 /*
72- * Change the end pointer, so bounds checks work.
73- * Change the pointer to packet data to help debugging.
74+ * Switch to the output buffer for dissection, and save it
75+ * on the buffer stack so it can be freed; our caller must
76+ * pop it when done.
77 */
78- sb = ndo->ndo_packetp;
79- se = ndo->ndo_snapend;
80- ndo->ndo_packetp = b;
81- ndo->ndo_snapend = t;
82+ if (!nd_push_buffer(ndo, b, b, (u_int)(t - b))) {
83+ free(b);
84+ (*ndo->ndo_error)(ndo, S_ERR_ND_MEM_ALLOC,
85+ "%s: can't push buffer on buffer stack", __func__);
86+ }
87 length = ND_BYTES_AVAILABLE_AFTER(b);
88
89 /* now lets guess about the payload codepoint format */
90@@ -1437,13 +1442,11 @@ ppp_hdlc(netdissect_options *ndo,
91 }
92
93 cleanup:
94- ndo->ndo_packetp = sb;
95- ndo->ndo_snapend = se;
96+ nd_pop_packet_info(ndo);
97 return;
98
99 trunc:
100- ndo->ndo_packetp = sb;
101- ndo->ndo_snapend = se;
102+ nd_pop_packet_info(ndo);
103 nd_print_trunc(ndo);
104 }
105
106diff --git a/print.c b/print.c
107index b9ba5997d..f20633388 100644
108--- a/print.c
109+++ b/print.c
110@@ -431,10 +431,14 @@ pretty_print_packet(netdissect_options *ndo, const struct pcap_pkthdr *h,
111 nd_pop_all_packet_info(ndo);
112
113 /*
114- * Restore the original snapend, as a printer might have
115- * changed it.
116+ * Restore the originals snapend and packetp, as a printer
117+ * might have changed them.
118+ *
119+ * XXX - nd_pop_all_packet_info() should have restored the
120+ * original values, but, just in case....
121 */
122 ndo->ndo_snapend = sp + h->caplen;
123+ ndo->ndo_packetp = sp;
124 if (ndo->ndo_Xflag) {
125 /*
126 * Print the raw packet data in hex and ASCII.
diff --git a/meta-networking/recipes-support/tcpdump/tcpdump_4.99.4.bb b/meta-networking/recipes-support/tcpdump/tcpdump_4.99.4.bb
index 803a9bb5f5..b05b832dd8 100644
--- a/meta-networking/recipes-support/tcpdump/tcpdump_4.99.4.bb
+++ b/meta-networking/recipes-support/tcpdump/tcpdump_4.99.4.bb
@@ -24,6 +24,7 @@ SRC_URI = " \
24 http://www.tcpdump.org/release/${BP}.tar.gz \ 24 http://www.tcpdump.org/release/${BP}.tar.gz \
25 file://add-ptest.patch \ 25 file://add-ptest.patch \
26 file://run-ptest \ 26 file://run-ptest \
27 file://CVE-2024-2397.patch \
27" 28"
28 29
29SRC_URI[sha256sum] = "0232231bb2f29d6bf2426e70a08a7e0c63a0d59a9b44863b7f5e2357a6e49fea" 30SRC_URI[sha256sum] = "0232231bb2f29d6bf2426e70a08a7e0c63a0d59a9b44863b7f5e2357a6e49fea"