From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) by passt.top (Postfix) with ESMTPS id DE0D85A004F for ; Fri, 07 Jun 2024 03:57:56 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=202312; t=1717725473; bh=58ZryVSJYQu9B+RArhJr4BjRryNI9Xg7dhdX/uismRw=; h=From:To:Cc:Subject:Date:From; b=GBh/LdN9nnlGXte/E5rnX6ZGargtLWdMFkH9Nx5o9osZ6w+Vr3ZflvUbb+H6VitED P/zFhOua0p3D1RFQjRcna2vc4l614qPp7L1Chw3OJNU/plGZ7D2pnAeVU2IuVbGiff H4rUbYSsKuUq0l7ZOo59czG12SCB4VFcFlAcx7Q0l9F23QTgUtXmOTF09CxrELnnpC AHVqkUkLS7tLSrrivHBLkxl3QDTex4SiOVK+qS1lkRaIFq9OPCt9YTtFgGwvsjaoPv j6YkxwCP8XSQ/5aoFBHD4s2oWfjLaIwQZ+jS4eEmgMNiMwx2XvwwNbJhy5ScAPMtQ4 crzP1/Al5lQrQ== Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4VwPV90T4vz4wc5; Fri, 7 Jun 2024 11:57:53 +1000 (AEST) From: David Gibson To: passt-dev@passt.top, Stefano Brivio Subject: [PATCH] tcp, flow: Fix some error paths which didn't clean up flows properly Date: Fri, 7 Jun 2024 11:55:24 +1000 Message-ID: <20240607015524.1633407-1-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.45.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-ID-Hash: EFSH4EGNQDEUHG23YHZGVQXGFDCBBC5N X-Message-ID-Hash: EFSH4EGNQDEUHG23YHZGVQXGFDCBBC5N X-MailFrom: dgibson@gandalf.ozlabs.org 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: David Gibson 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: Flow table entries need to be fully initialised before returning to the main epoll loop. Commit 0060acd1 ("flow: Clarify and enforce flow state transitions") now enforces that: once a flow is allocated we must either cancel it, or activate it before returning to the main loop, or we will hit an ASSERT(). Some error paths in tcp_conn_from_tap() weren't correctly updated for this requirement - we can exit with a flow entry incompletely initialised. Correct that by cancelling the flows in those situations. I don't have enough information to be certain if this is the cause for podman bug 22925, but it plausibly could be. Fixes: 0060acd1 ("flow: Clarify and enforce flow state transitions") Link: https://github.com/containers/podman/issues/22925 Signed-off-by: David Gibson --- tcp.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tcp.c b/tcp.c index 0dccde9c..cb613cf3 100644 --- a/tcp.c +++ b/tcp.c @@ -2067,7 +2067,7 @@ static void tcp_conn_from_tap(struct ctx *c, sa_family_t af, if (!bind(s, sa, sl)) { tcp_rst(c, conn); /* Nobody is listening then */ - return; + goto cancel; } if (errno != EADDRNOTAVAIL && errno != EACCES) conn_flag(c, conn, LOCAL); @@ -2080,7 +2080,7 @@ static void tcp_conn_from_tap(struct ctx *c, sa_family_t af, if (connect(s, sa, sl)) { if (errno != EINPROGRESS) { tcp_rst(c, conn); - return; + goto cancel; } tcp_get_sndbuf(conn); @@ -2088,7 +2088,7 @@ static void tcp_conn_from_tap(struct ctx *c, sa_family_t af, tcp_get_sndbuf(conn); if (tcp_send_flag(c, conn, SYN | ACK)) - return; + goto cancel; conn_event(c, conn, TAP_SYN_ACK_SENT); } -- 2.45.2