From mboxrd@z Thu Jan 1 00:00:00 1970 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=1796323837; b=FUGfQ/sFaFfV11AYsxmUVWiJqW0bYKaG33mUTvC/XtKz65eeTb45GUCr5CPhlPgX8i8k YZdOqhJw+6uHFMOzh2UqFKm1j/n4NZGjqZuAlsVrE1U0+uuJmmt87uEwMLcSbN6eXMoPj uxwhQ+NByJxbDastWlX5wst44N4FCEPRI6Sz1lef5Aah3FTl9UcD2TcSVyNzL5HAh9AyZ E75qm1GIHK1YHzjD88Dn8WNfTd65Bp25ow2uqKD/IBYXkNboetPzj/F+jq9/r5N/79ctS B3WI3yTlhfkQxnGFoxGwXKUZSsK+TmmB3KB27hikibRMt7Ewhqh3ZhPlfKAITBOqHsg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796323837; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=qRQovcrhBRQCsoM8acwaFJICE4Ma/SYcDL57UMprKEo=; b=kkHKhpRWKUBrgd4+WQcI0H83LzOvZYJFdZDmOrhz1qPifPd4dpA7jSFxlP+YrhMEm5gF 4etUr46e9rCujLcntCV9IXgKj33M4jOMgcPM/KfNsghjCBnTuALUr4Dw/4AJgSbFbbArc R0r9mFwaHf3lC7a8UK8eBBMfZtcyMOwF98SWUSRVslmEu2CiGXNC45wwX708gDYcGOG83 7BulClDLdYy1iUk6xRmYYtXWhzC1WSHbFBRNR9FPxY/ck87sXt41nRDLlyIUA0or2Ox7V U9tlhXz91xmx5D0x6He2KW5U6MbuZ3CCzG8A3qcMmaa+kA3RArSqmD7ZzMpTEMkmSlQ== 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=knLwKx9K; 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 7C101606A336 for ; Thu, 3 Dec 2026 18:50:37 +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=knLwKx9K Received: by smtp.kernel.org (Postfix) with ESMTPSA id 49E4F1F000C1; Thu, 3 Dec 2026 18:50:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796323837; bh=qRQovcrhBRQCsoM8acwaFJICE4Ma/SYcDL57UMprKEo=; h=From:Subject:Reply-To:To:In-Reply-To:References:Date; b=knLwKx9KrTooJztndZxZcLIJNKiDOliTbPR5IpzCYu2wna9L0IoA30z1fgZXlVW2k pZb5RH84KgZQUVlh/YcRnkNLkUQZJBc6HjEkjt+PyAurwPf8hsVHn7ir0cCJFXkb6a KVuZnZzfPPHk7h8DOkxvvXonaA0Y/bNUOPM11UW8VMBSJEqkHm3dFt4FSsgc4O+A8u 18eAi32grPqJmMzjyVteqc+4NTNnwqkt3ZCNolozTJuvq6pDUhKYxFBn3EIOAJBWuY 3jb8QAm1hAVphx6zFgoC/qygM2h179nIQRBHuXuNzcWQVZY08H7bmoXZL0Jk7C+zd8 qZYNJSPSUGEkg== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH mptcp-next mptcp-net v7 6/6] mptcp: count the DATA_FIN in mptcp_inq_hint Reply-To: sashiko-reviews@lists.linux.dev To: =?utf-8?b?TWF0dGhpZXUgQmFlcnRzIChOR0kwKQ==?= , "MPTCP Linux" In-Reply-To: <20261203-mptcp-fixes-for-siocinq-v7-6-e6d589de9cf8@kernel.org> References: <20261203-mptcp-fixes-for-siocinq-v7-0-e6d589de9cf8@kernel.org> <20261203-mptcp-fixes-for-siocinq-v7-6-e6d589de9cf8@kernel.org> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Thu, 03 Dec 2026 18:50:36 +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 3 potential issues to consider: - [Medium] mptcp: mptcp_inq_hint() omits pending FIN byte on fallback sockets - [Medium] mptcp: race in mptcp_inq_hint() counts spurious FIN on fallback RST - [Low] mptcp: mptcp_inq_hint() omits TCP_CLOSE check for rcv_data_fin -- commit 3d490bb2690ae1fefdf4a528196f8efa6be2b028 Author: Geliang Tang mptcp: count the DATA_FIN in mptcp_inq_hint This commit updates mptcp_inq_hint() to add the FIN byte to the available data count when SOCK_DONE is set or when a non-fallback connection has an in-sequence DATA_FIN pending. > diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c > index 1d330c5d09f42..e0e6266e11c85 100644 > --- a/net/mptcp/protocol.c > +++ b/net/mptcp/protocol.c > @@ -2487,22 +2487,17 @@ static bool mptcp_move_skbs(struct sock *sk) > static unsigned int mptcp_inq_hint(const struct sock *sk) > { > const struct mptcp_sock *msk =3D mptcp_sk(sk); > - const struct sk_buff *skb; > + u64 hint_val =3D mptcp_data_avail(msk); > =20 > - skb =3D skb_peek(&sk->sk_receive_queue); > - if (skb) { > - u64 hint_val =3D mptcp_data_avail(msk); > - > - if (hint_val >=3D INT_MAX) > - return INT_MAX; > - > - return (unsigned int)hint_val; > - } > + if (hint_val >=3D INT_MAX) > + return INT_MAX; > =20 > - if (sock_flag(sk, SOCK_DONE)) > - return 1; > + if (sock_flag(sk, SOCK_DONE) || > + (!__mptcp_check_fallback(msk) && > + mptcp_rcv_data_fin_in_seq(sk, NULL))) > + hint_val +=3D 1; [Severity: Medium] Can excluding __mptcp_check_fallback(msk) here omit the pending FIN byte on fallback sockets before mptcp_worker() sets SOCK_DONE on sk? When a fallen-back socket receives data and a TCP FIN in softirq, tcp_fin() sets SOCK_DONE on msk->first, move_skbs_to_msk() queues the data directly on sk->sk_receive_queue, and mptcp_data_ready() wakes userspace while SOCK_DONE propagation waits on mptcp_worker(): CPU0 (softirq / kworker) CPU1 (userspace) tcp_fin() sock_set_flag(ssk, SOCK_DONE) mptcp_data_ready() move_skbs_to_msk() sk->sk_data_ready(sk) subflow_sched_work_if_closed() mptcp_update_rcv_data_fin() mptcp_schedule_work(sk) mptcp_recvmsg() lock_sock(sk) ... (backlog_list empty) mptcp_worker() lock_sock(sk) (blocks) mptcp_inq_hint() <-- omits +1 With msk->backlog_list empty, mptcp_recvmsg() skips mptcp_move_skbs() and mptcp_check_data_fin(), so TCP_CM_INQ under-reports by 1 byte (or returns 0 instead of 1 after draining the last data bytes). Since callers of mptcp_inq_hint() hold lock_sock(sk), this could mirror mptcp_check_data_fin() and check (!__mptcp_check_fallback(msk) || (msk->first && sock_flag(msk->first, SOCK_DONE))) to count fallback FINs while still excluding fallback RSTs. [Severity: Medium] Does testing !__mptcp_check_fallback(msk) before mptcp_rcv_data_fin_in_seq(sk, NULL) race with a concurrent fallback and TCP RST and count a spurious FIN byte? mptcp_inq_hint() runs under lock_sock(sk) without msk->fallback_lock or the subflow lock. Concurrently in softirq, a non-MP_CAPABLE RST before fully_established (or a fallback followed by RST) sets MPTCP_FALLBACK_DONE before smp_wmb() and msk->rcv_data_fin =3D 1: CPU0 (userspace) CPU1 (softirq) mptcp_inq_hint() !__mptcp_check_fallback(msk) (true) tcp_reset() __mptcp_try_fallback() set_bit(MPTCP_FALLBACK_DONE, ...) subflow_sched_work_if_closed() mptcp_update_rcv_data_fin() smp_wmb() msk->rcv_data_fin =3D 1 mptcp_rcv_data_fin_in_seq() (true -> hint_val +=3D 1) <-- spurious FIN Because the reader checks MPTCP_FALLBACK_DONE before msk->rcv_data_fin with no barrier in between, it can observe the emulated DATA_FIN from the RST and report an unread FIN byte on a reset connection. Calling mptcp_rcv_data_fin_in_seq(sk, NULL) first, which executes the pairing smp_rmb() after reading msk->rcv_data_fin, and checking __mptcp_check_fallback(msk) afterward closes both the race window and load reordering. [Severity: Low] Should this check the socket state (like mptcp_pending_data_fin() does) so a stale rcv_data_fin on a TCP_CLOSE socket is not counted? In mptcp_check_fastclose(), mptcp_check_data_fin(sk) runs before locking and closing the subflows. A zero-length in-sequence DATA_FIN arriving on an open subflow in that window sets msk->rcv_data_fin =3D 1 just before sk transitions to TCP_CLOSE with ECONNRESET and SOCK_DONE unset: CPU0 (kworker) CPU1 (softirq) mptcp_check_fastclose() mptcp_check_data_fin(sk) mptcp_incoming_options() mptcp_update_rcv_data_fin() msk->rcv_data_fin =3D 1 sk->sk_err =3D ECONNRESET mptcp_set_state(sk, TCP_CLOSE) <-- rcv_data_fin left stale Once sk is in TCP_CLOSE, mptcp_pending_data_fin() returns false and mptcp_worker() exits early, leaving msk->rcv_data_fin permanently set without SOCK_DONE. When userspace drains queued data, mptcp_inq_hint() still adds +1 to TCP_CM_INQ even though the next recvmsg() will return -ECONNRESET rather than EOF. Using mptcp_pending_data_fin() (or excluding TCP_CLOSE) avoids counting an unprocessable DATA_FIN. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261203-mptcp-fixe= s-for-siocinq-v7-0-e6d589de9cf8@kernel.org?part=3D6