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=1796161373; b=fPTo74dW2qeLmdPhkoSl/q5S4BFqhbTlWnAmDNaBer9UdWADIqot3RRIw18tefQC20+E mm8y9a5rhz8BRgRKJHBNcp79tszr+0KaYIvr53P+Hwy0R0F7Ux1YqaeRcNgRpr5BvqET/ BUTrmIs64agqEXyxldBAc06yIRBi+JRpNwiRAoMRyLLKXipBGA84/87Z0G3SvIOTDXdx7 cmUyqNV4484aVN9gkx82To3iJtKxh/pFEUz23uGoY5yyJjqTWeEZ4WI5Y6nNlYD/E/7XA XKSG0kz824tbSHJZaJPiXT28cn0nWnDD51ywutUTWpVDgxX+QJBQCYUEu0hYk+aqOww== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796161373; h=Received:DKIM-Signature:From:To:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:MIME-Version:Content-Transfer-Encoding; bh=Ih85uHl9RH5sK7saBpcPFne/I2t8sF958uXht8nPKsU=; b=2NVzSm7l6sPbhNjuME3IHoQ4llE5fN6HIR+VSaX4TIcW0cFC338Ad7RirAEUHxFTNZPU bafWh3v7smHoOUH79iYedV0z1CLaQyDahjYhoMLC1YkH8pF42Sbi8/FhULtMy/N+51FnP PzPdpZ8/jt4kdxj/3Tw0IfRu7Tq/DgrzkRyEmPnnuUs8LUp3iw2p7U9vHFFH8gi6EdMTZ gp1UeDXaQCWIovctxqent+mpNI+hi1FecKW8xGnYkx4Vk6YrRfg6w1aHnTukikHPjUmFF UT5PFORpWmjGo0iQ7HxgK3Y+bFJa7gSDMoIfKxbXg2/9g5WnOAKwCoO3mW/Y+6PTndg== 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=IaLWpsE6; 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 3A358606A31A for ; Tue, 1 Dec 2026 21:42:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=IaLWpsE6 Received: by smtp.kernel.org (Postfix) with ESMTPSA id B01991F000C1 for ; Tue, 1 Dec 2026 21:42:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796161372; bh=Ih85uHl9RH5sK7saBpcPFne/I2t8sF958uXht8nPKsU=; h=From:To:Subject:Date:In-Reply-To:References; b=IaLWpsE69YXCuYZoGsaCcWMk+hLl2n1lmvzo99kgF6yprHni4ZSsCvobY/RhpyCl3 LGOWuy9CsvOnqGxmYMTnFBKk/WQ1m7+DATna6VsN/bpAf8UrNh4X8ldEhIGSEX2lGE I/FvDlntmVv8fBDGVJcCNfJshB09kWWwrqlt/IdpHtRRhQdovECzfSCzcOmywp9klI 8OB1H2obgHq07lVY0qN4vnjk+F34PNuxxuv7K6OndyjYoSB4SV4I2qWX4sm1syQ722 W1fx/31bHMyQd+siE3fWSH0gQ6o9EfGBIlljKrwDJDtlHJBW8R+Ik7uPTAyEOMyZwo u9VkPcUdsmHyg== From: Chuck Lever To: Subject: [PATCH v1 7/9] tlshd: Re-arm select() on each pass of the QUIC handshake loop Date: Tue, 1 Dec 2026 16:42:46 -0500 Message-ID: <20261201214249.296675-8-cel@kernel.org> X-Mailer: git-send-email 2.56.0 In-Reply-To: <20261201214249.296675-1-cel@kernel.org> References: <20261201214249.296675-1-cel@kernel.org> X-Mailing-List: kernel-tls-handshake@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 tlshd_quic_start_handshake() initializes readfds and tv once, before its receive loop. On Linux, select() overwrites tv with the time remaining and clears the socket from readfds when it times out. Once a total of one second has elapsed waiting for the peer, every later call has an empty set and a zero timeout and returns at once. The loop then spins on EAGAIN from recvmsg() until the handshake timer fires or the socket fails, so a peer that stalls mid-handshake keeps a tlshd child at 100% CPU. Reset readfds and tv before each call to select(). Fixes: 43a15fed2f33 ("tlshd: add support for quic handshake") Signed-off-by: Chuck Lever --- src/tlshd/quic.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/tlshd/quic.c b/src/tlshd/quic.c index 25813e7385bd..f845b21540f6 100644 --- a/src/tlshd/quic.c +++ b/src/tlshd/quic.c @@ -741,13 +741,10 @@ static void tlshd_quic_recv_session_ticket(struct tlshd_quic_conn *conn) void tlshd_quic_start_handshake(struct tlshd_quic_conn *conn) { int ret, sockfd = conn->parms->sockfd; - struct timeval tv = {1, 0}; struct tlshd_quic_msg *msg; + struct timeval tv; fd_set readfds; - FD_ZERO(&readfds); - FD_SET(sockfd, &readfds); - if (tlshd_quic_session_configure(conn)) { conn->errcode = EACCES; return; @@ -775,6 +772,11 @@ void tlshd_quic_start_handshake(struct tlshd_quic_conn *conn) } while (!quic_handshake_completed(conn)) { + /* select() modifies readfds and tv on return */ + FD_ZERO(&readfds); + FD_SET(sockfd, &readfds); + tv.tv_sec = 1; + tv.tv_usec = 0; ret = select(sockfd + 1, &readfds, NULL, NULL, &tv); if (ret < 0) { conn->errcode = errno; -- 2.56.0