aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Johnston <markj@FreeBSD.org>2021-04-26 18:53:16 +0000
committerMark Johnston <markj@FreeBSD.org>2021-05-03 12:39:02 +0000
commit0048a3237ddbf9b83b44a82d9467d65c646e3289 (patch)
tree2684c57c5f932322ce6a0936ed0386cbe41297ac
parentd7d72459f2cd5ef40683f05f6c6c23bf2a13718a (diff)
imgact_elf: Ensure that the return value in parse_notes is initialized
parse_notes relies on the caller-supplied callback to initialize "res". Two callbacks are used in practice, brandnote_cb and note_fctl_cb, and the latter fails to initialize res. Fix it. In the worst case, the bug would cause the inner loop of check_note to examine more program headers than necessary, and the note header usually comes last anyway. Reviewed by: kib Reported by: KMSAN Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D29986 (cherry picked from commit 409ab7e109c692014e3484a74af248dd7a4746e8)
-rw-r--r--sys/kern/imgact_elf.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/sys/kern/imgact_elf.c b/sys/kern/imgact_elf.c
index 4c05be66e51f..416de09630ae 100644
--- a/sys/kern/imgact_elf.c
+++ b/sys/kern/imgact_elf.c
@@ -2666,6 +2666,7 @@ note_fctl_cb(const Elf_Note *note, void *arg0, boolean_t *res)
p += roundup2(note->n_namesz, ELF_NOTE_ROUNDSIZE);
desc = (const Elf32_Word *)p;
*arg->fctl0 = desc[0];
+ *res = TRUE;
return (TRUE);
}