Skip to content

Commit ecfcc6f

Browse files
committed
Merge branch 'mptcp-more-fixes-for-6-3'
Matthieu Baerts says: ==================== mptcp: more fixes for 6.3 Patch 1 avoids scheduling the MPTCP worker on a closed socket on some edge cases. It fixes issues that can be visible from v5.11. Patch 2 makes sure the MPTCP worker doesn't try to manipulate disconnected sockets. This is also a fix for an issue that can be visible from v5.11. Patch 3 fixes a NULL pointer dereference when MPTCP FastOpen is used and an early fallback is done. A fix for v6.2. Patch 4 improves the stability of the userspace PM selftest for a subtest added in v6.2. ==================== Link: https://lore.kernel.org/r/20230411-upstream-net-20230411-mptcp-fixes-v1-0-ca540f3ef986@tessares.net Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2 parents 5b7be2d + 711ae78 commit ecfcc6f

File tree

5 files changed

+20
-18
lines changed

5 files changed

+20
-18
lines changed

net/mptcp/fastopen.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,18 @@
99
void mptcp_fastopen_subflow_synack_set_params(struct mptcp_subflow_context *subflow,
1010
struct request_sock *req)
1111
{
12-
struct sock *ssk = subflow->tcp_sock;
13-
struct sock *sk = subflow->conn;
12+
struct sock *sk, *ssk;
1413
struct sk_buff *skb;
1514
struct tcp_sock *tp;
1615

16+
/* on early fallback the subflow context is deleted by
17+
* subflow_syn_recv_sock()
18+
*/
19+
if (!subflow)
20+
return;
21+
22+
ssk = subflow->tcp_sock;
23+
sk = subflow->conn;
1724
tp = tcp_sk(ssk);
1825

1926
subflow->is_mptfo = 1;

net/mptcp/options.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1192,9 +1192,8 @@ bool mptcp_incoming_options(struct sock *sk, struct sk_buff *skb)
11921192
*/
11931193
if (TCP_SKB_CB(skb)->seq == TCP_SKB_CB(skb)->end_seq) {
11941194
if (mp_opt.data_fin && mp_opt.data_len == 1 &&
1195-
mptcp_update_rcv_data_fin(msk, mp_opt.data_seq, mp_opt.dsn64) &&
1196-
schedule_work(&msk->work))
1197-
sock_hold(subflow->conn);
1195+
mptcp_update_rcv_data_fin(msk, mp_opt.data_seq, mp_opt.dsn64))
1196+
mptcp_schedule_work((struct sock *)msk);
11981197

11991198
return true;
12001199
}

net/mptcp/protocol.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2626,7 +2626,7 @@ static void mptcp_worker(struct work_struct *work)
26262626

26272627
lock_sock(sk);
26282628
state = sk->sk_state;
2629-
if (unlikely(state == TCP_CLOSE))
2629+
if (unlikely((1 << state) & (TCPF_CLOSE | TCPF_LISTEN)))
26302630
goto unlock;
26312631

26322632
mptcp_check_data_fin_ack(sk);

net/mptcp/subflow.c

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -408,9 +408,8 @@ void mptcp_subflow_reset(struct sock *ssk)
408408

409409
tcp_send_active_reset(ssk, GFP_ATOMIC);
410410
tcp_done(ssk);
411-
if (!test_and_set_bit(MPTCP_WORK_CLOSE_SUBFLOW, &mptcp_sk(sk)->flags) &&
412-
schedule_work(&mptcp_sk(sk)->work))
413-
return; /* worker will put sk for us */
411+
if (!test_and_set_bit(MPTCP_WORK_CLOSE_SUBFLOW, &mptcp_sk(sk)->flags))
412+
mptcp_schedule_work(sk);
414413

415414
sock_put(sk);
416415
}
@@ -1118,8 +1117,8 @@ static enum mapping_status get_mapping_status(struct sock *ssk,
11181117
skb_ext_del(skb, SKB_EXT_MPTCP);
11191118
return MAPPING_OK;
11201119
} else {
1121-
if (updated && schedule_work(&msk->work))
1122-
sock_hold((struct sock *)msk);
1120+
if (updated)
1121+
mptcp_schedule_work((struct sock *)msk);
11231122

11241123
return MAPPING_DATA_FIN;
11251124
}
@@ -1222,17 +1221,12 @@ static void mptcp_subflow_discard_data(struct sock *ssk, struct sk_buff *skb,
12221221
/* sched mptcp worker to remove the subflow if no more data is pending */
12231222
static void subflow_sched_work_if_closed(struct mptcp_sock *msk, struct sock *ssk)
12241223
{
1225-
struct sock *sk = (struct sock *)msk;
1226-
12271224
if (likely(ssk->sk_state != TCP_CLOSE))
12281225
return;
12291226

12301227
if (skb_queue_empty(&ssk->sk_receive_queue) &&
1231-
!test_and_set_bit(MPTCP_WORK_CLOSE_SUBFLOW, &msk->flags)) {
1232-
sock_hold(sk);
1233-
if (!schedule_work(&msk->work))
1234-
sock_put(sk);
1235-
}
1228+
!test_and_set_bit(MPTCP_WORK_CLOSE_SUBFLOW, &msk->flags))
1229+
mptcp_schedule_work((struct sock *)msk);
12361230
}
12371231

12381232
static bool subflow_can_fallback(struct mptcp_subflow_context *subflow)

tools/testing/selftests/net/mptcp/userspace_pm.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -913,6 +913,7 @@ test_listener()
913913
$client4_port > /dev/null 2>&1 &
914914
local listener_pid=$!
915915

916+
sleep 0.5
916917
verify_listener_events $client_evts $LISTENER_CREATED $AF_INET 10.0.2.2 $client4_port
917918

918919
# ADD_ADDR from client to server machine reusing the subflow port
@@ -928,6 +929,7 @@ test_listener()
928929
# Delete the listener from the client ns, if one was created
929930
kill_wait $listener_pid
930931

932+
sleep 0.5
931933
verify_listener_events $client_evts $LISTENER_CLOSED $AF_INET 10.0.2.2 $client4_port
932934
}
933935

0 commit comments

Comments
 (0)