Skip to content

Commit b5941f0

Browse files
Paolo Abenikuba-moo
authored andcommitted
mptcp: fix sk_forward_memory corruption on retransmission
MPTCP sk_forward_memory handling is a bit special, as such field is protected by the msk socket spin_lock, instead of the plain socket lock. Currently we have a code path updating such field without handling the relevant lock: __mptcp_retrans() -> __mptcp_clean_una_wakeup() Several helpers in __mptcp_clean_una_wakeup() will update sk_forward_alloc, possibly causing such field corruption, as reported by Matthieu. Address the issue providing and using a new variant of blamed function which explicitly acquires the msk spin lock. Fixes: 64b9cea ("mptcp: fix spurious retransmissions") Closes: multipath-tcp/mptcp_net-next#172 Reported-by: Matthieu Baerts <matthieu.baerts@tessares.net> Tested-by: Matthieu Baerts <matthieu.baerts@tessares.net> 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>
1 parent 44991d6 commit b5941f0

1 file changed

Lines changed: 15 additions & 1 deletion

File tree

‎net/mptcp/protocol.c‎

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -947,6 +947,10 @@ static void __mptcp_update_wmem(struct sock *sk)
947947
{
948948
struct mptcp_sock *msk = mptcp_sk(sk);
949949

950+
#ifdef CONFIG_LOCKDEP
951+
WARN_ON_ONCE(!lockdep_is_held(&sk->sk_lock.slock));
952+
#endif
953+
950954
if (!msk->wmem_reserved)
951955
return;
952956

@@ -1085,10 +1089,20 @@ static void __mptcp_clean_una(struct sock *sk)
10851089

10861090
static void __mptcp_clean_una_wakeup(struct sock *sk)
10871091
{
1092+
#ifdef CONFIG_LOCKDEP
1093+
WARN_ON_ONCE(!lockdep_is_held(&sk->sk_lock.slock));
1094+
#endif
10881095
__mptcp_clean_una(sk);
10891096
mptcp_write_space(sk);
10901097
}
10911098

1099+
static void mptcp_clean_una_wakeup(struct sock *sk)
1100+
{
1101+
mptcp_data_lock(sk);
1102+
__mptcp_clean_una_wakeup(sk);
1103+
mptcp_data_unlock(sk);
1104+
}
1105+
10921106
static void mptcp_enter_memory_pressure(struct sock *sk)
10931107
{
10941108
struct mptcp_subflow_context *subflow;
@@ -2299,7 +2313,7 @@ static void __mptcp_retrans(struct sock *sk)
22992313
struct sock *ssk;
23002314
int ret;
23012315

2302-
__mptcp_clean_una_wakeup(sk);
2316+
mptcp_clean_una_wakeup(sk);
23032317
dfrag = mptcp_rtx_head(sk);
23042318
if (!dfrag) {
23052319
if (mptcp_data_fin_enabled(msk)) {

0 commit comments

Comments
 (0)