[PATCH v4 02/22] elf: only accept images matching the native ELF_CLASS
Sascha Hauer
s.hauer at pengutronix.de
Wed Jan 14 04:14:27 PST 2026
Reviewed-by: Ahmad Fatoum <a.fatoum at pengutronix.de>
Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
---
common/elf.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/common/elf.c b/common/elf.c
index 34d790bad3961664a8036c3299e675fa053b15a2..f772018deb3c5a07a9f76bc654e54ff46cc3612e 100644
--- a/common/elf.c
+++ b/common/elf.c
@@ -208,6 +208,9 @@ static int elf_check_image(struct elf_image *elf, void *buf)
return -ENOEXEC;
}
+ if (elf->class != ELF_CLASS)
+ return -EINVAL;
+
if (!elf_hdr_e_phnum(elf, buf)) {
pr_err("No phdr found.\n");
return -ENOEXEC;
--
2.47.3
More information about the barebox
mailing list