From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=103.168.172.145 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796393899; b=ObozewUTyCL/mXhs8hgb6B8upZKot11rm7Suawmp5csuRfGZWo8Q4k82wIThpGvStQqu zzO4Ohj5+Bc1DhtCXPGYVJxAiJWJ4fWVwdxusTuTCn7ifsRIYMXSkPwkjejtEy0Xlpz5w PMrbaw5rX9px/doxylR8YySbRX1mRxkJF+Y/00ywc4+y/cY11gU5GlYdrQIkENn6gGKRF 3oKfBJRa/LoEM99dcRtaJzmZFcFy5xHsCs5i9kJYoSosmQvw7JIdV6mR/A89Rp+ZRalJt P3QojegZCG6nKbThG8Gh/afOzVmhxBY/Lo0ADnM21xcdZwWzIF8cHf0dXHpJqn8vVew== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796393899; h=DMARC-Filter:Received:Received:DKIM-Signature:DKIM-Signature: X-DKIM2-Info:DKIM2-Signature:X-DKIM2-Info:Message-Instance: X-ME-Sender:X-ME-Received:X-ME-Proxy-Cause:X-ME-Proxy:Feedback-ID: Received:Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; bh=cPzaEVH3bzXj+5W0hH+DCerC+yU1bDDoEx0rsP4rD4A=; b=IH2x1aPTuXcoBj13qOQmAZFpLjCUHsLg7wGUrPB0FmLbTncAUaDUP2oYi7vrcYIZHhFv hbczKT5o9VrQJ2aNkQImRaBcRaJNCJHqMwpsCa0jyMP5BeDJnWj9/YMZ9oozuDMaqcmzO lBQdBO/VSfaSRX5KVAzHHrrNQkq9DvcAxG9dKhyQQeB8uiESAttLl1rzBR+B6BtXAFWC9 gPrWk3b8qazWxxxvT2kteN4o7eRYlBKlUCTPaF+CVAomVNeS2rMUo/pcrIPDgqQxLM56y fUiLX/yC6i/ZEgCIZl1CZF3npd8rZkJaBxCw+on7V2td6+YaCMXkAAcjBoJzvi0kuCQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none header.from=queasysnail.net; spf=pass smtp.mailfrom=queasysnail.net; dkim=pass header.d=queasysnail.net header.i=@queasysnail.net header.a=rsa-sha256 header.s=fm2 header.b=2cHIyhfi; dkim=pass header.d=messagingengine.com header.i=@messagingengine.com header.a=rsa-sha256 header.s=fm1 header.b=yc38Zj6z; arc=none smtp.remote-ip=103.168.172.145 Received: from fout-a2-smtp.messagingengine.com (fout-a2-smtp.messagingengine.com [103.168.172.145]) (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 E6E66606A332 for ; Fri, 4 Dec 2026 14:18:18 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org E6E66606A332 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=queasysnail.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=queasysnail.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=queasysnail.net header.i=@queasysnail.net header.a=rsa-sha256 header.s=fm2 header.b=2cHIyhfi; dkim=pass (2048-bit key, unprotected) header.d=messagingengine.com header.i=@messagingengine.com header.a=rsa-sha256 header.s=fm1 header.b=yc38Zj6z Received: from phl-compute-04.internal (phl-compute-04.internal [10.202.2.44]) by mailfout.phl.internal (Postfix) with ESMTP id 0B612EC0388 for ; Fri, 4 Dec 2026 09:18:18 -0500 (EST) Received: from phl-frontend-04 ([10.202.2.163]) by phl-compute-04.internal (MEProxy); Fri, 04 Dec 2026 09:18:18 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=queasysnail.net; h=cc:cc:content-type:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:subject:subject:to:to; s=fm2; t=1796393898; x= 1796480298; bh=cPzaEVH3bzXj+5W0hH+DCerC+yU1bDDoEx0rsP4rD4A=; b=2 cHIyhfiTrAiQnzXdzMXOoGyY5awGsd8nY0cLKFnoH2pNjH+oTGGizeX2gL5Q1d2f JUJXHpkX/DCr2ZMdn7whukqLEzSXTtEluAFl8SNOxEZBnr5l3/OlEXPYzOsI3HPd btm8vYPvnaHRR/kgBZSn02hdKB9k/OunEFp/wtk+czIWUL5jqOrlA0YP8cjGC5pG RuV7uBHF2PzSY10QuiWZLLlHsExwmndCd6eeYi7hOibjomzF6ucZEvnKbvK10acJ WFw65XZzMxsiTXWfIRdYNwgTrOc0nwtl66evERv7ZVdXMe1QxtW9O430vZXi9sJ3 7sshzhxluG/jl+Cpo3QnQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t= 1796393898; x=1796480298; bh=cPzaEVH3bzXj+5W0hH+DCerC+yU1bDDoEx0 rsP4rD4A=; b=yc38Zj6zrTS611zoiXEpanTI2LA0hTGGPqO1JIKPLdx+aNH1d6J 4z6x4vDrGZLtJg8Xuj+Jeb/aZ2K8LMaf3H3knCdLwad46pHiT0bIVJIQGO5J/B6D zGVfHDTiprYANRLS0PSR4TMzEil3JtcMEU733usUDiwXLBZNLyNznAjxQweCrtzS I38ZhEN/FguktlXIeyYnjwQDTEdt7gLTCsCn53hSx0FzEm5DD31B1UzB51iCAfSe fLE5Pf8gjj1I3LEqed5brdiJe/LhSRktzDidfZZgr7KR2BNSnFK99qq3pKt7HFgE /YVvw9J/5PFHalvWSEodCLMNfvNV8pxS6ag== X-DKIM2-Info: draft=ietf-dkim-dkim2-spec-09; repo=github.com/dkim2wg/interop; date=2026-11-03; sw=lmtpprox; action=sign d=queasysnail.net a=rsa-sha256; DKIM2-Signature: i=1; m=1; t=1796393898; d=queasysnail.net; mf=PHNkQHF1ZWFzeXNuYWlsLm5ldD4=; rt=PG5ldGRldkB2Z2VyLmtlcm5lbC5vcmc+; s=fm2:rsa-sha256:cGBCpGIdQwSe1b6FtmLgaDBWr+4PTSynQUUIuDSSn7WvyYF 14ktqifncHjIVbeTHPTcF/SuvFLOj3KEVFM0yFxvcz9lbEev1hY2h2WJ3MJVADDy rq97m6d7HVO/pfWAA1maZWGceyJ2ZkSOodvrZffgjp4D0p0TiRPzIgWa8sOSJ+Ca ujCwv0lcZf+rAu4/0QD6BObwRlZRdwZV28oeHRSWMrRmuoZqoDj5UV8K2qtBvkgK 93RsHYbRcYS3uuGJISSwNzl0jWP1hzmxdLY9+BxR9m4bumrzaBUR/ZqvJrfu/BAQ yu59xEQbmnQWiE+1WHK70F9MkvJ3KGg0HxfkS1Q==; X-DKIM2-Info: draft=ietf-dkim-dkim2-spec-09; repo=github.com/dkim2wg/interop; date=2026-11-03; sw=lmtpprox; action=mi-m=1; hc=12; hn=cc,content-disposition,content-type,date,feedback-id,from, in-reply-to,message-id,mime-version,references,subject,to; Message-Instance: m=1; h=sha256:NZYYGzxDGhw+TnDj7ZOWEm6zUv/SCBs2iFphdQkybxw=:zfZmyHuFc5wonvQXjYGyM5Yb8Z7uVyUe6xQp9Sr0kjs=; X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: dmFkZTEpRL/rRO2GPqKLuBCIr4SJ7mU9ia9XALfsUSsm18Wwl6sN90gojmDHUuRRJmgq22 JvMI3l7wJrfJhNdA9Ku9yRqKIV1bNjmwUWWytfQZGUU+U4R/L74mmWmU7CD/b1Ri5zAeGv 8IvA2Vdj00H61ja8uyPRMEkZ6DOhS8e3xijdUGau81LmxIEPWKFAptjLXPSocam4apsa8I X82n+ljW70uarMYUmUQNua2ds90OLpeIfl2wucKVDEcHbm/i4nN3zNKA51xN2Liw8DgGK2 B1W90h0Jy5wEDM5n4oJz0rTbc7BfibmoioO+GsAZSlYMBuZRM587N/upSoDaRessgVCJBy uaQRursRUyBExm47Hkc+GKRlhPSsLbbRCyBQt4ac5zcLB5+jH2UMWrsTAC3J30taLju7t4 BpBUsMn/mushl1HEIE3TTsHJfJ3IPxqD94P8m0a0UY/KphUZ6j5guLqBKn1QXUZYD96+23 JuvebtiQkCDRQ9rTzXQJoUWVF+kRWyvfw9zl7Kbfy7yKzZkHexKKZcawt8vc9DHya/Th0n 1vFe+91GqP0Sy7lsDS6/PwFpBknvCQU8jjD1PafvDIqtgBEu5NI7Evg8rH+1bJqqQrEl8R ttoaH9B2+Z7eJnbVko/xjxSjJR8TZ6BiaP4sbWcgypqPyy2KpV0o6h4l5GDQ X-ME-Proxy: Feedback-ID: i934648bf:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 4 Dec 2026 09:18:16 -0500 (EST) Date: Fri, 4 Dec 2026 15:18:15 +0100 From: Sabrina Dubroca To: dickson.wu@certik.com Cc: netdev@vger.kernel.org, John Fastabend , Jakub Kicinski , "David S. Miller" , Eric Dumazet , Paolo Abeni , Willem de Bruijn , Simon Horman Subject: Re: [PATCH net v2] tls: avoid recursion in tls_rx_rec_wait() Message-ID: References: <20261127-ktls-recwait-v1-1-81155599e61e@certik.com> <20261201-ktls-recwait-v2-1-12d374acc0ae@certik.com> X-Mailing-List: netdev@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline 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 > > 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 > 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 > --- > 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 > @@ -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