From: Matthieu Baerts <matttbe@kernel.org>
To: Li Xiasong <lixiasong1@huawei.com>,
Mat Martineau <martineau@kernel.org>,
Geliang Tang <geliang@kernel.org>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Simon Horman <horms@kernel.org>
Cc: netdev@vger.kernel.org, mptcp@lists.linux.dev,
linux-kernel@vger.kernel.org, yuehaibing@huawei.com,
zhangchangzhong@huawei.com, weiyongjun1@huawei.com
Subject: Re: [PATCH net v2] mptcp: fix soft lockup in mptcp_recvmsg()
Date: Tue, 24 Mar 2026 20:23:33 +0100 [thread overview]
Message-ID: <12ad947e-f386-4fcc-9043-bf4f95a7db83@kernel.org> (raw)
In-Reply-To: <20260324085131.4187473-1-lixiasong1@huawei.com>
Hi Li,
On 24/03/2026 09:51, Li Xiasong wrote:
> syzbot reported a soft lockup in mptcp_recvmsg() [0].
>
> When receiving data with MSG_PEEK | MSG_WAITALL flags, the skb is not
> removed from the sk_receive_queue. This causes sk_wait_data() to always
> find available data and never perform actual waiting, leading to a soft
> lockup.
>
> Fix this by adding a 'last' parameter to track the last peeked skb.
> This allows sk_wait_data() to make informed waiting decisions and prevent
> infinite loops when MSG_PEEK is used.
(...)
> diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c
> index cf1852b99963..401fb2b17685 100644
> --- a/net/mptcp/protocol.c
> +++ b/net/mptcp/protocol.c
> @@ -2006,7 +2006,7 @@ static void mptcp_eat_recv_skb(struct sock *sk, struct sk_buff *skb)
> static int __mptcp_recvmsg_mskq(struct sock *sk, struct msghdr *msg,
> size_t len, int flags, int copied_total,
> struct scm_timestamping_internal *tss,
> - int *cmsg_flags)
> + int *cmsg_flags, struct sk_buff **last)
> {
> struct mptcp_sock *msk = mptcp_sk(sk);
> struct sk_buff *skb, *tmp;
> @@ -2048,6 +2048,7 @@ static int __mptcp_recvmsg_mskq(struct sock *sk, struct msghdr *msg,
> }
>
> copied += count;
> + *last = skb;
My bad, my recommendation to move this assignment here was not a good
idea, because 'skb' can be freed at some points after mptcp_eat_recv_skb
that can be called here below.
If I'm not mistaken, when MSG_PEEK is not used, sk_wait_data() can
always be called with NULL for the last skb, because the queue is
supposed to be empty. If not, no need to wait for new packets, so NULL
can be used. Is that correct?
If yes, then I guess 'last' can be initialised to NULL before calling
__mptcp_recvmsg_mskq (limit scope), and only set to 'skb' here below,
when MSG_PEEK is not used (what you had in v1).
Would that work for you?
Cheers,
Matt
--
Sponsored by the NGI0 Core fund.
next prev parent reply other threads:[~2026-03-24 19:23 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-24 8:51 [PATCH net v2] mptcp: fix soft lockup in mptcp_recvmsg() Li Xiasong
2026-03-24 11:35 ` Matthieu Baerts
2026-03-24 19:23 ` Matthieu Baerts [this message]
2026-03-25 2:39 ` Li Xiasong
2026-03-25 7:16 ` Matthieu Baerts
2026-03-25 9:04 ` Matthieu Baerts
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=12ad947e-f386-4fcc-9043-bf4f95a7db83@kernel.org \
--to=matttbe@kernel.org \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=geliang@kernel.org \
--cc=horms@kernel.org \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lixiasong1@huawei.com \
--cc=martineau@kernel.org \
--cc=mptcp@lists.linux.dev \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=weiyongjun1@huawei.com \
--cc=yuehaibing@huawei.com \
--cc=zhangchangzhong@huawei.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox