* [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: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
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