Received: by 2002:a05:6359:6284:b0:131:369:b2a3 with SMTP id se4csp61733rwb; Fri, 4 Aug 2023 09:11:16 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHd5np1uaKxneZ4GZAbzV7H55mO3EPXfHxVmEbslmLKZ5+S+xXcG+ReOu6DOdJpbPYXBHNQ X-Received: by 2002:aa7:c7cf:0:b0:522:cc6c:e25e with SMTP id o15-20020aa7c7cf000000b00522cc6ce25emr1953213eds.3.1691165476019; Fri, 04 Aug 2023 09:11:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691165476; cv=none; d=google.com; s=arc-20160816; b=ITTsPTvUlioxRsgQxK+/+nmAZt2RnqoJnDQMm4P0cyCkqTApNhrJ2mu7nKfw6RW8Mh N+Hk0Nc0diEjCtBAH80Bg/Nr1nXG2Ig0mzPwlM6S6vrQFCRHGTjtkHvyx0FscBC59Ot/ /l5uB2IVVSWNOqPhTP/F8SaKYg8aJp3iGnJSkr6Fa9+8rYlk9u0jMvGvuKKVj3zCgCfO r+/lb8CYHJi6dtZeEHfzpximL6mzD+QKMyhMxAjuj/kVd7/E9HJUyOGUXwzqyfoat8Xc zKSctuy6aq1O+nUFJaCzEjd116UJBkDxLy4VJH4M4dEVqlUcjt0564NBONpwMPe1cYez +2rA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=/6TKiUoe55IIrqSia7IbdrPQay+jmTfT+IM/4+k+lpc=; fh=gf5cyT5X5PIjnDhZPCnpUxmKEJ9RUPZ+WrJnaMrXMqI=; b=UGzO8UZUC0InAfyj0KbmAGn8aeqDR/wSZpnVLnP5+91GqXmqTAwCMTLDtW1iVjxNNu DlHPLaSpl7jgoxIW6VR7LIb89Y4G8npZI6Is1uLxRTlOmr0fu72dp8fItjK25AHmb0Cx 4i86/YhYNGXy5p9fhfC5tkbimUw+ZQrdpkUOfqCIQwh557eX1y5YcNXCOD9Ou8HiSTST CZ7YwxGt9zf1Nros1pyI5zYW4KmOghdhWHPhF2f+SmaTq9gF0fdrIcPiurbzovlf5kac g1wkFQkQIRaCssZDs4aRwxbNXMFwSqasJO2sZZb8C/yDvkyrnqX5eXUuUbl0o5glTXcO PeLA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="eIJX/cfG"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e12-20020aa7d7cc000000b005231ebef9aasi911989eds.581.2023.08.04.09.10.43; Fri, 04 Aug 2023 09:11:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="eIJX/cfG"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231539AbjHDO3Y (ORCPT + 99 others); Fri, 4 Aug 2023 10:29:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52090 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231749AbjHDO3S (ORCPT ); Fri, 4 Aug 2023 10:29:18 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A497F46B3 for ; Fri, 4 Aug 2023 07:28:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1691159312; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=/6TKiUoe55IIrqSia7IbdrPQay+jmTfT+IM/4+k+lpc=; b=eIJX/cfGxTi17lgseDYrTmfI1jhQ1pRy1gjjFtAzQ7XPoEuc5ImPCeTvJLFLbXhAjlESHR nuaQuhPhMYFI/hzw1f0wIS+5Ei5MN/4E8GaULw/1EtnwOokrt14JBn1y6g3GLfHUAJG5jP S/Bj5QIZGuEImhC+r2T8r4ichUXi7nk= Received: from mail-qv1-f71.google.com (mail-qv1-f71.google.com [209.85.219.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-472-xFEcPNXaPaynC6HRqw_0qg-1; Fri, 04 Aug 2023 10:28:31 -0400 X-MC-Unique: xFEcPNXaPaynC6HRqw_0qg-1 Received: by mail-qv1-f71.google.com with SMTP id 6a1803df08f44-63d566837d3so24118336d6.3 for ; Fri, 04 Aug 2023 07:28:31 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691159311; x=1691764111; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=/6TKiUoe55IIrqSia7IbdrPQay+jmTfT+IM/4+k+lpc=; b=k6E0lUer5ZrjNSrZzFtbmoLvFmLuFm2uJ40YsW9RAAfnThg7Auigm8aOWnDfpyATiC qTUQCmDHTXC9qO3PVIiNfrzao0qYEyF/R3pEbsOHejlIpblo8GWu+KMeT9GGD9WeqNb+ DgQyWgEyVhv8VkFvjKQNwnhTLvRee12lbXCEcGxp36CNxK8axE5UuiYRXR1TPbo0dZD1 VfjqUPqfDAHD2l5A/P5ZkK+Uk6hKNv+kJPBw2A46bWoW6Ir5diNvYujSiz2jTco8YxNk 2oCQfAS3kCBxrBoo+LgFcs76CW7IvK1uuvKFV26XifnQJqkqdVlQXhmeuBCVEfI3OK9F YehA== X-Gm-Message-State: AOJu0YyVmMTScoaBnFRgCWK0PUADPpcKof6ysqCexvM/2AbPkpg3kAUL ON2lXgL4QK6Kbzm61b5M33e9xINH88Ngz4d/+9J7VUux9qdCK+klXAH0eorllBp1I7Q7FL32YGv NJvhhv5LewQ13gFo36bopcG2r X-Received: by 2002:a0c:9d04:0:b0:63c:eb1e:e004 with SMTP id m4-20020a0c9d04000000b0063ceb1ee004mr1771018qvf.3.1691159310917; Fri, 04 Aug 2023 07:28:30 -0700 (PDT) X-Received: by 2002:a0c:9d04:0:b0:63c:eb1e:e004 with SMTP id m4-20020a0c9d04000000b0063ceb1ee004mr1770996qvf.3.1691159310619; Fri, 04 Aug 2023 07:28:30 -0700 (PDT) Received: from sgarzare-redhat (host-82-57-51-214.retail.telecomitalia.it. [82.57.51.214]) by smtp.gmail.com with ESMTPSA id d30-20020a0caa1e000000b00637abbfaac9sm698043qvb.98.2023.08.04.07.28.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Aug 2023 07:28:30 -0700 (PDT) Date: Fri, 4 Aug 2023 16:28:25 +0200 From: Stefano Garzarella To: Arseniy Krasnov Cc: Arseniy Krasnov , Stefan Hajnoczi , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , "Michael S. Tsirkin" , Jason Wang , Bobby Eshleman , kvm@vger.kernel.org, virtualization@lists.linux-foundation.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, kernel@sberdevices.ru Subject: Re: [RFC PATCH v1 1/2] vsock: send SIGPIPE on write to shutdowned socket Message-ID: References: <20230801141727.481156-1-AVKrasnov@sberdevices.ru> <20230801141727.481156-2-AVKrasnov@sberdevices.ru> <44fef482-579a-fed6-6e8c-d400546285fc@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1; format=flowed Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <44fef482-579a-fed6-6e8c-d400546285fc@gmail.com> X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE, URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Aug 04, 2023 at 03:46:47PM +0300, Arseniy Krasnov wrote: >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 >>> --- >>> 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). Okay, but I think we should do also for SEQPACKET: https://pubs.opengroup.org/onlinepubs/009696699/functions/xsh_chap02_10.html In 2.10.6 Socket Types: "The SOCK_SEQPACKET socket type is similar to the SOCK_STREAM type, and is also connection-oriented. The only difference between these types is that record boundaries ..." Then in 2.10.14 Signals: "The SIGPIPE signal shall be sent to a thread that attempts to send data on a socket that is no longer able to send. In addition, the send operation fails with the error [EPIPE]." It's honestly not super clear, but I assume the problem is similar with seqpacket since it's connection-oriented, or did I miss something? For example in sctp_sendmsg() IIUC we raise a SIGPIPE regardless of whether the socket is STREAM or SEQPACKET. > >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. I'm okay calling 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. Do you mean that it is NOT related to this patchset? Thanks, Stefano