From nobody Wed Oct 22 12:52:39 2025 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 4cs8G014fnz6FDrQ; Wed, 22 Oct 2025 12:52:40 +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 4cs8Fz5tGJz3n2Q; Wed, 22 Oct 2025 12:52:39 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1761137559; 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=VlK1BEKRylYWHKORZjsYRFQFZGd1AQIv4RvHGkh3D2Q=; b=D7dNgGsx1KOC0A6sF7igGxmxINUEH4zkiNrsklCosKBTlRCykxuj+v1H6v9H7cFfYR+2eK 5XuNzNuq8TAahY8R1Wp18EoZFby/Lj3kdvJURNOAe4Hr4GIZigq7OtVGfKlbIMX4sv+l3P RoDcxVl/40/57L2Bqkl8R5hfpOiP5Gmtj1QcrT0xcXO2sSau9n2zUwAuPs58SS4ghcsRU/ 7b6LBWVQDwwMTv8JoSJM107jPT4iQZqzckE0Hwsx+qa176DW8/R8SMPLXASZ/qdVoXjT02 X8tStyYDrMEsM2p8L687L//+7uv87zur4DnLWe8pL+Zm0csI8kx5zLfXpE3dLA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1761137559; 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=VlK1BEKRylYWHKORZjsYRFQFZGd1AQIv4RvHGkh3D2Q=; b=WEBghRKB3GAwaAB/f/WptDsR5L8sy9vmzMFaxrsAFdRxyMJrInjWubs4eC17OypdrNzHxb Nz8qCBoiSJpqg+l0UnI2dp1y8YlecKpt5EvTEkIm7/T1EiFUx03yBazSkfL31U70vbIReR 4m1Rhcu4hcjHK8AOYyCcfWl8sddk++Cdw/fhsVx2Fn/i9B4WFaZPM4apsg/i1LN35PklF1 BIt7oYZYZH1782UkLgPRK+xReZiaBi1HIem6QTpSjixUY4pc2wCHyju3bKx+4tlfijqKK+ 80KzkHvwTYqQJqG5Se9vHK7XZWiX4FcThirekF/j+1XdxUebwNJEzJUnx0gxZQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1761137559; a=rsa-sha256; cv=none; b=RTyiFroJpHyBs0BqcUEvsIrg+tG4ZlS8l2k73VL6o6CxC3BH/uBR+S+/kaDSj/gEeAt6Dq jCbVSiF3UzbThY1qI8LjZlSf+jXWBpNnj+7yjiNW4jS0H3HEGQXXCuoIsN75BuECVqhFSR CjG3G5gp5LWIFQOt2E85S0s4ua4ebvVs3p9xfcXujMa/+RGeRmd7F+caakjxQ5foXh3grv p0XRwEFuukPkEfRLm2gDsew8UeLSfxigrdUJ2pEa9bY0KsbSbmRS/bAP9irYoj8DslDHtw cOOily9vLpZRshUumCq1UmMVt4Iu5D814ofKAl1gqtKyvF3AEACSIFEwLFGigw== 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 4cs8Fz5PgCzVF6; Wed, 22 Oct 2025 12:52:39 +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 59MCqdsS096204; Wed, 22 Oct 2025 12:52:39 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 59MCqd3L096201; Wed, 22 Oct 2025 12:52:39 GMT (envelope-from git) Date: Wed, 22 Oct 2025 12:52:39 GMT Message-Id: <202510221252.59MCqd3L096201@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mark Johnston Subject: git: 09ae918e1f00 - stable/15 - imgact_elf: Check note body sizes 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: markj X-Git-Repository: src X-Git-Refname: refs/heads/stable/15 X-Git-Reftype: branch X-Git-Commit: 09ae918e1f00572f9045283c281cf2d210ece491 Auto-Submitted: auto-generated The branch stable/15 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=09ae918e1f00572f9045283c281cf2d210ece491 commit 09ae918e1f00572f9045283c281cf2d210ece491 Author: Mark Johnston AuthorDate: 2025-10-15 20:14:36 +0000 Commit: Mark Johnston CommitDate: 2025-10-22 12:52:00 +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 (cherry picked from commit c86af2cc4cd12fb0174843b22d737c3b5b5d55d0) --- 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 1bc2491a1a12..bc4fcad6c61b 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))