From nobody Sun Aug 11 23:03:03 2024 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 4WhtTz3qkYz5SR7Z; Sun, 11 Aug 2024 23:03: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 "R11" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4WhtTz3JgBz44J2; Sun, 11 Aug 2024 23:03:03 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1723417383; 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=9o0Xg7GEOl60DZAyFoHU1IbVicRZHC1JP2n60lMhkFQ=; b=uNUMp2CPovXfUwscUyjdIaVxFPmRO797Pt8ZFvhe6JKsgZAHz1Lmt7uy0dNq1CfbeDbGfM Xtjmw94opclyE9kYuwVchwbGYV4qu5FGrtBPwqYfLTFLwiA3gJNEZL0FQm2xxfQOd8sOyV eYw/RDjxZuhS+cbg8AKLlp0Lr9vcGQvd1wDG7+sGu2rFMjGSxqdQBY5vDc7NZQR4RNZz+7 JolJqg5RJVp35aDS8olzPGkVXdjLBYCOMy55TPR2Cq+abyjPiabRBbDw4AQSlGyUeCKh9s dkTnSsvmjHmDe9IvZtjaqRX4kjAj6hG8BYEFbFjX51IVJHWWGyBaHOCsFiD6yA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1723417383; a=rsa-sha256; cv=none; b=ANpS74Jv6vLkGmgjxO3TEzfE90MnPmHy+WuHhGLh7czNPfzq1ZB3xA8FDc/YUnhji2WIR5 tI4OfQHweWO6FzLrGEoZ2TGHD5F3+/SsmdBTkR6lSSu4ngILquK/OPe8dAm0UbZxd24ZZ+ UoWeiZIts3Ips7BwHc+StIavl/iX8YJXUR+tiCPKYfUUUZvwRm/xl0zeomekyrnEkiLAsc 5OctpnR+rCWPmFw6frNkCt46/ThzAyzVf2lmZn634O46w5x5RhuqYmU6cbbcQSkLm/WL2t sB+lZ4tuWPowXVIrHUoJYySuJPlPNxUqETiNQrT9LiDhOH+sLkDQdJJw5DbhqQ== 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=1723417383; 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=9o0Xg7GEOl60DZAyFoHU1IbVicRZHC1JP2n60lMhkFQ=; b=oAM7WttQPL2IcdRboffZu0Wa2lwbYun2JaND4qZmPYm2XyU175HjNgYfs7w9rXtlb4RYh+ VTudnLix2yv5I8PyM2tyRGqX5uboJUWQv+aFCsL5gLETQ3GP7Ror6qYo+sdHXe64zEm/y6 odIBZxLBYGYDvbkjaESMnIFwcL8w6nb3eLdfMAqk0caqfjKFql3kJ7SUDGEuVOFwON77TD on0I7+BApkdW1ct+xnC54W9kqRp61zNPFH1sza7aRJsAmHZKLO/b2kKgYkPv7OV+qZMw98 X9Os5kdFKLaofmbItjxGENQwBZvuvMqqq2CEvRIrtyU/KaIRGAGtVTDf9WsoCg== 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 4WhtTz2w7hz133P; Sun, 11 Aug 2024 23:03:03 +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 47BN33mA032295; Sun, 11 Aug 2024 23:03:03 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 47BN33sO032292; Sun, 11 Aug 2024 23:03:03 GMT (envelope-from git) Date: Sun, 11 Aug 2024 23:03:03 GMT Message-Id: <202408112303.47BN33sO032292@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Ed Maste Subject: git: cbbc8d67301c - stable/14 - pipe: keep uio_iovcnt consistent 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 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/stable/14 X-Git-Reftype: branch X-Git-Commit: cbbc8d67301c650dd683566d44ff554993556224 Auto-Submitted: auto-generated The branch stable/14 has been updated by emaste: URL: https://cgit.FreeBSD.org/src/commit/?id=cbbc8d67301c650dd683566d44ff554993556224 commit cbbc8d67301c650dd683566d44ff554993556224 Author: Ed Maste AuthorDate: 2024-07-17 14:33:53 +0000 Commit: Ed Maste CommitDate: 2024-08-11 23:01:52 +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 (cherry picked from commit d8ff42e816848a0d4a427755b46b8560cb86ebc8) --- 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 1c8d72f70a92..4c6f010a03f6 100644 --- a/sys/kern/sys_pipe.c +++ b/sys/kern/sys_pipe.c @@ -942,8 +942,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);