From nobody Wed Sep 04 12:24:56 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 4WzMBd2vscz5TnMQ; Wed, 04 Sep 2024 12:24:57 +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 4WzMBd0ST1z56l2; Wed, 4 Sep 2024 12:24:57 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1725452697; 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=N9AZ5voyh447aUWXQ7gmAjfQ8o+0k0+2gCzDAVvmx9c=; b=rhzaV90h+9E7ryLqyfI9zPq0aIHjJcN1tVe5pfuL01R8+mqtUjTTpGkH9/C+FrKGN82VYa x2Skh2qk3PVssphF+cb59rVeZaKfSTU0PnqPRT+MmWRf9WgiYqur3Q0Q5x0EFPUiH02X31 9M4AiR+Fjiz3Rur0j4+1nKbXUhyh3FlP5bwBJp3zPOj1lj3w/DZrQemAf5dXXyskzXRXNA d8ujxe26ICZwV7C8wskLaHilwLMT7bj2h4rpvbBywNqirtMDMyaHPrucXW3DyjMIgVqyXc oWRRgbIXnaaaDgKGjdEAXnq0lvWs3DF7vIWNv8NN46zFjSyqnbQ97xlnd2oGrQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1725452697; a=rsa-sha256; cv=none; b=c4zJHBI/CbXslRhxCoSOiP/Jzja6Qb94or7yo7Ef6Llq/FqNH2iNBXliG+YOtw8MSgqJqP RfsBQTAwHV/82M3VDQA58/CNLGcQ2LjR2GvI9BU/bt6kdfAkUoOtveWFDiSmQV9lZyDJ8Z F8jiN0eWPIhVuE2uvn+wdbj39zq/AqbDklSknDCJHaN/gVgXHBsY66is8f/eC0DIoV8xxa cfInjjmm5amAMqJLOM1OMdIwPLi5DK/n0T7ZKpTBd+jnIMgS2S2lqTRS92Lql8aMJ+vkqu 1srDTolXreDoNwxb4NZ/9/5ToBLZaMsyMaqo3S+Lz2V1hrc0W2e0dT1m/08gyw== 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=1725452697; 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=N9AZ5voyh447aUWXQ7gmAjfQ8o+0k0+2gCzDAVvmx9c=; b=QXQ+Hmf+ykEJpjB2cbjDvQGJ4V1mx66nIfhEB/oiGcm7S4IiWFduTCh2oxbA87QORP6FKg ah9vQZUdfIQHt6h47IgGCv2C+BsYTJvZoUh1ZJVLjGRsYDYQaAuN0ppaxNvY5VEDCtQoD+ iISN3kBPxQMfC6kQ5VczeRdLHLCUelznfJc5YqVs/BBXZeP3VZ9RpxhObgvs43iij2FFfK NCdXw162fRpaI9dmjtKXRseopCg6Sd/zfY7bDaE4Vd+5FVTzKdx2X7KcB2/5zBYtBd+Fr9 DDrYq3nVTvKOSTmAtbimVQBSy8W1rOEsOhP1zgdrKm2ngSrSCOnvyQt2/+YM/A== 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 4WzMBc6MVZzNhS; Wed, 4 Sep 2024 12:24:56 +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 484COubc062560; Wed, 4 Sep 2024 12:24:56 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 484COuhc062557; Wed, 4 Sep 2024 12:24:56 GMT (envelope-from git) Date: Wed, 4 Sep 2024 12:24:56 GMT Message-Id: <202409041224.484COuhc062557@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mariusz Zaborski Subject: git: 9c2ef102166e - stable/14 - 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: oshogbo X-Git-Repository: src X-Git-Refname: refs/heads/stable/14 X-Git-Reftype: branch X-Git-Commit: 9c2ef102166eaab4c2531eb0ce6ffb20b82e778a Auto-Submitted: auto-generated The branch stable/14 has been updated by oshogbo: URL: https://cgit.FreeBSD.org/src/commit/?id=9c2ef102166eaab4c2531eb0ce6ffb20b82e778a commit 9c2ef102166eaab4c2531eb0ce6ffb20b82e778a Author: Mariusz Zaborski AuthorDate: 2024-08-26 18:20:24 +0000 Commit: Mariusz Zaborski CommitDate: 2024-09-04 12:26:05 +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) --- 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);