[PATCH] Add Prefer_MAP_32BIT_EXEC for Silvermont
H.J. Lu
hjl.tools@gmail.com
Fri Dec 11 19:46:00 GMT 2015
On Fri, Dec 11, 2015 at 10:11 AM, Zack Weinberg <zackw@panix.com> wrote:
> On Fri, Dec 11, 2015 at 12:02 PM, Adhemerval Zanella
> <adhemerval.zanella@linaro.org> wrote:
>> Another issue is this is basically limiting ALSR really hard on x86_64.
>> I also would prefer to make the default to *not* include this flag and
>> set the env. variable to actually enable it. If the cpu is slow doing
>> what's intended because it is buggy, let it be slow at default. Do not
>> break what was intended (full ALSR).
>
> FWIW, I was about to post the exact same objection. Relatedly, the
> environment variable should be handled through the normal ld.so-tuning
> environment variable mechanism (and, in particular, ineffective for
> set*id binaries).
>
We have discussed it internally. Since this is very critical for performance
on Silvermont based platforms, we want to keep it op-out for normal
programs and disable it for SUID programs. Reduced address range is no
worse than 32-bit programs.
Like this.
--
H.J.
---
/* Prefer_MAP_32BIT_EXEC reduces bits available for address space layout
randomization (ASLR). Prefer_MAP_32BIT_EXEC is disabled for SUID
programs and can also be disabled by setting environment variable,
LD_DISABLE_PREFER_MAP_32BIT_EXEC. */
static inline unsigned int
get_prefer_map_32bit_exec (void)
{
#if defined __LP64__ && IS_IN (rtld)
extern char **__environ attribute_hidden;
extern int __libc_enable_secure;
if (__builtin_expect (__libc_enable_secure, 0))
return 0;
for (char **current = __environ; *current != NULL; ++current)
{
/* Check LD_DISABLE_PREFER_MAP_32BIT_EXEC=. */
static const char *disable = "LD_DISABLE_PREFER_MAP_32BIT_EXEC=";
for (size_t i = 0; ; i++)
{
if (disable[i] != (*current)[i])
break;
if ((*current)[i] == '=')
return 0;
}
}
return bit_Prefer_MAP_32BIT_EXEC;
#else
return 0;
#endif
}
More information about the Libc-alpha
mailing list