public inbox for [email protected]
 help / color / mirror / Atom feed
* [PATCH] slc: Fix file descriptor leak
@ 2022-06-06  2:27 Ammar Faizi
  2022-06-06  2:28 ` Ammar Faizi
  2022-06-06  2:54 ` Alviro Iskandar Setiawan
  0 siblings, 2 replies; 10+ messages in thread
From: Ammar Faizi @ 2022-06-06  2:27 UTC (permalink / raw)
  To: Arthur Lapz; +Cc: GNU/Weeb Mailing List, Ammar Faizi

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

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [PATCH] slc: Fix file descriptor leak
  2022-06-06  2:27 [PATCH] slc: Fix file descriptor leak Ammar Faizi
@ 2022-06-06  2:28 ` Ammar Faizi
  2022-06-06  2:42   ` Arthur Lapz
  2022-06-06  2:54 ` Alviro Iskandar Setiawan
  1 sibling, 1 reply; 10+ messages in thread
From: Ammar Faizi @ 2022-06-06  2:28 UTC (permalink / raw)
  To: Arthur Lapz; +Cc: GNU/Weeb Mailing List

On 6/6/22 9:27 AM, Ammar Faizi wrote:
> 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]>
> ---

@rlapz, can you test this patch and see if it's a cure?

-- 
Ammar Faizi

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] slc: Fix file descriptor leak
  2022-06-06  2:28 ` Ammar Faizi
@ 2022-06-06  2:42   ` Arthur Lapz
  2022-06-06  2:46     ` Ammar Faizi
  0 siblings, 1 reply; 10+ messages in thread
From: Arthur Lapz @ 2022-06-06  2:42 UTC (permalink / raw)
  To: Ammar Faizi; +Cc: GNU/Weeb Mailing List

On Mon, 2022-06-06 at 09:28 +0700, Ammar Faizi wrote:
> On 6/6/22 9:27 AM, Ammar Faizi wrote:
> > 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]>
> > ---
> 
> @rlapz, can you test this patch and see if it's a cure?
> 

Unfortunately, this patch isn't a cure (still the same). :(
-- 
Arthur Lapz

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] slc: Fix file descriptor leak
  2022-06-06  2:42   ` Arthur Lapz
@ 2022-06-06  2:46     ` Ammar Faizi
  2022-06-06  2:51       ` Ammar Faizi
  0 siblings, 1 reply; 10+ messages in thread
From: Ammar Faizi @ 2022-06-06  2:46 UTC (permalink / raw)
  To: Arthur Lapz; +Cc: GNU/Weeb Mailing List

On 6/6/22 9:42 AM, Arthur Lapz wrote:
> Unfortunately, this patch isn't a cure (still the same). :(

Not sure what is going on here, but the file descriptor bug
did really exist and is fixed by that patch.

The current SLC server looks like this:

   The "lost client" has been connected!
   fd_in is down
   send: Connection reset by peer
   send: Broken pipe
   send: Broken pipe
   send: Broken pipe
   send: Broken pipe
   send: Broken pipe
   send: Broken pipe
   send: Broken pipe
   send: Broken pipe
   send: Broken pipe
   send: Broken pipe
   send: Broken pipe
   send: Broken pipe
   send: Broken pipe

I will investigate it later after doing some work.

-- 
Ammar Faizi

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] slc: Fix file descriptor leak
  2022-06-06  2:46     ` Ammar Faizi
@ 2022-06-06  2:51       ` Ammar Faizi
  2022-06-06  2:56         ` Arthur Lapz
  0 siblings, 1 reply; 10+ messages in thread
From: Ammar Faizi @ 2022-06-06  2:51 UTC (permalink / raw)
  To: Arthur Lapz; +Cc: GNU/Weeb Mailing List

On 6/6/22 9:46 AM, Ammar Faizi wrote:
> On 6/6/22 9:42 AM, Arthur Lapz wrote:
>> Unfortunately, this patch isn't a cure (still the same). :(
[...]
> 
> I will investigate it later after doing some work.
> 

I think this is now fixed. I can access:

    https://test-rlapz.gnuweeb.org/

perfectly fine. How did you test this?

-- 
Ammar Faizi

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] slc: Fix file descriptor leak
  2022-06-06  2:27 [PATCH] slc: Fix file descriptor leak Ammar Faizi
  2022-06-06  2:28 ` Ammar Faizi
@ 2022-06-06  2:54 ` Alviro Iskandar Setiawan
  2022-06-06  3:02   ` Ammar Faizi
  1 sibling, 1 reply; 10+ messages in thread
From: Alviro Iskandar Setiawan @ 2022-06-06  2:54 UTC (permalink / raw)
  To: Ammar Faizi; +Cc: Arthur Lapz, GNU/Weeb Mailing List

Lmao, that's a silly bug. The fix looks good to me.

Reviewed-by: Alviro Iskandar Setiawan <[email protected]>

tq

-- Viro

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] slc: Fix file descriptor leak
  2022-06-06  2:51       ` Ammar Faizi
@ 2022-06-06  2:56         ` Arthur Lapz
  2022-06-06  2:57           ` Ammar Faizi
  0 siblings, 1 reply; 10+ messages in thread
From: Arthur Lapz @ 2022-06-06  2:56 UTC (permalink / raw)
  To: Ammar Faizi; +Cc: GNU/Weeb Mailing List

On Mon, 2022-06-06 at 09:51 +0700, Ammar Faizi wrote:
> On 6/6/22 9:46 AM, Ammar Faizi wrote:
> > On 6/6/22 9:42 AM, Arthur Lapz wrote:
> > > Unfortunately, this patch isn't a cure (still the same). :(
> [...]
> > 
> > I will investigate it later after doing some work.
> > 
> 
> I think this is now fixed. I can access:
> 
>     https://test-rlapz.gnuweeb.org/
> 
> perfectly fine. How did you test this?
> 
Yes it is.

> How did you test this?
I did nothing.

I guess it worked because you have restarted the `slc server`
-- 
Arthur Lapz

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] slc: Fix file descriptor leak
  2022-06-06  2:56         ` Arthur Lapz
@ 2022-06-06  2:57           ` Ammar Faizi
  2022-06-06  2:59             ` Arthur Lapz
  0 siblings, 1 reply; 10+ messages in thread
From: Ammar Faizi @ 2022-06-06  2:57 UTC (permalink / raw)
  To: Arthur Lapz; +Cc: GNU/Weeb Mailing List

On 6/6/22 9:56 AM, Arthur Lapz wrote:
>> How did you test this?
> I did nothing.
> 
> I guess it worked because you have restarted the `slc server`

Yes, I have just restarted the SLC server. Do you have another
issue now?

-- 
Ammar Faizi

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] slc: Fix file descriptor leak
  2022-06-06  2:57           ` Ammar Faizi
@ 2022-06-06  2:59             ` Arthur Lapz
  0 siblings, 0 replies; 10+ messages in thread
From: Arthur Lapz @ 2022-06-06  2:59 UTC (permalink / raw)
  To: Ammar Faizi; +Cc: GNU/Weeb Mailing List

On Mon, 2022-06-06 at 09:57 +0700, Ammar Faizi wrote:
> On 6/6/22 9:56 AM, Arthur Lapz wrote:
> > > How did you test this?
> > I did nothing.
> > 
> > I guess it worked because you have restarted the `slc server`
> 
> Yes, I have just restarted the SLC server. Do you have another
> issue now?
> 
I don't have.
Thanks :3
-- 
Arthur Lapz

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] slc: Fix file descriptor leak
  2022-06-06  2:54 ` Alviro Iskandar Setiawan
@ 2022-06-06  3:02   ` Ammar Faizi
  0 siblings, 0 replies; 10+ messages in thread
From: Ammar Faizi @ 2022-06-06  3:02 UTC (permalink / raw)
  To: Alviro Iskandar Setiawan; +Cc: Arthur Lapz, GNU/Weeb Mailing List

On 6/6/22 9:54 AM, Alviro Iskandar Setiawan wrote:
> Reviewed-by: Alviro Iskandar Setiawan<[email protected]>

Pushed out with your Reviewed-by tag.

   https://github.com/ammarfaizi2/slc/commit/d406993c3fcbfb7f6a24264c911731505d310163

Thanks to Arthur for reporting.
Thanks to Alviro for reviewing.

-- 
Ammar Faizi

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2022-06-06  3:02 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-06-06  2:27 [PATCH] slc: Fix file descriptor leak Ammar Faizi
2022-06-06  2:28 ` 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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox