All of lore.kernel.org
 help / color / mirror / Atom feed
* [MPTCP] [PATCH net-next] mptcp: silence warning in subflow_data_ready()
@ 2020-07-15 20:27 ` Davide Caratti
  0 siblings, 0 replies; 4+ messages in thread
From: Davide Caratti @ 2020-07-15 20:27 UTC (permalink / raw)
  To: mptcp

[-- Attachment #1: Type: text/plain, Size: 1802 bytes --]

since commit d47a72152097 ("mptcp: fix race in subflow_data_ready()"), it
is possible to observe a regression in MP_JOIN kselftests. For sockets in
TCP_CLOSE state, it's not sufficient to just wake up the main socket: we
also need to ensure that received data are made available to the reader.
Silence the WARN_ON_ONCE() in these cases: it preserves the syzkaller fix
and restores kselftests	when they are ran as follows:

  # while true; do
  > make KBUILD_OUTPUT=/tmp/kselftest TARGETS=net/mptcp kselftest
  > done

Reported-by: Florian Westphal <fw(a)strlen.de>
Fixes: d47a72152097 ("mptcp: fix race in subflow_data_ready()")
Closes: https://github.com/multipath-tcp/mptcp_net-next/issues/47
Signed-off-by: Davide Caratti <dcaratti(a)redhat.com>
---
 net/mptcp/subflow.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/net/mptcp/subflow.c b/net/mptcp/subflow.c
index 9f7f3772c13c..519122e66f17 100644
--- a/net/mptcp/subflow.c
+++ b/net/mptcp/subflow.c
@@ -869,18 +869,19 @@ void mptcp_space(const struct sock *ssk, int *space, int *full_space)
 static void subflow_data_ready(struct sock *sk)
 {
 	struct mptcp_subflow_context *subflow = mptcp_subflow_ctx(sk);
+	u16 state = 1 << inet_sk_state_load(sk);
 	struct sock *parent = subflow->conn;
 	struct mptcp_sock *msk;
 
 	msk = mptcp_sk(parent);
-	if ((1 << inet_sk_state_load(sk)) & (TCPF_LISTEN | TCPF_CLOSE)) {
+	if (state & TCPF_LISTEN) {
 		set_bit(MPTCP_DATA_READY, &msk->flags);
 		parent->sk_data_ready(parent);
 		return;
 	}
 
 	WARN_ON_ONCE(!__mptcp_check_fallback(msk) && !subflow->mp_capable &&
-		     !subflow->mp_join);
+		     !subflow->mp_join && !(state & TCPF_CLOSE));
 
 	if (mptcp_subflow_data_available(sk))
 		mptcp_data_ready(parent, sk);
-- 
2.26.2

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH net-next] mptcp: silence warning in subflow_data_ready()
@ 2020-07-15 20:27 ` Davide Caratti
  0 siblings, 0 replies; 4+ messages in thread
From: Davide Caratti @ 2020-07-15 20:27 UTC (permalink / raw)
  To: Mat Martineau, Matthieu Baerts; +Cc: David S. Miller, netdev, mptcp

since commit d47a72152097 ("mptcp: fix race in subflow_data_ready()"), it
is possible to observe a regression in MP_JOIN kselftests. For sockets in
TCP_CLOSE state, it's not sufficient to just wake up the main socket: we
also need to ensure that received data are made available to the reader.
Silence the WARN_ON_ONCE() in these cases: it preserves the syzkaller fix
and restores kselftests	when they are ran as follows:

  # while true; do
  > make KBUILD_OUTPUT=/tmp/kselftest TARGETS=net/mptcp kselftest
  > done

Reported-by: Florian Westphal <fw@strlen.de>
Fixes: d47a72152097 ("mptcp: fix race in subflow_data_ready()")
Closes: https://github.com/multipath-tcp/mptcp_net-next/issues/47
Signed-off-by: Davide Caratti <dcaratti@redhat.com>
---
 net/mptcp/subflow.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/net/mptcp/subflow.c b/net/mptcp/subflow.c
index 9f7f3772c13c..519122e66f17 100644
--- a/net/mptcp/subflow.c
+++ b/net/mptcp/subflow.c
@@ -869,18 +869,19 @@ void mptcp_space(const struct sock *ssk, int *space, int *full_space)
 static void subflow_data_ready(struct sock *sk)
 {
 	struct mptcp_subflow_context *subflow = mptcp_subflow_ctx(sk);
+	u16 state = 1 << inet_sk_state_load(sk);
 	struct sock *parent = subflow->conn;
 	struct mptcp_sock *msk;
 
 	msk = mptcp_sk(parent);
-	if ((1 << inet_sk_state_load(sk)) & (TCPF_LISTEN | TCPF_CLOSE)) {
+	if (state & TCPF_LISTEN) {
 		set_bit(MPTCP_DATA_READY, &msk->flags);
 		parent->sk_data_ready(parent);
 		return;
 	}
 
 	WARN_ON_ONCE(!__mptcp_check_fallback(msk) && !subflow->mp_capable &&
-		     !subflow->mp_join);
+		     !subflow->mp_join && !(state & TCPF_CLOSE));
 
 	if (mptcp_subflow_data_available(sk))
 		mptcp_data_ready(parent, sk);
-- 
2.26.2


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [MPTCP] Re: [PATCH net-next] mptcp: silence warning in subflow_data_ready()
  2020-07-15 20:27 ` Davide Caratti
@ 2020-07-16  9:52 ` Matthieu Baerts
  -1 siblings, 0 replies; 4+ messages in thread
From: Matthieu Baerts @ 2020-07-16  9:52 UTC (permalink / raw)
  To: mptcp

[-- Attachment #1: Type: text/plain, Size: 1101 bytes --]

Hi Davide,

On 15/07/2020 22:27, Davide Caratti wrote:
> since commit d47a72152097 ("mptcp: fix race in subflow_data_ready()"), it
> is possible to observe a regression in MP_JOIN kselftests. For sockets in
> TCP_CLOSE state, it's not sufficient to just wake up the main socket: we
> also need to ensure that received data are made available to the reader.
> Silence the WARN_ON_ONCE() in these cases: it preserves the syzkaller fix
> and restores kselftests	when they are ran as follows:
> 
>    # while true; do
>    > make KBUILD_OUTPUT=/tmp/kselftest TARGETS=net/mptcp kselftest
>    > done
> 
> Reported-by: Florian Westphal <fw(a)strlen.de>
> Fixes: d47a72152097 ("mptcp: fix race in subflow_data_ready()")
> Closes: https://github.com/multipath-tcp/mptcp_net-next/issues/47
> Signed-off-by: Davide Caratti <dcaratti(a)redhat.com>

Thank you for the patch!
It looks good to me and it fixes the kselftests on my side as well!

Reviewed-by: Matthieu Baerts <matthieu.baerts(a)tessares.net>

Cheers,
Matt
-- 
Tessares | Belgium | Hybrid Access Solutions
www.tessares.net

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH net-next] mptcp: silence warning in subflow_data_ready()
@ 2020-07-16  9:52 ` Matthieu Baerts
  0 siblings, 0 replies; 4+ messages in thread
From: Matthieu Baerts @ 2020-07-16  9:52 UTC (permalink / raw)
  To: Davide Caratti; +Cc: Mat Martineau, David S. Miller, netdev, mptcp

Hi Davide,

On 15/07/2020 22:27, Davide Caratti wrote:
> since commit d47a72152097 ("mptcp: fix race in subflow_data_ready()"), it
> is possible to observe a regression in MP_JOIN kselftests. For sockets in
> TCP_CLOSE state, it's not sufficient to just wake up the main socket: we
> also need to ensure that received data are made available to the reader.
> Silence the WARN_ON_ONCE() in these cases: it preserves the syzkaller fix
> and restores kselftests	when they are ran as follows:
> 
>    # while true; do
>    > make KBUILD_OUTPUT=/tmp/kselftest TARGETS=net/mptcp kselftest
>    > done
> 
> Reported-by: Florian Westphal <fw@strlen.de>
> Fixes: d47a72152097 ("mptcp: fix race in subflow_data_ready()")
> Closes: https://github.com/multipath-tcp/mptcp_net-next/issues/47
> Signed-off-by: Davide Caratti <dcaratti@redhat.com>

Thank you for the patch!
It looks good to me and it fixes the kselftests on my side as well!

Reviewed-by: Matthieu Baerts <matthieu.baerts@tessares.net>

Cheers,
Matt
-- 
Tessares | Belgium | Hybrid Access Solutions
www.tessares.net

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-07-16  9:52 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-16  9:52 [MPTCP] Re: [PATCH net-next] mptcp: silence warning in subflow_data_ready() Matthieu Baerts
2020-07-16  9:52 ` Matthieu Baerts
  -- strict thread matches above, loose matches on Subject: below --
2020-07-15 20:27 [MPTCP] " Davide Caratti
2020-07-15 20:27 ` Davide Caratti

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.