lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Wed, 26 Mar 2014 07:09:32 -0700
From:	Eric Dumazet <eric.dumazet@...il.com>
To:	Rainer Weikusat <rweikusat@...ileactivedefense.com>
Cc:	David Miller <davem@...emloft.net>, netdev <netdev@...r.kernel.org>
Subject: Re: [PATCH] net: unix: non blocking recvmsg() should not return
 -EINTR

On Wed, 2014-03-26 at 13:17 +0000, Rainer Weikusat wrote:
> Eric Dumazet <eric.dumazet@...il.com> writes:
> > From: Eric Dumazet <edumazet@...gle.com>
> >
> > Some applications didn't expect recvmsg() on a non blocking socket
> > could return -EINTR. This possibility was added as a side effect
> > of commit b3ca9b02b00704 ("net: fix multithreaded signal handling in
> > unix recv routines").
> >
> > To hit this bug, you need to be a bit unlucky, as the u->readlock
> > mutex is usually held for very small periods.
> 
> This would mean that 'some applications' are broken, cf
> 
> [EAGAIN] or [EWOULDBLOCK]
>     The socket's file descriptor is marked O_NONBLOCK and no data is
>     waiting to be received; or MSG_OOB is set and no out-of-band data is
>     available and either the socket's file descriptor is marked
>     O_NONBLOCK or the socket does not support blocking to await
>     out-of-band data.
> 
> [EINTR]
>     This function was interrupted by a signal before any data was
>     available.
>     
> http://pubs.opengroup.org/onlinepubs/9699919799/functions/recvmsg.html
> 
> and
> 
>  EAGAIN or EWOULDBLOCK
>               The socket is marked nonblocking and the receive operation
>               would block, or a receive timeout had been set and the
>               timeout expired before data was received.
> 
>  EINTR  The receive was interrupted by delivery of a signal before any
>         data were available; see signal(7).
> 
> [3.27 Linux recvmsg(2)]
> 
> since the function was interrupted before any data was available and it
> is unknown if the condition supposed to be signalled by EAGAIN had
> otherwise occurred.
> 
> A correct 'fix'/ workaround would seem to be using mutex_trylock and
> abort execution immediately with -EAGAIN in case the operation had to
> wait for the lock, although this is inconsistent with the usual
> semantics of 'blocking' which implies that the operation may take an
> indefinite amount of time because it waits for an external event which
> might never occur.

Before your patch, -EAGAIN was delivered, -EINTR was _never_ delivered.

Thats a fact. If you read the manpage, its in this order :

When using a nonblocking socket, and no data is available, EAGAIN or
EWOULDBLOCK is delivered.

-EINTR is not expected from a non blocking system call. Period.

After your patch, -EINTR might be delivered, and it breaks legacy
applications.




Please send a fix if you think you have a better one, thanks


--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ