public inbox for passt-dev@passt.top
 help / color / mirror / code / Atom feed
From: Volker Diels-Grabsch <v@njh.eu>
To: passt-dev@passt.top
Cc: Volker Diels-Grabsch <v@njh.eu>
Subject: [PATCH] Fix segfault on TCP connection before first passt socket connection
Date: Tue,  9 Sep 2025 17:04:12 +0200	[thread overview]
Message-ID: <20250909150412.843578-1-v@njh.eu> (raw)

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;
 
-- 
@@ -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


             reply	other threads:[~2025-09-09 15:04 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-09-09 15:04 Volker Diels-Grabsch [this message]
2025-09-10  1:58 ` [PATCH] Fix segfault on TCP connection before first passt socket connection David Gibson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250909150412.843578-1-v@njh.eu \
    --to=v@njh.eu \
    --cc=passt-dev@passt.top \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://passt.top/passt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for IMAP folder(s).