mptcp: stop using the mptcp_has_another_subflow() helper
authorPaolo Abeni <pabeni@redhat.com>
Wed, 18 May 2022 22:04:43 +0000 (15:04 -0700)
committerJakub Kicinski <kuba@kernel.org>
Fri, 20 May 2022 03:05:07 +0000 (20:05 -0700)
The mentioned helper requires the msk socket lock, and the
current callers don't own it nor can't acquire it, so the
access is racy.

All the current callers are really checking for infinite mapping
fallback, and the latter condition is explicitly tracked by
the relevant msk variable: we can safely remove the caller usage
- and the caller itself.

The issue is present since MP_FAIL implementation, but the
fix only applies since the infinite fallback support, ence the
somewhat unexpected fixes tag.

Fixes: 0530020a7c8f ("mptcp: track and update contiguous data status")
Acked-and-tested-by: Geliang Tang <geliang.tang@suse.com>
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Signed-off-by: Mat Martineau <mathew.j.martineau@linux.intel.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
net/mptcp/pm.c
net/mptcp/protocol.h
net/mptcp/subflow.c

index 59fdab2d0c271102b05f18ad5bf745d6a65e930c..8ba51120f35b38ae7970f048b2094255de5fae9a 100644 (file)
@@ -303,7 +303,7 @@ void mptcp_pm_mp_fail_received(struct sock *sk, u64 fail_seq)
 
        pr_debug("fail_seq=%llu", fail_seq);
 
-       if (mptcp_has_another_subflow(sk) || !READ_ONCE(msk->allow_infinite_fallback))
+       if (!READ_ONCE(msk->allow_infinite_fallback))
                return;
 
        if (!READ_ONCE(subflow->mp_fail_response_expect)) {
index 08b8015cb69fb17741982b248e9ef1b5aaebc0c2..fb4760ee8d47977e9d8bb20f36da5cec2ff3430e 100644 (file)
@@ -650,19 +650,6 @@ static inline void mptcp_subflow_tcp_fallback(struct sock *sk,
        inet_csk(sk)->icsk_af_ops = ctx->icsk_af_ops;
 }
 
-static inline bool mptcp_has_another_subflow(struct sock *ssk)
-{
-       struct mptcp_subflow_context *subflow = mptcp_subflow_ctx(ssk), *tmp;
-       struct mptcp_sock *msk = mptcp_sk(subflow->conn);
-
-       mptcp_for_each_subflow(msk, tmp) {
-               if (tmp != subflow)
-                       return true;
-       }
-
-       return false;
-}
-
 void __init mptcp_proto_init(void);
 #if IS_ENABLED(CONFIG_MPTCP_IPV6)
 int __init mptcp_proto_v6_init(void);
index aecd98ac5dfe9b73e332f863c2946e107661705d..27273cf091dbeda4e481a00a5ac0716963f7f06d 100644 (file)
@@ -1233,8 +1233,7 @@ fallback:
        if (!__mptcp_check_fallback(msk)) {
                /* RFC 8684 section 3.7. */
                if (subflow->send_mp_fail) {
-                       if (mptcp_has_another_subflow(ssk) ||
-                           !READ_ONCE(msk->allow_infinite_fallback)) {
+                       if (!READ_ONCE(msk->allow_infinite_fallback)) {
                                ssk->sk_err = EBADMSG;
                                tcp_set_state(ssk, TCP_CLOSE);
                                subflow->reset_transient = 0;