From nobody Tue Aug 13 16:44:41 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 4Wjy0V27b7z5T22G; Tue, 13 Aug 2024 16:44:42 +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 4Wjy0V16pcz4RLC; Tue, 13 Aug 2024 16:44:42 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1723567482; 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=x0ORNvf+3goee9VCNmKRJbB8iy/ss8Zao92vfcIh9Yo=; b=pl+G2/18ZNmLzg81BpLlOuPip9MO1MeCPRmwXmJs10oSOTuPS92fZ1fxktSzUelvnBWvgh u86liogPzgADXKirDjK+zOQAS3XncgblBkbm2sKATV6ysZ8gIpENhSplCUwJcQFWtRaPIv pWo/ppiBhaVm2RK/ibOU8UESxxAhBa/ncdOzGwDE8JsNe3T7yWvNaaW4j7FMOBXzyaV/Tk Lb0nCFKLCfKbTp/PD7NCBGML8ZbG6xS2sFJc2s62C5fpVSWtMBe1lUZ8aO14CInDRFuhCh jydjQkM0d8ZvmwFo9GLr17addVTOdyLD2chvPvZ3sdLtgL5t0fMEY/gR+78eNA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1723567482; a=rsa-sha256; cv=none; b=V1XmExBoAciZaygspBGoEnEFjgpjnc+alSRg0a0PM8DK6+jkMeaQ5FM13scRY4ehPSTmwY 7kgfgrfUJgBzmxRx1u7uT4hQaFIcsuSllWbov8CicLh6NolgLiTJthB8+nCKG6X5oTT8NN sa7IALEnpw5QuDUtJtU469VOeY3Vo7PJ4dXk8VE5DV0Zi85hCkHbk8I8FxMS76HN0WtFHe ZE+TsnBMqSDhvDjJ049Jr8zG3tYScLJXvJzQUMGpfPGj9rbK3UHpkAunoY4T1dGbSI0yjk RUkcw76BOQErZw6izrbjSNrjQbdmigNxg44ZJYlM8InOc73BqAVYlmRdEmOOvg== 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=1723567482; 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=x0ORNvf+3goee9VCNmKRJbB8iy/ss8Zao92vfcIh9Yo=; b=mL0RNheIjcxN2+60njjKBpvDbaWQ36ABGZ4JD0iK7nmvONB+qK/Kp0Vuf/XEnDR2oKGp/Y Fw+o9N82BYwbysEEBVU/bvilxXJLSiqXZrN0Afbp+Hj5pZnk4dIXtwedgJMHhp3B+2FfRS LI1TqvgqvqOv41R66FipAb6VQUCW+cnoRlvmIaZD4uHw18yq7L0fxAi7akPdg9lJ5YZAiD ouZJuqpZP6oTQ9H216PmoD/MivSKT8GCQyM0aZcfqiL4Y5KkY1am/fyx12GzgSr8K9tQlv PqYHRrqYCq4IQEBEOkra49wToKKdnMdBmzv2xkAz5Asx+twL1hcFFCDNHzZBMA== 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 4Wjy0V0ZcqzJSk; Tue, 13 Aug 2024 16:44: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 47DGifKO067524; Tue, 13 Aug 2024 16:44:41 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 47DGif72067521; Tue, 13 Aug 2024 16:44:41 GMT (envelope-from git) Date: Tue, 13 Aug 2024 16:44:41 GMT Message-Id: <202408131644.47DGif72067521@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: 8807350405ce - releng/13.4 - 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/releng/13.4 X-Git-Reftype: branch X-Git-Commit: 8807350405ce08278dbd8d2d370f9f09d7c2ad47 Auto-Submitted: auto-generated The branch releng/13.4 has been updated by emaste: URL: https://cgit.FreeBSD.org/src/commit/?id=8807350405ce08278dbd8d2d370f9f09d7c2ad47 commit 8807350405ce08278dbd8d2d370f9f09d7c2ad47 Author: Ed Maste AuthorDate: 2024-07-17 14:33:53 +0000 Commit: Ed Maste CommitDate: 2024-08-13 16:39:56 +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) (cherry picked from commit cbbc8d67301c650dd683566d44ff554993556224) (cherry picked from commit 0fb9da95f7cb1730fdf4308f9a12ff8a80c28c87) Approved by: re (cperciva) --- 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 19f5f07d7523..dd1fd9b6d2a9 100644 --- a/sys/kern/sys_pipe.c +++ b/sys/kern/sys_pipe.c @@ -901,8 +901,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);