Compare commits
No commits in common. 'cs10' and 'c9' have entirely different histories.
@ -1,3 +1,3 @@
|
||||
SOURCES/tcpdump-4.99.4.tar.gz
|
||||
SOURCES/tcpdump-4.99.4.tar.gz.sig
|
||||
SOURCES/tcpslice-1.7.tar.gz
|
||||
SOURCES/tcpdump-4.99.0.tar.gz
|
||||
SOURCES/tcpdump-4.99.0.tar.gz.sig
|
||||
SOURCES/tcpslice-1.3.tar.gz
|
||||
|
@ -1,3 +1,3 @@
|
||||
cc005539296900ce6a90c61f4099bd0f3ef3dd26 SOURCES/tcpdump-4.99.4.tar.gz
|
||||
cddad6f90391208fadc513aac9a90b622411ef00 SOURCES/tcpdump-4.99.4.tar.gz.sig
|
||||
8fb66de200a35b1b228e9cc3b13e59c648e48fee SOURCES/tcpslice-1.7.tar.gz
|
||||
4348a93b47a5b35a9c04abcee4d84a04b1a681f8 SOURCES/tcpdump-4.99.0.tar.gz
|
||||
3fadebc3d3edaa3f4326a11864a0034ba1f2ccb7 SOURCES/tcpdump-4.99.0.tar.gz.sig
|
||||
4445c159ce45fa6fd9767658918eaf59175afac3 SOURCES/tcpslice-1.3.tar.gz
|
||||
|
@ -0,0 +1,48 @@
|
||||
From 030859fce9c77417de657b9bb29c0f78c2d68f4a Mon Sep 17 00:00:00 2001
|
||||
From: Denis Ovsienko <denis@ovsienko.info>
|
||||
Date: Thu, 30 Dec 2021 17:52:52 +0000
|
||||
Subject: [PATCH] CVE-2021-41043: Fix a use-after-free in extract_slice().
|
||||
|
||||
This issue was discovered by Mohammad Hosein Askari (@C0NSTANTINE110),
|
||||
see GitHub issue #11.
|
||||
|
||||
In extract_slice() pcap_dump_open() takes a pcap_t argument to tell
|
||||
which DLT to use for the output file. This used to be the pcap_t of the
|
||||
first input file, as main() requires at least one input file. However,
|
||||
the loop before pcap_dump_open() closes all, including the first, input
|
||||
files that don't meet a test condition. This way, when the first file
|
||||
didn't meet the condition, the call to pcap_dump_open() would end up as
|
||||
a use-after-free. Make the pcap_dump_open() call before the loop, when
|
||||
the first array element is always valid, and fix this problem.
|
||||
---
|
||||
diff --git a/tcpslice-1.3/tcpslice.c b/tcpslice-1.3/tcpslice.c
|
||||
index e7b9ba8..507dd1b 100644
|
||||
--- a/tcpslice-1.3/tcpslice.c
|
||||
+++ b/tcpslice-1.3/tcpslice.c
|
||||
@@ -838,6 +838,13 @@ extract_slice(struct state *states, int numfiles, const char *write_file_name,
|
||||
TV_SUB(start_time, base_time, &relative_start);
|
||||
TV_SUB(stop_time, base_time, &relative_stop);
|
||||
|
||||
+ /* Always write the output file, use the first input file's DLT. */
|
||||
+ global_dumper = pcap_dump_open(states[0].p, write_file_name);
|
||||
+ if (!global_dumper) {
|
||||
+ error("error creating output file '%s': %s",
|
||||
+ write_file_name, pcap_geterr(states[0].p));
|
||||
+ }
|
||||
+
|
||||
for (i = 0; i < numfiles; ++i) {
|
||||
s = &states[i];
|
||||
|
||||
@@ -876,12 +883,6 @@ extract_slice(struct state *states, int numfiles, const char *write_file_name,
|
||||
get_next_packet(s);
|
||||
}
|
||||
|
||||
- global_dumper = pcap_dump_open(states->p, write_file_name);
|
||||
- if (!global_dumper) {
|
||||
- error( "error creating output file %s: %s",
|
||||
- write_file_name, pcap_geterr( states->p ) );
|
||||
- }
|
||||
-
|
||||
|
||||
/*
|
||||
* Now, loop thru all the packets in all the files,
|
@ -1,154 +0,0 @@
|
||||
From 9ce43fa1e06b1ac2ddf1630a0e90337136ea27c5 Mon Sep 17 00:00:00 2001
|
||||
From: Guy Harris <gharris@sonic.net>
|
||||
Date: Mon, 21 Aug 2023 23:15:14 -0700
|
||||
Subject: [PATCH] pgm: fix the way we step through the packet.
|
||||
|
||||
Step past the PGM header after we finish processing it and before we
|
||||
process the message-type-specific header.
|
||||
|
||||
Step past the message-type-specific fixed-length header before we
|
||||
process the stuff after that header.
|
||||
|
||||
This makes the code a bit clearer (by explicitly advancing bp by the
|
||||
size of the stuff we just processed, rather than doing so by trickery
|
||||
involving adding 1 to a pointer to a structure), and fixes the
|
||||
processing of message types that don't have a message-type-specific
|
||||
header (where we weren't stepping past the PGM header). It also affects
|
||||
the way we handle messages of an unknown type.
|
||||
|
||||
(cherry picked from commit 9a3eebde95cf1032ac68ae4312e2db14bb1fe58d)
|
||||
---
|
||||
print-pgm.c | 29 +++++++++++++++--------------
|
||||
tests/pgm_opts_asan.out | 2 +-
|
||||
tests/pgm_opts_asan_2.out | 2 +-
|
||||
tests/pgm_opts_asan_3.out | 2 +-
|
||||
4 files changed, 18 insertions(+), 17 deletions(-)
|
||||
|
||||
diff --git a/print-pgm.c b/print-pgm.c
|
||||
index ccb0b46a..8a7e215b 100644
|
||||
--- a/print-pgm.c
|
||||
+++ b/print-pgm.c
|
||||
@@ -220,13 +220,14 @@ pgm_print(netdissect_options *ndo,
|
||||
pgm->pgm_gsid[3],
|
||||
pgm->pgm_gsid[4],
|
||||
pgm->pgm_gsid[5]);
|
||||
+ bp += sizeof(struct pgm_header);
|
||||
switch (pgm_type_val) {
|
||||
case PGM_SPM: {
|
||||
const struct pgm_spm *spm;
|
||||
|
||||
- spm = (const struct pgm_spm *)(pgm + 1);
|
||||
+ spm = (const struct pgm_spm *)bp;
|
||||
ND_TCHECK_SIZE(spm);
|
||||
- bp = (const u_char *) (spm + 1);
|
||||
+ bp += sizeof(struct pgm_spm);
|
||||
|
||||
switch (GET_BE_U_2(spm->pgms_nla_afi)) {
|
||||
case AFNUM_INET:
|
||||
@@ -256,9 +257,9 @@ pgm_print(netdissect_options *ndo,
|
||||
const struct pgm_poll *pgm_poll;
|
||||
uint32_t ivl, rnd, mask;
|
||||
|
||||
- pgm_poll = (const struct pgm_poll *)(pgm + 1);
|
||||
+ pgm_poll = (const struct pgm_poll *)bp;
|
||||
ND_TCHECK_SIZE(pgm_poll);
|
||||
- bp = (const u_char *) (pgm_poll + 1);
|
||||
+ bp += sizeof(struct pgm_poll);
|
||||
|
||||
switch (GET_BE_U_2(pgm_poll->pgmp_nla_afi)) {
|
||||
case AFNUM_INET:
|
||||
@@ -294,35 +295,35 @@ pgm_print(netdissect_options *ndo,
|
||||
case PGM_POLR: {
|
||||
const struct pgm_polr *polr_msg;
|
||||
|
||||
- polr_msg = (const struct pgm_polr *)(pgm + 1);
|
||||
+ polr_msg = (const struct pgm_polr *)bp;
|
||||
ND_TCHECK_SIZE(polr_msg);
|
||||
ND_PRINT("POLR seq %u round %u",
|
||||
GET_BE_U_4(polr_msg->pgmp_seq),
|
||||
GET_BE_U_2(polr_msg->pgmp_round));
|
||||
- bp = (const u_char *) (polr_msg + 1);
|
||||
+ bp += sizeof(struct pgm_polr);
|
||||
break;
|
||||
}
|
||||
case PGM_ODATA: {
|
||||
const struct pgm_data *odata;
|
||||
|
||||
- odata = (const struct pgm_data *)(pgm + 1);
|
||||
+ odata = (const struct pgm_data *)bp;
|
||||
ND_TCHECK_SIZE(odata);
|
||||
ND_PRINT("ODATA trail %u seq %u",
|
||||
GET_BE_U_4(odata->pgmd_trailseq),
|
||||
GET_BE_U_4(odata->pgmd_seq));
|
||||
- bp = (const u_char *) (odata + 1);
|
||||
+ bp += sizeof(struct pgm_data);
|
||||
break;
|
||||
}
|
||||
|
||||
case PGM_RDATA: {
|
||||
const struct pgm_data *rdata;
|
||||
|
||||
- rdata = (const struct pgm_data *)(pgm + 1);
|
||||
+ rdata = (const struct pgm_data *)bp;
|
||||
ND_TCHECK_SIZE(rdata);
|
||||
ND_PRINT("RDATA trail %u seq %u",
|
||||
GET_BE_U_4(rdata->pgmd_trailseq),
|
||||
GET_BE_U_4(rdata->pgmd_seq));
|
||||
- bp = (const u_char *) (rdata + 1);
|
||||
+ bp += sizeof(struct pgm_data);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -332,9 +333,9 @@ pgm_print(netdissect_options *ndo,
|
||||
const struct pgm_nak *nak;
|
||||
char source_buf[INET6_ADDRSTRLEN], group_buf[INET6_ADDRSTRLEN];
|
||||
|
||||
- nak = (const struct pgm_nak *)(pgm + 1);
|
||||
+ nak = (const struct pgm_nak *)bp;
|
||||
ND_TCHECK_SIZE(nak);
|
||||
- bp = (const u_char *) (nak + 1);
|
||||
+ bp += sizeof(struct pgm_nak);
|
||||
|
||||
/*
|
||||
* Skip past the source, saving info along the way
|
||||
@@ -401,11 +402,11 @@ pgm_print(netdissect_options *ndo,
|
||||
case PGM_ACK: {
|
||||
const struct pgm_ack *ack;
|
||||
|
||||
- ack = (const struct pgm_ack *)(pgm + 1);
|
||||
+ ack = (const struct pgm_ack *)bp;
|
||||
ND_TCHECK_SIZE(ack);
|
||||
ND_PRINT("ACK seq %u",
|
||||
GET_BE_U_4(ack->pgma_rx_max_seq));
|
||||
- bp = (const u_char *) (ack + 1);
|
||||
+ bp += sizeof(struct pgm_ack);
|
||||
break;
|
||||
}
|
||||
|
||||
diff --git a/tests/pgm_opts_asan.out b/tests/pgm_opts_asan.out
|
||||
index 6cc9b065..7527bda3 100644
|
||||
--- a/tests/pgm_opts_asan.out
|
||||
+++ b/tests/pgm_opts_asan.out
|
||||
@@ -1,2 +1,2 @@
|
||||
1 00:04:16.587271427 IP (tos 0x41,ECT(1), id 0, offset 0, flags [none], proto PGM (113), length 32639, options (unknown 89 [bad length 232]), bad cksum 5959 (->9eb9)!)
|
||||
- 128.121.89.107 > 89.89.16.63: 128.121.89.107.4 > 89.89.16.63.225: PGM, length 0 0x3414eb1f0022 UNKNOWN type 0x1f OPTS LEN 225 OPT_1F [13] OPT_06 [26] PATH_NLA [4] [|pgm]
|
||||
+ 128.121.89.107 > 89.89.16.63: 128.121.89.107.4 > 89.89.16.63.225: PGM, length 0 0x3414eb1f0022 UNKNOWN type 0x1f[Bad OPT_LENGTH option, length 0 != 4]
|
||||
diff --git a/tests/pgm_opts_asan_2.out b/tests/pgm_opts_asan_2.out
|
||||
index 1785a571..53830c85 100644
|
||||
--- a/tests/pgm_opts_asan_2.out
|
||||
+++ b/tests/pgm_opts_asan_2.out
|
||||
@@ -1,2 +1,2 @@
|
||||
1 00:04:16.587271427 IP (tos 0x41,ECT(1), id 0, offset 0, flags [none], proto PGM (113), length 32639, options (unknown 89 [bad length 232]), bad cksum 5959 (->96b9)!)
|
||||
- 128.121.89.107 > 89.89.16.63: 128.121.89.107.4 > 89.89.16.63.225: PGM, length 0 0x3414eb1f0022 UNKNOWN type 0x1f OPTS LEN 225 OPT_1F [13] OPT_06 [26] [Bad OPT_PGMCC_DATA option, length 4 < 12]
|
||||
+ 128.121.89.107 > 89.89.16.63: 128.121.89.107.4 > 89.89.16.63.225: PGM, length 0 0x3414eb1f0022 UNKNOWN type 0x1f[Bad OPT_LENGTH option, length 0 != 4]
|
||||
diff --git a/tests/pgm_opts_asan_3.out b/tests/pgm_opts_asan_3.out
|
||||
index 2e35f2fa..b8864e29 100644
|
||||
--- a/tests/pgm_opts_asan_3.out
|
||||
+++ b/tests/pgm_opts_asan_3.out
|
||||
@@ -1,2 +1,2 @@
|
||||
1 00:04:16.587271427 IP (tos 0x41,ECT(1), id 0, offset 0, flags [none], proto PGM (113), length 32639, options (unknown 89 [bad length 232]), bad cksum 5959 (->f814)!)
|
||||
- 128.121.89.16 > 0.89.16.63: 128.121.89.16.4 > 0.89.16.63.225: PGM, length 0 0x3414eb1f0022 UNKNOWN type 0x1f OPTS LEN 225 OPT_1F [13] OPT_06 [26] [Bad OPT_REDIRECT option, length 4 < 8]
|
||||
+ 128.121.89.16 > 0.89.16.63: 128.121.89.16.4 > 0.89.16.63.225: PGM, length 0 0x3414eb1f0022 UNKNOWN type 0x1f[Bad OPT_LENGTH option, length 0 != 4]
|
||||
--
|
||||
2.41.0
|
||||
|
@ -1,48 +0,0 @@
|
||||
From 627a1b7fdceaad8745c438bb0037e59689a1f0df Mon Sep 17 00:00:00 2001
|
||||
From: Guy Harris <gharris@sonic.net>
|
||||
Date: Tue, 22 Aug 2023 12:23:20 -0700
|
||||
Subject: [PATCH] pgm: don't advance bp by the option haeder length twice.
|
||||
|
||||
At those points, we've already advanced it by the option header length,
|
||||
and opt_len includes that length, so advance bp by opt_len minus the
|
||||
option header length.
|
||||
|
||||
(cherry picked from commit 09b0447fad52298440e05e7368f9d24492d0b0fe)
|
||||
---
|
||||
print-pgm.c | 6 +++---
|
||||
1 file changed, 3 insertions(+), 3 deletions(-)
|
||||
|
||||
diff --git a/print-pgm.c b/print-pgm.c
|
||||
index 8a7e215b..1e67db77 100644
|
||||
--- a/print-pgm.c
|
||||
+++ b/print-pgm.c
|
||||
@@ -661,7 +661,7 @@ pgm_print(netdissect_options *ndo,
|
||||
|
||||
case PGM_OPT_PATH_NLA:
|
||||
ND_PRINT(" PATH_NLA [%u]", opt_len);
|
||||
- bp += opt_len;
|
||||
+ bp += opt_len - 2;
|
||||
opts_len -= opt_len;
|
||||
break;
|
||||
|
||||
@@ -703,7 +703,7 @@ pgm_print(netdissect_options *ndo,
|
||||
|
||||
case PGM_OPT_CR:
|
||||
ND_PRINT(" CR");
|
||||
- bp += opt_len;
|
||||
+ bp += opt_len - 2;
|
||||
opts_len -= opt_len;
|
||||
break;
|
||||
|
||||
@@ -807,7 +807,7 @@ pgm_print(netdissect_options *ndo,
|
||||
|
||||
default:
|
||||
ND_PRINT(" OPT_%02X [%u] ", opt_type, opt_len);
|
||||
- bp += opt_len;
|
||||
+ bp += opt_len - 2;
|
||||
opts_len -= opt_len;
|
||||
break;
|
||||
}
|
||||
--
|
||||
2.41.0
|
||||
|
@ -1,122 +0,0 @@
|
||||
From b9811ef5bb1b7d45a90e042f81f3aaf233c8bcb2 Mon Sep 17 00:00:00 2001
|
||||
From: Guy Harris <gharris@sonic.net>
|
||||
Date: Tue, 12 Mar 2024 00:37:23 -0700
|
||||
Subject: [PATCH] ppp: use the buffer stack for the de-escaping buffer.
|
||||
|
||||
This both saves the buffer for freeing later and saves the packet
|
||||
pointer and snapend to be restored when packet processing is complete,
|
||||
even if an exception is thrown with longjmp.
|
||||
|
||||
This means that the hex/ASCII printing in pretty_print_packet()
|
||||
processes the packet data as captured or read from the savefile, rather
|
||||
than as modified by the PPP printer, so that the bounds checking is
|
||||
correct.
|
||||
|
||||
That fixes CVE-2024-2397, which was caused by an exception being thrown
|
||||
by the hex/ASCII printer (which should only happen if those routines are
|
||||
called by a packet printer, not if they're called for the -X/-x/-A
|
||||
flag), which jumps back to the setjmp() that surrounds the packet
|
||||
printer. Hilarity^Winfinite looping ensues.
|
||||
|
||||
Also, restore ndo->ndo_packetp before calling the hex/ASCII printing
|
||||
routine, in case nd_pop_all_packet_info() didn't restore it.
|
||||
---
|
||||
print-ppp.c | 31 +++++++++++++++++--------------
|
||||
print.c | 8 ++++++--
|
||||
2 files changed, 23 insertions(+), 16 deletions(-)
|
||||
|
||||
diff --git a/print-ppp.c b/print-ppp.c
|
||||
index 2cf06c363..9aed23eb9 100644
|
||||
--- a/print-ppp.c
|
||||
+++ b/print-ppp.c
|
||||
@@ -37,6 +37,8 @@
|
||||
|
||||
#include "netdissect-stdinc.h"
|
||||
|
||||
+#include <stdlib.h>
|
||||
+
|
||||
#ifdef __bsdi__
|
||||
#include <net/slcompress.h>
|
||||
#include <net/if_ppp.h>
|
||||
@@ -1358,7 +1360,6 @@ ppp_hdlc(netdissect_options *ndo,
|
||||
u_char *b, *t, c;
|
||||
const u_char *s;
|
||||
u_int i, proto;
|
||||
- const void *sb, *se;
|
||||
|
||||
if (caplen == 0)
|
||||
return;
|
||||
@@ -1366,9 +1367,11 @@ ppp_hdlc(netdissect_options *ndo,
|
||||
if (length == 0)
|
||||
return;
|
||||
|
||||
- b = (u_char *)nd_malloc(ndo, caplen);
|
||||
- if (b == NULL)
|
||||
- return;
|
||||
+ b = (u_char *)malloc(caplen);
|
||||
+ if (b == NULL) {
|
||||
+ (*ndo->ndo_error)(ndo, S_ERR_ND_MEM_ALLOC,
|
||||
+ "%s: malloc", __func__);
|
||||
+ }
|
||||
|
||||
/*
|
||||
* Unescape all the data into a temporary, private, buffer.
|
||||
@@ -1389,13 +1392,15 @@ ppp_hdlc(netdissect_options *ndo,
|
||||
}
|
||||
|
||||
/*
|
||||
- * Change the end pointer, so bounds checks work.
|
||||
- * Change the pointer to packet data to help debugging.
|
||||
+ * Switch to the output buffer for dissection, and save it
|
||||
+ * on the buffer stack so it can be freed; our caller must
|
||||
+ * pop it when done.
|
||||
*/
|
||||
- sb = ndo->ndo_packetp;
|
||||
- se = ndo->ndo_snapend;
|
||||
- ndo->ndo_packetp = b;
|
||||
- ndo->ndo_snapend = t;
|
||||
+ if (!nd_push_buffer(ndo, b, b, (u_int)(t - b))) {
|
||||
+ free(b);
|
||||
+ (*ndo->ndo_error)(ndo, S_ERR_ND_MEM_ALLOC,
|
||||
+ "%s: can't push buffer on buffer stack", __func__);
|
||||
+ }
|
||||
length = ND_BYTES_AVAILABLE_AFTER(b);
|
||||
|
||||
/* now lets guess about the payload codepoint format */
|
||||
@@ -1437,13 +1442,11 @@ ppp_hdlc(netdissect_options *ndo,
|
||||
}
|
||||
|
||||
cleanup:
|
||||
- ndo->ndo_packetp = sb;
|
||||
- ndo->ndo_snapend = se;
|
||||
+ nd_pop_packet_info(ndo);
|
||||
return;
|
||||
|
||||
trunc:
|
||||
- ndo->ndo_packetp = sb;
|
||||
- ndo->ndo_snapend = se;
|
||||
+ nd_pop_packet_info(ndo);
|
||||
nd_print_trunc(ndo);
|
||||
}
|
||||
|
||||
diff --git a/print.c b/print.c
|
||||
index b9ba5997d..f20633388 100644
|
||||
--- a/print.c
|
||||
+++ b/print.c
|
||||
@@ -431,10 +431,14 @@ pretty_print_packet(netdissect_options *ndo, const struct pcap_pkthdr *h,
|
||||
nd_pop_all_packet_info(ndo);
|
||||
|
||||
/*
|
||||
- * Restore the original snapend, as a printer might have
|
||||
- * changed it.
|
||||
+ * Restore the originals snapend and packetp, as a printer
|
||||
+ * might have changed them.
|
||||
+ *
|
||||
+ * XXX - nd_pop_all_packet_info() should have restored the
|
||||
+ * original values, but, just in case....
|
||||
*/
|
||||
ndo->ndo_snapend = sp + h->caplen;
|
||||
+ ndo->ndo_packetp = sp;
|
||||
if (ndo->ndo_Xflag) {
|
||||
/*
|
||||
* Print the raw packet data in hex and ASCII.
|
@ -1,2 +0,0 @@
|
||||
#Type Name ID GECOS Home directory Shell
|
||||
u tcpdump 72 "tcpdump" - -
|
Loading…
Reference in new issue