]> git.baikalelectronics.ru Git - kernel.git/commit
af_unix: fix regression in read after shutdown
authorVincent Whitchurch <vincent.whitchurch@axis.com>
Fri, 19 Nov 2021 12:05:21 +0000 (13:05 +0100)
committerDavid S. Miller <davem@davemloft.net>
Sat, 20 Nov 2021 15:10:30 +0000 (15:10 +0000)
commite18920ae331104f50bbadce1534c2a2e242424c4
tree4966bb9cf1b8b1b6a46b7cc25c3ca507c5851c8d
parentbb3a50cd41c1dc8d4a4336ddf7d1884d38d3d517
af_unix: fix regression in read after shutdown

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 8cee822891d74fda ("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: cdb4ba507fb4db1b0a3 ("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 <vincent.whitchurch@axis.com>
Tested-by: Casey Schaufler <casey@schaufler-ca.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/unix/af_unix.c