public inbox for [email protected]
 help / color / mirror / Atom feed
From: Ammar Faizi <[email protected]>
To: Arthur Lapz <[email protected]>
Cc: GNU/Weeb Mailing List <[email protected]>,
	Ammar Faizi <[email protected]>
Subject: [PATCH] slc: Fix file descriptor leak
Date: Mon,  6 Jun 2022 09:27:47 +0700	[thread overview]
Message-ID: <[email protected]> (raw)

Arthur Lapz reported that he is seeing a blocking socket from the
public client side after the app side has closed the connection.

This turned out that we haven't closed the SLC socket file descriptor:

```
     Isolated                              Server
     --------                              ------

      fd_app --                         -- fd_public_client
               |----[ SLC circuit ]----|
  fd_circuit --                         -- fd_circuit

```
After the app in the isolated client has closed its fd, we didn't close
the fd_app and fd_circuit. That's why the server is still sleeping,
waiting for any response from the isolated area.

This was just a typo in if statements that caused the close() paths were
not taken. Simply fix the typo. Change "==" to "!=".

Link: https://t.me/lostcontrol_s1/16737
Link: https://t.me/lostcontrol_s1/16739 # Reproducer
Fixes: 04a86adffa415e8365d27929bbb826028e00bfd3 ("Initial commit")
Reported-by: Arthur Lapz <[email protected]>
Signed-off-by: Ammar Faizi <[email protected]>
---
 slc.cpp | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/slc.cpp b/slc.cpp
index bd836cb..5fcdd93 100644
--- a/slc.cpp
+++ b/slc.cpp
@@ -600,9 +600,9 @@ out_free:
 
 	socket_bridge(fd_pa, fd_pb);
 out:
-	if (fd_pa == -1)
+	if (fd_pa != -1)
 		close(fd_pa);
-	if (fd_pb == -1)
+	if (fd_pb != -1)
 		close(fd_pb);
 	return NULL;
 }
-- 
Ammar Faizi

             reply	other threads:[~2022-06-06  2:27 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-06  2:27 Ammar Faizi [this message]
2022-06-06  2:28 ` [PATCH] slc: Fix file descriptor leak Ammar Faizi
2022-06-06  2:42   ` Arthur Lapz
2022-06-06  2:46     ` Ammar Faizi
2022-06-06  2:51       ` Ammar Faizi
2022-06-06  2:56         ` Arthur Lapz
2022-06-06  2:57           ` Ammar Faizi
2022-06-06  2:59             ` Arthur Lapz
2022-06-06  2:54 ` Alviro Iskandar Setiawan
2022-06-06  3:02   ` Ammar Faizi

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 \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    /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.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox