Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

mptcp: fix potential wake-up event loss

After the blamed commit below, the send buffer auto-tuning can
happen after that the mptcp_propagate_sndbuf() completes - via
the delegated action infrastructure.

We must check for write space even after such change or we risk
missing the wake-up event.

Fixes: 8005184fd1ca ("mptcp: refactor sndbuf auto-tuning")
Cc: stable@vger.kernel.org
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Reviewed-by: Mat Martineau <martineau@kernel.org>
Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
Link: https://lore.kernel.org/r/20240223-upstream-net-20240223-misc-fixes-v1-6-162e87e48497@kernel.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Paolo Abeni and committed by
Jakub Kicinski
b111d8fb adf1bb78

+11 -10
+11 -10
net/mptcp/protocol.h
··· 790 790 READ_ONCE(msk->write_seq) == READ_ONCE(msk->snd_nxt); 791 791 } 792 792 793 + static inline void mptcp_write_space(struct sock *sk) 794 + { 795 + if (sk_stream_is_writeable(sk)) { 796 + /* pairs with memory barrier in mptcp_poll */ 797 + smp_mb(); 798 + if (test_and_clear_bit(MPTCP_NOSPACE, &mptcp_sk(sk)->flags)) 799 + sk_stream_write_space(sk); 800 + } 801 + } 802 + 793 803 static inline void __mptcp_sync_sndbuf(struct sock *sk) 794 804 { 795 805 struct mptcp_subflow_context *subflow; ··· 818 808 819 809 /* the msk max wmem limit is <nr_subflows> * tcp wmem[2] */ 820 810 WRITE_ONCE(sk->sk_sndbuf, new_sndbuf); 811 + mptcp_write_space(sk); 821 812 } 822 813 823 814 /* The called held both the msk socket and the subflow socket locks, ··· 847 836 local_bh_disable(); 848 837 mptcp_subflow_delegate(subflow, MPTCP_DELEGATE_SNDBUF); 849 838 local_bh_enable(); 850 - } 851 - 852 - static inline void mptcp_write_space(struct sock *sk) 853 - { 854 - if (sk_stream_is_writeable(sk)) { 855 - /* pairs with memory barrier in mptcp_poll */ 856 - smp_mb(); 857 - if (test_and_clear_bit(MPTCP_NOSPACE, &mptcp_sk(sk)->flags)) 858 - sk_stream_write_space(sk); 859 - } 860 839 } 861 840 862 841 void mptcp_destroy_common(struct mptcp_sock *msk, unsigned int flags);