From: sashiko-bot@kernel.org
To: "Geliang Tang" <geliang@kernel.org>, mptcp@lists.linux.dev
Subject: Re: [PATCH mptcp-next v15 05/11] mptcp: defer read_sock cleanup to mptcp_worker
Date: Fri, 23 Oct 2026 02:29:56 +0000 [thread overview]
Message-ID: <sashiko-outbox-182233@kernel.org> (raw)
In-Reply-To: <d3072fed79af4d6dc637fd7ecf2263ac0d189cc6.1792718041.git.tanggeliang@kylinos.cn>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] mptcp: msk->read_copied overflow in __mptcp_read_sock() skips rbuf cleanup
--
commit dbba5fc9642f463a94cfb4b42a591e715b089eca
Author: Paolo Abeni <pabeni@redhat.com>
mptcp: defer read_sock cleanup to mptcp_worker
This commit defers mptcp_rcv_space_adjust() and mptcp_cleanup_rbuf() from
__mptcp_read_sock() to mptcp_worker() by accumulating consumed bytes in
msk->read_copied and scheduling work with MPTCP_WORK_READ_COMPLETE.
> diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c
> index 01eb7fb314e76..3c3ad8991799a 100644
> --- a/net/mptcp/protocol.c
> +++ b/net/mptcp/protocol.c
> @@ -3149,6 +3149,21 @@ static void mptcp_backlog_purge(struct sock *sk)
> sk_mem_reclaim(sk);
> }
>
> +static void mptcp_read_complete(struct sock *sk)
> +{
> + struct mptcp_sock *msk = mptcp_sk(sk);
> + int read_copied;
> +
> + mptcp_data_lock(sk);
> + read_copied = msk->read_copied;
> + msk->read_copied = 0;
> + mptcp_data_unlock(sk);
> +
> + mptcp_rcv_space_adjust(msk, read_copied);
> + if (read_copied > 0)
> + mptcp_cleanup_rbuf(msk, read_copied);
> +}
[ ... ]
> @@ -4696,11 +4712,14 @@ static int __mptcp_read_sock(struct sock *sk, read_descriptor_t *desc,
> if (noack)
> goto out;
>
> - mptcp_rcv_space_adjust(msk, copied);
> -
> + /* The backlog flushing is only needed when some data is actually
> + * moved and will take place in mptcp_release_cb() via
> + * release_sock() in the worker.
> + */
> if (copied > 0) {
> - mptcp_recv_skb(sk, &offset);
> - mptcp_cleanup_rbuf(msk, copied);
> + msk->read_copied += copied;
> + set_bit(MPTCP_WORK_READ_COMPLETE, &msk->flags);
> + mptcp_schedule_work(sk);
> }
[Severity: Medium]
Can accumulating copied into msk->read_copied in __mptcp_read_sock() without
saturating cause mptcp_read_complete() to skip receive buffer cleanup and
window updates when msk->read_copied wraps?
In net/mptcp/protocol.h, struct mptcp_sock defines read_copied as a signed
int. If multiple calls to __mptcp_read_sock() (for example via
mptcp_splice_read() or BH-context sk->sk_read_sock()) consume enough data
before mptcp_worker() runs mptcp_read_complete() that msk->read_copied
overflows and wraps to zero or a negative value, mptcp_read_complete() resets
msk->read_copied to 0 and skips mptcp_cleanup_rbuf(msk, read_copied).
At the same time, mptcp_rcv_space_adjust() in net/mptcp/protocol.c also
returns early when copied <= 0, and when given a large positive accumulated
read_copied it adds into another signed int without saturation:
net/mptcp/protocol.c:mptcp_rcv_space_adjust() {
...
if (copied <= 0)
return;
if (!msk->rcvspace_init)
mptcp_rcv_space_init(msk, msk->first);
msk->rcvq_space.copied += copied;
...
}
Skipping mptcp_cleanup_rbuf() after draining the receive queue prevents
subflows from calling tcp_cleanup_rbuf() to send window-update ACKs, which can
stall the connection if the receive window was exhausted, while also skipping
receive buffer autotuning.
Would it make sense to use saturating addition (or a wider type) when
accumulating msk->read_copied and msk->rcvq_space.copied so thatread_copied
remains positive when mptcp_read_complete() drains it?
--
Sashiko AI review · https://sashiko.dev/#/patchset/cover.1792718041.git.tanggeliang@kylinos.cn?part=5
next prev parent reply other threads:[~2026-10-23 2:29 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-23 1:58 [PATCH mptcp-next v15 00/11] Reduce the differences between TCP and MPTCP for TLS usage Geliang Tang
2026-10-23 1:58 ` [PATCH mptcp-next v15 01/11] mptcp: drop the mptcp_ooo_try_coalesce() helper Geliang Tang
2026-10-23 1:58 ` [PATCH mptcp-next v15 02/11] mptcp: drop the cant_coalesce CB field Geliang Tang
2026-10-23 2:35 ` sashiko-bot
2026-10-23 1:58 ` [PATCH mptcp-next v15 03/11] mptcp: remove CB offset field Geliang Tang
2026-10-23 1:58 ` [PATCH mptcp-next v15 04/11] mptcp: sync mptcp skb cb layout with tcp one Geliang Tang
2026-10-23 2:35 ` sashiko-bot
2026-10-23 1:58 ` [PATCH mptcp-next v15 05/11] mptcp: defer read_sock cleanup to mptcp_worker Geliang Tang
2026-10-23 2:29 ` sashiko-bot [this message]
2026-10-23 1:58 ` [PATCH mptcp-next v15 06/11] mptcp: align FIN handling with TCP via SOCK_DONE Geliang Tang
2026-10-23 2:29 ` sashiko-bot
2026-10-23 1:58 ` [PATCH mptcp-next v15 07/11] mptcp: implement peek_len for proto_ops Geliang Tang
2026-10-23 2:19 ` sashiko-bot
2026-10-23 1:58 ` [PATCH mptcp-next v15 08/11] mptcp: add sendmsg_locked to proto_ops Geliang Tang
2026-10-23 1:58 ` [PATCH mptcp-next v15 09/11] mptcp: track app-limited state in mptcp_sendmsg Geliang Tang
2026-10-23 1:58 ` [PATCH mptcp-next v15 10/11] selftests: mptcp: sockopt: check app_limited Geliang Tang
2026-10-23 1:58 ` [PATCH mptcp-next v15 11/11] mptcp: update mptcp_check_readable Geliang Tang
2026-10-23 3:11 ` [PATCH mptcp-next v15 00/11] Reduce the differences between TCP and MPTCP for TLS usage MPTCP CI
-- strict thread matches above, loose matches on Subject: below --
2026-10-24 16:26 [PATCH mptcp-next v15 05/11] mptcp: defer read_sock cleanup to mptcp_worker netdev-bot+sashiko
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=sashiko-outbox-182233@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=geliang@kernel.org \
--cc=mptcp@lists.linux.dev \
--cc=sashiko-reviews@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.