void __libc_init_AT_SECURE(KernelArgumentBlock& args) {
  __libc_auxv = args.auxv;

  // Check that the kernel provided a value for AT_SECURE.
  bool found_AT_SECURE = false;
  for (ElfW(auxv_t)* v = __libc_auxv; v->a_type != AT_NULL; ++v) {
    if (v->a_type == AT_SECURE) {
      found_AT_SECURE = true;
      break;
    }
  }
  if (!found_AT_SECURE) __early_abort(__LINE__);

  if (getauxval(AT_SECURE)) {
    // If this is a setuid/setgid program, close the security hole described in
    // https://www.freebsd.org/security/advisories/FreeBSD-SA-02:23.stdio.asc
    __nullify_closed_stdio();

    __sanitize_environment_variables(args.envp);
  }

  // Now the environment has been sanitized, make it available.
  environ = args.envp;

  __initialize_personality();
}
void linker_env_init(KernelArgumentBlock& args) {
  // Store environment pointer - can't be NULL.
  _envp = args.envp;

  __init_AT_SECURE(args);
  __sanitize_environment_variables();
}
Exemple #3
0
void linker_env_init(KernelArgumentBlock& args) {
  // Store environment pointer - can't be NULL.
  _envp = args.envp;
  // ARC MOD BEGIN
  // Neither NaCl nor Bare Metal provides AT_SECURE.
#if !defined(HAVE_ARC)
  __init_AT_SECURE(args);
  __sanitize_environment_variables();
#endif
  // ARC MOD END
}