views:

1021

answers:

3

I'm working on a runtime system for parallel programs that can take advantage of a common address space layout across multiple processes, potentially spread over several (thousand) nodes. Many times, software built for this environment is run on Linux systems that have address space randomization enabled by default, and users may not want or be able to disable it system-wide (via sysctl -w kernel.randomize_va_space=0 and the like). This imposes some limitations on the parallel programs, and can hurt performance. Thus, we want to figure out how to disable it for the binaries that we build. Security is not an issue, as this software is always running in controlled environments.

I've found references to various flags and variables, like ET_EXEC, EF_AS_NO_RANDOM (apparently never merged?) and PF_RANDOMIZE, but I can't find any document that describes what I can do to set these flags. An ideal answer would tell me what compiler/assembler/linker flag will disable randomization for the resulting binary, and what versions of the tool-chain/kernel this works on. Next best would be a tool that does the same after a binary is built.

Since I'm sure someone will suggest it, I'm already aware that we can make this change at runtime with setarch -R, but it's preferable to record this in the executable.

It looks like paxctl -rx ought to do the trick, but it doesn't seem to apply to the current method used in kernels that don't include the PaX patches.

A: 

Is there some reason you can't map a shared memory space or use a named FIFO?

greyfade
There is. We're running across multiple nodes.
Novelocrat
A: 

At least some earlier versions of ASLR in the Linux kernel preserved offsets when forking. Rather than disabling randomization for your processes, might you simply be able to arrange them under a parent/child process hierarchy that kept the offsets the same between instances of the binary forked by the same parent?

rcoder
No, we can't, because these processes are running across multiple nodes. Thread migration is much easier when we don't have to jump through hoops to manually synchronize the address space.
Novelocrat
+1  A: 

Presumably you have some kind of daemon which invokes your parallel programs on the nodes. If so, you can make this common parent disable ASLR for any child processes it creates.

Look in GDB sources (7.0 or CVS Head) for how to do that. The gist of it is to call personality(orig_personality|ADDR_NO_RANDOMIZE) after fork and before exec.

Employed Russian
I'll investigate and try this now.
Novelocrat
Seems to have worked. Thanks!
Novelocrat