From owner-svn-src-head@FreeBSD.ORG Tue Jun 17 05:29:19 2014 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 832239C; Tue, 17 Jun 2014 05:29:19 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 70B732531; Tue, 17 Jun 2014 05:29:19 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.8/8.14.8) with ESMTP id s5H5TJ0a058450; Tue, 17 Jun 2014 05:29:19 GMT (envelope-from dchagin@svn.freebsd.org) Received: (from dchagin@localhost) by svn.freebsd.org (8.14.8/8.14.8/Submit) id s5H5TITT058443; Tue, 17 Jun 2014 05:29:18 GMT (envelope-from dchagin@svn.freebsd.org) Message-Id: <201406170529.s5H5TITT058443@svn.freebsd.org> From: Dmitry Chagin Date: Tue, 17 Jun 2014 05:29:18 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r267563 - in head/sys: amd64/linux32 i386/linux kern sys X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.18 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: Tue, 17 Jun 2014 05:29:19 -0000 Author: dchagin Date: Tue Jun 17 05:29:18 2014 New Revision: 267563 URL: http://svnweb.freebsd.org/changeset/base/267563 Log: Revert r266925 as it can lead to instant panic at fexecve(): To allow to run the interpreter itself add a new ELF branding type. Pointed out by: kib, mjg Modified: head/sys/amd64/linux32/linux32_sysvec.c head/sys/i386/linux/linux_sysvec.c head/sys/kern/imgact_elf.c head/sys/sys/imgact_elf.h Modified: head/sys/amd64/linux32/linux32_sysvec.c ============================================================================== --- head/sys/amd64/linux32/linux32_sysvec.c Tue Jun 17 05:24:45 2014 (r267562) +++ head/sys/amd64/linux32/linux32_sysvec.c Tue Jun 17 05:29:18 2014 (r267563) @@ -1083,7 +1083,7 @@ static Elf32_Brandinfo linux_brand = { .sysvec = &elf_linux_sysvec, .interp_newpath = NULL, .brand_note = &linux32_brandnote, - .flags = BI_CAN_EXEC_DYN | BI_BRAND_NOTE | BI_CAN_EXEC_INTERP + .flags = BI_CAN_EXEC_DYN | BI_BRAND_NOTE }; static Elf32_Brandinfo linux_glibc2brand = { @@ -1095,7 +1095,7 @@ static Elf32_Brandinfo linux_glibc2brand .sysvec = &elf_linux_sysvec, .interp_newpath = NULL, .brand_note = &linux32_brandnote, - .flags = BI_CAN_EXEC_DYN | BI_BRAND_NOTE | BI_CAN_EXEC_INTERP + .flags = BI_CAN_EXEC_DYN | BI_BRAND_NOTE }; Elf32_Brandinfo *linux_brandlist[] = { Modified: head/sys/i386/linux/linux_sysvec.c ============================================================================== --- head/sys/i386/linux/linux_sysvec.c Tue Jun 17 05:24:45 2014 (r267562) +++ head/sys/i386/linux/linux_sysvec.c Tue Jun 17 05:29:18 2014 (r267563) @@ -1058,7 +1058,7 @@ static Elf32_Brandinfo linux_brand = { .sysvec = &elf_linux_sysvec, .interp_newpath = NULL, .brand_note = &linux_brandnote, - .flags = BI_CAN_EXEC_DYN | BI_BRAND_NOTE | BI_CAN_EXEC_INTERP + .flags = BI_CAN_EXEC_DYN | BI_BRAND_NOTE }; static Elf32_Brandinfo linux_glibc2brand = { @@ -1070,7 +1070,7 @@ static Elf32_Brandinfo linux_glibc2brand .sysvec = &elf_linux_sysvec, .interp_newpath = NULL, .brand_note = &linux_brandnote, - .flags = BI_CAN_EXEC_DYN | BI_BRAND_NOTE | BI_CAN_EXEC_INTERP + .flags = BI_CAN_EXEC_DYN | BI_BRAND_NOTE }; Elf32_Brandinfo *linux_brandlist[] = { Modified: head/sys/kern/imgact_elf.c ============================================================================== --- head/sys/kern/imgact_elf.c Tue Jun 17 05:24:45 2014 (r267562) +++ head/sys/kern/imgact_elf.c Tue Jun 17 05:29:18 2014 (r267563) @@ -261,8 +261,6 @@ __elfN(get_brandinfo)(struct image_param { const Elf_Ehdr *hdr = (const Elf_Ehdr *)imgp->image_header; Elf_Brandinfo *bi; - const char *fname_name, *interp_brand_name; - int fname_len, interp_len; boolean_t ret; int i; @@ -313,33 +311,6 @@ __elfN(get_brandinfo)(struct image_param } } - /* Some ABI allows to run the interpreter itself. */ - for (i = 0; i < MAX_BRANDS; i++) { - bi = elf_brand_list[i]; - if (bi == NULL || bi->flags & BI_BRAND_NOTE_MANDATORY) - continue; - if (hdr->e_machine != bi->machine || - (bi->flags & BI_CAN_EXEC_INTERP) == 0) - continue; - /* - * Compare the interpreter name not the path to allow run it - * from everywhere. - */ - interp_brand_name = strrchr(bi->interp_path, '/'); - if (interp_brand_name == NULL) - interp_brand_name = bi->interp_path; - interp_len = strlen(interp_brand_name); - fname_name = strrchr(imgp->args->fname, '/'); - if (fname_name == NULL) - fname_name = imgp->args->fname; - fname_len = strlen(fname_name); - if (fname_len < interp_len) - continue; - ret = strncmp(fname_name, interp_brand_name, interp_len); - if (ret == 0) - return (bi); - } - /* Lacking a recognized interpreter, try the default brand */ for (i = 0; i < MAX_BRANDS; i++) { bi = elf_brand_list[i]; Modified: head/sys/sys/imgact_elf.h ============================================================================== --- head/sys/sys/imgact_elf.h Tue Jun 17 05:24:45 2014 (r267562) +++ head/sys/sys/imgact_elf.h Tue Jun 17 05:29:18 2014 (r267563) @@ -77,7 +77,6 @@ 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_CAN_EXEC_INTERP 0x0008 /* Allow to run interpreter itself. */ } __ElfN(Brandinfo); __ElfType(Auxargs);