All of lore.kernel.org
 help / color / mirror / Atom feed
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] tls: avoid recursion in tls_rx_rec_wait()
Date: Mon, 30 Nov 2026 12:48:00 +0100	[thread overview]
Message-ID: <aw1icK1OSpeezog9@krikkit> (raw)
In-Reply-To: <20261127-ktls-recwait-v1-1-81155599e61e@certik.com>

I don't think you need to bother security@kernel.org since you sent
this publicly. Dropped the cc.

2026-11-27, 14:01:16 +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 self-call was expected to become a loop, but the wait entry is
> address-taken and live across the call, so the compiler keeps a real

I'm not clear on what "address-taken" means and why it makes a
difference to the compiler in deciding tail call vs real call.
(not sure yet if it's worth adding to the commit message)

> call. GCC 13.3 and Clang 18.1 both do this on x86_64 defconfig and on a

In https://lore.kernel.org/netdev/20250812062825.391c030c@kernel.org/
Jakub said "both clang and gcc get it right", I wonder what
changed. Or is it just old versions being a bit dumb?

> distro config, with and without KASAN, costing 128 to 288 bytes of
> stack per retry. A local user can keep draining the queue with
> TCP_ZEROCOPY_RECEIVE while a reader waits and overflow the kernel

Or we should disallow this for all ULPs? I think they're all going to
get confused by their data being stolen.


[...]
> diff --git a/net/tls/tls_sw.c b/net/tls/tls_sw.c
> index 226e0f176fdc..363aae36ac69 100644
> --- a/net/tls/tls_sw.c
> +++ b/net/tls/tls_sw.c
> @@ -1104,9 +1104,11 @@ 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);
>  	DEFINE_WAIT_FUNC(wait, woken_wake_function);
> -	int ret = 0;
> +	int ret;
>  	long timeo;

nit: reverse xmas tree
https://docs.kernel.org/process/maintainer-netdev.html

>  
> +retry:
> +	ret = 0;
>  	/* a rekey is pending, let userspace deal with it */
>  	if (unlikely(ctx->key_update_pending))
>  		return -EKEYEXPIRED;

-- 
Sabrina

  reply	other threads:[~2026-11-30 11:48 UTC|newest]

Thread overview: 7+ 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
2026-11-27 14:01 ` Dickson Wu via B4 Relay
2026-11-30 11:48 ` Sabrina Dubroca [this message]
2026-11-30 18:51   ` Dickson Wu
2026-12-01 20:38   ` Dickson Wu
2026-12-01 20:37 ` [PATCH net v2] " Dickson Wu
2026-12-01 20:37   ` Dickson Wu via B4 Relay

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=aw1icK1OSpeezog9@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 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.