Netdev Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH] tipc: fix shutdown() of connection oriented socket
@ 2020-09-05 6:14 Tetsuo Handa
2020-09-07 3:28 ` Jakub Kicinski
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Tetsuo Handa @ 2020-09-05 6:14 UTC (permalink / raw)
To: Jon Maloy, Ying Xue, Parthasarathy Bhuvaragan
Cc: David S. Miller, Jakub Kicinski, netdev, tipc-discussion, Tetsuo Handa
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@I-love.SAKURA.ne.jp>
---
net/tipc/socket.c | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
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 */
--
2.18.4
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] tipc: fix shutdown() of connection oriented socket
2020-09-05 6:14 [PATCH] tipc: fix shutdown() of connection oriented socket Tetsuo Handa
@ 2020-09-07 3:28 ` Jakub Kicinski
2020-09-08 16:11 ` Xue, Ying
2020-09-10 19:22 ` David Miller
2 siblings, 0 replies; 4+ messages in thread
From: Jakub Kicinski @ 2020-09-07 3:28 UTC (permalink / raw)
To: Jon Maloy
Cc: Tetsuo Handa, Ying Xue, Parthasarathy Bhuvaragan,
David S. Miller, netdev, tipc-discussion
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@I-love.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 */
^ permalink raw reply [flat|nested] 4+ messages in thread
* RE: [PATCH] tipc: fix shutdown() of connection oriented socket
2020-09-05 6:14 [PATCH] tipc: fix shutdown() of connection oriented socket Tetsuo Handa
2020-09-07 3:28 ` Jakub Kicinski
@ 2020-09-08 16:11 ` Xue, Ying
2020-09-10 19:22 ` David Miller
2 siblings, 0 replies; 4+ messages in thread
From: Xue, Ying @ 2020-09-08 16:11 UTC (permalink / raw)
To: Tetsuo Handa, Jon Maloy, Parthasarathy Bhuvaragan
Cc: David S. Miller, Jakub Kicinski, netdev, tipc-discussion
-----Original Message-----
From: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
Sent: Saturday, September 5, 2020 2:15 PM
To: Jon Maloy <jmaloy@redhat.com>; Xue, Ying <Ying.Xue@windriver.com>; Parthasarathy Bhuvaragan <parthasarathy.bhuvaragan@gmail.com>
Cc: David S. Miller <davem@davemloft.net>; Jakub Kicinski <kuba@kernel.org>; netdev@vger.kernel.org; tipc-discussion@lists.sourceforge.net; Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
Subject: [PATCH] tipc: fix shutdown() of connection oriented socket
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@I-love.SAKURA.ne.jp>
Acked-by: Ying Xue <ying.xue@windriver.com>
---
net/tipc/socket.c | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
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 */
--
2.18.4
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] tipc: fix shutdown() of connection oriented socket
2020-09-05 6:14 [PATCH] tipc: fix shutdown() of connection oriented socket Tetsuo Handa
2020-09-07 3:28 ` Jakub Kicinski
2020-09-08 16:11 ` Xue, Ying
@ 2020-09-10 19:22 ` David Miller
2 siblings, 0 replies; 4+ messages in thread
From: David Miller @ 2020-09-10 19:22 UTC (permalink / raw)
To: penguin-kernel
Cc: jmaloy, ying.xue, parthasarathy.bhuvaragan, kuba, netdev,
tipc-discussion
From: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
Date: Sat, 5 Sep 2020 15:14:47 +0900
> 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@I-love.SAKURA.ne.jp>
Applied and queued up for -stable, thank you.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2020-09-10 19:23 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-05 6:14 [PATCH] tipc: fix shutdown() of connection oriented socket Tetsuo Handa
2020-09-07 3:28 ` Jakub Kicinski
2020-09-08 16:11 ` Xue, Ying
2020-09-10 19:22 ` David Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).