From nobody Thu Aug 08 18:16:54 2024 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 4WfwHC1N6jz5Rtn4; Thu, 08 Aug 2024 18:16:55 +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 4WfwHC0rdSz4bF7; Thu, 8 Aug 2024 18:16:55 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1723141015; 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=jGUzeccrzJxApaibuMlzi7j04oHfKpxNOWLeP/RXamI=; b=dbv6wWKGO6wWpsB2UYwKWs9a1Lg0CgPwulxEtnYuZYBGl8mAkuZgjZuyaWIW6qSnMh3RLI RQDI+Qg9oBmkn1m6DvW8fn89Mq1dwFg4JMJVouT3lu5x89WC2TTDVjYNqi3sKYzyTEIqBW i5A9fqNkSUHAF4U9izd2+UncQyKgSjmcKoKTUnHhgEkiqZ6HzQnkyXOX8YwpxhxKjQCrjF qQbTv3duCzdfi9xVRzR5l6ITlfDIh+eIOw/SbshcSWzkjK9oLZ4Iu1bcSrQM8CP97u9h/z /QHixZTQEAGh+Ky0hYnKSw5qegTxJQiflGvG0K7NWHWBtHyygMGJqSCIDb5ZTg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1723141015; a=rsa-sha256; cv=none; b=Myso4cUiJN3gKpY9r8mJhYLBvTmTZuE6lLQebIFApgBKDgaFKj6tJD0apAtsmW/hYxRoz3 KyP71/ctb4QqtIl4Gx1syKtEB2NzG0upJWZ84LDYwbVofufgVr99/NclCXo7twUMWKw3rK 2HBE/vjGOrYey3mCVjacORvuIkletbZziwLePD8Ryulmsu4Hrk6X75VIi5vN++390gOrPg rikRAF838Lt7+lMtGAm+ldjFzKkSqWdbgneeewywWczk8fr5WmCz+bYouSvqLuoLz2LlK2 UQCBYBGGQShUvl5rDk8efBhQmoLVygcU9HD4LO5+IoCEbNMD/BSNDhamWLGDUQ== 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=1723141015; 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=jGUzeccrzJxApaibuMlzi7j04oHfKpxNOWLeP/RXamI=; b=xon6OkkuruXBvfH/FaBzzb95SGNc58DyevcocZGJebjYPWjSWHGulH37c/GgQmwCgcAwpc gLBK3OAb+AiAV9vwDunjVDHWY1IvqM2p/6/Zq8qzdgdi9JoB7s5rEJk+8lWyq7hZKGUKZX YWhpJ4ftjlBsg3smhKyNMdNKkEBgnR72VcKaWpnLIqR9/1exTnjYqpEU/7LCG5bmFQGIhm SYttOCaNdIVQZPopRqmVIG9hUhtmG9UJXZn6qMMhaCisCZSXPynnc+xA7kB4zVHSPXlei1 GEi95fTpPQmxI4PVkjg1YDj6TKOs3d4s9iFZ0YEySJKq2JLPZGsPXR/CPVLq/A== 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 4WfwHC0S25zkWh; Thu, 8 Aug 2024 18:16:55 +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 478IGshf030684; Thu, 8 Aug 2024 18:16:54 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 478IGsNi030681; Thu, 8 Aug 2024 18:16:54 GMT (envelope-from git) Date: Thu, 8 Aug 2024 18:16:54 GMT Message-Id: <202408081816.478IGsNi030681@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Ed Maste Subject: git: d8ff42e81684 - main - pipe: keep uio_iovcnt consistent 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: emaste X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: d8ff42e816848a0d4a427755b46b8560cb86ebc8 Auto-Submitted: auto-generated The branch main has been updated by emaste: URL: https://cgit.FreeBSD.org/src/commit/?id=d8ff42e816848a0d4a427755b46b8560cb86ebc8 commit d8ff42e816848a0d4a427755b46b8560cb86ebc8 Author: Ed Maste AuthorDate: 2024-07-17 14:33:53 +0000 Commit: Ed Maste CommitDate: 2024-08-08 18:16:26 +0000 pipe: keep uio_iovcnt consistent In pipe_build_write_buffer we increment uio_iov but did not update uio_iovcnt. This would not cause an OOB read (thanks to to uio_resid) but is inconsistent and could be an issue if other code changes are made in the future. Reported by: Synacktiv Reviewed by: jhb, markj, brooks Sponsored by: The Alpha-Omega Project Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D45999 --- sys/kern/sys_pipe.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/sys/kern/sys_pipe.c b/sys/kern/sys_pipe.c index 70b2a03e0140..73b6facec6c7 100644 --- a/sys/kern/sys_pipe.c +++ b/sys/kern/sys_pipe.c @@ -941,8 +941,10 @@ pipe_build_write_buffer(struct pipe *wpipe, struct uio *uio) uio->uio_iov->iov_len -= size; uio->uio_iov->iov_base = (char *)uio->uio_iov->iov_base + size; - if (uio->uio_iov->iov_len == 0) + if (uio->uio_iov->iov_len == 0) { uio->uio_iov++; + uio->uio_iovcnt--; + } uio->uio_resid -= size; uio->uio_offset += size; return (0);