From nobody Tue May 6 20:05:42 2025 X-Original-To: dev-commits-src-main@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 4ZsTsg0hj8z5vLLh; Tue, 06 May 2025 20:05:43 +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 "R11" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4ZsTsf675Wz4H5s; Tue, 06 May 2025 20:05:42 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1746561942; 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=yWQyB4K0hNBReuVSdjrcLJioxt23MDJePXikIqanREQ=; b=FT9Z8fLxAlbifZvoiVY9h/gVh0DyZ8UihV9kyamngQaKgvVEfvPMU1SmbMBWChBvmBAi+9 yTc6DGOFwkkDGG0YDu/sK0dIK4Uk6BqlFtL1VQC5vzwOGZ3rJeIMwDp1qCyxCcyxyhKSpb ipYsEPkiQcIXKql6KcRm3KhM0CCuxBKGdLvHF/6QjM21SInhPU9vKlRjB/G+mnAuqlEocm kJwssCZI2jsv6ZZgI+ZMmlj5cr6CzdP9DjqxH8r2SybetWqGaIt1HHz+e0nxPgYIj59KbC Wzn+3C+dUNHxz0CemISfFue4O5guGW7frhYKF0eNA3D3Xv3c0A+YG/f5+EZ36w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1746561942; 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=yWQyB4K0hNBReuVSdjrcLJioxt23MDJePXikIqanREQ=; b=YCyiuGwjMFHZJRJwXqSmjAK3tLruJPPeGfez5jxxiLl/EUDa1J5bBq01Betm6FZqEEax1p pnYXstFtoEzTBI5/tNXegeWcxGocRYElaTCUtTNnqFjf5ZbKZQRpfKO88swcI7W62K26Ep sENfeh1x9GdERUIQPe5jhSUhJUABqtJbSxjlMNTfnTYZCHbVvUqYbooK0BnvcA6ENo6g1k VBU+/tslTG9uZUUItbptyuSVdXkyKUBaw4+DMFKwn5wksuM/Pezpm/ngneV02nGrTad0dB 9he3eq26sgVLCtbWjXbVvVrigoK13ReEiLsuh8r6JLPkEkY8q7N7XJlAuLzzVQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1746561942; a=rsa-sha256; cv=none; b=TFQgKZTWef+WwH1yQHH7zFNx9rFa/RDARmJ/s+95MowewqpbagYC0Sr5bBz1dG4go9zr9o 7G6/OIc9QkTsS+21fgz+mQrdTtXrZ2gTN9iF4SK3Wi4W3BWgSm6XsGqGNDxzgK0YWk+L2X 2p0fkCFNy7x/k1ivQYA75jLAJnFkYYzNkVfhdWjJ56IiKV6IZIsFrKC+Tjz3CfRlgto5Gf 9gySouZkixxZuXitzY4kY/eJjlTRBKw60Qg/xnb/jG6HwMO/aEfPTMNwiOzQxDE8G93Miu IirQFkyhcEVNiFHot6wBNWDgZLXbVT/MhxvOXs7StwENd4LDF7KG47/ou8Rlcg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (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 did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4ZsTsf5dVBz1D7X; Tue, 06 May 2025 20:05:42 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 546K5gYP015143; Tue, 6 May 2025 20:05:42 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 546K5g9g015140; Tue, 6 May 2025 20:05:42 GMT (envelope-from git) Date: Tue, 6 May 2025 20:05:42 GMT Message-Id: <202505062005.546K5g9g015140@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Gleb Smirnoff Subject: git: 56a3db77fdfd - main - sendfile: fix CURVNET_SET()/CURVNET_RESTORE() List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: glebius X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 56a3db77fdfde014aab5430e24efe10cffa15fe6 Auto-Submitted: auto-generated The branch main has been updated by glebius: URL: https://cgit.FreeBSD.org/src/commit/?id=56a3db77fdfde014aab5430e24efe10cffa15fe6 commit 56a3db77fdfde014aab5430e24efe10cffa15fe6 Author: Gleb Smirnoff AuthorDate: 2025-05-06 20:00:45 +0000 Commit: Gleb Smirnoff CommitDate: 2025-05-06 20:00:45 +0000 sendfile: fix CURVNET_SET()/CURVNET_RESTORE() Keep it set around the main cycle that works with the socket and restore before the cleanup path, cause there are jumps into cleanup that precede the main cycle. Fixes: 9a7d03c7df3536cdb5faf0848c6dab4a5d7bcef8 --- sys/kern/kern_sendfile.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/sys/kern/kern_sendfile.c b/sys/kern/kern_sendfile.c index c428d80e0e1a..cfacfe40b832 100644 --- a/sys/kern/kern_sendfile.c +++ b/sys/kern/kern_sendfile.c @@ -787,7 +787,6 @@ vn_sendfile(struct file *fp, int sockfd, struct uio *hdr_uio, error = sendfile_getsock(td, sockfd, &sock_fp, &so); if (error != 0) goto out; - CURVNET_SET(so->so_vnet); pr = so->so_proto; #ifdef MAC @@ -817,6 +816,7 @@ vn_sendfile(struct file *fp, int sockfd, struct uio *hdr_uio, error = SOCK_IO_SEND_LOCK(so, SBL_WAIT | SBL_NOINTR); if (error != 0) goto out; + CURVNET_SET(so->so_vnet); #ifdef KERN_TLS tls = ktls_hold(so->so_snd.sb_tls_info); #endif @@ -1225,6 +1225,7 @@ prepend_header: */ if (trl_uio != NULL) { SOCK_IO_SEND_UNLOCK(so); + CURVNET_RESTORE(); error = kern_writev(td, sockfd, trl_uio); if (error == 0) sbytes += td->td_retval[0]; @@ -1233,6 +1234,7 @@ prepend_header: done: SOCK_IO_SEND_UNLOCK(so); + CURVNET_RESTORE(); out: /* * If there was no error we have to clear td->td_retval[0] @@ -1270,7 +1272,6 @@ out: #endif if (error == ERESTART) error = EINTR; - CURVNET_RESTORE(); return (error); }