From nobody Wed Sep 04 19:13:10 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 4WzXFg1hxMz5VCWt; Wed, 04 Sep 2024 19:13:11 +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 4WzXFg14Gyz42kj; Wed, 4 Sep 2024 19:13:11 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1725477191; 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=8TCoMRT9T9P6/qzYnUED0FczEWdzSsvt32D4SQqPM6E=; b=rhBw0gDDWGzzU4zAdmvJbWg3CQLDPtcsLli8bk9EeZGqc5NLzyS+EwgvkwXhCYkP951xNQ zTiaGlSS3Ikk5hHAniNcJtlcCXgUd3/QjuOQ+He6F1L4vlNDe9JuvVwaIeq/tksu0G12aj YB7iZjNMKNlxNwtJzD3jiX9dIPNDkzeVfQtnFgBIJn35AXv6W4ndKb9R+hVZMHnZtN0VF+ 5O8B1Ouz77bfrOhmQnBLYOOmkqCWVmlp9VB/xLPGKetJi8tE9EWN9oyRmNf5mmbbEjVvUq xBQN10QqSAGR0MZRVMAa8woGCA7EFo7dNct9M0L5bnNeN8fhD6kdWn/USpaYzA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1725477191; a=rsa-sha256; cv=none; b=KwGqSe1KCY3MlAYgNHhTSYtSZ7ekyKIL/AG73288/TxUPsRbmXPOYfiCNfNGlx2D1jpRES CpCozqZ5IosT2S9VAMTCAAP6MY7+8tDffapOon5YZhD9JF+QPslvVGoER0zKSh1IKcKdx0 yyBsRUauJidG7x3Ra4PiuoTkaaneQu1b7o1AwPZvLUN5jeNUrC2nfT8ZaD6jHk0PHdhvH+ PBlWLZM5HsgZeViNTnkn0nP6yRQCx5g9zwqvSGyXG7e6i8ZafaXA1WeJXwFuG2UuTLubWP FIpPuos44cBdEzIjxll5M4Mkxmtw9FQwQ1OgcysW+vHxW83fMoCKXgJgLnCewg== 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=1725477191; 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=8TCoMRT9T9P6/qzYnUED0FczEWdzSsvt32D4SQqPM6E=; b=JtZkmbg6TtXSTNX6BduTHwzziHgRTDEv4wPIY54psP2LV3pSc3BUfNJ08akAa+yqL47VyK SehegjzMawlleQkkGx1qfzhMf8wcbOz7NQa+v4pa3mGOdCIdxn2rIu8VK1ZIbCOP7Km0L9 KSwmT03WD7zdC9r8McSoVRBgWblq/eyA3esY0TrjiI82SH1QGKr47PtLsyf0bkBjo3DIen O+UGiSDvB1cgXm5jSkI6H4DY8Wohi9CBlsAm8877MBkR/XNgSFH9Y0zEx/y3KLFx/0D0Ri IXoBN7bApZMZWQzmJm4O+uY7D8uukD8+ewXKRbxseRPi+vEhjAZpai0Os1A55g== 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 4WzXFg0cZRzcTr; Wed, 4 Sep 2024 19:13:11 +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 484JDAQl061248; Wed, 4 Sep 2024 19:13:10 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 484JDAvL061245; Wed, 4 Sep 2024 19:13:10 GMT (envelope-from git) Date: Wed, 4 Sep 2024 19:13:10 GMT Message-Id: <202409041913.484JDAvL061245@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: 3aa9be7e3334 - releng/13.4 - libnv: verify that string is null terminated 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: 3aa9be7e33344c0cc3f50062bac4926cdb49d36d Auto-Submitted: auto-generated The branch releng/13.4 has been updated by emaste: URL: https://cgit.FreeBSD.org/src/commit/?id=3aa9be7e33344c0cc3f50062bac4926cdb49d36d commit 3aa9be7e33344c0cc3f50062bac4926cdb49d36d Author: Mariusz Zaborski AuthorDate: 2024-08-26 18:20:24 +0000 Commit: Ed Maste CommitDate: 2024-09-04 19:10:30 +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 03bef9971d73621e1703a0bad41b598bc2fce9c6) Approved by: so Approved by: re (cperciva) --- 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 41d262a18c9b..cfe168c38026 100644 --- a/sys/contrib/libnv/bsd_nvpair.c +++ b/sys/contrib/libnv/bsd_nvpair.c @@ -986,6 +986,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);