From nobody Wed Sep 4 21:07:27 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 4WzZnX1dNQz5VP0H; Wed, 04 Sep 2024 21:07:28 +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 4WzZnW6vjqz4VfB; Wed, 4 Sep 2024 21:07:27 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1725484048; 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=Tf/J/z4vdOj9cpE98pjkX41FKtlXIbTrreBUC31KgZM=; b=eRbOHJUsOHiqAMvqwsOLcsgcI6NpwEak8OYPJ4SpPZ2rtg6Fml0UHb2X/RN3UoqKoC69Ub QNcCy/5HInNevyV4KIadXcK8cumXEbGuN0ltNRIewtunImIyk2WDOONb7Akouu+RIB/kjs e8VkF+GDXsF9hj9ftXp2k4icWySMnInLzc3QOM2SpJScgYc7sqxtzO2u7XA+u6fUFSz79S tf/Nnd04tKXR4snOmCQwCsUd8fTozp5V+4udarFaZ4P+MfgcGfdaKKYvZesdTynEyZGY+4 eKON4m8LtIyFvfpH+nNyaxL+5LrlVdeqO6qVQY5jHStqL7IiNJF5Qk59gg49yw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1725484048; a=rsa-sha256; cv=none; b=Sh6fqAe4wqdOAOipeQYvYtfV53k6FWs0JuoTbtWurm2mxQXHJBPZTDwQOukngzVkM6gx2Y NFbf51wtA6xKBfgwDmn0nzHAI/xZ4pz99D0BSJajnCNbFaHFqhlpeTpCsTfvg4N5IO01e2 gjqw9WdasGJ7nCOJESZ7Y+Z/SXGzkvgUKOUS6XJ0hFDAjnyJAhIXkrfx7FrcmnlqQBJOnq PY+YtOfBY0uQU4qtD4ZRCdUU9kZg7+6IbJvvNokPDApaJiBw1qfq6E7fcpulfyz1Wh5Ei2 UWcMZkyIZyALDniDqBqN63EhmMZnLZOEZrjfUKXWJ4BGLyOslrlWrK/TJlc0FA== 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=1725484048; 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=Tf/J/z4vdOj9cpE98pjkX41FKtlXIbTrreBUC31KgZM=; b=cr6CDLrXt1ZLXDRpRIwcoW85dlk0tv53WnDkvk0O2O4sZWXsilGGQkf3SMOiCBWOjVOl6h vK/JKqbUtRHGDu4MtTLebk9168T/weuaeR61tG69qjn8Yusi4fvZed2ZcWApS6J5bOKkbT a8vQdRax6+s7/0BC0Jp5ikrutjCYE0YYwzXIAtiiPE/N1r9dDkhy6dYw6LOyf1bdJnuiTZ cnKPJBtix4GiFATRaKGNhHAIgV4j0z5hBdcp1EOPK5qJmYIaloDgwpjf5NjfTipHHoSaFV wHEx0OukCc3LCpgyJoLpsKGcpM2LKksE/9pof1P7iytQjHYsZB+ATRxwgyLXHw== 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 4WzZnW6Wm7zgcR; Wed, 4 Sep 2024 21:07:27 +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 484L7Rmt053098; Wed, 4 Sep 2024 21:07:27 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 484L7RVV053095; Wed, 4 Sep 2024 21:07:27 GMT (envelope-from git) Date: Wed, 4 Sep 2024 21:07:27 GMT Message-Id: <202409042107.484L7RVV053095@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: d87f821959fb - releng/14.1 - 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/14.1 X-Git-Reftype: branch X-Git-Commit: d87f821959fb59f902a2064afa37a70180385377 Auto-Submitted: auto-generated The branch releng/14.1 has been updated by emaste: URL: https://cgit.FreeBSD.org/src/commit/?id=d87f821959fb59f902a2064afa37a70180385377 commit d87f821959fb59f902a2064afa37a70180385377 Author: Mariusz Zaborski AuthorDate: 2024-08-26 18:20:24 +0000 Commit: Ed Maste CommitDate: 2024-09-04 20:46:46 +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);