Commit 0183a74c authored by Tetsuo Handa's avatar Tetsuo Handa Committed by Greg Kroah-Hartman

tipc: fix shutdown() of connection oriented socket

[ Upstream commit a4b5cc9e ]

I confirmed that the problem fixed by commit 2a63866c ("tipc: fix
shutdown() of connectionless socket") also applies to stream socket.

----------
#include <sys/socket.h>
#include <unistd.h>
#include <sys/wait.h>

int main(int argc, char *argv[])
{
        int fds[2] = { -1, -1 };
        socketpair(PF_TIPC, SOCK_STREAM /* or SOCK_DGRAM */, 0, fds);
        if (fork() == 0)
                _exit(read(fds[0], NULL, 1));
        shutdown(fds[0], SHUT_RDWR); /* This must make read() return. */
        wait(NULL); /* To be woken up by _exit(). */
        return 0;
}
----------

Since shutdown(SHUT_RDWR) should affect all processes sharing that socket,
unconditionally setting sk->sk_shutdown to SHUTDOWN_MASK will be the right
behavior.
Signed-off-by: default avatarTetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
Acked-by: default avatarYing Xue <ying.xue@windriver.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent d82e08de
...@@ -2565,10 +2565,7 @@ static int tipc_shutdown(struct socket *sock, int how) ...@@ -2565,10 +2565,7 @@ static int tipc_shutdown(struct socket *sock, int how)
lock_sock(sk); lock_sock(sk);
__tipc_shutdown(sock, TIPC_CONN_SHUTDOWN); __tipc_shutdown(sock, TIPC_CONN_SHUTDOWN);
if (tipc_sk_type_connectionless(sk)) sk->sk_shutdown = SHUTDOWN_MASK;
sk->sk_shutdown = SHUTDOWN_MASK;
else
sk->sk_shutdown = SEND_SHUTDOWN;
if (sk->sk_state == TIPC_DISCONNECTING) { if (sk->sk_state == TIPC_DISCONNECTING) {
/* Discard any unreceived messages */ /* Discard any unreceived messages */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment