mirror of
https://github.com/genodelabs/genode.git
synced 2025-03-28 06:39:14 +00:00
base-linux: disable ASLR for child processes
ASLR collides with the libc's fork mechanism on 32-bit. In particular, the tool_chain_auto.run scenario would sporadically fail while mirroring the parent's address space. Fixes #3710
This commit is contained in:
parent
7a5841b637
commit
d8bcaa4fa4
@ -101,11 +101,13 @@ inline int lx_ioctl_iomem(int fd, unsigned long phys, Genode::size_t offset)
|
|||||||
return lx_syscall(SYS_ioctl, fd, _IOW('g', 1, void *), &range);
|
return lx_syscall(SYS_ioctl, fd, _IOW('g', 1, void *), &range);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline int lx_ioctl_irq(int fd, int irq)
|
inline int lx_ioctl_irq(int fd, int irq)
|
||||||
{
|
{
|
||||||
return lx_syscall(SYS_ioctl, fd, _IOW('g', 2, int*), &irq);
|
return lx_syscall(SYS_ioctl, fd, _IOW('g', 2, int*), &irq);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**************************************
|
/**************************************
|
||||||
** Process creation and destruction **
|
** Process creation and destruction **
|
||||||
**************************************/
|
**************************************/
|
||||||
@ -161,6 +163,23 @@ inline int lx_pollpid()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Disable address-space layout randomization for child processes
|
||||||
|
*
|
||||||
|
* The virtual address space layout is managed by Genode, not the kernel.
|
||||||
|
* Otherwise, the libc's fork mechanism could not work on Linux.
|
||||||
|
*/
|
||||||
|
inline void lx_disable_aslr()
|
||||||
|
{
|
||||||
|
/* defined in linux/personality.h */
|
||||||
|
enum { ADDR_NO_RANDOMIZE = 0x0040000UL };
|
||||||
|
|
||||||
|
unsigned long const orig_flags = lx_syscall(SYS_personality, 0xffffffff);
|
||||||
|
|
||||||
|
(void)lx_syscall(SYS_personality, orig_flags | ADDR_NO_RANDOMIZE);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/********************************************
|
/********************************************
|
||||||
** Communication over Unix-domain sockets **
|
** Communication over Unix-domain sockets **
|
||||||
********************************************/
|
********************************************/
|
||||||
|
@ -91,6 +91,9 @@ static void sigchld_handler(int)
|
|||||||
Platform::Platform()
|
Platform::Platform()
|
||||||
: _core_mem_alloc(nullptr)
|
: _core_mem_alloc(nullptr)
|
||||||
{
|
{
|
||||||
|
/* make 'mmap' behave deterministically */
|
||||||
|
lx_disable_aslr();
|
||||||
|
|
||||||
/* catch control-c */
|
/* catch control-c */
|
||||||
lx_sigaction(LX_SIGINT, sigint_handler, false);
|
lx_sigaction(LX_SIGINT, sigint_handler, false);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user