lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Sun, 6 Sep 2020 20:28:13 -0700
From:   Jakub Kicinski <kuba@...nel.org>
To:     Jon Maloy <jmaloy@...hat.com>
Cc:     Tetsuo Handa <penguin-kernel@...ove.SAKURA.ne.jp>,
        Ying Xue <ying.xue@...driver.com>,
        Parthasarathy Bhuvaragan <parthasarathy.bhuvaragan@...il.com>,
        "David S. Miller" <davem@...emloft.net>, netdev@...r.kernel.org,
        tipc-discussion@...ts.sourceforge.net
Subject: Re: [PATCH] tipc: fix shutdown() of connection oriented socket

On Sat,  5 Sep 2020 15:14:47 +0900 Tetsuo Handa wrote:
> I confirmed that the problem fixed by commit 2a63866c8b51a3f7 ("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: Tetsuo Handa <penguin-kernel@...ove.SAKURA.ne.jp>

Jon, this looks correct to me but it may change the behavior for
applications (at least poll events).

Please review.

> diff --git a/net/tipc/socket.c b/net/tipc/socket.c
> index ebd280e767bd..11b27ddc75ba 100644
> --- a/net/tipc/socket.c
> +++ b/net/tipc/socket.c
> @@ -2771,10 +2771,7 @@ static int tipc_shutdown(struct socket *sock, int how)
>  
>  	trace_tipc_sk_shutdown(sk, NULL, TIPC_DUMP_ALL, " ");
>  	__tipc_shutdown(sock, TIPC_CONN_SHUTDOWN);
> -	if (tipc_sk_type_connectionless(sk))
> -		sk->sk_shutdown = SHUTDOWN_MASK;
> -	else
> -		sk->sk_shutdown = SEND_SHUTDOWN;
> +	sk->sk_shutdown = SHUTDOWN_MASK;
>  
>  	if (sk->sk_state == TIPC_DISCONNECTING) {
>  		/* Discard any unreceived messages */

Powered by blists - more mailing lists