Skip to content

Commit a657430

Browse files
mjmartineaudavem330
authored andcommitted
mptcp: Acquire the subflow socket lock before modifying MP_PRIO flags
When setting up a subflow's flags for sending MP_PRIO MPTCP options, the subflow socket lock was not held while reading and modifying several struct members that are also read and modified in mptcp_write_options(). Acquire the subflow socket lock earlier and send the MP_PRIO ACK with that lock already acquired. Add a new variant of the mptcp_subflow_send_ack() helper to use with the subflow lock held. Fixes: 0670654 ("mptcp: add the outgoing MP_PRIO support") Acked-by: Paolo Abeni <[email protected]> Signed-off-by: Mat Martineau <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent c21b50d commit a657430

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed

net/mptcp/pm_netlink.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -728,19 +728,22 @@ static int mptcp_pm_nl_mp_prio_send_ack(struct mptcp_sock *msk,
728728
mptcp_for_each_subflow(msk, subflow) {
729729
struct sock *ssk = mptcp_subflow_tcp_sock(subflow);
730730
struct mptcp_addr_info local;
731+
bool slow;
731732

732733
local_address((struct sock_common *)ssk, &local);
733734
if (!mptcp_addresses_equal(&local, addr, addr->port))
734735
continue;
735736

737+
slow = lock_sock_fast(ssk);
736738
if (subflow->backup != bkup)
737739
msk->last_snd = NULL;
738740
subflow->backup = bkup;
739741
subflow->send_mp_prio = 1;
740742
subflow->request_bkup = bkup;
741743

742744
pr_debug("send ack for mp_prio");
743-
mptcp_subflow_send_ack(ssk);
745+
__mptcp_subflow_send_ack(ssk);
746+
unlock_sock_fast(ssk, slow);
744747

745748
return 0;
746749
}

net/mptcp/protocol.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -506,13 +506,18 @@ static inline bool tcp_can_send_ack(const struct sock *ssk)
506506
(TCPF_SYN_SENT | TCPF_SYN_RECV | TCPF_TIME_WAIT | TCPF_CLOSE | TCPF_LISTEN));
507507
}
508508

509+
void __mptcp_subflow_send_ack(struct sock *ssk)
510+
{
511+
if (tcp_can_send_ack(ssk))
512+
tcp_send_ack(ssk);
513+
}
514+
509515
void mptcp_subflow_send_ack(struct sock *ssk)
510516
{
511517
bool slow;
512518

513519
slow = lock_sock_fast(ssk);
514-
if (tcp_can_send_ack(ssk))
515-
tcp_send_ack(ssk);
520+
__mptcp_subflow_send_ack(ssk);
516521
unlock_sock_fast(ssk, slow);
517522
}
518523

net/mptcp/protocol.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -607,6 +607,7 @@ void __init mptcp_subflow_init(void);
607607
void mptcp_subflow_shutdown(struct sock *sk, struct sock *ssk, int how);
608608
void mptcp_close_ssk(struct sock *sk, struct sock *ssk,
609609
struct mptcp_subflow_context *subflow);
610+
void __mptcp_subflow_send_ack(struct sock *ssk);
610611
void mptcp_subflow_send_ack(struct sock *ssk);
611612
void mptcp_subflow_reset(struct sock *ssk);
612613
void mptcp_subflow_queue_clean(struct sock *ssk);

0 commit comments

Comments
 (0)