Commit ecd53057 authored by Ken Thomases's avatar Ken Thomases Committed by Alexandre Julliard

libwine: On Mac, disable ASLR for Wine processes.

ASLR can allow dyld to be loaded where it overlaps one of the regions that the preloader would like to reserve. That, in turn, can prevent Wine from using the shared user data region. With ASLR disabled, dyld will be loaded immediately after the preloader, which has a defined base address. This uses an Apple extension to posix_spawn() that allows it to replace the calling process's image, like a more featureful execve(). The flag to disable ASLR is technically private SPI, but has remained stable for many versions of the OS. And the Mac preloader is already stepping over that line. Signed-off-by: 's avatarKen Thomases <ken@codeweavers.com> Signed-off-by: 's avatarAlexandre Julliard <julliard@winehq.org>
parent 6428c456
......@@ -33,6 +33,13 @@
#ifdef HAVE_PWD_H
#include <pwd.h>
#endif
#ifdef __APPLE__
#include <crt_externs.h>
#include <spawn.h>
#ifndef _POSIX_SPAWN_DISABLE_ASLR
#define _POSIX_SPAWN_DISABLE_ASLR 0x0100
#endif
#endif
#include "wine/library.h"
static const char server_config_dir[] = "/.wine"; /* config dir relative to $HOME */
......@@ -558,6 +565,15 @@ static void preloader_exec( char **argv, int use_preloader )
new_argv = xmalloc( (last_arg - argv + 2) * sizeof(*argv) );
memcpy( new_argv + 1, argv, (last_arg - argv + 1) * sizeof(*argv) );
new_argv[0] = full_name;
#ifdef __APPLE__
{
posix_spawnattr_t attr;
posix_spawnattr_init( &attr );
posix_spawnattr_setflags( &attr, POSIX_SPAWN_SETEXEC | _POSIX_SPAWN_DISABLE_ASLR );
posix_spawn( NULL, full_name, NULL, &attr, new_argv, *_NSGetEnviron() );
posix_spawnattr_destroy( &attr );
}
#endif
execv( full_name, new_argv );
free( new_argv );
free( full_name );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment