Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795056669; b=Ho0BkyyGqD+EUx2tDw2WjRFL9PfsszO2/U/+r4A58EMq7VeDUd+7e/ygB138RcyAjOLf FHq4PBc32ZFrwD4KyeemnRaybDt78zRPTgczOU+5qYV4cPi9MsCEijDlKM1P9T4meanJK rUwS4y4msYOqCRRCngdsIe/U95b86+rAt+1b+rErFMQbVoGnDTYCDNpP5MijaXmN4ldBQ jyx84knfluVDU+TBuE5fuFUwaa7hVw8lRMuhzYTwywM9oi7Do49TvKCVI6ebZo7bRMuK+ EXsl5vJJ3ISianZ0N9Wr2XgaPDyQujGq/gEoxr/rhN1ooG3dyabfcWy1iMrJK+XTjpQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795056669; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=O59fd2sGf1GWq8ZIIDE6q4Rce4Ve/bceBQtNSYrAhoI=; b=aap9hTRpOnyv5tYx/rhYICPPo3ULFo9zojtAjVsa7RVpBPxMaXxyz7hepVIBSxrm1n1g 2AvBaTTQJW/WBgrbebry3ASdyvuNxlApFxHhyalw28kV0EnlgNaINPf2/5FVh+5bH0HWk X/InXVKK5YTRn4++SD8uvJnRPlLPiLEdwHyb04xxBfVK1Wv5w0U7j4+8XfVrHZ0yujYEH 6mGxgTcSGFGMe9Gh1yU2yXCiSDOMKy6XhOx3/3rI4Zigmh7BJ8KF+eJ8q1LoACXwpsCQI rzj25dZwdUEXs0Sbe0la+xK3ZEtVpuVhbScWLXL4OXpYScYM/tcMFKSUYaRnxJ5x0kw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=j3rYNmez; arc=none smtp.remote-ip=100.103.45.18 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 9E100606A320; Thu, 19 Nov 2026 02:51:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=j3rYNmez Received: by smtp.kernel.org (Postfix) with ESMTPSA id EEA491F000C4; Thu, 19 Nov 2026 02:51:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1795056669; bh=O59fd2sGf1GWq8ZIIDE6q4Rce4Ve/bceBQtNSYrAhoI=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=j3rYNmezB2JxJJO+6BF0bABZK7KfvBERKcGGFROWHTgxPqnls2Pm2a74/GgWP4PfN k6YgkHLw7kTLOtt1AIdYPjXe8BuHAcsc4kBYMY1CUA7A0Ac8FI4zB3HxvFxQnREUy7 eBhjXcIWTF3L/jZkQGBXWDLrPzgPR5uvNPkGrfi4= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Rishikesh Jethwani , Jakub Kicinski , Sasha Levin Subject: [PATCH 5.15 2069/2214] tls: device: protect async RX resync state during device-down Date: Wed, 18 Nov 2026 16:02:25 +0100 Message-ID: <20261118150133.406121877@linuxfoundation.org> X-Mailer: git-send-email 2.56.0 In-Reply-To: <20261118150009.797899913@linuxfoundation.org> References: <20261118150009.797899913@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: patches@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 5.15-stable review patch. If anyone has any objections, please let me know. ------------------ From: Rishikesh Jethwani [ Upstream commit f89a228125238f8d4c7e2b8161e2a85fe35307b6 ] tls_device_rx_resync_new_rec() can run in process context with the socket lock held, but without an RCU read lock: from the strparser work item (tls_strp_work()) and from the receive paths (tls_rx_rec_wait(), tls_rx_rec_done()). The resync_async pointer belongs to the driver RX context, which tls_device_down() tears down from the netdev notifier without taking the socket lock; only the softirq entry to the parser is implicitly inside an RCU section. If the parser passes the TLS_RX_DEV_DEGRADED check before device-down sets it, tls_device_down() can complete synchronize_net() and delete the driver context before the parser accesses resync_async->req or its record log. In the asynchronous stage the parser also writes the record log, so this is a write to freed memory, not only a stale read. The RCU section in tls_device_resync_rx() starts after those accesses and therefore does not prevent the use-after-free. Found by code inspection; not reproduced. Hitting the window requires the parser to be preempted between the DEGRADED check and the resync_async access across the device-down grace period and the driver's teardown. Fixes: ed9b7646b06a ("net/tls: Add asynchronous resync") Signed-off-by: Rishikesh Jethwani Link: https://patch.msgid.link/20261013213517.2219663-1-rjethwani@purestorage.com Signed-off-by: Jakub Kicinski Signed-off-by: Sasha Levin --- net/tls/tls_device.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/net/tls/tls_device.c b/net/tls/tls_device.c index 636e106679056..33c3fbb7c5a12 100644 --- a/net/tls/tls_device.c +++ b/net/tls/tls_device.c @@ -753,8 +753,15 @@ void tls_device_rx_resync_new_rec(struct sock *sk, u32 rcd_len, u32 seq) if (tls_ctx->rx_conf != TLS_HW) return; + + /* The parser also runs in process context, without an RCU read lock. + * Protect the driver's resync_async state before checking the flags: + * device-down sets DEGRADED and waits for synchronize_net() before + * freeing it, without taking the socket lock. + */ + rcu_read_lock(); if (unlikely(test_bit(TLS_RX_DEV_DEGRADED, &tls_ctx->flags))) - return; + goto out; prot = &tls_ctx->prot_info; rx_ctx = tls_offload_ctx_rx(tls_ctx); @@ -769,11 +776,11 @@ void tls_device_rx_resync_new_rec(struct sock *sk, u32 rcd_len, u32 seq) if (likely(!is_req_pending) || req_seq != seq || !atomic64_try_cmpxchg(&rx_ctx->resync_req, &resync_req, 0)) - return; + goto out; break; case TLS_OFFLOAD_SYNC_TYPE_CORE_NEXT_HINT: if (likely(!rx_ctx->resync_nh_do_now)) - return; + goto out; /* head of next rec is already in, note that the sock_inq will * include the currently parsed message when called from parser @@ -782,7 +789,7 @@ void tls_device_rx_resync_new_rec(struct sock *sk, u32 rcd_len, u32 seq) if (sock_data > rcd_len) { trace_tls_device_rx_resync_nh_delay(sk, sock_data, rcd_len); - return; + goto out; } rx_ctx->resync_nh_do_now = 0; @@ -793,16 +800,18 @@ void tls_device_rx_resync_new_rec(struct sock *sk, u32 rcd_len, u32 seq) resync_req = atomic64_read(&rx_ctx->resync_async->req); is_req_pending = resync_req; if (likely(!is_req_pending)) - return; + goto out; if (!tls_device_rx_resync_async(rx_ctx->resync_async, resync_req, &seq, &rcd_delta)) - return; + goto out; tls_bigint_subtract(rcd_sn, rcd_delta); break; } tls_device_resync_rx(tls_ctx, sk, seq, rcd_sn); +out: + rcu_read_unlock(); } static void tls_device_core_ctrl_rx_resync(struct tls_context *tls_ctx, -- 2.53.0