From nobody Wed Oct 22 13:01:17 2025 X-Original-To: dev-commits-src-branches@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 4cs8Rx6n0Fz6FFgp; Wed, 22 Oct 2025 13:01:17 +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 4cs8Rx3G8rz3pX2; Wed, 22 Oct 2025 13:01:17 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1761138077; 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=U6RhGAdh923eMPNbxf4bfS78rSWDdD/JiNJG+uwrfso=; b=OkIS/RqnM6fMpJWyMt66rKpxPBYX0Ex8HPrWov7ZRbfkfoztpVz+uP/Gz4ErjQgZXeW8kk iS5AHmc9lekXyfMtcVTEFDAGHVb04V+Mdj4SyJXtcNkKdjfseVLncEpxnTMm2OIBny/1rg EJ6TKusi4Nil0v48zk7nz0wnzxIVuHm8AQz8xsUwDbS7rduSj+CWC04yxb51Br5bdfYh+k gRzM2iLMjnU78OONygfNabrXoCHy0fMDN4ALmLkT+ycQcY2wA0Ko4ImYDNP4+Kgo1KRacX IL2L51SyXnJBPt0pn4ZnMKqOfVBkijBIKGsqTtGmELotl8UcbCT4uIu+HY4hpQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1761138077; 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=U6RhGAdh923eMPNbxf4bfS78rSWDdD/JiNJG+uwrfso=; b=rCEL92RCEl+uMnoPUk6qbvEExTsuzZh71bZjmNF+7h8POmMHhirOCwLmJ9CvzCkLiIxl41 swb+zqmkUT8MLnmEBcyf35EgTL6+UbTICJ5gD+HTO1q6woAiudZXgixck0dIaVvC4Tx0Q1 akDjCaIoBc1AlDy6W3FIqgEHg/cYvBuqxUdvInI6CWZweCJA/OGlqWsmLl0gPSStsV/Vog o5WXrvFqu9tn1v8eNVLv1j1BtTghmJj8U0AsiWosJbEKH+h1YzXD+hJ18wnLMrgiKtx+M2 0m/dQyL3LcPkqcHUtd3XdWuTGFwOLOTiGsq2dyHRgd3zYja5BMSNqv6T6/cdDw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1761138077; a=rsa-sha256; cv=none; b=PU5QNTvFW05xNNfUREgEUp679+FWeSH1EcJSXhWqNUlaJR9eZsQKNnx7V1ADWHFVBMUN0g lROfgVSMzqSBglo/5Y/ZZIWnASpwM27AONfAeaJFOJil0VznYfEwO9XowYE7hMN0Ope/a0 OfFT+WcAWwhadvJxeBx7C0AY2Lx4ITcWa/HROUfgdzVbPQhKq8IOEEEE5oJvRRHL53v0Yd ROega3HbiJPLUxyPeJPzZADF5EmdRxfup7qUYvN4WLzhBxqiGl7FF+IDzOPlavpGV5z0Zl L8fofmFPiFumj7G1m2Wu8rO/WmcffwDAEm+2ME0TYg1EEP97zWpvI5epJwO9RQ== 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 4cs8Rx2ZnqzTkt; Wed, 22 Oct 2025 13:01:17 +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 59MD1HY9009828; Wed, 22 Oct 2025 13:01:17 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 59MD1HPp009825; Wed, 22 Oct 2025 13:01:17 GMT (envelope-from git) Date: Wed, 22 Oct 2025 13:01:17 GMT Message-Id: <202510221301.59MD1HPp009825@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: 1508441e71f1 - stable/14 - imgact_elf: Check note body sizes List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-branches@freebsd.org Sender: owner-dev-commits-src-branches@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/14 X-Git-Reftype: branch X-Git-Commit: 1508441e71f13b3d66c854677216a4a8c8ca5e03 Auto-Submitted: auto-generated The branch stable/14 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=1508441e71f13b3d66c854677216a4a8c8ca5e03 commit 1508441e71f13b3d66c854677216a4a8c8ca5e03 Author: Mark Johnston AuthorDate: 2025-10-15 20:14:36 +0000 Commit: Mark Johnston CommitDate: 2025-10-22 12:34:04 +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 0a09bb9e3891..f73fd997594d 100644 --- a/sys/kern/imgact_elf.c +++ b/sys/kern/imgact_elf.c @@ -2802,7 +2802,7 @@ __elfN(parse_notes)(struct image_params *imgp, 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 || @@ -2810,9 +2810,9 @@ __elfN(parse_notes)(struct image_params *imgp, 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))