From: Jiang Wang <hidden> Date: 2021-10-04 23:26:14
Commit 94531cfcbe79 ("af_unix: Add unix_stream_proto for sockmap")
sets unix domain socket peer state to TCP_CLOSE
in unix_shutdown. This could happen when the local end is shutdown
but the other end is not. Then the other end will get read or write
failures which is not expected.
Fix the issue by setting the local state to shutdown.
Fixes: 94531cfcbe79 (af_unix: Add unix_stream_proto for sockmap)
Suggested-by: Cong Wang <redacted>
Reported-by: Casey Schaufler <casey@schaufler-ca.com>
Signed-off-by: Jiang Wang <redacted>
---
net/unix/af_unix.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
Commit 94531cfcbe79 ("af_unix: Add unix_stream_proto for sockmap")
sets unix domain socket peer state to TCP_CLOSE
in unix_shutdown. This could happen when the local end is shutdown
but the other end is not. Then the other end will get read or write
failures which is not expected.
Fix the issue by setting the local state to shutdown.
Fixes: 94531cfcbe79 (af_unix: Add unix_stream_proto for sockmap)
Suggested-by: Cong Wang <redacted>
Reported-by: Casey Schaufler <casey@schaufler-ca.com>
Signed-off-by: Jiang Wang <redacted>
This patch looks like it has fixed the problem. My test cases
are now getting expected results consistently. Please add any
or all of:
Tested-by: Casey Schaufler <casey@schaufler-ca.com>
Reviewed-by: Casey Schaufler <casey@schaufler-ca.com>
On Oct 4, 2021, at 5:04 PM, Casey Schaufler [off-list ref] wrote:
On 10/4/2021 4:25 PM, Jiang Wang wrote:
quoted
Commit 94531cfcbe79 ("af_unix: Add unix_stream_proto for sockmap")
sets unix domain socket peer state to TCP_CLOSE
in unix_shutdown. This could happen when the local end is shutdown
but the other end is not. Then the other end will get read or write
failures which is not expected.
Fix the issue by setting the local state to shutdown.
Fixes: 94531cfcbe79 (af_unix: Add unix_stream_proto for sockmap)
Suggested-by: Cong Wang <redacted>
Reported-by: Casey Schaufler <casey@schaufler-ca.com>
Signed-off-by: Jiang Wang <redacted>
This patch looks like it has fixed the problem. My test cases
are now getting expected results consistently. Please add any
or all of:
Tested-by: Casey Schaufler <casey@schaufler-ca.com>
Reviewed-by: Casey Schaufler <casey@schaufler-ca.com>
Hello:
This patch was applied to bpf/bpf.git (refs/heads/master):
On Mon, 4 Oct 2021 23:25:28 +0000 you wrote:
Commit 94531cfcbe79 ("af_unix: Add unix_stream_proto for sockmap")
sets unix domain socket peer state to TCP_CLOSE
in unix_shutdown. This could happen when the local end is shutdown
but the other end is not. Then the other end will get read or write
failures which is not expected.
Fix the issue by setting the local state to shutdown.
[...]
From: Vincent Whitchurch <hidden> Date: 2021-11-11 14:00:10
On Mon, Oct 04, 2021 at 11:25:28PM +0000, Jiang Wang wrote:
Commit 94531cfcbe79 ("af_unix: Add unix_stream_proto for sockmap")
sets unix domain socket peer state to TCP_CLOSE
in unix_shutdown. This could happen when the local end is shutdown
but the other end is not. Then the other end will get read or write
failures which is not expected.
Fix the issue by setting the local state to shutdown.
Fixes: 94531cfcbe79 (af_unix: Add unix_stream_proto for sockmap)
Suggested-by: Cong Wang <redacted>
Reported-by: Casey Schaufler <casey@schaufler-ca.com>
Signed-off-by: Jiang Wang <redacted>
This patch changed the behaviour of read(2) after a shutdown(2) on the
local end of a UDS. Before this patch, reading from a UDS after a local
shutdown(SHUT_RDWR) would return the data written or EOF if there is no
data, but now it always returns -EINVAL.
For example, the following test program succeeds with "read 16 bytes" on
v5.14 but fails with "read: Invalid argument" on v5.15 and mainline:
#include <err.h>
#include <errno.h>
#include <stdio.h>
#include <sys/socket.h>
#include <sys/unistd.h>
int main(int argc, char *argv[]) {
int sock[2];
int ret;
ret = socketpair(AF_UNIX, SOCK_STREAM, 0, sock);
if (ret < 0)
err(1, "socketpair");
char buf[16] = {};
ret = write(sock[1], buf, sizeof(buf));
if (ret < 0)
err(1, "write");
ret = shutdown(sock[0], SHUT_RDWR);
if (ret < 0)
err(1, "shutdown");
ssize_t bytes = read(sock[0], buf, sizeof(buf));
if (bytes < 0)
err(1, "read");
printf("read %zd bytes\n", bytes);
return 0;
}
From: Jakub Kicinski <kuba@kernel.org> Date: 2021-11-19 14:14:24
On Thu, 11 Nov 2021 15:00:02 +0100 Vincent Whitchurch wrote:
On Mon, Oct 04, 2021 at 11:25:28PM +0000, Jiang Wang wrote:
quoted
Commit 94531cfcbe79 ("af_unix: Add unix_stream_proto for sockmap")
sets unix domain socket peer state to TCP_CLOSE
in unix_shutdown. This could happen when the local end is shutdown
but the other end is not. Then the other end will get read or write
failures which is not expected.
Fix the issue by setting the local state to shutdown.
Fixes: 94531cfcbe79 (af_unix: Add unix_stream_proto for sockmap)
Suggested-by: Cong Wang <redacted>
Reported-by: Casey Schaufler <casey@schaufler-ca.com>
Signed-off-by: Jiang Wang <redacted>
This patch changed the behaviour of read(2) after a shutdown(2) on the
local end of a UDS. Before this patch, reading from a UDS after a local
shutdown(SHUT_RDWR) would return the data written or EOF if there is no
data, but now it always returns -EINVAL.
For example, the following test program succeeds with "read 16 bytes" on
v5.14 but fails with "read: Invalid argument" on v5.15 and mainline:
From: Jakub Kicinski <kuba@kernel.org> Date: 2021-11-19 14:28:26
On Fri, 19 Nov 2021 06:14:19 -0800 Jakub Kicinski wrote:
On Thu, 11 Nov 2021 15:00:02 +0100 Vincent Whitchurch wrote:
quoted
On Mon, Oct 04, 2021 at 11:25:28PM +0000, Jiang Wang wrote:
quoted
Commit 94531cfcbe79 ("af_unix: Add unix_stream_proto for sockmap")
sets unix domain socket peer state to TCP_CLOSE
in unix_shutdown. This could happen when the local end is shutdown
but the other end is not. Then the other end will get read or write
failures which is not expected.
Fix the issue by setting the local state to shutdown.
Fixes: 94531cfcbe79 (af_unix: Add unix_stream_proto for sockmap)
Suggested-by: Cong Wang <redacted>
Reported-by: Casey Schaufler <casey@schaufler-ca.com>
Signed-off-by: Jiang Wang <redacted>
This patch changed the behaviour of read(2) after a shutdown(2) on the
local end of a UDS. Before this patch, reading from a UDS after a local
shutdown(SHUT_RDWR) would return the data written or EOF if there is no
data, but now it always returns -EINVAL.
For example, the following test program succeeds with "read 16 bytes" on
v5.14 but fails with "read: Invalid argument" on v5.15 and mainline:
Cong, Jiang, was this regression addressed?
Ah, just saw the patch. What timing.
Thanks Vincent!