Date: Wed, 22 Oct 2025 13:01:17 GMT From: Mark Johnston <markj@FreeBSD.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org Subject: git: 1508441e71f1 - stable/14 - imgact_elf: Check note body sizes Message-ID: <202510221301.59MD1HPp009825@gitrepo.freebsd.org>
index | next in thread | raw e-mail
The branch stable/14 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=1508441e71f13b3d66c854677216a4a8c8ca5e03 commit 1508441e71f13b3d66c854677216a4a8c8ca5e03 Author: Mark Johnston <markj@FreeBSD.org> AuthorDate: 2025-10-15 20:14:36 +0000 Commit: Mark Johnston <markj@FreeBSD.org> 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 <ivansprundel@ioactive.com> 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))home | help
Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202510221301.59MD1HPp009825>
