From nobody Wed Oct 15 20:20:09 2025 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 4cn2WZ1ld8z6CwKn; Wed, 15 Oct 2025 20:20:10 +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 "R12" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4cn2WZ0wQsz3FgF; Wed, 15 Oct 2025 20:20:10 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1760559610; 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=5t4HqIcTRoDTu5aeX1MnQYPXabnAWaycPauHZ3mLx8Y=; b=NPTFn5W/oSmPTIMV0T6SudTxOJlQqhQOP3zjI1xPjXrPod8S0PDYbRDzlzeZZSzt2BmjJD TPj0YSTOJKJWM8KgIrlbU5YptQtxNZQiIQoy3w/0q9C9trgVk9qdXLloFk5froB4RmjO5z qNshIVNGX6tlO86R+arnmTDZE09Y+1mdMbpph0FneIT9GHthQsJi1g7SQbyf6QrxRkNlEA z58hSd1q9NknCyYQu/PuDN5IAUyPxW1iT2GB6e7X45uAThp58Y+0ZY7FdAMbPX9hQD6fHr NZJEvQakVSE/+nAGAnz8P+MMc7uD8OrbFASMrtIAd2AYugoms44rf1Hs8pMxyQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1760559610; 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=5t4HqIcTRoDTu5aeX1MnQYPXabnAWaycPauHZ3mLx8Y=; b=JXEcvTldDaXSWq6CkZk962VTu2SXNdCNkAiozwNnV7GiZH3rF4JQuQyoWnqo4f2c7GEeok zAs7ENnfXCevcLUETP4xn+yosOq74ZnJDoqAtssrJysvT0TutA1Q7I/qdsRQAtBeMhZri/ EY73lCvDpzYCWjJNff7JFKeQtSbrSw5KAhtE0dTfowB02QI9FDcW0uDhV81E63CM6gDsWl S9yD46eKpvnJD6rbHQ9BPLJoW01eLNEzpdh8w4Tw6Ag5d9ReaIjmJhVYjbmGNaTTxJgCmL iHG20MIkExygMKYWHIgOPhE31vBAet5AFxG88nwK15BPyPkf654RPbjcZIyABQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1760559610; a=rsa-sha256; cv=none; b=V5ahtFWtN1tuBQibJ+dC3dDx/mX4Rgv64ok7AgGgD89IFgzbne49Te9tFvEGex3iLEvgSb 5NQjf2XsNf8HQAV8HsRK68NlocGYUdawesEbh24ey1QcynAWd1MOhfNAlyxNxpM6iQWUSk OTKkiLE9NhJVEU7k69i2/JGY53cuMSk15nhjFzpHoA487bE7yKYK82CCernH5MZGLHnS9B L+CKGZT/Prz8qA/qA6ZFxq/Vpkj0g2S+6iNRUHHcUIULI0fR6EVbomph4gGMKPOXZv+upt gxXS0GQn5uWW2HLcAAB6Q3BwXrxaF+Lgx+M5/iYfN7zK+PngRt5Uk6TElng8BQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none 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 4cn2WZ07nmztXN; Wed, 15 Oct 2025 20:20:10 +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 59FKK9Pe031320; Wed, 15 Oct 2025 20:20:09 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 59FKK9t2031314; Wed, 15 Oct 2025 20:20:09 GMT (envelope-from git) Date: Wed, 15 Oct 2025 20:20:09 GMT Message-Id: <202510152020.59FKK9t2031314@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mark Johnston Subject: git: c86af2cc4cd1 - main - imgact_elf: Check note body sizes 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: markj X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: c86af2cc4cd12fb0174843b22d737c3b5b5d55d0 Auto-Submitted: auto-generated The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=c86af2cc4cd12fb0174843b22d737c3b5b5d55d0 commit c86af2cc4cd12fb0174843b22d737c3b5b5d55d0 Author: Mark Johnston AuthorDate: 2025-10-15 20:14:36 +0000 Commit: Mark Johnston CommitDate: 2025-10-15 20:14:36 +0000 imgact_elf: Check note body sizes In parse_notes we validate that the note name fits within the note buffer, but we do not do the same for the note data, so there is some potential for an OOB read in the note handler. Add a bounds check. Reported by: Ilja Van Sprundel Reviewed by: kib, emaste MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D53063 --- sys/kern/imgact_elf.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sys/kern/imgact_elf.c b/sys/kern/imgact_elf.c index c53707a1286c..a1fabbc86f27 100644 --- a/sys/kern/imgact_elf.c +++ b/sys/kern/imgact_elf.c @@ -2831,7 +2831,7 @@ __elfN(parse_notes)(const struct image_params *imgp, const Elf_Note *checknote, } if ((const char *)note_end - (const char *)note < sizeof(Elf_Note)) { - uprintf("ELF note to short\n"); + uprintf("ELF note too short\n"); goto retf; } if (note->n_namesz != checknote->n_namesz || @@ -2839,9 +2839,9 @@ __elfN(parse_notes)(const struct image_params *imgp, const Elf_Note *checknote, note->n_type != checknote->n_type) goto nextnote; note_name = (const char *)(note + 1); - if (note_name + checknote->n_namesz >= - (const char *)note_end || strncmp(note_vendor, - note_name, checknote->n_namesz) != 0) + if (note_name + roundup2(note->n_namesz, ELF_NOTE_ROUNDSIZE) + + note->n_descsz >= (const char *)note_end || + strncmp(note_vendor, note_name, checknote->n_namesz) != 0) goto nextnote; if (cb(note, cb_arg, &res))