From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from fhigh-b4-smtp.messagingengine.com (fhigh-b4-smtp.messagingengine.com [202.12.124.155]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D316D6FC5 for ; Sun, 7 Jun 2026 22:10:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=202.12.124.155 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780870259; cv=none; b=Stttw82SQRvgs7Zczz5OlfURXkRrzEzR3p2DQN6eLp8AWsTE7FRcXAmcpJj4BaW73bcYRmMUbcreVHHZ6nnk0S3wRwdITOuF18KTCc/DM3fTWAOI5kFF8CwEJhtSvhsloibjhS+CM2NXaVa/dp44i8PxY3VWO0i1JYUxzfL1cIQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780870259; c=relaxed/simple; bh=cSg3mEe/nk3Hc3/J47bZa6b7/HjEyK6H3PEjizIHGyc=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=eBlJbIBUeeQKPnfMtw3FCK0oMGesiQCtM0Mpg4Gg+js4iP2QaWgn9t0oj4bwSHwoZhi2eg+trUnfbX+OCDE5JvQVGt77+Vm6rtaeRu3IYt0Q7Ln63Vz8EPjY6YSeF4/xXlEN9cHA0MlDXxwVKoWq+sIh0Ks0bk5sR+I5nmlJU5Q= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=queasysnail.net; spf=pass smtp.mailfrom=queasysnail.net; dkim=pass (2048-bit key) header.d=queasysnail.net header.i=@queasysnail.net header.b=hZt+8u3C; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=FAycgVaQ; arc=none smtp.client-ip=202.12.124.155 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) header.d=queasysnail.net header.i=@queasysnail.net header.b="hZt+8u3C"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="FAycgVaQ" Received: from phl-compute-04.internal (phl-compute-04.internal [10.202.2.44]) by mailfhigh.stl.internal (Postfix) with ESMTP id 61E257A00E2; Sun, 7 Jun 2026 18:10:54 -0400 (EDT) Received: from phl-frontend-04 ([10.202.2.163]) by phl-compute-04.internal (MEProxy); Sun, 07 Jun 2026 18:10:54 -0400 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=1780870254; x= 1780956654; bh=ORguDEtjWww27H8qt3wdVTnWIh76EuvWiCrQuOvCf9Q=; b=h Zt+8u3CV9Jn58jSQ7/XHw4zz+UvDZO6uSpTluShesHenVeigSomUGF07APL1CM3c XTUFwl09Ca+J3YVfXXTiPJl/lpmOremYfBLDhTGGvoiX7pNiDlcv/Cfk6ysx8iPI 5XEOQEel4iBZdZ2OGoF1X9Fj3TWspfzJ9PZbmKlaJp7QIic9UPt7LUN+h5Mbcz0R hGpnNvgZ4bAE8JxkYydtIZvjaNPACYDbfTnxUQ2j7W1gg9Ro4bfPelJxl2i/b3jN YucWBNYEh/VjJGk1QjryjbRtRqfUyMlRDrpCzlga4pkfkiDwVCnz8m2RvsNlwil3 A2TDz6R8AEKEWeTSyoWvw== 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= 1780870254; x=1780956654; bh=ORguDEtjWww27H8qt3wdVTnWIh76EuvWiCr QuOvCf9Q=; b=FAycgVaQQDKMIi+e+ssmtCWu4Mps9FctGkov5C91kHF3LQeTeYU q5HUuZVhu0SJ4dotPQHIzexYRUP6c4Urm1e7C281jLRBl6f3WvD1GwHDj0AYhKau 85GE6etrHHrGXiUe+vRrEcL0/7FCuqUbuXLFDON3hldH43+op01Cz6vRWFB6PmqO lca8xfBZd3vGNh2WEkWyuU2dJvLNYDgy4wIsLLMT1qxdhXil2IZoz2S73Vci076e 7YVH/RpaZt37VcdXkPeDy6WbefMr9PYQTEynVIQcQdHGVIOIzjfefWGaLkEI1Xzl Twq91wfDi4eNzSE8XJhvMt798rXhbBU27hg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: dmFkZTEzypjPAMTRugTLai+EOQ1s2Juwf36K9gfdJJ2HR/CddZi/x+tXzrWsUY1VRJ//4o h4Z9fPhvuObMo8dXmVJeXScZHRlc3epOR1IbBXqDBCir071An/ldMAStQm2t2JES//fyNM 87gK22OYlR1tRlF3kKTjs4/LrcBTwzGLSyC/QKj8UL5wl68DDjCWDvLqCluwYtG6MMia0b WturvXTHX3s9p0Z8G7BLwIqy6gTBt/Al3ZU6JvLfiT3NlnggJzrURkddLLw7K4sKunRbrr ub45Y+3B1Qo7Pxigsohjylx8KBgAvixyO9TVjb/N2FXXSY/OwuVa8hojRbsDxX5u0QHATg dDaMxPPQ21L0ExjE2SMMntDutyhtYkD/E3tHrWOzFP33/uqsfzJ7wblns+oqiDzQNulcNR +i5C2XOqk/UmCVeADpHM3ssn6O0h8D11o/2UF8T+zoDFvfRYGIR3wcxjBgWS/ulYw3X2BA n8CTgjP7icDJCNZIi6T10G2nJgkrbxFFkHqsKfBlEr0Nny9UcpYUEbIm64o+OPH2c7zcly ySEPR6Aw+kKdEQEGnuVR+9l3QSGLasyTD7zXDKShnp6VahBM2MqOaJcjwO1X+0wRSJBAFK 5N9G4Jt7RI4lOPXzRJW2BKD9blrWtM5yKQOqUTXvKzLaGiVWqi4bKWDi8y7g X-ME-Proxy: Feedback-ID: i934648bf:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sun, 7 Jun 2026 18:10:53 -0400 (EDT) Date: Mon, 8 Jun 2026 00:10:51 +0200 From: Sabrina Dubroca To: Chuck Lever Cc: John Fastabend , Jakub Kicinski , Eric Dumazet , Simon Horman , Paolo Abeni , netdev@vger.kernel.org, kernel-tls-handshake@lists.linux.dev, Chuck Lever , Hannes Reinecke Subject: Re: [PATCH net-next v12 6/6] tls: Flush backlog before waiting for a new record Message-ID: References: <20260604-tls-read-sock-v12-0-b114efa6e3e2@oracle.com> <20260604-tls-read-sock-v12-6-b114efa6e3e2@oracle.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20260604-tls-read-sock-v12-6-b114efa6e3e2@oracle.com> 2026-06-04, 13:48:29 -0400, Chuck Lever wrote: > From: Chuck Lever > > While lock_sock is held, incoming TCP segments land on > sk->sk_backlog rather than sk->sk_receive_queue. > tls_rx_rec_wait() inspects only sk_receive_queue, so backlog > data remains invisible. For non-blocking callers (read_sock, > and recvmsg or splice_read with MSG_DONTWAIT) this causes a > spurious -EAGAIN. For blocking callers it forces an > unnecessary sleep/wakeup cycle. > > Flush the backlog inside tls_rx_rec_wait() before checking > sk_receive_queue so the strparser can parse newly-arrived > segments immediately. On the next loop iteration > tls_read_flush_backlog() may redundantly flush, but this > path is cold and the cost is negligible. > > Backlog processing can run tcp_reset(), which calls > tcp_done_with_error() to set sk->sk_err = ECONNRESET and then > tcp_done() to set sk->sk_shutdown = SHUTDOWN_MASK. The pre-existing > top-of-loop sk_err check already ran before the flush, so the > freshly-set error would be masked by the next-line sk_shutdown test > returning 0 (EOF). Re-check sk_err immediately before the sk_shutdown > test so a connection abort surfaces as -ECONNRESET rather than a clean > EOF. > > Commit f508262ae9f2 ("tls: Preserve sk_err across recvmsg() when > data has been copied") gave the top-of-loop sk_err check a > has_copied split. The recheck applies the same handling: when the > caller has already copied bytes, sk_err is reported but preserved > so the error surfaces on the next call; otherwise sock_error() > consumes it so the error is reported exactly once. > > Suggested-by: Sabrina Dubroca > Link: https://lore.kernel.org/netdev/ahgHgQ84RCc8uYrG@krikkit/ > Reviewed-by: Hannes Reinecke > Signed-off-by: Chuck Lever > --- > net/tls/tls_sw.c | 12 ++++++++++++ > 1 file changed, 12 insertions(+) Reviewed-by: Sabrina Dubroca Thanks for your patience with this series, Chuck. -- Sabrina