Re: [Libguestfs] [PATCH libnbd v2 0/3] Use GNUTLS_NO_SIGNAL if available

2022-07-28 Thread Richard W.M. Jones
On Thu, Jul 28, 2022 at 12:16:15PM -0500, Eric Blake wrote: > On Thu, Jul 28, 2022 at 03:19:07PM +0100, Richard W.M. Jones wrote: > > V1 was here: > > > > https://listman.redhat.com/archives/libguestfs/2022-July/029545.html > > > > The original second patch is now upstream. > > > > As well as

Re: [Libguestfs] [PATCH libnbd v2 1/3] lib/crypto: Use GNUTLS_NO_SIGNAL if available

2022-07-28 Thread Richard W.M. Jones
On Thu, Jul 28, 2022 at 12:12:37PM -0500, Eric Blake wrote: > On Thu, Jul 28, 2022 at 03:19:08PM +0100, Richard W.M. Jones wrote: > > libnbd has long used MSG_NOSIGNAL to avoid receiving SIGPIPE if we > > accidentally write on a closed socket, which is a nice alternative to > > using a SIGPIPE

Re: [Libguestfs] [PATCH libnbd v2 0/3] Use GNUTLS_NO_SIGNAL if available

2022-07-28 Thread Eric Blake
On Thu, Jul 28, 2022 at 03:19:07PM +0100, Richard W.M. Jones wrote: > V1 was here: > > https://listman.redhat.com/archives/libguestfs/2022-July/029545.html > > The original second patch is now upstream. > > As well as updating 1/3 with the feedback, I added two new patches. > > This has been

Re: [Libguestfs] [PATCH libnbd v2 1/3] lib/crypto: Use GNUTLS_NO_SIGNAL if available

2022-07-28 Thread Eric Blake
On Thu, Jul 28, 2022 at 03:19:08PM +0100, Richard W.M. Jones wrote: > libnbd has long used MSG_NOSIGNAL to avoid receiving SIGPIPE if we > accidentally write on a closed socket, which is a nice alternative to > using a SIGPIPE signal handler. However with TLS connections, gnutls > did not use

[Libguestfs] [PATCH libnbd v2 3/3] docs: Document signal handling

2022-07-28 Thread Richard W.M. Jones
Document that libnbd doesn't set signal handlers, use of MSG_NOSIGNAL or SO_NOSIGPIPE, and optional registration of a global SIGPIPE handler. --- docs/libnbd.pod | 12 1 file changed, 12 insertions(+) diff --git a/docs/libnbd.pod b/docs/libnbd.pod index 7cb2a48473..dd880c3bff 100644

[Libguestfs] [PATCH libnbd v2 2/3] generator: Set SO_NOSIGPIPE on sockets

2022-07-28 Thread Richard W.M. Jones
If the platform supports it, set the SO_NOSIGPIPE socket option on sockets that we create in nbd_connect_* functions (except nbd_connect_socket where the caller gets to choose). Link: https://www.doof.me.uk/2020/09/23/sigpipe-and-how-to-ignore-it/ --- generator/states-connect.c | 17

[Libguestfs] [PATCH libnbd v2 0/3] Use GNUTLS_NO_SIGNAL if available

2022-07-28 Thread Richard W.M. Jones
V1 was here: https://listman.redhat.com/archives/libguestfs/2022-July/029545.html The original second patch is now upstream. As well as updating 1/3 with the feedback, I added two new patches. This has been compile tested on FreeBSD and doesn't seem to break anything, but testing if it

[Libguestfs] [PATCH libnbd v2 1/3] lib/crypto: Use GNUTLS_NO_SIGNAL if available

2022-07-28 Thread Richard W.M. Jones
libnbd has long used MSG_NOSIGNAL to avoid receiving SIGPIPE if we accidentally write on a closed socket, which is a nice alternative to using a SIGPIPE signal handler. However with TLS connections, gnutls did not use this flag and so programs using libnbd + TLS would receive SIGPIPE in some

Re: [Libguestfs] [PATCH libnbd 1/2] lib/crypto: Use GNUTLS_NO_SIGNAL if available

2022-07-28 Thread Laszlo Ersek
On 07/28/22 15:01, Richard W.M. Jones wrote: > On Thu, Jul 28, 2022 at 02:57:49PM +0200, Laszlo Ersek wrote: >> On 07/27/22 18:30, Richard W.M. Jones wrote: >>> libnbd has long used MSG_NOSIGNAL to avoid receiving SIGPIPE if we >>> accidentally write on a closed socket, which is a nice alternative

Re: [Libguestfs] [PATCH libnbd 1/2] lib/crypto: Use GNUTLS_NO_SIGNAL if available

2022-07-28 Thread Richard W.M. Jones
On Thu, Jul 28, 2022 at 02:57:49PM +0200, Laszlo Ersek wrote: > On 07/27/22 18:30, Richard W.M. Jones wrote: > > libnbd has long used MSG_NOSIGNAL to avoid receiving SIGPIPE if we > > accidentally write on a closed socket, which is a nice alternative to > > using a SIGPIPE signal handler. However

Re: [Libguestfs] [PATCH libnbd 2/2] lib/crypto.c: Ignore TLS premature termination after write shutdown

2022-07-28 Thread Laszlo Ersek
On 07/27/22 18:30, Richard W.M. Jones wrote: > qemu-nbd doesn't call gnutls_bye to cleanly shut down the connection > after we send NBD_CMD_DISC. When copying from a qemu-nbd server (or > any operation which calls nbd_shutdown) you will see errors like this: > > $ nbdcopy

Re: [Libguestfs] [PATCH libnbd 2/2] lib/crypto.c: Ignore TLS premature termination after write shutdown

2022-07-28 Thread Richard W.M. Jones
On Thu, Jul 28, 2022 at 07:26:16AM -0500, Eric Blake wrote: > On Wed, Jul 27, 2022 at 05:30:59PM +0100, Richard W.M. Jones wrote: > > qemu-nbd doesn't call gnutls_bye to cleanly shut down the connection > > after we send NBD_CMD_DISC. When copying from a qemu-nbd server (or > > any operation

Re: [Libguestfs] [PATCH libnbd 1/2] lib/crypto: Use GNUTLS_NO_SIGNAL if available

2022-07-28 Thread Laszlo Ersek
On 07/27/22 18:30, Richard W.M. Jones wrote: > libnbd has long used MSG_NOSIGNAL to avoid receiving SIGPIPE if we > accidentally write on a closed socket, which is a nice alternative to > using a SIGPIPE signal handler. However with TLS connections, gnutls > did not use this flag and so programs

Re: [Libguestfs] [PATCH libnbd 1/2] lib/crypto: Use GNUTLS_NO_SIGNAL if available

2022-07-28 Thread Richard W.M. Jones
On Thu, Jul 28, 2022 at 07:22:23AM -0500, Eric Blake wrote: > On Wed, Jul 27, 2022 at 05:30:58PM +0100, Richard W.M. Jones wrote: > > libnbd has long used MSG_NOSIGNAL to avoid receiving SIGPIPE if we > > accidentally write on a closed socket, which is a nice alternative to > > using a SIGPIPE

Re: [Libguestfs] [PATCH libnbd 2/2] lib/crypto.c: Ignore TLS premature termination after write shutdown

2022-07-28 Thread Eric Blake
On Wed, Jul 27, 2022 at 05:30:59PM +0100, Richard W.M. Jones wrote: > qemu-nbd doesn't call gnutls_bye to cleanly shut down the connection > after we send NBD_CMD_DISC. When copying from a qemu-nbd server (or > any operation which calls nbd_shutdown) you will see errors like this: > > $

Re: [Libguestfs] [PATCH libnbd 1/2] lib/crypto: Use GNUTLS_NO_SIGNAL if available

2022-07-28 Thread Eric Blake
On Wed, Jul 27, 2022 at 05:30:58PM +0100, Richard W.M. Jones wrote: > libnbd has long used MSG_NOSIGNAL to avoid receiving SIGPIPE if we > accidentally write on a closed socket, which is a nice alternative to > using a SIGPIPE signal handler. However with TLS connections, gnutls Especially since