Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796282535; b=qkeCywq9kVz7pFZTa2wSGCH6+5WYMRgbRQ2J/pSHww1Pmjrji8wDPql/P7PD0Gh2A3+1 MC66YStFeSTiwPVzPjospycYSq7G1HO1HviQUwV0IFKTkp/lQEO/s4Wa608HoWwBZMkDg WHgAzXXRBPGGip7dQma0qOuqYJQ05nxCd+8Mmxw50T5+xiwvpHF1OGYhEzbMvyYOYndYe h1ziF5FGrvroqgPqdmyyULEzHM7sxkQ9/J7+iS+HJ3wP/w9UUX5wMiMwQPi9BtkpTLbI8 Nn0WEbfDxKsf/UjUtCOYuzSo5zG4hx5kH0hfU5FU66+Wd3kI33k7EAHlakNcd2bkTnA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796282535; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=3iccCNRxEfrawATy1t1EG9z8TlEJTNeNEgfVCuzuBGg=; b=xu99mKND82IpEU0P+3JNmIzg4R9oVvFtBrPgtEKle2aaxydOeTaKx3y8UoODCHUCHAV5 Hyp7no+rY51JFIEWw+87VUKFJkgTz8Aiff0vJA8ojtTSrC/vfPIT8L4H7ySaMiU2oPgaw SCm9m3kec1yYM4CTfW/mJji7gRlbTv7qvzroZlPzjeEfoz9PA8ZU9Uc2Yq8GPlZ1HAHGc WHKO9d5F3yn1zond5UQjbZScwkK+gsol5HhB2jamQj/b5WO/biJF6fW+HiL/KD4YRKxsG 49/wLKon4++oHOdLcKh0LBZG64gh7liB0Zq9eH+PEDJ4+PZeXP4AeySx5YSFJoBiuaw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=gy0QC8wA; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 48923606A322 for ; Thu, 3 Dec 2026 07:22:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=gy0QC8wA Received: by smtp.kernel.org (Postfix) with ESMTPSA id C0E5F1F00893; Thu, 3 Dec 2026 07:22:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796282534; bh=3iccCNRxEfrawATy1t1EG9z8TlEJTNeNEgfVCuzuBGg=; h=From:Subject:Reply-To:To:In-Reply-To:References:Date; b=gy0QC8wAa/n8TNjtqbJU5R+LfT2RfgLsEz644XZvqX35XO8SWJfivsWSYn5ovamu7 uHNuJFMFn9PoqeUIGwwBmVzfE4UdQs9s5Eie0JTiVQpEbmuClSl11LglwVBCvMPZB6 25keGrGbyXj8duScSYoyXAWdVQNs85QE1KP3qlKWflFBvadGs6oveu+5BWznqJrOUO tjP3ZdpDz+KhX1TPmOMOZdlcL4QMG2I9Jtq/NL2/ZWxwCcHyov85bN5WGtJb8d3rpi 6WrOV6fC6CFAJLDdBb4UMAG9oGuWC2FSaXeDjlp2TKUBOvehCLaSUG/DTk6ZB/Ire5 FlpFGFRfPqrDA== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH mptcp-next v10 1/4] mptcp: track app-limited state in mptcp_sendmsg Reply-To: sashiko-reviews@lists.linux.dev To: "Geliang Tang" , mptcp@lists.linux.dev In-Reply-To: <3311ba5fb214546589dbeddb9051eee19201c63d.1796281059.git.tanggeliang@kylinos.cn> References: <3311ba5fb214546589dbeddb9051eee19201c63d.1796281059.git.tanggeliang@kylinos.cn> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Thu, 03 Dec 2026 07:22:14 +0000 X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Thank you for your contribution! Sashiko AI review found 4 potential issues to consider: - [Medium] mptcp: stale msk->app_limited persists past mptcp_sendmsg() into later pushes - [Medium] mptcp: clearing msk->app_limited on first subflow skips other subflows - [Low] mptcp: unlocked read of msk->cb_flags in mptcp_rate_check_app_limited() - [Low] mptcp: overflowing u8 bitfield with app_limited grows struct mptcp_sock -- commit e31ed458b18e6de3bbc4393082fedf86b119c7a2 Author: Geliang Tang mptcp: track app-limited state in mptcp_sendmsg This commit adds mptcp_rate_check_app_limited() to latch MPTCP-level application-limited state in msk->app_limited at the start of mptcp_sendmsg(), and consumes it in __subflow_push_pending() by calling tcp_rate_check_app_limited() on the scheduled subflow. > diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c > index b9c6e5a615c8b..7e0bafef6735c 100644 > --- a/net/mptcp/protocol.c > +++ b/net/mptcp/protocol.c > @@ -1815,6 +1815,11 @@ static int __subflow_push_pending(struct sock *sk,= struct sock *ssk, > struct mptcp_data_frag *dfrag; > int len, copied =3D 0, err =3D 0; > =20 > + if (msk->app_limited) { > + tcp_rate_check_app_limited(ssk); > + msk->app_limited =3D 0; > + } > + > while ((dfrag =3D mptcp_send_head(sk))) { > info->sent =3D dfrag->already_sent; > info->limit =3D dfrag->data_len; [Severity: Medium] Does clearing msk->app_limited here skip tcp_rate_check_app_limited() on other idle subflows? When a burst after an idle gap exceeds MPTCP_SEND_BURST_SIZE (or a scheduler marks multiple subflows in one mptcp_sched_get_send() call), __mptcp_push_pending() pushes across multiple subflows, but every subflow after the first sees msk->app_limited =3D=3D 0. Because mptcp_subflow_get_send() compares linger_time with strict less-than, the first idle subflow on conn_list is always picked first and clears the flag, leaving secondary subflows running BBR to treat app-limited samples as non-app-limited. Clearing msk->app_limited before mptcp_sendmsg_frag() also loses the flag when the first scheduled subflow fails to enqueue any data, so the next subflow that actually transmits misses the check. > @@ -2112,6 +2117,20 @@ static void mptcp_rps_record_subflows(const struct= mptcp_sock *msk) > } > } > =20 > +static void mptcp_rate_check_app_limited(struct sock *sk) > +{ > + struct mptcp_sock *msk =3D mptcp_sk(sk); > + unsigned long flags, cb_flags; > + > + flags =3D READ_ONCE(msk->flags); > + cb_flags =3D READ_ONCE(msk->cb_flags); > + > + msk->app_limited =3D msk->write_seq =3D=3D msk->snd_nxt && > + !mptcp_send_head(sk) && > + !test_bit(MPTCP_WORK_RTX, &flags) && > + !test_bit(MPTCP_RETRANSMIT, &cb_flags); > +} > + > static int mptcp_sendmsg(struct sock *sk, struct msghdr *msg, size_t len) > { > struct mptcp_sock *msk =3D mptcp_sk(sk); [Severity: Low] Is reading msk->cb_flags without mptcp_data_lock(sk) a data race? mptcp_sendmsg() holds lock_sock(sk) without mptcp_data_lock(sk), while softirq and timer handlers modify msk->cb_flags with non-atomic __set_bit() under bh_lock_sock(sk) specifically when sock_owned_by_user() is true: CPU0 CPU1 () mptcp_sendmsg() lock_sock(sk) mptcp_rate_check_app_limited() READ_ONCE(msk->cb_flags) mptcp_retransmit_timer() bh_lock_sock(sk) __set_bit(MPTCP_RETRANSMIT, &msk->cb_flags) <-- data race Pairing an unmarked non-atomic __set_bit() with an unlocked READ_ONCE() violates msk->cb_flags locking and triggers KCSAN under CONFIG_KCSAN_STRICT=3Dy. > @@ -2142,6 +2161,9 @@ static int mptcp_sendmsg(struct sock *sk, struct ms= ghdr *msg, size_t len) > =20 > timeo =3D sock_sndtimeo(sk, msg->msg_flags & MSG_DONTWAIT); > =20 > + /* is sending application-limited? */ > + mptcp_rate_check_app_limited(sk); > + > if ((1 << sk->sk_state) & ~(TCPF_ESTABLISHED | TCPF_CLOSE_WAIT)) { > ret =3D sk_stream_wait_connect(sk, &timeo); > if (ret) [Severity: Medium] Can msk->app_limited remain stale past this mptcp_sendmsg() call and falsely mark a later push as application-limited? msk->app_limited is only cleared inside __subflow_push_pending(). Because __mptcp_sync_sndbuf() sets sk->sk_sndbuf larger than each subflow's sk_sndbuf, a prior push routinely drains msk->rtx_queue (leaving write_seq =3D=3D snd_nxt and !mptcp_send_head(sk)) while filling ssk so !sk_stream_memory_free(ssk). On the next back-to-back mptcp_sendmsg(), mptcp_rate_check_app_limited() sets msk->app_limited =3D 1, the copy loop enqueues new dfrags, and __mptcp_push_pending() breaks out when mptcp_sched_get_send() finds no subflow with free memory. msk->app_limited then stays 1 while unsent dfrags sit queued. When an ACK later drains ssk and triggers ack_update_msk() -> __mptcp_check_push() -> __subflow_push_pending(), it consumes the stale flag and calls tcp_rate_check_app_limited(ssk), letting BBR misclassify non-app-limited samples and degrading bandwidth estimation. The same stale flag survives across sk_stream_wait_memory() when msk's send buffer is full, as well as early exits with copied =3D=3D 0. Clearing msk->app_limited before sleeping in wait_for_memory and on exit from mptcp_sendmsg() would keep it scoped to the current send. > diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h > index 7cdd0a7e8296b..97c6e3281acc4 100644 > --- a/net/mptcp/protocol.h > +++ b/net/mptcp/protocol.h > @@ -349,7 +349,8 @@ struct mptcp_sock { > in_accept_queue:1, > free_first:1, > rcvspace_init:1, > - fastclosing:1; > + fastclosing:1, > + app_limited:1; > u32 notsent_lowat; > int keepalive_cnt; > int keepalive_idle; [Severity: Low] Does adding app_limited:1 as a 9th bit to this u8 bitfield grow struct mptcp_sock by 8 bytes? Overflowing the 8-bit group adds 3 bytes of padding before notsent_lowat and 4 bytes of padding after maxseg before struct work_struct work, enlarging both struct mptcp_sock and struct mptcp6_sock. Placing a bool app_limited in the existing 2-byte hole between allow_subflows and subflow_id avoids any size increase. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/cover.1796281059.gi= t.tanggeliang@kylinos.cn?part=3D1