Module Name: src
Committed By: martin
Date: Wed Oct 23 19:17:15 UTC 2019
Modified Files:
src/sys/lib/libsa [netbsd-9]: loadfile_elf32.c
Log Message:
Pull up following revision(s) (requested by maxv in ticket #361):
sys/lib/libsa/loadfile_elf32.c: revision 1.56
Make sure we're dealing with a static binary. Otherwise we could crash if
the user mistakenly tries to boot a KASLR kernel with 'boot' instead of
'pkboot'. Now we fail cleanly. Reported by cryo@.
To generate a diff of this commit:
cvs rdiff -u -r1.55 -r1.55.2.1 src/sys/lib/libsa/loadfile_elf32.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/lib/libsa/loadfile_elf32.c
diff -u src/sys/lib/libsa/loadfile_elf32.c:1.55 src/sys/lib/libsa/loadfile_elf32.c:1.55.2.1
--- src/sys/lib/libsa/loadfile_elf32.c:1.55 Sun Jul 21 16:53:17 2019
+++ src/sys/lib/libsa/loadfile_elf32.c Wed Oct 23 19:17:15 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: loadfile_elf32.c,v 1.55 2019/07/21 16:53:17 rin Exp $ */
+/* $NetBSD: loadfile_elf32.c,v 1.55.2.1 2019/10/23 19:17:15 martin Exp $ */
/*
* Copyright (c) 1997, 2008, 2017 The NetBSD Foundation, Inc.
@@ -699,6 +699,11 @@ ELFNAMEEND(loadfile_static)(int fd, Elf_
internalize_ehdr(elf->e_ident[EI_DATA], elf);
+ if (elf->e_type != ET_EXEC) {
+ errno = EINVAL;
+ return 1;
+ }
+
sz = elf->e_phnum * sizeof(Elf_Phdr);
phdr = ALLOC(sz);
ret = ELFNAMEEND(readfile_local)(fd, elf->e_phoff, phdr, sz);