Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F158199907
D55480.id172579.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
D55480.id172579.diff
View Options
diff --git a/sys/arm64/include/elf.h b/sys/arm64/include/elf.h
--- a/sys/arm64/include/elf.h
+++ b/sys/arm64/include/elf.h
@@ -74,6 +74,8 @@
#define ELF_MACHINE_OK(x) ((x) == (ELF_ARCH))
+#define ELF_IS_CHERI(hdr) (((hdr)->e_flags & EF_AARCH64_CHERI_PURECAP) != 0)
+
/* Define "machine" characteristics */
#if __ELF_WORD_SIZE == 64
#define ELF_TARG_CLASS ELFCLASS64
diff --git a/sys/kern/imgact_elf.c b/sys/kern/imgact_elf.c
--- a/sys/kern/imgact_elf.c
+++ b/sys/kern/imgact_elf.c
@@ -36,6 +36,7 @@
#include <sys/param.h>
#include <sys/capsicum.h>
#include <sys/compressor.h>
+#include <sys/elf.h>
#include <sys/exec.h>
#include <sys/fcntl.h>
#include <sys/imgact.h>
@@ -500,6 +501,7 @@
hdr->e_ident[EI_DATA] != ELF_TARG_DATA ||
hdr->e_ident[EI_VERSION] != EV_CURRENT ||
hdr->e_phentsize != sizeof(Elf_Phdr) ||
+ ELF_IS_CHERI(hdr) ||
hdr->e_version != ELF_TARG_VER)
return (ENOEXEC);
diff --git a/sys/kern/link_elf.c b/sys/kern/link_elf.c
--- a/sys/kern/link_elf.c
+++ b/sys/kern/link_elf.c
@@ -1077,6 +1077,11 @@
error = ENOEXEC;
goto out;
}
+ if (ELF_IS_CHERI(hdr)) {
+ link_elf_error(filename, "CHERI pure capability ABI");
+ error = ENOEXEC;
+ goto out;
+ }
/*
* We rely on the program header being in the first page.
diff --git a/sys/kern/link_elf_obj.c b/sys/kern/link_elf_obj.c
--- a/sys/kern/link_elf_obj.c
+++ b/sys/kern/link_elf_obj.c
@@ -387,6 +387,7 @@
hdr->e_ident[EI_VERSION] != EV_CURRENT ||
hdr->e_version != EV_CURRENT ||
hdr->e_type != ET_REL ||
+ ELF_IS_CHERI(hdr) ||
hdr->e_machine != ELF_TARG_MACH) {
error = EFTYPE;
goto out;
@@ -798,6 +799,11 @@
error = ENOEXEC;
goto out;
}
+ if (ELF_IS_CHERI(hdr)) {
+ link_elf_error(filename, "Pure capability ABI");
+ error = ENOEXEC;
+ goto out;
+ }
lf = linker_make_file(filename, &link_elf_class);
if (!lf) {
diff --git a/sys/sys/elf.h b/sys/sys/elf.h
--- a/sys/sys/elf.h
+++ b/sys/sys/elf.h
@@ -38,4 +38,11 @@
#include <sys/elf32.h>
#include <sys/elf64.h>
+#ifndef ELF_IS_CHERI
+#if __has_feature(capabilities)
+#error "Must have ELF_IS_CHERI for CHERI architectures"
+#endif
+#define ELF_IS_CHERI(hdr) false
+#endif
+
#endif /* !_SYS_ELF_H_ */
diff --git a/sys/sys/elf_common.h b/sys/sys/elf_common.h
--- a/sys/sys/elf_common.h
+++ b/sys/sys/elf_common.h
@@ -344,6 +344,7 @@
#define EF_ARM_ABI_FLOAT_HARD 0x00000400
#define EF_ARM_VFP_FLOAT EF_ARM_ABI_FLOAT_HARD /* Pre-V5 ABI name */
#define EF_ARM_MAVERICK_FLOAT 0x00000800
+#define EF_AARCH64_CHERI_PURECAP 0x00010000
#define EF_MIPS_NOREORDER 0x00000001
#define EF_MIPS_PIC 0x00000002 /* Contains PIC code */
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, May 30, 5:18 PM (4 h, 1 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
33637351
Default Alt Text
D55480.id172579.diff (2 KB)
Attached To
Mode
D55480: ELF: detect and reject CheriABI binaries
Attached
Detach File
Event Timeline
Log In to Comment