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]
Message-ID: <44fef482-579a-fed6-6e8c-d400546285fc@gmail.com>
Date: Fri, 4 Aug 2023 15:46:47 +0300
From: Arseniy Krasnov <oxffffaa@...il.com>
To: Stefano Garzarella <sgarzare@...hat.com>,
 Arseniy Krasnov <AVKrasnov@...rdevices.ru>
Cc: Stefan Hajnoczi <stefanha@...hat.com>,
 "David S. Miller" <davem@...emloft.net>, Eric Dumazet <edumazet@...gle.com>,
 Jakub Kicinski <kuba@...nel.org>, Paolo Abeni <pabeni@...hat.com>,
 "Michael S. Tsirkin" <mst@...hat.com>, Jason Wang <jasowang@...hat.com>,
 Bobby Eshleman <bobby.eshleman@...edance.com>, kvm@...r.kernel.org,
 virtualization@...ts.linux-foundation.org, netdev@...r.kernel.org,
 linux-kernel@...r.kernel.org, kernel@...rdevices.ru
Subject: Re: [RFC PATCH v1 1/2] vsock: send SIGPIPE on write to shutdowned
 socket

Hi Stefano,

On 02.08.2023 10:46, Stefano Garzarella wrote:
> On Tue, Aug 01, 2023 at 05:17:26PM +0300, Arseniy Krasnov wrote:
>> POSIX requires to send SIGPIPE on write to SOCK_STREAM socket which was
>> shutdowned with SHUT_WR flag or its peer was shutdowned with SHUT_RD
>> flag. Also we must not send SIGPIPE if MSG_NOSIGNAL flag is set.
>>
>> Signed-off-by: Arseniy Krasnov <AVKrasnov@...rdevices.ru>
>> ---
>> net/vmw_vsock/af_vsock.c | 3 +++
>> 1 file changed, 3 insertions(+)
>>
>> diff --git a/net/vmw_vsock/af_vsock.c b/net/vmw_vsock/af_vsock.c
>> index 020cf17ab7e4..013b65241b65 100644
>> --- a/net/vmw_vsock/af_vsock.c
>> +++ b/net/vmw_vsock/af_vsock.c
>> @@ -1921,6 +1921,9 @@ static int vsock_connectible_sendmsg(struct socket *sock, struct msghdr *msg,
>>             err = total_written;
>>     }
>> out:
>> +    if (sk->sk_type == SOCK_STREAM)
>> +        err = sk_stream_error(sk, msg->msg_flags, err);
> 
> Do you know why we don't need this for SOCK_SEQPACKET and SOCK_DGRAM?

Yes, here is my explanation:

This function checks that input error is SIGPIPE, and if so it sends SIGPIPE to the 'current' thread
(except case when MSG_NOSIGNAL flag is set). This behaviour is described in POSIX:

Page 367 (description of defines from sys/socket.h):
MSG_NOSIGNAL: No SIGPIPE generated when an attempt to send is made on a stream-
oriented socket that is no longer connected.

Page 497 (description of SOCK_STREAM):
A SIGPIPE signal is raised if a thread sends on a broken stream (one that is
no longer connected).

Page 1802 (description of 'send()' call):
MSG_NOSIGNAL

Requests not to send the SIGPIPE signal if an attempt to
send is made on a stream-oriented socket that is no
longer connected. The [EPIPE] error shall still be
returned

And the same for 'sendto()' and 'sendmsg()'

Link to the POSIX document:
https://www.open-std.org/jtc1/sc22/open/n4217.pdf

TCP (I think we must rely on it), KCM, SMC sockets (all of them are stream) work in the same
way by calling this function. AF_UNIX also works in the same way, but it implements SIGPIPE handling
without this function.

The only thing that confused me a little bit, that sockets above returns EPIPE when
we have only SEND_SHUTDOWN set, but for AF_VSOCK EPIPE is returned for RCV_SHUTDOWN
also, but I think it is related to this patchset.


Thanks, Arseniy

> 
> Thanks,
> Stefano
> 
>> +
>>     release_sock(sk);
>>     return err;
>> }
>> -- 
>> 2.25.1
>>
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ