summaryrefslogtreecommitdiffstats
path: root/sys/kern/imgact_elf.c
diff options
context:
space:
mode:
authorbz <bz@FreeBSD.org>2009-08-30 14:38:17 +0000
committerbz <bz@FreeBSD.org>2009-08-30 14:38:17 +0000
commit840afe36da862eaa9287a996548968cbbb30c461 (patch)
tree5dcb3648d211506c50b4c9ede361f0ea41795981 /sys/kern/imgact_elf.c
parent5fb95a2095446b02c21f0e4ecad4b7bff41c856a (diff)
downloadFreeBSD-src-840afe36da862eaa9287a996548968cbbb30c461.zip
FreeBSD-src-840afe36da862eaa9287a996548968cbbb30c461.tar.gz
Make sure FreeBSD binaries without .note.ABI-tag section work
correctly and do not match a colliding Debian GNU/kFreeBSD brandinfo statements. For this mark the Debian GNU/kFreeBSD brandinfo that it must have an .note.ABI-tag section and ignore the old EI_OSABI brandinfo when comparing a possibly colliding set of options. Due to SYSINIT we add the brandinfo in a non-deterministic order, so native FreeBSD is not always first. We may want to consider to force native FreeBSD to come first as well. The only way a problem could currently be noticed is when running an i386 binary without the .note.ABI-tag on amd64 and the Debian GNU/kFreeBSD brandinfo was matched first, as the fallback to ld-elf32.so.1 does not exist in that case. Reported and tested by: ticso In collaboration with: kib MFC after: 3 days
Diffstat (limited to 'sys/kern/imgact_elf.c')
-rw-r--r--sys/kern/imgact_elf.c18
1 files changed, 13 insertions, 5 deletions
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);
}
OpenPOWER on IntegriCloud