Date: Fri, 23 Mar 2018 19:30:00 +0000 (UTC) From: John Baldwin <jhb@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r331458 - stable/11/sys/kern Message-ID: <201803231930.w2NJU0QR091939@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: jhb Date: Fri Mar 23 19:30:00 2018 New Revision: 331458 URL: https://svnweb.freebsd.org/changeset/base/331458 Log: MFC 328909: Always give ELF brands a chance to veto a match. If a brand provides a header_supported hook, check it when trying to find a brand based on a matching interpreter as well as in the final loop for the fallback brand. Previously a brand might reject a binary via a header_supported hook in one of the earlier loops, but still be chosen by one of these later loops. Sponsored by: DARPA / AFRL Modified: stable/11/sys/kern/imgact_elf.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/kern/imgact_elf.c ============================================================================== --- stable/11/sys/kern/imgact_elf.c Fri Mar 23 18:41:28 2018 (r331457) +++ stable/11/sys/kern/imgact_elf.c Fri Mar 23 19:30:00 2018 (r331458) @@ -320,7 +320,7 @@ __elfN(get_brandinfo)(struct image_params *imgp, const strcmp((const char *)&hdr->e_ident[OLD_EI_BRAND], bi->compat_3_brand) == 0))) { /* Looks good, but give brand a chance to veto */ - if (!bi->header_supported || + if (bi->header_supported == NULL || bi->header_supported(imgp)) { /* * Again, prefer strictly matching @@ -368,7 +368,8 @@ __elfN(get_brandinfo)(struct image_params *imgp, const /* ELF image p_filesz includes terminating zero */ strlen(bi->interp_path) + 1 == interp_name_len && strncmp(interp, bi->interp_path, interp_name_len) - == 0) + == 0 && (bi->header_supported == NULL || + bi->header_supported(imgp))) return (bi); } } @@ -380,7 +381,9 @@ __elfN(get_brandinfo)(struct image_params *imgp, const (interp != NULL && (bi->flags & BI_BRAND_ONLY_STATIC) != 0)) continue; if (hdr->e_machine == bi->machine && - __elfN(fallback_brand) == bi->brand) + __elfN(fallback_brand) == bi->brand && + (bi->header_supported == NULL || + bi->header_supported(imgp))) return (bi); } return (NULL);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201803231930.w2NJU0QR091939>