From nobody Wed Sep 04 20:54:12 2024 X-Original-To: dev-commits-src-branches@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 4WzZVD5Yy0z5VMrj; Wed, 04 Sep 2024 20:54:12 +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 4WzZVD3hhbz4PYj; Wed, 4 Sep 2024 20:54:12 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1725483252; 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=FbMFWPhh8gMk2ulyv10v8MTXLkfw80DoQ1yzCM5lNJc=; b=ensWsPoFRMeT77RwRQ39q2xNLZeTJxe1rvwK0yaCdV+1+QeJcKAdEeCnxPSOE3m0oY2QLY PcGnjxKovJkoHkyVcj8UAncytJYbMTh8jEhVj/oQjvnFk0vNIwtE1toD37MTPEqU0J4K7m 0CMiuT+Z8F6izP6A6pLD7JcPrHwLtpwMcZBZ1KtzVFx6BaOBMSq7q3dKdsuuxFPqxo89sE aLcCyJWdX7W/WxQ+sxkuts/pPGuqv3dj3YXkr6ak6sEoqsX+WYLVIauWvSla7i+5z6o3/i TyxsVz9bS1WT8MJVmavOx3ks2SB3tvErSabgjp9NDm8AyCKr7N2ERyJ3y/wGkw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1725483252; a=rsa-sha256; cv=none; b=uNVzEeU7MU4QtMneOfgCkjmJmUzhlH7uzgVtSu2qKiAlw01y7Mdd5naO+n41kt7oHbwvI5 6SzkvoeNXx2UP2X6nqhDwSZbuWo31ZxmLydTxV49cEs6IuIAEwm444pKUNSZ4R+mm/kuJu h2SGhj9a80sG+J+xrO5CZsxgfptS8XXXVHeJ8URMjhLB5LMIZCWFu69LZw03eWuETo6ebu X/NDlKE6EQmYCKBW53CrOIasSJytdbTiDdVrwxAbm8t3SjcFjMXGgtLcUPwtYlMwU+jSGk tXfj4599kV9M/U+v/2Enl2ZoilZXNSlID0xQiRf+1kSv9Oi//pIZumMTtT+xMQ== 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=1725483252; 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=FbMFWPhh8gMk2ulyv10v8MTXLkfw80DoQ1yzCM5lNJc=; b=o15PGSb7c9D1FglqsaXLpaSLRn/A8xDTTPU5GXUvKJeviQ2+mMFd5Cn16B9DyjL++Ax9CU jnPmGSXKPv94vWx+gjuxwSZX1QSGJmv5BmXHL47ArMazTr+XLJojxAL/YN4DtegfpAoQmm v6/1vffasUPil50NYoHafprLM9YOoYTE2+sWZuW3usDled5uJPv2KrM9wyYfVbsTd9NlwW uVbgwn1phZ1VpjbfugCzxXqxDcq5941HlEzgLIh8DQCTFyrPFMhX0HZQV0iI/gT7lv91vn Lr4A3Avw8UU6URDocybWOr7kxASCAu3QMPhty6EtY33dnihYfrxX0ubuCBoebw== 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 4WzZVD3JjFzfjG; Wed, 4 Sep 2024 20:54:12 +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 484KsCrk033687; Wed, 4 Sep 2024 20:54:12 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 484KsC5H033684; Wed, 4 Sep 2024 20:54:12 GMT (envelope-from git) Date: Wed, 4 Sep 2024 20:54:12 GMT Message-Id: <202409042054.484KsC5H033684@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: b219ce1c5a93 - releng/14.0 - libnv: verify that string is null terminated List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-branches@freebsd.org Sender: owner-dev-commits-src-branches@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/14.0 X-Git-Reftype: branch X-Git-Commit: b219ce1c5a9349f3925daf994904d4891ad8bf9e Auto-Submitted: auto-generated The branch releng/14.0 has been updated by emaste: URL: https://cgit.FreeBSD.org/src/commit/?id=b219ce1c5a9349f3925daf994904d4891ad8bf9e commit b219ce1c5a9349f3925daf994904d4891ad8bf9e Author: Mariusz Zaborski AuthorDate: 2024-08-26 18:20:24 +0000 Commit: Ed Maste CommitDate: 2024-09-04 20:48:29 +0000 libnv: verify that string is null terminated During unpacking, we ensure that we do not read beyond the declared size. However, unpack uses a function that copies null-terminated strings. Prior to this commit, if the last string was not null-terminated, it could result in copying data into a buffer smaller than the allocated size. Security: FreeBSD-24:09.libnv Security: CVE-2024-45288 Security: CAP-03 Reported by: Synacktiv Sponsored by: The Alpha-Omega Project Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D46138 (cherry picked from commit 3aaaca1b51ad844ef9e9b3d945217ab3dd189bae) (cherry picked from commit 9c2ef102166eaab4c2531eb0ce6ffb20b82e778a) Approved by: so --- sys/contrib/libnv/bsd_nvpair.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/sys/contrib/libnv/bsd_nvpair.c b/sys/contrib/libnv/bsd_nvpair.c index 9560ebc74f83..a977d7941aa3 100644 --- a/sys/contrib/libnv/bsd_nvpair.c +++ b/sys/contrib/libnv/bsd_nvpair.c @@ -988,6 +988,10 @@ nvpair_unpack_string_array(bool isbe __unused, nvpair_t *nvp, for (ii = 0; ii < nvp->nvp_nitems; ii++) { len = strnlen(tmp, size - 1) + 1; size -= len; + if (tmp[len - 1] != '\0') { + ERRNO_SET(EINVAL); + return (NULL); + } if (size < 0) { ERRNO_SET(EINVAL); return (NULL);