svn commit: r315753 - in head/sys: amd64/cloudabi32 amd64/cloudabi64 arm/cloudabi32 arm64/cloudabi64 i386/cloudabi32 kern sys
Konstantin Belousov
kib at FreeBSD.org
Wed Mar 22 22:23:03 UTC 2017
Author: kib
Date: Wed Mar 22 22:23:01 2017
New Revision: 315753
URL: https://svnweb.freebsd.org/changeset/base/315753
Log:
Add a flag BI_BRAND_ONLY_STATIC to specify that the brand only
matches static binaries.
Interpretation of the 'static' there is that the binary must not
specify an interpreter. In particular, shared objects are matched by
the brand if BI_CAN_EXEC_DYN is also set.
This improves precision of the brand matching, which should eliminate
surprises due to brand ordering.
Revert r315701.
Discussed with and tested by: ed (previous version)
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Modified:
head/sys/amd64/cloudabi32/cloudabi32_sysvec.c
head/sys/amd64/cloudabi64/cloudabi64_sysvec.c
head/sys/arm/cloudabi32/cloudabi32_sysvec.c
head/sys/arm64/cloudabi64/cloudabi64_sysvec.c
head/sys/i386/cloudabi32/cloudabi32_sysvec.c
head/sys/kern/imgact_elf.c
head/sys/sys/imgact_elf.h
Modified: head/sys/amd64/cloudabi32/cloudabi32_sysvec.c
==============================================================================
--- head/sys/amd64/cloudabi32/cloudabi32_sysvec.c Wed Mar 22 22:20:47 2017 (r315752)
+++ head/sys/amd64/cloudabi32/cloudabi32_sysvec.c Wed Mar 22 22:23:01 2017 (r315753)
@@ -228,5 +228,5 @@ Elf32_Brandinfo cloudabi32_brand = {
.machine = EM_386,
.sysvec = &cloudabi32_elf_sysvec,
.compat_3_brand = "CloudABI",
- .interp_path = "/nonexistent",
+ .flags = BI_BRAND_NOTE_ONLY_STATIC,
};
Modified: head/sys/amd64/cloudabi64/cloudabi64_sysvec.c
==============================================================================
--- head/sys/amd64/cloudabi64/cloudabi64_sysvec.c Wed Mar 22 22:20:47 2017 (r315752)
+++ head/sys/amd64/cloudabi64/cloudabi64_sysvec.c Wed Mar 22 22:23:01 2017 (r315753)
@@ -212,7 +212,6 @@ Elf64_Brandinfo cloudabi64_brand = {
.brand = ELFOSABI_CLOUDABI,
.machine = EM_X86_64,
.sysvec = &cloudabi64_elf_sysvec,
- .flags = BI_CAN_EXEC_DYN,
+ .flags = BI_CAN_EXEC_DYN | BI_BRAND_NOTE_ONLY_STATIC,
.compat_3_brand = "CloudABI",
- .interp_path = "/nonexistent",
};
Modified: head/sys/arm/cloudabi32/cloudabi32_sysvec.c
==============================================================================
--- head/sys/arm/cloudabi32/cloudabi32_sysvec.c Wed Mar 22 22:20:47 2017 (r315752)
+++ head/sys/arm/cloudabi32/cloudabi32_sysvec.c Wed Mar 22 22:23:01 2017 (r315753)
@@ -190,5 +190,5 @@ Elf32_Brandinfo cloudabi32_brand = {
.machine = EM_ARM,
.sysvec = &cloudabi32_elf_sysvec,
.compat_3_brand = "CloudABI",
- .interp_path = "/nonexistent",
+ .flags = BI_BRAND_NOTE_ONLY_STATIC,
};
Modified: head/sys/arm64/cloudabi64/cloudabi64_sysvec.c
==============================================================================
--- head/sys/arm64/cloudabi64/cloudabi64_sysvec.c Wed Mar 22 22:20:47 2017 (r315752)
+++ head/sys/arm64/cloudabi64/cloudabi64_sysvec.c Wed Mar 22 22:23:01 2017 (r315753)
@@ -181,7 +181,6 @@ Elf64_Brandinfo cloudabi64_brand = {
.brand = ELFOSABI_CLOUDABI,
.machine = EM_AARCH64,
.sysvec = &cloudabi64_elf_sysvec,
- .flags = BI_CAN_EXEC_DYN,
+ .flags = BI_CAN_EXEC_DYN | BI_BRAND_NOTE_ONLY_STATIC,
.compat_3_brand = "CloudABI",
- .interp_path = "/nonexistent",
};
Modified: head/sys/i386/cloudabi32/cloudabi32_sysvec.c
==============================================================================
--- head/sys/i386/cloudabi32/cloudabi32_sysvec.c Wed Mar 22 22:20:47 2017 (r315752)
+++ head/sys/i386/cloudabi32/cloudabi32_sysvec.c Wed Mar 22 22:23:01 2017 (r315753)
@@ -201,5 +201,5 @@ Elf32_Brandinfo cloudabi32_brand = {
.machine = EM_386,
.sysvec = &cloudabi32_elf_sysvec,
.compat_3_brand = "CloudABI",
- .interp_path = "/nonexistent",
+ .flags = BI_BRAND_NOTE_ONLY_STATIC,
};
Modified: head/sys/kern/imgact_elf.c
==============================================================================
--- head/sys/kern/imgact_elf.c Wed Mar 22 22:20:47 2017 (r315752)
+++ head/sys/kern/imgact_elf.c Wed Mar 22 22:23:01 2017 (r315753)
@@ -273,6 +273,9 @@ __elfN(get_brandinfo)(struct image_param
bi = elf_brand_list[i];
if (bi == NULL)
continue;
+ if (interp != NULL &&
+ (bi->flags & BI_BRAND_NOTE_ONLY_STATIC) != 0)
+ 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);
@@ -305,7 +308,9 @@ __elfN(get_brandinfo)(struct image_param
/* 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 || bi->flags & BI_BRAND_NOTE_MANDATORY)
+ if (bi == NULL || (bi->flags & BI_BRAND_NOTE_MANDATORY) != 0 ||
+ (interp != NULL && (bi->flags &
+ BI_BRAND_NOTE_ONLY_STATIC) != 0))
continue;
if (hdr->e_machine == bi->machine &&
(hdr->e_ident[EI_OSABI] == bi->brand ||
@@ -351,7 +356,8 @@ __elfN(get_brandinfo)(struct image_param
if (interp != NULL) {
for (i = 0; i < MAX_BRANDS; i++) {
bi = elf_brand_list[i];
- if (bi == NULL || bi->flags & BI_BRAND_NOTE_MANDATORY)
+ if (bi == NULL || (bi->flags & (BI_BRAND_NOTE_MANDATORY |
+ BI_BRAND_NOTE_ONLY_STATIC)) != 0)
continue;
if (hdr->e_machine == bi->machine &&
/* ELF image p_filesz includes terminating zero */
@@ -365,7 +371,9 @@ __elfN(get_brandinfo)(struct image_param
/* Lacking a recognized interpreter, try the default brand */
for (i = 0; i < MAX_BRANDS; i++) {
bi = elf_brand_list[i];
- if (bi == NULL || bi->flags & BI_BRAND_NOTE_MANDATORY)
+ if (bi == NULL || (bi->flags & BI_BRAND_NOTE_MANDATORY) != 0 ||
+ (interp != NULL && (bi->flags &
+ BI_BRAND_NOTE_ONLY_STATIC) != 0))
continue;
if (hdr->e_machine == bi->machine &&
__elfN(fallback_brand) == bi->brand)
Modified: head/sys/sys/imgact_elf.h
==============================================================================
--- head/sys/sys/imgact_elf.h Wed Mar 22 22:20:47 2017 (r315752)
+++ head/sys/sys/imgact_elf.h Wed Mar 22 22:23:01 2017 (r315753)
@@ -81,6 +81,7 @@ typedef struct {
#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. */
+#define BI_BRAND_NOTE_ONLY_STATIC 0x0008
} __ElfN(Brandinfo);
__ElfType(Auxargs);
More information about the svn-src-all
mailing list