From: Sabrina Dubroca <sd@queasysnail.net>
To: dickson.wu@certik.com
Cc: netdev@vger.kernel.org, John Fastabend <john.fastabend@gmail.com>,
Jakub Kicinski <kuba@kernel.org>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@kernel.org>,
Paolo Abeni <pabeni@redhat.com>,
Willem de Bruijn <willemb@google.com>,
Simon Horman <horms@kernel.org>
Subject: Re: [PATCH net v2] tls: avoid recursion in tls_rx_rec_wait()
Date: Fri, 4 Dec 2026 15:18:15 +0100 [thread overview]
Message-ID: <axLLpy5qrG5TmFgV@krikkit> (raw)
In-Reply-To: <20261201-ktls-recwait-v2-1-12d374acc0ae@certik.com>
2026-12-01, 20:37:45 +0000, Dickson Wu via B4 Relay wrote:
> From: Dickson Wu <dickson.wu@certik.com>
>
> When a ready record disappears from the TCP receive queue while the
> socket lock is released, tls_strp_msg_load() returns false and
> tls_rx_rec_wait() retries by calling itself.
>
> The wait-queue helpers receive a pointer to a wait entry on this
> function's stack. The compiler cannot tell whether they still have
> that pointer after the entry is removed, so it keeps the stack frame
> when the function calls itself again. GCC 14.2.0 and 15.3.0 and Clang
> 19.1.7 and 20.1.8 all emit a call on x86_64 defconfig with CONFIG_TLS=y,
> both with and without KASAN. Each retry adds 128 to 288 bytes to the
> kernel stack.
>
> A local user can keep draining the queue with TCP_ZEROCOPY_RECEIVE while
> a reader waits and overflow the kernel stack. With CONFIG_VMAP_STACK
> that hits the guard page and panics.
>
> Go back to the top of the function instead, as suggested when the
> retry was added, resetting released and ret to what the recursive call
> used.
>
> Suggested-by: Paolo Abeni <pabeni@redhat.com>
> Link: https://lore.kernel.org/netdev/b3a83032-8ed4-4d5d-9df9-6dbd02acac1c@redhat.com/
> Fixes: 6db015fc4b5d ("tls: handle data disappearing from under the TLS ULP")
> Signed-off-by: Dickson Wu <dickson.wu@certik.com>
> ---
> Changes in v2:
> - Order the local declarations from longest to shortest.
> - Explain why the compiler keeps the wait entry's stack frame.
> - Report GCC 14/15 and Clang 19/20 results with and without KASAN.
Thanks.
Reviewed-by: Sabrina Dubroca <sd@queasysnail.net>
> @@ -1101,12 +1101,13 @@ unlock:
> static int
> tls_rx_rec_wait(struct sock *sk, bool nonblock, bool released, bool has_copied)
> {
> - struct tls_context *tls_ctx = tls_get_ctx(sk);
> - struct tls_sw_context_rx *ctx = tls_sw_ctx_rx(tls_ctx);
> + struct tls_sw_context_rx *ctx = tls_sw_ctx_rx(tls_get_ctx(sk));
Sorry, I meant only for the "int ret" change. xmas tree ordering for
tls_ctx is not really possible in many functions.
(no need to resend)
--
Sabrina
prev parent reply other threads:[~2026-12-04 14:18 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-27 14:01 [PATCH net] tls: avoid recursion in tls_rx_rec_wait() Dickson Wu via B4 Relay
2026-11-30 11:48 ` Sabrina Dubroca
2026-11-30 18:51 ` Dickson Wu
2026-12-01 20:38 ` Dickson Wu
2026-12-01 20:37 ` [PATCH net v2] " Dickson Wu via B4 Relay
2026-12-04 14:18 ` Sabrina Dubroca [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=axLLpy5qrG5TmFgV@krikkit \
--to=sd@queasysnail.net \
--cc=davem@davemloft.net \
--cc=dickson.wu@certik.com \
--cc=edumazet@kernel.org \
--cc=horms@kernel.org \
--cc=john.fastabend@gmail.com \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=willemb@google.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