From nobody Fri May 22 18:33:57 2026 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4gMYp35WQXz6fQ1S for ; Fri, 22 May 2026 18:34:03 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R13" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 4gMYp33YPdz3HrY for ; Fri, 22 May 2026 18:34:03 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1779474843; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=HHpdUuI4jyCgvJIg0nF3c6qPbBrmy1x5el+YUiyE1fc=; b=iyWkVKvRafKoirStpnP430dnii/Y6qBA58wK7M0gO17e2E7IWkWcFzGNkFhYQ4hGmtVe3a 1HYekbTHCk0Br+YpPp2Cg5ERiBwu4myWqxHlHkUTll6p6l/sCaOrsOzLm8s410Lo1sfzrM ecXtTJ4cCL1czmmx5vXuhE3W9aHim6UESZfo+FIETDbIFTV0udfs+UUG/dQYGIaKgcvXGh G5q0a7QhgaLb7G4K+/66ougztIstwQe/KwRy7tryvkMiOAbukfnRIpfVtDIPq8RlyR9sLS GLYQT59PnfsNm4toWDgCXEdI1wu3wuaUmOTXHXp/SfJCgZQHNSa/6AZxOsfIeA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1779474843; a=rsa-sha256; cv=none; b=SxgAShvol/AdoSjAbC7HG/eRP6bQ8V5sGsiiWN5Us6syHqpflnLJgJsnYtTq48n+EuN/Xb y2373obo3QrEgHcusiPpf53ToS2HgmLrTl04vxDCWyBx/9NTwxGrCFLDFTyUjHU6zNQ6Vy wOzYuhbCB3FhUDTManCJMNbKdgDEXVFx17ZMojweIecoQ6awqUEmIaQM70/mgL8NATrKqO f1WZO8nGKxpAop9lEx+mBjQHTFlWY87zlxV1hW/7hak4NDO0br3NPBUNSHIuBMTFIL/ihT 9v5uDuqHWMVHaBuMrIqQHhpIL60oZpf8T4rckFO7XEZb/Sz/Ftf7Qctsn9c9QA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1779474843; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=HHpdUuI4jyCgvJIg0nF3c6qPbBrmy1x5el+YUiyE1fc=; b=h53v5L0+jLLF5xmcYpRSV1U4dinE+xx4INr8UnwXQ+ZZHH8/8LAQsZPesI8x2H1za5oYJD ANpz4nGzhFH0Z6fUOkG5xNU/wS28Cc5zCZiHDlsEVW/6Vvb8uLQHC+yqWEGChI/yKldYwK N31pnF0Ghl0uD9jLECM8IPvlpGS2djw7TRI2OoyV93aj+nldk9A/P7BWJ7q23QjQXF+eb7 cq6xZiNw1KIDd22iNkw8GRDZ133N6rmWbhQpD0Ji1ay2yr1qM3wfZA8BxDVdSX3sZdKfA+ ux24OlF2ckEokQFECCO8t8uRheKrl2aeK5k6P/fy8yw1zVe0jL9xqKzXQKTw3g== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4gMYp31jxYzZ6T for ; Fri, 22 May 2026 18:34:03 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 3db1a by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Fri, 22 May 2026 18:33:57 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Andrew Gallatin Subject: git: fd9af1e7084c - main - sendfile: Fix bug when using headers with SW KTLS offload List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.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-Transfer-Encoding: 8bit X-Git-Committer: gallatin X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: fd9af1e7084c550358d9598407f9ee7583e6a53f Auto-Submitted: auto-generated Date: Fri, 22 May 2026 18:33:57 +0000 Message-Id: <6a10a195.3db1a.b58a602@gitrepo.freebsd.org> The branch main has been updated by gallatin: URL: https://cgit.FreeBSD.org/src/commit/?id=fd9af1e7084c550358d9598407f9ee7583e6a53f commit fd9af1e7084c550358d9598407f9ee7583e6a53f Author: Andrew Gallatin AuthorDate: 2026-05-22 17:57:54 +0000 Commit: Andrew Gallatin CommitDate: 2026-05-22 18:33:41 +0000 sendfile: Fix bug when using headers with SW KTLS offload When using SW KTLS, we must account for the headers in sf_iodone() in terms of either freeing or enqueuing them for TLS work. Not doing so can lead to a situation where we enqueue only the payload, and not the header, for encryption. Rather than leaking the header, the socket is left "hung" with the header marked M_NOTREADY. Sponsored by: Netflix Reviewed by: glebius, kib Differential Revision: https://reviews.freebsd.org/D57134 MFC After: 14 days --- sys/kern/kern_sendfile.c | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/sys/kern/kern_sendfile.c b/sys/kern/kern_sendfile.c index 9992b83ad6a8..cf9716560c07 100644 --- a/sys/kern/kern_sendfile.c +++ b/sys/kern/kern_sendfile.c @@ -95,6 +95,8 @@ struct sf_io { vm_pindex_t pindex0; #ifdef KERN_TLS struct ktls_session *tls; + struct mbuf *tls_m; + int tls_enq_cnt; #endif vm_page_t pa[]; }; @@ -338,7 +340,12 @@ sendfile_iodone(void *arg, vm_page_t *pa, int count, int error) so->so_proto->pr_abort(so); so->so_error = EIO; - mb_free_notready(sfio->m, sfio->npages); +#ifdef KERN_TLS + if (sfio->tls_m != NULL) + mb_free_notready(sfio->tls_m, sfio->tls_enq_cnt); + else +#endif + mb_free_notready(sfio->m, sfio->npages); #ifdef KERN_TLS } else if (sfio->tls != NULL && sfio->tls->mode == TCP_TLS_MODE_SW) { /* @@ -350,7 +357,10 @@ sendfile_iodone(void *arg, vm_page_t *pa, int count, int error) * Donate the socket reference from sfio to rather * than explicitly invoking soref(). */ - ktls_enqueue(sfio->m, so, sfio->npages); + if (sfio->tls_m != NULL) + ktls_enqueue(sfio->tls_m, so, sfio->tls_enq_cnt); + else + ktls_enqueue(sfio->m, so, sfio->npages); goto out_with_ref; #endif } else @@ -897,6 +907,8 @@ vn_sendfile(struct file *fp, int sockfd, struct uio *hdr_uio, * for all of sfio's lifetime. */ sfio->tls = tls; + sfio->tls_m = NULL; + sfio->tls_enq_cnt = 0; #endif vm_object_pip_add(obj, 1); error = sendfile_swapin(obj, sfio, &nios, off, space, rhpages, @@ -1125,6 +1137,13 @@ prepend_header: } else { sfio->so = so; sfio->m = m0; +#ifdef KERN_TLS + if (hdrlen != 0 && tls != NULL && + tls->mode == TCP_TLS_MODE_SW) { + sfio->tls_m = m; + sfio->tls_enq_cnt = tls_enq_cnt; + } +#endif soref(so); error = pr->pr_send(so, PRUS_NOTREADY, m, NULL, NULL, td);