Create a generalized exec hook that different architectures can hook

into if they need to, but default to no action.

Differential Review: https://reviews.freebsd.org/D2718
This commit is contained in:
Warner Losh 2016-01-03 04:32:02 +00:00
parent 9df1d85ebb
commit 8fd53f4577
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=293066
11 changed files with 63 additions and 3 deletions

View File

@ -80,4 +80,6 @@ extern void *__tls_get_addr(tls_index *ti);
#define RTLD_DEFAULT_STACK_PF_EXEC PF_X
#define RTLD_DEFAULT_STACK_EXEC PROT_EXEC
#define md_abi_variant_hook(x)
#endif

View File

@ -79,4 +79,6 @@ void *__tls_get_addr(tls_index *ti) __exported;
#define RTLD_DEFAULT_STACK_PF_EXEC PF_X
#define RTLD_DEFAULT_STACK_EXEC PROT_EXEC
#define md_abi_variant_hook(x)
#endif

View File

@ -17,6 +17,41 @@ __FBSDID("$FreeBSD$");
#include "rtld.h"
#include "paths.h"
void
arm_abi_variant_hook(Elf_Auxinfo **aux_info)
{
Elf_Word ehdr;
/*
* If we're running an old kernel that doesn't provide any data fail
* safe by doing nothing.
*/
if (aux_info[AT_EHDRFLAGS] == NULL)
return;
ehdr = aux_info[AT_EHDRFLAGS]->a_un.a_val;
/*
* Hard float ABI binaries are the default, and use the default paths
* and such.
*/
if ((ehdr & EF_ARM_VFP_FLOAT) != 0)
return;
/*
* This is a soft float ABI binary. We need to use the soft float
* settings. For the moment, the standard library path includes the hard
* float paths as well. When upgrading, we need to execute the wrong
* kind of binary until we've installed the new binaries. We could go
* off whether or not /libsoft exists, but the simplicity of having it
* in the path wins.
*/
ld_elf_hints_default = _PATH_SOFT_ELF_HINTS;
ld_path_libmap_conf = _PATH_SOFT_LIBMAP_CONF;
ld_path_rtld = _PATH_SOFT_RTLD;
ld_standard_library_path = SOFT_STANDARD_LIBRARY_PATH;
ld_env_prefix = LD_SOFT_;
}
void
init_pltgot(Obj_Entry *obj)
{

View File

@ -75,4 +75,9 @@ extern void *__tls_get_addr(tls_index *ti);
#define RTLD_DEFAULT_STACK_PF_EXEC PF_X
#define RTLD_DEFAULT_STACK_EXEC PROT_EXEC
extern void arm_abi_variant_hook(Elf_Auxinfo **);
#define md_abi_variant_hook(x) arm_abi_variant_hook(x)
#define RTLD_VARIANT_ENV_NAMES
#endif

View File

@ -80,4 +80,6 @@ void *__tls_get_addr(tls_index *ti) __exported;
#define RTLD_DEFAULT_STACK_PF_EXEC PF_X
#define RTLD_DEFAULT_STACK_EXEC PROT_EXEC
#define md_abi_variant_hook(x)
#endif

View File

@ -75,4 +75,6 @@ extern void *__tls_get_addr(tls_index *ti);
#define RTLD_DEFAULT_STACK_PF_EXEC PF_X
#define RTLD_DEFAULT_STACK_EXEC PROT_EXEC
#define md_abi_variant_hook(x)
#endif

View File

@ -1,8 +1,6 @@
/*-
* Copyright 1996, 1997, 1998, 1999, 2000 John D. Polstra.
* Copyright 2003 Alexander Kabaev <kan@FreeBSD.ORG>.
* Copyright 2009-2012 Konstantin Belousov <kib@FreeBSD.ORG>.
* Copyright 2012 John Marino <draco@marino.st>.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@ -61,7 +59,13 @@
#define LD_ "LD_"
#endif
extern char *ld_path_elf_hints;
#define _PATH_SOFT_ELF_HINTS "/var/run/ld-elf-soft.so.hints"
#define _PATH_SOFT_LIBMAP_CONF "/etc/libmap-soft.conf"
#define _PATH_SOFT_RTLD "/libexec/ld-elf.so.1"
#define SOFT_STANDARD_LIBRARY_PATH "/libsoft:/usr/libsoft:/lib:/usr/lib"
#define LD_SOFT_ "LD_SOFT_"
extern char *ld_elf_hints_default;
extern char *ld_path_libmap_conf;
extern char *ld_path_rtld;
extern char *ld_standard_library_path;

View File

@ -90,4 +90,6 @@ extern void *__tls_get_addr(tls_index* ti);
#define RTLD_DEFAULT_STACK_PF_EXEC PF_X
#define RTLD_DEFAULT_STACK_EXEC PROT_EXEC
#define md_abi_variant_hook(x)
#endif

View File

@ -82,4 +82,6 @@ extern void *__tls_get_addr(tls_index* ti);
#define RTLD_DEFAULT_STACK_PF_EXEC PF_X
#define RTLD_DEFAULT_STACK_EXEC PROT_EXEC
#define md_abi_variant_hook(x)
#endif

View File

@ -419,6 +419,8 @@ _rtld(Elf_Addr *sp, func_ptr_type *exit_proc, Obj_Entry **objp)
trust = !issetugid();
md_abi_variant_hook(aux_info);
ld_bind_now = getenv(_LD("BIND_NOW"));
/*
* If the process is tainted, then we un-set the dangerous environment

View File

@ -71,4 +71,6 @@ extern void *__tls_get_addr(tls_index *ti);
#define RTLD_DEFAULT_STACK_PF_EXEC 0
#define RTLD_DEFAULT_STACK_EXEC 0
#define md_abi_variant_hook(x)
#endif