Skip to content

Commit 1c7c3a9

Browse files
Paolo Abenigregkh
authored andcommitted
mptcp: ensure context reset on disconnect()
[ Upstream commit 86730ac ] After the blamed commit below, if the MPC subflow is already in TCP_CLOSE status or has fallback to TCP at mptcp_disconnect() time, mptcp_do_fastclose() skips setting the `send_fastclose flag` and the later __mptcp_close_ssk() does not reset anymore the related subflow context. Any later connection will be created with both the `request_mptcp` flag and the msk-level fallback status off (it is unconditionally cleared at MPTCP disconnect time), leading to a warning in subflow_data_ready(): WARNING: CPU: 26 PID: 8996 at net/mptcp/subflow.c:1519 subflow_data_ready (net/mptcp/subflow.c:1519 (discriminator 13)) Modules linked in: CPU: 26 UID: 0 PID: 8996 Comm: syz.22.39 Not tainted 6.18.0-rc7-05427-g11fc074f6c36 #1 PREEMPT(voluntary) Hardware name: Bochs Bochs, BIOS Bochs 01/01/2011 RIP: 0010:subflow_data_ready (net/mptcp/subflow.c:1519 (discriminator 13)) Code: 90 0f 0b 90 90 e9 04 fe ff ff e8 b7 1e f5 fe 89 ee bf 07 00 00 00 e8 db 19 f5 fe 83 fd 07 0f 84 35 ff ff ff e8 9d 1e f5 fe 90 <0f> 0b 90 e9 27 ff ff ff e8 8f 1e f5 fe 4c 89 e7 48 89 de e8 14 09 RSP: 0018:ffffc9002646fb30 EFLAGS: 00010293 RAX: 0000000000000000 RBX: ffff88813b218000 RCX: ffffffff825c8435 RDX: ffff8881300b3580 RSI: ffffffff825c8443 RDI: 0000000000000005 RBP: 000000000000000b R08: ffffffff825c8435 R09: 000000000000000b R10: 0000000000000005 R11: 0000000000000007 R12: ffff888131ac0000 R13: 0000000000000000 R14: 0000000000000000 R15: 0000000000000000 FS: 00007f88330af6c0(0000) GS:ffff888a93dd2000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 00007f88330aefe8 CR3: 000000010ff59000 CR4: 0000000000350ef0 Call Trace: <TASK> tcp_data_ready (net/ipv4/tcp_input.c:5356) tcp_data_queue (net/ipv4/tcp_input.c:5445) tcp_rcv_state_process (net/ipv4/tcp_input.c:7165) tcp_v4_do_rcv (net/ipv4/tcp_ipv4.c:1955) __release_sock (include/net/sock.h:1158 (discriminator 6) net/core/sock.c:3180 (discriminator 6)) release_sock (net/core/sock.c:3737) mptcp_sendmsg (net/mptcp/protocol.c:1763 net/mptcp/protocol.c:1857) inet_sendmsg (net/ipv4/af_inet.c:853 (discriminator 7)) __sys_sendto (net/socket.c:727 (discriminator 15) net/socket.c:742 (discriminator 15) net/socket.c:2244 (discriminator 15)) __x64_sys_sendto (net/socket.c:2247) do_syscall_64 (arch/x86/entry/syscall_64.c:63 (discriminator 1) arch/x86/entry/syscall_64.c:94 (discriminator 1)) entry_SYSCALL_64_after_hwframe (arch/x86/entry/entry_64.S:130) RIP: 0033:0x7f883326702d Address the issue setting an explicit `fastclosing` flag at fastclose time, and checking such flag after mptcp_do_fastclose(). Fixes: ae15506 ("mptcp: fix duplicate reset on fastclose") Cc: stable@vger.kernel.org Signed-off-by: Paolo Abeni <pabeni@redhat.com> Reviewed-by: Matthieu Baerts (NGI0) <matttbe@kernel.org> Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org> Link: https://patch.msgid.link/20251212-net-mptcp-subflow_data_ready-warn-v1-2-d1f9fd1c36c8@kernel.org Signed-off-by: Paolo Abeni <pabeni@redhat.com> [ Adjust context ] Signed-off-by: Sasha Levin <sashal@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 58a3263 commit 1c7c3a9

2 files changed

Lines changed: 7 additions & 4 deletions

File tree

net/mptcp/protocol.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2478,10 +2478,10 @@ bool __mptcp_retransmit_pending_data(struct sock *sk)
24782478
*/
24792479
static void __mptcp_subflow_disconnect(struct sock *ssk,
24802480
struct mptcp_subflow_context *subflow,
2481-
unsigned int flags)
2481+
bool fastclosing)
24822482
{
24832483
if (((1 << ssk->sk_state) & (TCPF_CLOSE | TCPF_LISTEN)) ||
2484-
subflow->send_fastclose) {
2484+
fastclosing) {
24852485
/* The MPTCP code never wait on the subflow sockets, TCP-level
24862486
* disconnect should never fail
24872487
*/
@@ -2533,7 +2533,7 @@ static void __mptcp_close_ssk(struct sock *sk, struct sock *ssk,
25332533

25342534
need_push = (flags & MPTCP_CF_PUSH) && __mptcp_retransmit_pending_data(sk);
25352535
if (!dispose_it) {
2536-
__mptcp_subflow_disconnect(ssk, subflow, flags);
2536+
__mptcp_subflow_disconnect(ssk, subflow, msk->fastclosing);
25372537
release_sock(ssk);
25382538

25392539
goto out;
@@ -2845,6 +2845,7 @@ static void mptcp_do_fastclose(struct sock *sk)
28452845
struct mptcp_sock *msk = mptcp_sk(sk);
28462846

28472847
mptcp_set_state(sk, TCP_CLOSE);
2848+
msk->fastclosing = 1;
28482849

28492850
/* Explicitly send the fastclose reset as need */
28502851
if (__mptcp_check_fallback(msk))
@@ -3362,6 +3363,7 @@ static int mptcp_disconnect(struct sock *sk, int flags)
33623363
msk->bytes_sent = 0;
33633364
msk->bytes_retrans = 0;
33643365
msk->rcvspace_init = 0;
3366+
msk->fastclosing = 0;
33653367

33663368
WRITE_ONCE(sk->sk_shutdown, 0);
33673369
sk_error_report(sk);

net/mptcp/protocol.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,8 @@ struct mptcp_sock {
316316
fastopening:1,
317317
in_accept_queue:1,
318318
free_first:1,
319-
rcvspace_init:1;
319+
rcvspace_init:1,
320+
fastclosing:1;
320321
u32 notsent_lowat;
321322
int keepalive_cnt;
322323
int keepalive_idle;

0 commit comments

Comments
 (0)