diff options
-rw-r--r-- | sys/amd64/amd64/elf_machdep.c | 2 | ||||
-rw-r--r-- | sys/compat/ia32/ia32_sysvec.c | 2 | ||||
-rw-r--r-- | sys/i386/i386/elf_machdep.c | 2 | ||||
-rw-r--r-- | sys/kern/imgact_elf.c | 18 | ||||
-rw-r--r-- | sys/sys/imgact_elf.h | 5 |
5 files changed, 19 insertions, 10 deletions
diff --git a/sys/amd64/amd64/elf_machdep.c b/sys/amd64/amd64/elf_machdep.c index ea48b25..d5e7a6e 100644 --- a/sys/amd64/amd64/elf_machdep.c +++ b/sys/amd64/amd64/elf_machdep.c @@ -118,7 +118,7 @@ static Elf64_Brandinfo kfreebsd_brand_info = { .sysvec = &elf64_freebsd_sysvec, .interp_newpath = NULL, .brand_note = &elf64_kfreebsd_brandnote, - .flags = BI_CAN_EXEC_DYN | BI_BRAND_NOTE + .flags = BI_CAN_EXEC_DYN | BI_BRAND_NOTE_MANDATORY }; SYSINIT(kelf64, SI_SUB_EXEC, SI_ORDER_ANY, diff --git a/sys/compat/ia32/ia32_sysvec.c b/sys/compat/ia32/ia32_sysvec.c index 5c2c571..46e0b80 100644 --- a/sys/compat/ia32/ia32_sysvec.c +++ b/sys/compat/ia32/ia32_sysvec.c @@ -180,7 +180,7 @@ static Elf32_Brandinfo kia32_brand_info = { .interp_path = "/lib/ld.so.1", .sysvec = &ia32_freebsd_sysvec, .brand_note = &elf32_kfreebsd_brandnote, - .flags = BI_CAN_EXEC_DYN | BI_BRAND_NOTE + .flags = BI_CAN_EXEC_DYN | BI_BRAND_NOTE_MANDATORY }; SYSINIT(kia32, SI_SUB_EXEC, SI_ORDER_ANY, diff --git a/sys/i386/i386/elf_machdep.c b/sys/i386/i386/elf_machdep.c index a4ff9e2..abfe147 100644 --- a/sys/i386/i386/elf_machdep.c +++ b/sys/i386/i386/elf_machdep.c @@ -117,7 +117,7 @@ static Elf32_Brandinfo kfreebsd_brand_info = { .sysvec = &elf32_freebsd_sysvec, .interp_newpath = NULL, .brand_note = &elf32_kfreebsd_brandnote, - .flags = BI_CAN_EXEC_DYN | BI_BRAND_NOTE + .flags = BI_CAN_EXEC_DYN | BI_BRAND_NOTE_MANDATORY }; SYSINIT(kelf32, SI_SUB_EXEC, SI_ORDER_ANY, diff --git a/sys/kern/imgact_elf.c b/sys/kern/imgact_elf.c index 6803523..ba5833a 100644 --- a/sys/kern/imgact_elf.c +++ b/sys/kern/imgact_elf.c @@ -238,8 +238,10 @@ __elfN(get_brandinfo)(struct image_params *imgp, const char *interp, /* Look for an ".note.ABI-tag" ELF section */ for (i = 0; i < MAX_BRANDS; i++) { bi = elf_brand_list[i]; - if (bi != NULL && hdr->e_machine == bi->machine && - (bi->flags & BI_BRAND_NOTE) != 0) { + if (bi == NULL) + continue; + if (hdr->e_machine == bi->machine && (bi->flags & + (BI_BRAND_NOTE|BI_BRAND_NOTE_MANDATORY)) != 0) { ret = __elfN(check_note)(imgp, bi->brand_note, osrel); if (ret) return (bi); @@ -249,7 +251,9 @@ __elfN(get_brandinfo)(struct image_params *imgp, const char *interp, /* If the executable has a brand, search for it in the brand list. */ for (i = 0; i < MAX_BRANDS; i++) { bi = elf_brand_list[i]; - if (bi != NULL && hdr->e_machine == bi->machine && + if (bi == NULL || bi->flags & BI_BRAND_NOTE_MANDATORY) + continue; + if (hdr->e_machine == bi->machine && (hdr->e_ident[EI_OSABI] == bi->brand || strncmp((const char *)&hdr->e_ident[OLD_EI_BRAND], bi->compat_3_brand, strlen(bi->compat_3_brand)) == 0)) @@ -260,7 +264,9 @@ __elfN(get_brandinfo)(struct image_params *imgp, const char *interp, if (interp != NULL) { for (i = 0; i < MAX_BRANDS; i++) { bi = elf_brand_list[i]; - if (bi != NULL && hdr->e_machine == bi->machine && + if (bi == NULL || bi->flags & BI_BRAND_NOTE_MANDATORY) + continue; + if (hdr->e_machine == bi->machine && strcmp(interp, bi->interp_path) == 0) return (bi); } @@ -269,7 +275,9 @@ __elfN(get_brandinfo)(struct image_params *imgp, const char *interp, /* Lacking a recognized interpreter, try the default brand */ for (i = 0; i < MAX_BRANDS; i++) { bi = elf_brand_list[i]; - if (bi != NULL && hdr->e_machine == bi->machine && + if (bi == NULL || bi->flags & BI_BRAND_NOTE_MANDATORY) + continue; + if (hdr->e_machine == bi->machine && __elfN(fallback_brand) == bi->brand) return (bi); } diff --git a/sys/sys/imgact_elf.h b/sys/sys/imgact_elf.h index 3eecf85..4ccee5d 100644 --- a/sys/sys/imgact_elf.h +++ b/sys/sys/imgact_elf.h @@ -74,8 +74,9 @@ typedef struct { const char *interp_newpath; int flags; Elf_Brandnote *brand_note; -#define BI_CAN_EXEC_DYN 0x0001 -#define BI_BRAND_NOTE 0x0002 +#define BI_CAN_EXEC_DYN 0x0001 +#define BI_BRAND_NOTE 0x0002 /* May have note.ABI-tag section. */ +#define BI_BRAND_NOTE_MANDATORY 0x0004 /* Must have note.ABI-tag section. */ } __ElfN(Brandinfo); __ElfType(Auxargs); |