* [PATCH] Fix segfault on TCP connection before first passt socket connection
@ 2025-09-09 15:04 Volker Diels-Grabsch
2025-09-10 1:58 ` David Gibson
0 siblings, 1 reply; 2+ messages in thread
From: Volker Diels-Grabsch @ 2025-09-09 15:04 UTC (permalink / raw)
To: passt-dev; +Cc: Volker Diels-Grabsch
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
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] Fix segfault on TCP connection before first passt socket connection
2025-09-09 15:04 [PATCH] Fix segfault on TCP connection before first passt socket connection Volker Diels-Grabsch
@ 2025-09-10 1:58 ` David Gibson
0 siblings, 0 replies; 2+ messages in thread
From: David Gibson @ 2025-09-10 1:58 UTC (permalink / raw)
To: Volker Diels-Grabsch; +Cc: passt-dev
[-- Attachment #1: Type: text/plain, Size: 1415 bytes --]
On Tue, Sep 09, 2025 at 05:04:12PM +0200, Volker Diels-Grabsch wrote:
> 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.
Right, this band-aids the problem, but isn't the correct fix.
Getting a NULL pointer here indicates that we're putting a frame into
the queue without setting the corresponding tcp_frame_conns[] entry,
which is definitely wrong.
Thanks for the reproducer, I'm having a look into this now.
> ---
> 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
>
--
David Gibson (he or they) | I'll have my music baroque, and my code
david AT gibson.dropbear.id.au | minimalist, thank you, not the other way
| around.
http://www.ozlabs.org/~dgibson
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-09-10 2:12 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-09-09 15:04 [PATCH] Fix segfault on TCP connection before first passt socket connection Volker Diels-Grabsch
2025-09-10 1:58 ` David Gibson
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).