From owner-svn-src-head@FreeBSD.ORG Sun Mar 11 19:38:50 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id B268D106566C; Sun, 11 Mar 2012 19:38:50 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 841158FC0C; Sun, 11 Mar 2012 19:38:50 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q2BJcoje023915; Sun, 11 Mar 2012 19:38:50 GMT (envelope-from kib@svn.freebsd.org) Received: (from kib@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q2BJcouo023913; Sun, 11 Mar 2012 19:38:50 GMT (envelope-from kib@svn.freebsd.org) Message-Id: <201203111938.q2BJcouo023913@svn.freebsd.org> From: Konstantin Belousov Date: Sun, 11 Mar 2012 19:38:50 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r232828 - head/sys/kern X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 11 Mar 2012 19:38:50 -0000 Author: kib Date: Sun Mar 11 19:38:49 2012 New Revision: 232828 URL: http://svn.freebsd.org/changeset/base/232828 Log: ELF image can have several PT_NOTE program headers. Look for the ELF brand note in each header, instead of using only first one. Reviewed by: kan Tested by: andrew (arm), flo (sparc64) MFC after: 3 weeks Modified: head/sys/kern/imgact_elf.c Modified: head/sys/kern/imgact_elf.c ============================================================================== --- head/sys/kern/imgact_elf.c Sun Mar 11 19:23:42 2012 (r232827) +++ head/sys/kern/imgact_elf.c Sun Mar 11 19:38:49 2012 (r232828) @@ -1549,32 +1549,14 @@ __elfN(putnote)(void *dst, size_t *off, *off += roundup2(note.n_descsz, sizeof(Elf_Size)); } -/* - * 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) +__elfN(parse_notes)(struct image_params *imgp, Elf_Brandnote *checknote, + int32_t *osrel, const Elf_Phdr *pnote) { 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); @@ -1613,6 +1595,31 @@ nextnote: } /* + * 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_Phdr *phdr; + const Elf_Ehdr *hdr; + int i; + + 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 && + __elfN(parse_notes)(imgp, checknote, osrel, &phdr[i])) + return (TRUE); + } + return (FALSE); + +} + +/* * Tell kern_execve.c about it, with a little help from the linker. */ static struct execsw __elfN(execsw) = {