svn commit: r190520 - in stable/7/sys: . amd64/amd64 amd64/linux32 arm/arm compat/ia32 compat/svr4 contrib/pf dev/ath/ath_hal dev/cxgb i386/i386 i386/linux ia64/ia64 kern powerpc/powerpc sparc64/sp...

Dmitry Chagin dchagin at FreeBSD.org
Sun Mar 29 01:07:38 PDT 2009


Author: dchagin
Date: Sun Mar 29 08:07:36 2009
New Revision: 190520
URL: http://svn.freebsd.org/changeset/base/190520

Log:
  Merge from head to stable/7:
  
  r189771:
  Implement new way of branding ELF binaries by looking to a
  ".note.ABI-tag" section.
  
  The search order of a brand is changed, now first of all the
  ".note.ABI-tag" is looked through.
  
  Move code which fetch osreldate for ELF binary to check_note() handler.
  
  r189919:
  Use the properly sized types for ELF object header and program headers.
  This fixes osrel fetching from the FreeBSD branding note for the 64bit
  platforms (bug introduced by r189771).
  
  r190264:
  Fix several issues with parsing the notes for ELF objects.
  
  Badly formed ELF note may cause the caclulated pointer to the next note
  to point both after the note region, that was checked in the code, but
  also to point before the region, that was not checked [1]. Remember the
  first note location in note0 and leap out if the note is not between
  note0 and note_end.
  
  In the similar way, badly formed note may cause infinite loop by
  pointing next note into the same or previous note. Guard against this
  by
  limiting amount of loop iterations by arbitrary choosen big number.
  
  For clarity, check the calculated note alignment in each iteration.
  
  PR:     kern/132886
  Approved by:	re(Ken Smith)

Modified:
  stable/7/sys/   (props changed)
  stable/7/sys/amd64/amd64/elf_machdep.c
  stable/7/sys/amd64/linux32/linux32_sysvec.c
  stable/7/sys/arm/arm/elf_machdep.c
  stable/7/sys/compat/ia32/ia32_sysvec.c
  stable/7/sys/compat/svr4/svr4_sysvec.c
  stable/7/sys/contrib/pf/   (props changed)
  stable/7/sys/dev/ath/ath_hal/   (props changed)
  stable/7/sys/dev/cxgb/   (props changed)
  stable/7/sys/i386/i386/elf_machdep.c
  stable/7/sys/i386/linux/linux_sysvec.c
  stable/7/sys/ia64/ia64/elf_machdep.c
  stable/7/sys/kern/imgact_elf.c
  stable/7/sys/powerpc/powerpc/elf_machdep.c
  stable/7/sys/sparc64/sparc64/elf_machdep.c
  stable/7/sys/sys/imgact_elf.h

Modified: stable/7/sys/amd64/amd64/elf_machdep.c
==============================================================================
--- stable/7/sys/amd64/amd64/elf_machdep.c	Sun Mar 29 07:10:52 2009	(r190519)
+++ stable/7/sys/amd64/amd64/elf_machdep.c	Sun Mar 29 08:07:36 2009	(r190520)
@@ -83,7 +83,8 @@ static Elf64_Brandinfo freebsd_brand_inf
 	.interp_path	= "/libexec/ld-elf.so.1",
 	.sysvec		= &elf64_freebsd_sysvec,
 	.interp_newpath	= NULL,
-	.flags		= BI_CAN_EXEC_DYN,
+	.brand_note	= &elf64_freebsd_brandnote,
+	.flags		= BI_CAN_EXEC_DYN
 };
 
 SYSINIT(elf64, SI_SUB_EXEC, SI_ORDER_ANY,
@@ -98,7 +99,8 @@ static Elf64_Brandinfo freebsd_brand_oin
 	.interp_path	= "/usr/libexec/ld-elf.so.1",
 	.sysvec		= &elf64_freebsd_sysvec,
 	.interp_newpath	= NULL,
-	.flags		= BI_CAN_EXEC_DYN,
+	.brand_note	= &elf64_freebsd_brandnote,
+	.flags		= BI_CAN_EXEC_DYN
 };
 
 SYSINIT(oelf64, SI_SUB_EXEC, SI_ORDER_ANY,

Modified: stable/7/sys/amd64/linux32/linux32_sysvec.c
==============================================================================
--- stable/7/sys/amd64/linux32/linux32_sysvec.c	Sun Mar 29 07:10:52 2009	(r190519)
+++ stable/7/sys/amd64/linux32/linux32_sysvec.c	Sun Mar 29 08:07:36 2009	(r190520)
@@ -1034,6 +1034,16 @@ struct sysentvec elf_linux_sysvec = {
 	.sv_maxssiz	= &linux32_maxssiz,
 };
 
+static char GNULINUX_ABI_VENDOR[] = "GNU";
+
+static Elf_Brandnote linux32_brandnote = {
+	.hdr.n_namesz	= sizeof(GNULINUX_ABI_VENDOR),
+	.hdr.n_descsz	= 16,
+	.hdr.n_type	= 1,
+	.vendor		= GNULINUX_ABI_VENDOR,
+	.flags		= 0
+};
+
 static Elf32_Brandinfo linux_brand = {
 	.brand		= ELFOSABI_LINUX,
 	.machine	= EM_386,
@@ -1042,7 +1052,8 @@ static Elf32_Brandinfo linux_brand = {
 	.interp_path	= "/lib/ld-linux.so.1",
 	.sysvec		= &elf_linux_sysvec,
 	.interp_newpath	= NULL,
-	.flags		= BI_CAN_EXEC_DYN,
+	.brand_note	= &linux32_brandnote,
+	.flags		= BI_CAN_EXEC_DYN
 };
 
 static Elf32_Brandinfo linux_glibc2brand = {
@@ -1053,7 +1064,8 @@ static Elf32_Brandinfo linux_glibc2brand
 	.interp_path	= "/lib/ld-linux.so.2",
 	.sysvec		= &elf_linux_sysvec,
 	.interp_newpath	= NULL,
-	.flags		= BI_CAN_EXEC_DYN,
+	.brand_note	= &linux32_brandnote,
+	.flags		= BI_CAN_EXEC_DYN
 };
 
 Elf32_Brandinfo *linux_brandlist[] = {

Modified: stable/7/sys/arm/arm/elf_machdep.c
==============================================================================
--- stable/7/sys/arm/arm/elf_machdep.c	Sun Mar 29 07:10:52 2009	(r190519)
+++ stable/7/sys/arm/arm/elf_machdep.c	Sun Mar 29 08:07:36 2009	(r190520)
@@ -83,7 +83,8 @@ static Elf32_Brandinfo freebsd_brand_inf
 	.interp_path	= "/libexec/ld-elf.so.1",
 	.sysvec		= &elf32_freebsd_sysvec,
 	.interp_newpath	= NULL,
-	.flags		= BI_CAN_EXEC_DYN,
+	.brand_note	= &elf32_freebsd_brandnote,
+	.flags		= BI_CAN_EXEC_DYN
 };
 
 SYSINIT(elf32, SI_SUB_EXEC, SI_ORDER_ANY,
@@ -98,7 +99,8 @@ static Elf32_Brandinfo freebsd_brand_oin
 	.interp_path	= "/usr/libexec/ld-elf.so.1",
 	.sysvec		= &elf32_freebsd_sysvec,
 	.interp_newpath	= NULL,
-	.flags		= BI_CAN_EXEC_DYN,
+	.brand_note	= &elf32_freebsd_brandnote,
+	.flags		= BI_CAN_EXEC_DYN
 };
 
 SYSINIT(oelf32, SI_SUB_EXEC, SI_ORDER_ANY,

Modified: stable/7/sys/compat/ia32/ia32_sysvec.c
==============================================================================
--- stable/7/sys/compat/ia32/ia32_sysvec.c	Sun Mar 29 07:10:52 2009	(r190519)
+++ stable/7/sys/compat/ia32/ia32_sysvec.c	Sun Mar 29 08:07:36 2009	(r190520)
@@ -147,6 +147,7 @@ static Elf32_Brandinfo ia32_brand_info =
 	.interp_path	= "/libexec/ld-elf.so.1",
 	.sysvec		= &ia32_freebsd_sysvec,
 	.interp_newpath	= "/libexec/ld-elf32.so.1",
+	.brand_note	= &elf32_freebsd_brandnote,
 	.flags		= BI_CAN_EXEC_DYN
 };
 
@@ -162,7 +163,8 @@ static Elf32_Brandinfo ia32_brand_oinfo 
 	.interp_path	= "/usr/libexec/ld-elf.so.1",
 	.sysvec		= &ia32_freebsd_sysvec,
 	.interp_newpath	= "/libexec/ld-elf32.so.1",
-	.flags		= BI_CAN_EXEC_DYN,
+	.brand_note	= &elf32_freebsd_brandnote,
+	.flags		= BI_CAN_EXEC_DYN
 };
 
 SYSINIT(oia32, SI_SUB_EXEC, SI_ORDER_ANY,

Modified: stable/7/sys/compat/svr4/svr4_sysvec.c
==============================================================================
--- stable/7/sys/compat/svr4/svr4_sysvec.c	Sun Mar 29 07:10:52 2009	(r190519)
+++ stable/7/sys/compat/svr4/svr4_sysvec.c	Sun Mar 29 08:07:36 2009	(r190520)
@@ -206,6 +206,7 @@ Elf32_Brandinfo svr4_brand = {
 	.interp_path	= "/lib/libc.so.1",
 	.sysvec		= &svr4_sysvec,
 	.interp_newpath	= NULL,
+	.brand_note	= NULL,
 	.flags		= 0
 };
 

Modified: stable/7/sys/i386/i386/elf_machdep.c
==============================================================================
--- stable/7/sys/i386/i386/elf_machdep.c	Sun Mar 29 07:10:52 2009	(r190519)
+++ stable/7/sys/i386/i386/elf_machdep.c	Sun Mar 29 08:07:36 2009	(r190520)
@@ -83,7 +83,8 @@ static Elf32_Brandinfo freebsd_brand_inf
 	.interp_path	= "/libexec/ld-elf.so.1",
 	.sysvec		= &elf32_freebsd_sysvec,
 	.interp_newpath	= NULL,
-	.flags		= BI_CAN_EXEC_DYN,
+	.brand_note	= &elf32_freebsd_brandnote,
+	.flags		= BI_CAN_EXEC_DYN
 };
 
 SYSINIT(elf32, SI_SUB_EXEC, SI_ORDER_ANY,
@@ -98,7 +99,8 @@ static Elf32_Brandinfo freebsd_brand_oin
 	.interp_path	= "/usr/libexec/ld-elf.so.1",
 	.sysvec		= &elf32_freebsd_sysvec,
 	.interp_newpath	= NULL,
-	.flags		= BI_CAN_EXEC_DYN,
+	.brand_note	= &elf32_freebsd_brandnote,
+	.flags		= BI_CAN_EXEC_DYN
 };
 
 SYSINIT(oelf32, SI_SUB_EXEC, SI_ORDER_ANY,

Modified: stable/7/sys/i386/linux/linux_sysvec.c
==============================================================================
--- stable/7/sys/i386/linux/linux_sysvec.c	Sun Mar 29 07:10:52 2009	(r190519)
+++ stable/7/sys/i386/linux/linux_sysvec.c	Sun Mar 29 08:07:36 2009	(r190520)
@@ -869,6 +869,16 @@ struct sysentvec elf_linux_sysvec = {
 	.sv_maxssiz	= NULL
 };
 
+static char GNULINUX_ABI_VENDOR[] = "GNU";
+
+static Elf_Brandnote linux_brandnote = {
+	.hdr.n_namesz	= sizeof(GNULINUX_ABI_VENDOR),
+	.hdr.n_descsz	= 16,
+	.hdr.n_type	= 1,
+	.vendor		= GNULINUX_ABI_VENDOR,
+	.flags		= 0
+};
+
 static Elf32_Brandinfo linux_brand = {
 	.brand		= ELFOSABI_LINUX,
 	.machine	= EM_386,
@@ -877,7 +887,8 @@ static Elf32_Brandinfo linux_brand = {
 	.interp_path	= "/lib/ld-linux.so.1",
 	.sysvec		= &elf_linux_sysvec,
 	.interp_newpath	= NULL,
-	.flags		= BI_CAN_EXEC_DYN,
+	.brand_note	= &linux_brandnote,
+	.flags		= BI_CAN_EXEC_DYN
 };
 
 static Elf32_Brandinfo linux_glibc2brand = {
@@ -888,7 +899,8 @@ static Elf32_Brandinfo linux_glibc2brand
 	.interp_path	= "/lib/ld-linux.so.2",
 	.sysvec		= &elf_linux_sysvec,
 	.interp_newpath	= NULL,
-	.flags		= BI_CAN_EXEC_DYN,
+	.brand_note	= &linux_brandnote,
+	.flags		= BI_CAN_EXEC_DYN
 };
 
 Elf32_Brandinfo *linux_brandlist[] = {

Modified: stable/7/sys/ia64/ia64/elf_machdep.c
==============================================================================
--- stable/7/sys/ia64/ia64/elf_machdep.c	Sun Mar 29 07:10:52 2009	(r190519)
+++ stable/7/sys/ia64/ia64/elf_machdep.c	Sun Mar 29 08:07:36 2009	(r190520)
@@ -91,7 +91,8 @@ static Elf64_Brandinfo freebsd_brand_inf
 	.interp_path	= "/libexec/ld-elf.so.1",
 	.sysvec		= &elf64_freebsd_sysvec,
 	.interp_newpath	= NULL,
-	.flags		= BI_CAN_EXEC_DYN,
+	.brand_note	= &elf64_freebsd_brandnote,
+	.flags		= BI_CAN_EXEC_DYN
 };
 SYSINIT(elf64, SI_SUB_EXEC, SI_ORDER_ANY,
     (sysinit_cfunc_t)elf64_insert_brand_entry, &freebsd_brand_info);
@@ -104,7 +105,8 @@ static Elf64_Brandinfo freebsd_brand_oin
 	.interp_path	= "/usr/libexec/ld-elf.so.1",
 	.sysvec		= &elf64_freebsd_sysvec,
 	.interp_newpath	= NULL,
-	.flags		= BI_CAN_EXEC_DYN,
+	.brand_note	= &elf64_freebsd_brandnote,
+	.flags		= BI_CAN_EXEC_DYN
 };
 SYSINIT(oelf64, SI_SUB_EXEC, SI_ORDER_ANY,
     (sysinit_cfunc_t)elf64_insert_brand_entry, &freebsd_brand_oinfo);

Modified: stable/7/sys/kern/imgact_elf.c
==============================================================================
--- stable/7/sys/kern/imgact_elf.c	Sun Mar 29 07:10:52 2009	(r190519)
+++ stable/7/sys/kern/imgact_elf.c	Sun Mar 29 08:07:36 2009	(r190520)
@@ -78,14 +78,16 @@ __FBSDID("$FreeBSD$");
 #define OLD_EI_BRAND	8
 
 static int __elfN(check_header)(const Elf_Ehdr *hdr);
-static Elf_Brandinfo *__elfN(get_brandinfo)(const Elf_Ehdr *hdr,
-    const char *interp);
+static Elf_Brandinfo *__elfN(get_brandinfo)(struct image_params *imgp,
+    const char *interp, int32_t *osrel);
 static int __elfN(load_file)(struct proc *p, const char *file, u_long *addr,
     u_long *entry, size_t pagesize);
 static int __elfN(load_section)(struct vmspace *vmspace, vm_object_t object,
     vm_offset_t offset, caddr_t vmaddr, size_t memsz, size_t filsz,
     vm_prot_t prot, size_t pagesize);
 static int __CONCAT(exec_, __elfN(imgact))(struct image_params *imgp);
+static boolean_t __elfN(check_note)(struct image_params *imgp,
+    Elf_Brandnote *checknote, int32_t *osrel);
 
 SYSCTL_NODE(_kern, OID_AUTO, __CONCAT(elf, __ELF_WORD_SIZE), CTLFLAG_RW, 0,
     "");
@@ -110,6 +112,16 @@ static Elf_Brandinfo *elf_brand_list[MAX
 #define	round_page_ps(va, ps)	(((va) + (ps - 1)) & ~(ps - 1))
 #define	aligned(a, t)	(trunc_page_ps((u_long)(a), sizeof(t)) == (u_long)(a))
 
+static const char FREEBSD_ABI_VENDOR[] = "FreeBSD";
+
+Elf_Brandnote __elfN(freebsd_brandnote) = {
+	.hdr.n_namesz	= sizeof(FREEBSD_ABI_VENDOR),
+	.hdr.n_descsz	= sizeof(int32_t),
+	.hdr.n_type	= 1,
+	.vendor		= FREEBSD_ABI_VENDOR,
+	.flags		= BN_CAN_FETCH_OSREL
+};
+
 int
 __elfN(insert_brand_entry)(Elf_Brandinfo *entry)
 {
@@ -161,19 +173,32 @@ __elfN(brand_inuse)(Elf_Brandinfo *entry
 }
 
 static Elf_Brandinfo *
-__elfN(get_brandinfo)(const Elf_Ehdr *hdr, const char *interp)
+__elfN(get_brandinfo)(struct image_params *imgp, const char *interp,
+    int32_t *osrel)
 {
+	const Elf_Ehdr *hdr = (const Elf_Ehdr *)imgp->image_header;
 	Elf_Brandinfo *bi;
+	boolean_t ret;
 	int i;
 
 	/*
-	 * We support three types of branding -- (1) the ELF EI_OSABI field
+	 * We support four types of branding -- (1) the ELF EI_OSABI field
 	 * that SCO added to the ELF spec, (2) FreeBSD 3.x's traditional string
-	 * branding w/in the ELF header, and (3) path of the `interp_path'
-	 * field.  We should also look for an ".note.ABI-tag" ELF section now
-	 * in all Linux ELF binaries, FreeBSD 4.1+, and some NetBSD ones.
+	 * branding w/in the ELF header, (3) path of the `interp_path'
+	 * field, and (4) the ".note.ABI-tag" ELF section.
 	 */
 
+	/* 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->brand_note != NULL) {
+			ret = __elfN(check_note)(imgp, bi->brand_note, osrel);
+			if (ret)
+				return (bi);
+		}
+	}
+
 	/* 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];
@@ -597,13 +622,11 @@ fail:
 	return (error);
 }
 
-static const char FREEBSD_ABI_VENDOR[] = "FreeBSD";
-
 static int
 __CONCAT(exec_, __elfN(imgact))(struct image_params *imgp)
 {
 	const Elf_Ehdr *hdr = (const Elf_Ehdr *)imgp->image_header;
-	const Elf_Phdr *phdr, *pnote = NULL;
+	const Elf_Phdr *phdr;
 	Elf_Auxargs *elf_auxargs;
 	struct vmspace *vmspace;
 	vm_prot_t prot;
@@ -611,12 +634,11 @@ __CONCAT(exec_, __elfN(imgact))(struct i
 	u_long text_addr = 0, data_addr = 0;
 	u_long seg_size, seg_addr;
 	u_long addr, entry = 0, proghdr = 0;
+	int32_t osrel = 0;
 	int error = 0, i;
 	const char *interp = NULL, *newinterp = NULL;
 	Elf_Brandinfo *brand_info;
-	const Elf_Note *note, *note_end;
 	char *path;
-	const char *note_name;
 	struct thread *td = curthread;
 	struct sysentvec *sv;
 
@@ -654,7 +676,7 @@ __CONCAT(exec_, __elfN(imgact))(struct i
 		}
 	}
 
-	brand_info = __elfN(get_brandinfo)(hdr, interp);
+	brand_info = __elfN(get_brandinfo)(imgp, interp, &osrel);
 	if (brand_info == NULL) {
 		uprintf("ELF binary type \"%u\" not known.\n",
 		    hdr->e_ident[EI_OSABI]);
@@ -758,9 +780,6 @@ __CONCAT(exec_, __elfN(imgact))(struct i
 		case PT_PHDR: 	/* Program header table info */
 			proghdr = phdr[i].p_vaddr;
 			break;
-		case PT_NOTE:
-			pnote = &phdr[i];
-			break;
 		default:
 			break;
 		}
@@ -849,41 +868,7 @@ __CONCAT(exec_, __elfN(imgact))(struct i
 
 	imgp->auxargs = elf_auxargs;
 	imgp->interpreted = 0;
-
-	/*
-	 * Try to fetch the osreldate for FreeBSD binary from the ELF
-	 * OSABI-note. Only the first page of the image is searched,
-	 * the same as for headers.
-	 */
-	if (pnote != NULL && pnote->p_offset < PAGE_SIZE &&
-	    pnote->p_offset + pnote->p_filesz < PAGE_SIZE ) {
-		note = (const Elf_Note *)(imgp->image_header + pnote->p_offset);
-		if (!aligned(note, Elf32_Addr)) {
-			free(imgp->auxargs, M_TEMP);
-			imgp->auxargs = NULL;
-			return (ENOEXEC);
-		}
-		note_end = (const Elf_Note *)(imgp->image_header + pnote->p_offset +
-		    pnote->p_filesz);
-		while (note < note_end) {
-			if (note->n_namesz == sizeof(FREEBSD_ABI_VENDOR) &&
-			    note->n_descsz == sizeof(int32_t) &&
-			    note->n_type == 1 /* ABI_NOTETYPE */) {
-				note_name = (const char *)(note + 1);
-				if (strncmp(FREEBSD_ABI_VENDOR, note_name,
-				    sizeof(FREEBSD_ABI_VENDOR)) == 0) {
-					imgp->proc->p_osrel = *(const int32_t *)
-					    (note_name +
-					    round_page_ps(sizeof(FREEBSD_ABI_VENDOR),
-						sizeof(Elf32_Addr)));
-					break;
-				}
-			}
-			note = (const Elf_Note *)((const char *)(note + 1) +
-			    round_page_ps(note->n_namesz, sizeof(Elf32_Addr)) +
-			    round_page_ps(note->n_descsz, sizeof(Elf32_Addr)));
-		}
-	}
+	imgp->proc->p_osrel = osrel;
 
 	return (error);
 }
@@ -1349,6 +1334,71 @@ __elfN(putnote)(void *dst, size_t *off, 
 }
 
 /*
+ * Try to find the appropriate ABI-note section for checknote,
+ * fetch the osreldate for binary from the ELF OSABI-note. Only the
+ * first page of the image is searched, the same as for headers.
+ */
+static boolean_t
+__elfN(check_note)(struct image_params *imgp, Elf_Brandnote *checknote,
+    int32_t *osrel)
+{
+	const Elf_Note *note, *note0, *note_end;
+	const Elf_Phdr *phdr, *pnote;
+	const Elf_Ehdr *hdr;
+	const char *note_name;
+	int i;
+
+	pnote = NULL;
+	hdr = (const Elf_Ehdr *)imgp->image_header;
+	phdr = (const Elf_Phdr *)(imgp->image_header + hdr->e_phoff);
+
+	for (i = 0; i < hdr->e_phnum; i++) {
+		if (phdr[i].p_type == PT_NOTE) {
+			pnote = &phdr[i];
+			break;
+		}
+	}
+
+	if (pnote == NULL || pnote->p_offset >= PAGE_SIZE ||
+	    pnote->p_offset + pnote->p_filesz >= PAGE_SIZE)
+		return (FALSE);
+
+	note = note0 = (const Elf_Note *)(imgp->image_header + pnote->p_offset);
+	note_end = (const Elf_Note *)(imgp->image_header +
+	    pnote->p_offset + pnote->p_filesz);
+	for (i = 0; i < 100 && note >= note0 && note < note_end; i++) {
+		if (!aligned(note, Elf32_Addr))
+			return (FALSE);
+		if (note->n_namesz != checknote->hdr.n_namesz ||
+		    note->n_descsz != checknote->hdr.n_descsz ||
+		    note->n_type != checknote->hdr.n_type)
+			goto nextnote;
+		note_name = (const char *)(note + 1);
+		if (strncmp(checknote->vendor, note_name,
+		    checknote->hdr.n_namesz) != 0)
+			goto nextnote;
+
+		/*
+		 * Fetch the osreldate for binary
+		 * from the ELF OSABI-note if necessary.
+		 */
+		if ((checknote->flags & BN_CAN_FETCH_OSREL) != 0 &&
+		    osrel != NULL)
+			*osrel = *(const int32_t *) (note_name +
+			    roundup2(checknote->hdr.n_namesz,
+			    sizeof(Elf32_Addr)));
+		return (TRUE);
+
+nextnote:
+		note = (const Elf_Note *)((const char *)(note + 1) +
+		    roundup2(note->n_namesz, sizeof(Elf32_Addr)) +
+		    roundup2(note->n_descsz, sizeof(Elf32_Addr)));
+	}
+
+	return (FALSE);
+}
+
+/*
  * Tell kern_execve.c about it, with a little help from the linker.
  */
 static struct execsw __elfN(execsw) = {

Modified: stable/7/sys/powerpc/powerpc/elf_machdep.c
==============================================================================
--- stable/7/sys/powerpc/powerpc/elf_machdep.c	Sun Mar 29 07:10:52 2009	(r190519)
+++ stable/7/sys/powerpc/powerpc/elf_machdep.c	Sun Mar 29 08:07:36 2009	(r190520)
@@ -86,7 +86,8 @@ static Elf32_Brandinfo freebsd_brand_inf
 	.interp_path	= "/libexec/ld-elf.so.1",
 	.sysvec		= &elf32_freebsd_sysvec,
 	.interp_newpath	= NULL,
-	.flags		= BI_CAN_EXEC_DYN,
+	.brand_note	= &elf32_freebsd_brandnote,
+	.flags		= BI_CAN_EXEC_DYN
 };
 
 SYSINIT(elf32, SI_SUB_EXEC, SI_ORDER_ANY,
@@ -101,7 +102,8 @@ static Elf32_Brandinfo freebsd_brand_oin
 	.interp_path	= "/usr/libexec/ld-elf.so.1",
 	.sysvec		= &elf32_freebsd_sysvec,
 	.interp_newpath	= NULL,
-	.flags		= BI_CAN_EXEC_DYN,
+	.brand_note	= &elf32_freebsd_brandnote,
+	.flags		= BI_CAN_EXEC_DYN
 };
 
 SYSINIT(oelf32, SI_SUB_EXEC, SI_ORDER_ANY,

Modified: stable/7/sys/sparc64/sparc64/elf_machdep.c
==============================================================================
--- stable/7/sys/sparc64/sparc64/elf_machdep.c	Sun Mar 29 07:10:52 2009	(r190519)
+++ stable/7/sys/sparc64/sparc64/elf_machdep.c	Sun Mar 29 08:07:36 2009	(r190520)
@@ -98,7 +98,8 @@ static Elf64_Brandinfo freebsd_brand_inf
 	.interp_path	= "/libexec/ld-elf.so.1",
 	.sysvec		= &elf64_freebsd_sysvec,
 	.interp_newpath	= NULL,
-	.flags		= BI_CAN_EXEC_DYN,
+	.brand_note	= &elf64_freebsd_brandnote,
+	.flags		= BI_CAN_EXEC_DYN
 };
 
 SYSINIT(elf64, SI_SUB_EXEC, SI_ORDER_ANY,
@@ -113,7 +114,8 @@ static Elf64_Brandinfo freebsd_brand_oin
 	.interp_path	= "/usr/libexec/ld-elf.so.1",
 	.sysvec		= &elf64_freebsd_sysvec,
 	.interp_newpath	= NULL,
-	.flags		= BI_CAN_EXEC_DYN,
+	.brand_note	= &elf64_freebsd_brandnote,
+	.flags		= BI_CAN_EXEC_DYN
 };
 
 SYSINIT(oelf64, SI_SUB_EXEC, SI_ORDER_ANY,

Modified: stable/7/sys/sys/imgact_elf.h
==============================================================================
--- stable/7/sys/sys/imgact_elf.h	Sun Mar 29 07:10:52 2009	(r190519)
+++ stable/7/sys/sys/imgact_elf.h	Sun Mar 29 08:07:36 2009	(r190520)
@@ -56,6 +56,13 @@ typedef struct {
 } __ElfN(Auxargs);
 
 typedef struct {
+	Elf_Note	hdr;
+	const char *	vendor;
+	int		flags;
+#define	BN_CAN_FETCH_OSREL	0x0001
+} Elf_Brandnote;
+
+typedef struct {
 	int brand;
 	int machine;
 	const char *compat_3_brand;	/* pre Binutils 2.10 method (FBSD 3) */
@@ -63,8 +70,9 @@ typedef struct {
 	const char *interp_path;
 	struct sysentvec *sysvec;
 	const char *interp_newpath;
-        int flags;
-#define		BI_CAN_EXEC_DYN	0x0001
+	Elf_Brandnote *brand_note;
+	int flags;
+#define	BI_CAN_EXEC_DYN	0x0001
 } __ElfN(Brandinfo);
 
 __ElfType(Auxargs);
@@ -82,7 +90,7 @@ int	__elfN(coredump)(struct thread *, st
 void	__elfN(dump_thread)(struct thread *, void *, size_t *);
 
 extern	int __elfN(fallback_brand);
-
+extern Elf_Brandnote __elfN(freebsd_brandnote);
 #endif /* _KERNEL */
 
 #endif /* !_SYS_IMGACT_ELF_H_ */


More information about the svn-src-all mailing list