All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Geliang Tang" <geliang@kernel.org>, mptcp@lists.linux.dev
Subject: Re: [PATCH mptcp-next v9] mptcp: count the DATA_FIN in mptcp_inq_hint
Date: Sun, 06 Dec 2026 01:28:49 +0000	[thread overview]
Message-ID: <sashiko-outbox-252039@kernel.org> (raw)
In-Reply-To: <30e3f1d6eabedf2cc62dbb742d48983187c90ffd.1796518897.git.tanggeliang@kylinos.cn>

Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [Medium] mptcp: mptcp_recvmsg() can return EOF instead of ECONNRESET
  on fallback RST
- [Low] mptcp: mptcp_splice_read() skips pending DATA_FIN processing
--

commit 2c5b77605c15fa6fb81035b488f9f109e3948643
Author: Geliang Tang <geliang@kernel.org>

mptcp: count the DATA_FIN in mptcp_inq_hint

This commit adds the DATA_FIN byte to mptcp_inq_hint() when SOCK_DONE is
set or a pending EOF is detected, and processes pending DATA_FINs
synchronously in mptcp_recvmsg().

> diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c
> index 14fca55d46199..7ae33bfd2d448 100644
> --- a/net/mptcp/protocol.c
> +++ b/net/mptcp/protocol.c

[ ... ]

> @@ -2480,22 +2495,15 @@ static bool mptcp_move_skbs(struct sock *sk)
>  static unsigned int mptcp_inq_hint(const struct sock *sk)
>  {
>  	const struct mptcp_sock *msk = mptcp_sk(sk);
> -	const struct sk_buff *skb;
> -
> -	skb = skb_peek(&sk->sk_receive_queue);
> -	if (skb) {
> -		u64 hint_val = mptcp_data_avail(msk);
> +	u64 hint_val = mptcp_data_avail(msk);
>  
> -		if (hint_val >= INT_MAX)
> -			return INT_MAX;
> -
> -		return (unsigned int)hint_val;
> -	}
> +	if (hint_val >= INT_MAX)
> +		return INT_MAX;
>  
> -	if (sock_flag(sk, SOCK_DONE))
> -		return 1;
> +	if (sock_flag(sk, SOCK_DONE) || mptcp_pending_eof(sk, NULL))
> +		hint_val += 1;
>  
> -	return 0;
> +	return (unsigned int)hint_val;
>  }

[Severity: Low]
Does mptcp_splice_read() also need to process a pending DATA_FIN
synchronously?

A zero-length recvmsg() with TCP_INQ skips the receive loop in
mptcp_recvmsg() without calling mptcp_check_data_fin(), yet
mptcp_inq_hint() still advertises the pending EOF byte via
mptcp_pending_eof().

If userspace then calls non-blocking splice() before mptcp_worker() runs
while msk->backlog_list is empty, mptcp_recv_skb() skips
mptcp_move_skbs(), so SOCK_DONE and RCV_SHUTDOWN remain unset and
mptcp_splice_read() returns -EAGAIN instead of 0.  Processing a pending
DATA_FIN synchronously in mptcp_splice_read() would close this window.

> @@ -2544,6 +2552,12 @@ static int mptcp_recvmsg(struct sock *sk, struct msghdr *msg, size_t len,
>  		if (!list_empty(&msk->backlog_list) && mptcp_move_skbs(sk))
>  			continue;
>  
> +		/* The RX path may have queued the data directly and left
> +		 * the DATA_FIN for the worker to process.
> +		 */
> +		if (unlikely(READ_ONCE(msk->rcv_data_fin)))
> +			mptcp_check_data_fin(sk);
> +
>  		/* only the MPTCP socket status is relevant here. The exit
>  		 * conditions mirror closely tcp_recvmsg()
>  		 */

[Severity: Medium]
Can calling mptcp_check_data_fin() unconditionally here cause
mptcp_recvmsg() to return 0 instead of -ECONNRESET on a fallback socket
reset?

CPU0                               CPU1 (<softirq>)
mptcp_recvmsg()
  lock_sock(sk)
                                   tcp_reset(ssk)
                                     tcp_done_with_error(ssk, ECONNRESET)
                                       subflow_state_change(ssk)
                                         subflow_sched_work_if_closed()
                                           msk->rcv_data_fin = 1
                                         subflow_error_report(ssk)
                                           set MPTCP_ERROR_REPORT in cb_flags
  mptcp_check_data_fin(sk)
    sk->sk_shutdown |= RCV_SHUTDOWN
  sock_error(sk) == 0
  if (sk->sk_shutdown & RCV_SHUTDOWN)
    break;  <-- returns 0 (EOF)
  release_sock(sk)
    __mptcp_error_report(sk)

On a fallback connection with an empty receive queue, a concurrent RST
sets msk->rcv_data_fin via subflow_sched_work_if_closed() without setting
SOCK_DONE on msk->first.  Because lock_sock(sk) is held,
subflow_error_report() defers sk->sk_err until release_sock(sk).

mptcp_check_data_fin() still sets RCV_SHUTDOWN when mptcp_check_fin_eof()
is false, so mptcp_recvmsg() sees sock_error(sk) == 0 and returns 0
instead of -ECONNRESET.  Gating this call on mptcp_pending_eof(sk, NULL)
would avoid consuming a RST-emulated DATA_FIN before error propagation.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/30e3f1d6eabedf2cc62dbb742d48983187c90ffd.1796518897.git.tanggeliang@kylinos.cn?part=1

      reply	other threads:[~2026-12-06  1:28 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-06  1:07 [PATCH mptcp-next v9] mptcp: count the DATA_FIN in mptcp_inq_hint Geliang Tang
2026-12-06  1:28 ` sashiko-bot [this message]

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-252039@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.