• Tetsuo Handa's avatar
    tipc: fix shutdown() of connection oriented socket · a4b5cc9e
    Tetsuo Handa authored
    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>
    a4b5cc9e
socket.c 103 KB