Shepherd 0.9.0 ‘make-inetd-constructor’ can leak file descriptors

DoneSubmitted by Ludovic Courtès.
Details
2 participants
  • Ludovic Courtès
  • Ludovic Courtès
Owner
unassigned
Severity
important
L
L
Ludovic Courtès wrote on 2 May 16:52 +0200
(address . bug-guix@gnu.org)
87fslsrnqi.fsf@inria.fr
‘make-inetd-constructor’ creates a socket and then calls bind(2) on it.

Toggle snippet (9 lines)
(lambda args
(let ((sock (non-blocking-port
(socket (sockaddr:fam address) socket-style 0)))
[…])
(setsockopt sock SOL_SOCKET SO_REUSEADDR 1)
[…]
(bind sock address)

If bind(2) fails, for instance with EADDRINUSE, the socket it created is
leaked; it will be closed “eventually”, when GC runs, but that could
happen much later.

Solution is to use some sort of ‘unwind-protect’ and close it upon
exception.

Ludo’.
L
L
Ludovic Courtès wrote on 2 May 22:49 +0200
control message for bug #55223
(address . control@debbugs.gnu.org)
87v8unr77i.fsf@gnu.org
severity 55223 important
quit
L
L
Ludovic Courtès wrote on 2 May 23:11 +0200
Re: bug#55223: Shepherd 0.9.0 ‘make-inetd-const ructor’ can leak file descriptors
(address . 55223-done@debbugs.gnu.org)
87h767r65q.fsf@gnu.org
Ludovic Courtès <ludovic.courtes@inria.fr> skribis:

Toggle quote (14 lines)
> ‘make-inetd-constructor’ creates a socket and then calls bind(2) on it.
>
> (lambda args
> (let ((sock (non-blocking-port
> (socket (sockaddr:fam address) socket-style 0)))
> […])
> (setsockopt sock SOL_SOCKET SO_REUSEADDR 1)
> […]
> (bind sock address)
>
> If bind(2) fails, for instance with EADDRINUSE, the socket it created is
> leaked; it will be closed “eventually”, when GC runs, but that could
> happen much later.

Fixed in Shepherd commit b4a30a309f0e9451a671691b19fa7a5e1ef92b69.

Ludo’.
Closed
?
Your comment

This issue is archived.

To comment on this conversation send email to 55223@debbugs.gnu.org