Article View: linux.kernel.netdev
Article #5287Re: [PATCH net v2 1/2] kcm: defer receive parsing when the lower socket's read_sock may sleep
From: netdev-bot+sashiko
Date: Tue, 20 Oct 2026 03:13
Date: Tue, 20 Oct 2026 03:13
133 lines
12391 bytes
12391 bytes
Thank you for your contribution! Sashiko AI review found 1 potential
issue(s) to consider.
Critical: 0 ยท High: 0 ยท Medium: 1 ยท Low: 0
If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).
- [Medium] RX can stall indefinitely when kTLS RX is installed before the
TCP socket is attached to KCM.
--
kcm: defer receive parsing when the lower socket's read_sock may sleep
This patch changes psock_data_ready() so that it only calls
strp_data_ready() inline when the lower socket's read_sock is
tcp_read_sock(). Any other read_sock, such as kTLS's tls_sw_read_sock(),
is handed to the strparser work through strp_check_rcv(), so it runs
under lock_sock() and not in softirq context.
> diff --git a/net/kcm/kcmsock.c b/net/kcm/kcmsock.c
> index 71af69d442f21..ec7aaba17fe60 100644
> --- a/net/kcm/kcmsock.c
> +++ b/net/kcm/kcmsock.c
[ ... ]
> @@ -358,8 +383,12 @@ static void psock_data_ready(struct sock *sk)
> read_lock_bh(&sk->sk_callback_lock);
>
> psock = (struct kcm_psock *)sk->sk_user_data;
> - if (likely(psock))
> - strp_data_ready(&psock->strp);
> + if (likely(psock)) {
> + if (psock_can_parse_inline(sk))
> + strp_data_ready(&psock->strp);
> + else
> + strp_check_rcv(&psock->strp);
> + }
[Severity: Medium]
Can receive stall on a kTLS psock when TLS_RX is configured before
kcm_attach()? The commit message tests this ordering and says there is
"no strparser need_bytes stall".
After this change, every read on a kTLS psock goes through do_strp_work().
That work is only queued again when psock_data_ready() runs, which means
when new TCP data arrives. do_strp_work() itself only requeues on -ENOMEM:
net/strparser/strparser.c:do_strp_work() {
...
if (strp_read_sock(strp) == -ENOMEM)
queue_work(strp_wq, &strp->work);
...
}
When a KCM message spans multiple TLS records, tls_sw_read_sock() calls
tls_rx_rec_done() before read_actor(). The ciphertext of the current
record has therefore already been consumed from the TCP queue:
net/tls/tls_sw.c:tls_sw_read_sock() {
...
tls_rx_rec_done(ctx);
}
...
used = read_actor(desc, skb, rxm->offset, rxm->full_len);
...
}
kTLS does not override peek_len, so in __strp_recv() strp_peek_len() is
tcp_inq(). The current record is no longer counted in it:
net/strparser/strparser.c:__strp_recv() {
...
if (stm->strp.full_len - stm->accum_len >
strp_peek_len(strp)) {
...
strp->need_bytes = stm->strp.full_len -
stm->accum_len;
...
desc->count = 0; /* Stop reading socket */
break;
...
}
Won't this stop the read pass even when the next TLS records are already
fully queued in TCP? The commit message says the need_bytes check in
strp_data_ready() isn't meaningful for kTLS because it counts ciphertext.
This check uses the same TCP byte count, and it is still in place.
A second trigger looks possible as well. If tls_strp_read_sock() returns
-ENOMEM during tls_rx_rec_wait(), tls_strp_check_rcv() queues
tls_strp_work. The nonblocking reader returns -EAGAIN, desc.error stays 0
and kcm_read_sock_done() returns 0, so do_strp_work() does not requeue.
In both cases the next-record notification goes only through this path:
tls_rx_reader_release() or tls_strp_work()
tls_rx_msg_maybe_announce()
ctx->saved_data_ready(strp->sk)
tls_sw_strparser_arm() captured saved_data_ready before kcm_attach()
installed psock_data_ready:
net/tls/tls_sw.c:tls_sw_strparser_arm() {
...
rx_ctx->saved_data_ready = sk->sk_data_ready;
sk->sk_data_ready = tls_data_ready;
...
}
So saved_data_ready is sock_def_readable(), which never reaches the KCM
strparser. Would the last multi-record message of a burst then stay
undelivered until the peer sends more data or a FIN?
The peek check in __strp_recv() and the stale saved_data_ready both
predate this patch. With this patch, though, all progress depends on
psock_data_ready() being called again. Deferring everything to the
workqueue also means segments that arrive while the work is pending get
merged into one read pass, because queue_work() does nothing while the
work is already queued.
>
> read_unlock_bh(&sk->sk_callback_lock);
> }
--
Sashiko AI review ยท https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261016025059.289202-1-rjethwani%40purestorage.com
Technical Details
Message-ID:
<179246598215.3135.10799623566753910125@kernel.org>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-349013-linux-kernel-netdev=dewy.ruReferences:
<20261016025059.289202-2-rjethwani@purestorage.com>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-349013-linux-kernel-netdev=dewy.ru From: netdev-bot+sashiko@kernel.org Newsgroups: linux.kernel.netdev Subject: Re: [PATCH net v2 1/2] kcm: defer receive parsing when the lower socket's read_sock may sleep Date: Tue, 20 Oct 2026 03:13:02 +0000 Organization: Usenet Network Message-ID: <179246598215.3135.10799623566753910125@kernel.org> References: <20261016025059.289202-2-rjethwani@purestorage.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="3774375"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:nPUBlmJ9JO/bOUzdKEwCXGoZj/Q= sha256:nGXyMH9LcapPEERQd4kGq2xB0r/f5b5SdpsAYm86R9A= sha1:7wbL6l3EfHM5900EaQTdsW0GRGY= sha256:RmSNWH2kfCWediLUO20KWKV8SLX26IeaZj+PNAEFAn8= List-ID: <netdev.vger.kernel.org> X-Mailpost-Empty-Hdrs: X-Spam-Level X-Received: from localhost (localhost [127.0.0.1]) by mail.dewy.ru (Postfix) with ESMTP id CE972110BE9; Tue, 20 Oct 2026 06:26:51 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.728 X-Spam-Status: No, score=-3.728 tagged_above=-9999 required=6.31 tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.329, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key) header.d=kernel.org X-Received: from mail.dewy.ru ([127.0.0.1]) by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id rtmCEFkh_vjS; Tue, 20 Oct 2026 06:26:48 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=104.64.211.4; helo=sin.lore.kernel.org; envelope-from=netdev+bounces-349013-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org X-Received: from sin.lore.kernel.org (sin.lore.kernel.org [104.64.211.4]) by mail.dewy.ru (Postfix) with ESMTPS id D83A5110BE3; Tue, 20 Oct 2026 06:26:37 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by sin.lore.kernel.org (Postfix) with ESMTP id 1A0242DAB8; Tue, 20 Oct 2026 03:15:41 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1792465984; b=iB6aW6ZvElJObY1RsiXmHjuyIzjTB7MHlaWoxiYryRCsrwf/5LNArqPbBG2mBomn5goR hne7Nmd/9bzSCtQ85QyY1sDxUAxk/VedGPZ969g3fqoQ+4htPEhmaZfjHDVDsTZ+nPQC1 juBxeIEpmgs6zT1/sV2MpmcRh4e3TNhRKsBG+Zz+DTLlmWD42zM86eh+/rQnX46F/VMUq 7EEZmJ/T7padMczOT6x21SvzZM8YG8pPlbCu5T9SMPWxlUOsWueeoiTW/ze3CUFnxZdpw EHJs+q1HRQo0pqRvxq3QiTAftHUfSPB+UixGIQ/8LQMxSrJcp0dzuXVIriTwXmfE1Vg== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1792465984; h=X-Original-To:Received:Received:DKIM-Signature:Subject:From:To:Cc: Date:Message-ID:In-Reply-To:References:X-sashiko-severity: Content-Type:Content-Transfer-Encoding:X-Mailing-List:List-Id: List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner: Precedence:MIME-Version; bh=8vp1+uc0abbvdHBdCyhwDvYNDCnOgemx3ZrP8ySOog4=; b=5J71kE8MOq9W6dusm2AiaOO0o/11cmTc7zTmDBMCZWRA5+RyAfiYgBqZQCNLlFL/bd6v 9g/2Lo/x+Hpzh+kwSADuy93gXfZjZ3cGvd/UWrRv3UBMuedyPPz8MnrcmmAIZuCfcNUWa GD56kJhZdeQabjqXEnFW2KGvUd/HQsIJ6UrVFAKx1YHRoprz+2sPwXyDj7Ex6jtlGXqt3 7vZNGLCXlJebflYQSj9dizjXJXhcWLZ9YgiuEqa8ASHb47FyFydU1e2+Q+wzMECj6WfG7 adKwqRYwgUcKfc7A3kdHaE/OmsBj33An68v9hRQDOtUmZ7056MYUgN1i2k0xYjLUj5Q== X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b="NsLqQ/hT"; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id AA0B9606AF61; Tue, 20 Oct 2026 03:13:04 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=NsLqQ/hT X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1792465983; b=jE8F5Him2oSlD0XzROuZQeQKdxr+t8MhlGzFEHLybWdczPoqW+zX7cuQYpxMAW85FN8o KL5deF5NDdQunin6I4LllbMhuyIyRfkdtWmCh2rfhcUGIVoDI+eVLWwwkREEbYXB0sowN pG8itS3CLqQaGeMuM4B0IamXI56CtDaLYdpIlf9hVTpz4uB3wXu909GEyXqUIS+R3V1CM 1gSSBG5SW3gjlbFDvweAeKqmuYPTWUxRz0GV2ZUSOMOXfMXHkTdFYazKyEdfFFnlKqkZt M4FgeGqnug20tWPjVUN3GB+xvM8tLbIU8cA3FeDDJClE/CNculpvtWN/rgcJzn5z8Sg== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1792465983; h=Received:DKIM-Signature:Subject:From:To:Cc:Date:Message-ID: In-Reply-To:References:X-sashiko-severity:Content-Type: Content-Transfer-Encoding:MIME-Version; bh=8vp1+uc0abbvdHBdCyhwDvYNDCnOgemx3ZrP8ySOog4=; b=aWcPxetmqc9hYMAYQbh3YtmO6l8dDT4AqAbfSyaGQw7BcANsChQJFvMbucIN3ah7567D NE/ZTywn+JXM3tPFxmbs9W4xN4pL1+yVvPXrzfqWCTxxeVffzkUxCwdKYYjinjJb38CF7 AlYnpRtI/5o24vXilpUiitszsscjWSQXV7gDcfvm/4dZPRdDmVW024HxdIkezmhVznVdY +yIibzEpJMn2jRyy44J8IpHBAV8G5NiP8wwF0immRxk07Ckwj2jScU5Ep6jPO/eFucfCd SSm9q3e2pdpyWZbUH5ulk2zeaTxrxuJQCidh0UCGhDLhUV3FiahogN+WfCs8yVqHYvA== X-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="NsLqQ/hT"; arc=none smtp.remote-ip=100.103.45.18 X-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 857FE606A319 for <netdev@vger.kernel.org>; Tue, 20 Oct 2026 03:13:03 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id A454E1F000C4; Tue, 20 Oct 2026 03:13:02 +0000 (UTC) X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1792465983; bh=8vp1+uc0abbvdHBdCyhwDvYNDCnOgemx3ZrP8ySOog4=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=NsLqQ/hTQ111jtW/ctrQvanQEfS1jVTWVyIevDApfakms/kWZ7g3x4PDBcNjd0xIM XAo6UnFTG9JEm/Ka492yrChQx+3nOPeuZzvZSC0FHFhRLQnL83Rpl/Ghl2wauC/vLk Nyxr/VRWXHP+dKK07d6SiGG6xFSzImwk+Ts9G/Dt323O7GyrUyWnIsfRPrcKkOOf82 kuGTkwFly/TVwn2CCIoAr5VXmi5/1mNlDo9T5m2ijpnjLwY8vd6ksSBQjuQOPNrwAD zrz9HtDXLEAetHCiTYYftfL9UheiMMkbcKjXCnkJjroN0GALg9nWGSCJ2ubvaa1Zq/ 8xu4R2pKi/1xw== X-Cc: netdev@vger.kernel.org, davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com, horms@kernel.org X-In-Reply-To: <20261016025059.289202-2-rjethwani@purestorage.com> X-sashiko-severity: Medium X-Mailing-List: netdev@vger.kernel.org X-List-Post: <mailto:netdev@vger.kernel.org> X-List-Help: <mailto:netdev+help@vger.kernel.org> X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org> X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org> X-List-Owner: <mailto:netdev+owner@vger.kernel.org> X-Precedence: list