From nobody Wed Sep 04 12:22:29 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 4WzM7n3VrGz5TnJF; Wed, 04 Sep 2024 12:22:29 +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 4WzM7n1sS9z54bY; Wed, 4 Sep 2024 12:22:29 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1725452549; 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=WKtnuSJf1mI++TTGx/9/BXiNYoEZP+F/nvN/LHq2V4g=; b=cDGfLVcaKklQIk4huvzEgmU+N+/NClsVQ89hhcULsltX23wUzF4MpetSEj0O36OnTOHa3V MKCdw2uZgWxI3dWH803EBVKg4Vfb/XlpAwBcQzSu5wEMowns/HfTnuVls0vYPcaDdY2mQb Mij2gz+Ia5ufRYo7EI+eHotX4Uxm9+fEjeIgDArL7VxnoJTU0KMENrlJKVoUwAHrnNyofx U9NI5ana1VOAuvy6X1rqltcExCYZDZ6KxDzhrI1TnXvnEoFq7/NETc26SeFbNxobtcK0Zb cjwf7R2TU/dsEKfhx/gQgt2eu02Oh+1kQnHzOStoZhWjk3UHf/58tQXsxn4/YQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1725452549; a=rsa-sha256; cv=none; b=Zs0ygs4+io8ayvF4ucr2ak7L1Uwm4LGUPXWsFFQ+mDT0AwZaeESMhKPBVlxHB61z3eQLz/ 6QQ/06En1B7odDc168eczJ50nce+IuZ8lGTsJGIlA2yEdoa69Mi0g/y/6ZnY/vBWTv5qg4 ROCTl5HNkF2FYx8szMmTDoFu33/8gdYlPtMY7xrwAXzsD65ZLWjfwM6EJpw/rZlYClX38x inPmpBVF1bT3Xwh3VtYWeDK8iZzuq9LHfDB3xnvu0YJjgYaZdJrjmfuL6I1zmEPC19xUfN q/NS9hhUsH9DjI+MUw+rHcBa6Htdl+OPPaEcAq9WAl+I3PL3lOSipqKHr0T2YQ== 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=1725452549; 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=WKtnuSJf1mI++TTGx/9/BXiNYoEZP+F/nvN/LHq2V4g=; b=ZPXBnsuzqhaTTOPTxJHyADwRj3g4UaDXCodpdGcYxBFpi8BqWOe3LXarSqovgvcB91Z+X2 BCsrOrve82MwfYa3hM2a/wqtxbn3fvvlPVf4XBdhfHqmysx2Ey6WlQgIB7Hh7N/j1awQun DHNdEc3bcIQV44RLBVgQ2pI859169FXckpzKIyhPUvpIV4spz+seFO+4L1MiN/1MfWp3JL Ec5NGJrJjXwpALKuAW2x90yziBxmFmxWb9Uer+A1HrUvZhQSoSO8Wo/LIvF+0tHeIJRqej p5BbVwC6WOhyzxDpMHwfVpdiLKNx1LZaUsUODsEvoIHotBUQQ8t4eennbwc30g== 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 4WzM7n1SL2zPDM; Wed, 4 Sep 2024 12:22:29 +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 484CMTBc061677; Wed, 4 Sep 2024 12:22:29 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 484CMTmU061674; Wed, 4 Sep 2024 12:22:29 GMT (envelope-from git) Date: Wed, 4 Sep 2024 12:22:29 GMT Message-Id: <202409041222.484CMTmU061674@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mariusz Zaborski Subject: git: 3aaaca1b51ad - main - libnv: verify that string is null terminated 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: oshogbo X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 3aaaca1b51ad844ef9e9b3d945217ab3dd189bae Auto-Submitted: auto-generated The branch main has been updated by oshogbo: URL: https://cgit.FreeBSD.org/src/commit/?id=3aaaca1b51ad844ef9e9b3d945217ab3dd189bae commit 3aaaca1b51ad844ef9e9b3d945217ab3dd189bae Author: Mariusz Zaborski AuthorDate: 2024-08-26 18:20:24 +0000 Commit: Mariusz Zaborski CommitDate: 2024-09-04 11:42:55 +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 --- 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);