Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2BE49C4332F for ; Fri, 19 Nov 2021 21:16:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234896AbhKSVTG (ORCPT ); Fri, 19 Nov 2021 16:19:06 -0500 Received: from sonic304-28.consmr.mail.ne1.yahoo.com ([66.163.191.154]:44080 "EHLO sonic304-28.consmr.mail.ne1.yahoo.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234738AbhKSVTF (ORCPT ); Fri, 19 Nov 2021 16:19:05 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1637356563; bh=vFJtUdvDjuctXd1U2IkO+EN/0QC8+ex4lFMDF5hvvuM=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From:Subject:Reply-To; b=V4r/XpD1uud2QawIyawkM5dhY3jGitPOaLGlFPWIsXPnx+Wu6GRImD70umGpFPu+LVBBg3fUk//ULNxwGKlOvQ0cGmlmhnCZ1vQpuuSbtDcpChSB+GLcTd9PTYocGYUGFSzWq8+gwIAvfjd+QJWwWec+/KImbQhOW3Ilb0CetvFvsl/JszZJmdZi+lhfzxeuPWm3OXpLDoAZaXrw0qX94X8fo8IaOCWg5Ucq/SD1/e/l4Jt5Z/nUU3ovQ0poy/AtUW90s/q3zNkc9T8XI8vUgNGQBZoZ5bf4MBwnj5AYjLX6G90l+Pk6mvEe6XdwV+hI5TaRoW2hnOUh4yRyj6hA9g== X-SONIC-DKIM-SIGN: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1637356563; bh=5CzMVBtMTRZgC201e8LfM4zRbB+hj2BfNa5O1wtVV0O=; h=X-Sonic-MF:Date:Subject:To:From:From:Subject; b=psiG8CaUU/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1u3mef2jYeCyIIkcIaiw WC1BGN2v69pMym0Zfvpjx8VNBWFn3vEoJZvxPjcDEKIV9atg9jnwkxp7SZCg4wDAywv6BPRJxHNy 4snx_BUhuhU_XnncfCkS0Hy._3PFZazU5vFesutpo4PV1H7GokOIaAhOHvq6JazOCNavwZlQ1F3x 86jPVwD41quk_s3Ie9x1n60Gd1LJvQzqCj3xOHD4.BD6NbC.ZdyVBnueZRtsK5T_85uSr5iVh7dX QjIwwFe5HyCKJJNS74AUpN3JvFEZTcc35B.sN.G5B1B4EX0LSDu_Z693uFPnibK4BTu9M.TCBNYg Hayd8T7wtA6Zs0AbRQl6uHCicfZx7csSsHEQKL_789bafRHcyQxpV.9gG_qPUOm5BFo1FYulQ1BH GOW6V_eNNnOqQovcNyQ9y4RCOjNTT3Mkds.Rsh2MvqvF99NpAQWzPFHbUtqzxThuT3s9Wm0taevU DvdnUqAds88aejLPmJItzeYLM_Bk8VbZ4H9y3yv4.iIwEtGdysTRCgFKFt1Ahp_l.gN3gXFgl9A- - X-Sonic-MF: Received: from sonic.gate.mail.ne1.yahoo.com by sonic304.consmr.mail.ne1.yahoo.com with HTTP; Fri, 19 Nov 2021 21:16:03 +0000 Received: by kubenode502.mail-prod1.omega.bf1.yahoo.com (VZM Hermes SMTP Server) with ESMTPA ID 66df3053efa0f9cbcd5295357ddbd602; Fri, 19 Nov 2021 21:15:58 +0000 (UTC) Message-ID: Date: Fri, 19 Nov 2021 13:15:54 -0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.3.0 Subject: Re: [PATCH] af_unix: fix regression in read after shutdown Content-Language: en-US To: Vincent Whitchurch , "David S. Miller" , Jakub Kicinski , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko Cc: kernel@axis.com, Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh , Jiang Wang , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, bpf@vger.kernel.org, Casey Schaufler References: <20211119120521.18813-1-vincent.whitchurch@axis.com> From: Casey Schaufler In-Reply-To: <20211119120521.18813-1-vincent.whitchurch@axis.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Mailer: WebService/1.1.19306 mail.backend.jedi.jws.acl:role.jedi.acl.token.atz.jws.hermes.yahoo Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 11/19/2021 4:05 AM, Vincent Whitchurch wrote: > On kernels before v5.15, calling read() on a unix socket after > shutdown(SHUT_RD) or shutdown(SHUT_RDWR) would return the data > previously written or EOF. But now, while read() after > shutdown(SHUT_RD) still behaves the same way, read() after > shutdown(SHUT_RDWR) always fails with -EINVAL. > > This behaviour change was apparently inadvertently introduced as part of > a bug fix for a different regression caused by the commit adding sockmap > support to af_unix, commit 94531cfcbe79c359 ("af_unix: Add > unix_stream_proto for sockmap"). Those commits, for unclear reasons, > started setting the socket state to TCP_CLOSE on shutdown(SHUT_RDWR), > while this state change had previously only been done in > unix_release_sock(). > > Restore the original behaviour. The sockmap tests in > tests/selftests/bpf continue to pass after this patch. > > Fixes: d0c6416bd7091647f60 ("unix: Fix an issue in unix_shutdown causing the other end read/write failures") > Link: https://lore.kernel.org/lkml/20211111140000.GA10779@axis.com/ > Signed-off-by: Vincent Whitchurch This change passes the test case that lead to the original problem report. Tested-by: Casey Schaufler > --- > net/unix/af_unix.c | 3 --- > 1 file changed, 3 deletions(-) > > diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c > index 78e08e82c08c..b0bfc78e421c 100644 > --- a/net/unix/af_unix.c > +++ b/net/unix/af_unix.c > @@ -2882,9 +2882,6 @@ static int unix_shutdown(struct socket *sock, int mode) > > unix_state_lock(sk); > sk->sk_shutdown |= mode; > - if ((sk->sk_type == SOCK_STREAM || sk->sk_type == SOCK_SEQPACKET) && > - mode == SHUTDOWN_MASK) > - sk->sk_state = TCP_CLOSE; > other = unix_peer(sk); > if (other) > sock_hold(other);