From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: passt.top; dmarc=none (p=none dis=none) header.from=njh.eu Received: from mail.notjusthosting.com (mail.notjusthosting.com [IPv6:2a01:4f8:a0:516f:1::1]) by passt.top (Postfix) with ESMTPS id 2F0E05A0271 for ; Tue, 09 Sep 2025 17:04:18 +0200 (CEST) Received: from dynamic-2a02-3100-18df-9500-c6e4-f42f-769b-a770.310.pool.telefonica.de ([2a02:3100:18df:9500:c6e4:f42f:769b:a770] helo=vlap) by mail.notjusthosting.com with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1uvztJ-00009B-Mz; Tue, 09 Sep 2025 17:04:17 +0200 From: Volker Diels-Grabsch To: passt-dev@passt.top Subject: [PATCH] Fix segfault on TCP connection before first passt socket connection Date: Tue, 9 Sep 2025 17:04:12 +0200 Message-ID: <20250909150412.843578-1-v@njh.eu> X-Mailer: git-send-email 2.47.3 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-ID-Hash: FK56DZ4OSDD7J7TLY674CZWXMKSM64WC X-Message-ID-Hash: FK56DZ4OSDD7J7TLY674CZWXMKSM64WC X-MailFrom: v@njh.eu X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Volker Diels-Grabsch X-Mailman-Version: 3.3.8 Precedence: list List-Id: Development discussion and patches for passt Archived-At: Archived-At: List-Archive: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: This issue can be reproduced by running passt with TCP forwarding and connecting to that TCP port before the first client (e.g. QEMU) connects to the passt socket. Example: (sleep 0.1; ssh -p 22000 127.0.0.1) & passt -f -t 22000:22 Although this commit likely doesn't fix the root cause of this issue, it does reliably fix the segfault. --- tcp_buf.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tcp_buf.c b/tcp_buf.c index bc898de..1a06f15 100644 --- a/tcp_buf.c +++ b/tcp_buf.c @@ -120,6 +120,9 @@ static void tcp_revert_seq(const struct ctx *c, struct tcp_tap_conn **conns, uint32_t seq = ntohl(th->seq); uint32_t peek_offset; + if (conn == NULL) + continue; + if (SEQ_LE(conn->seq_to_tap, seq)) continue; -- 2.47.3