2.6.12-rc3 mmap lack of consistency among runs
Quoted 5 lines · Andrew Morton
Maybe you're being bitten by the address space randomisation.
Try
echo 0 >/proc/sys/kernel/randomize_va_space
Ok, it solves my issue, but:
. desabling it through 'echo 0 > /proc/sys/kernel/randomize_va_space' is not
a solution because only the application knows that it wants it to be desabled, and the application is not root so cannot write to /proc; morever the application can only speak for itself so desabling should be on a per process bias.
I can hardly imagine to publish a warning in the README such as:
This software only works if your Linux kernel is configured so that /proc/sys/kernel/randomize_va_space = 0
. second, my process restart succeeding roughly in 50% cases means that the
randomisation performed is just a toy. A virus assuming fixed memory layout will still succeed 50% of times to install.
All in all, I'm not concerned about Linux kernel to randomise or not, but I need to have a reliable way to request a memory region and be granted that I can request the same one in a futur run.
What is the proper way to get such a memory area ?
Quoted 8 lines · Hubert Tonneau
Quoted 5 lines · Andrew Morton
Maybe you're being bitten by the address space randomisation.
Try
echo 0 >/proc/sys/kernel/randomize_va_space
Quoted 7 lines
Ok, it solves my issue, but:
. desabling it through 'echo 0 >
/proc/sys/kernel/randomize_va_space' is not
a solution because only the application knows that it wants it to be desabled, and the application is not root so cannot write to /proc; morever the application can only speak for itself so desabling should be on a per process bias.
You can disable randomization on a per-executable basis by setting an ELF personality. I forget the magic incantation. Arjan?
Quoted 7 lines
I can hardly imagine to publish a warning in the README such as:
This software only works if your Linux kernel is configured so that/proc/sys/kernel/randomize_va_space= 0. second, my process restart succeeding roughly in 50% cases means that the
randomisation performed is just a toy. A virus assuming fixed memory layout will still succeed 50% of times to install.
Dunno.
Quoted 4 lines
All in all, I'm not concerned about Linux kernel to randomise or not, but I need to have a reliable way to request a memory region and be granted that I can request the same one in a futur run.
What is the proper way to get such a memory area ?
MAP_FIXED?
Quoted 5 lines · Andrew Morton
Quoted 2 lines
application can only speak for itself so desabling should be on a per process bias.
You can disable randomization on a per-executable basis by setting an ELF personality. I forget the magic incantation. Arjan?
setarch -R
Quoted 10 lines
Quoted 8 lines
I can hardly imagine to publish a warning in the README such as:
This software only works if your Linux kernel is configured so that/proc/sys/kernel/randomize_va_space= 0. second, my process restart succeeding roughly in 50% cases means that the
randomisation performed is just a toy. A virus assuming fixed memory layout will still succeed 50% of times to install.Dunno.
It just means that half the time the old value was below the current boundary, and half the time above. Eg half the time it was in free space and you succeeded but left a gap, the other half there was a conflict. Says nothing about the value of randomisation...
Quoted 7 lines
Quoted 5 lines
All in all, I'm not concerned about Linux kernel to randomise or not, but I need to have a reliable way to request a memory region and be granted that I can request the same one in a futur run.
What is the proper way to get such a memory area ?
MAP_FIXED?
MAP_FIXED is generally a really bad idea though.
Quoted 7 lines · Hubert Tonneau
Quoted 5 lines · Andrew Morton
Maybe you're being bitten by the address space randomisation.
Try
echo 0 >/proc/sys/kernel/randomize_va_space
Quoted 7 lines
Ok, it solves my issue, but:
. desabling it through 'echo 0 >
/proc/sys/kernel/randomize_va_space' is not
a solution because only the application knows that it wants it to be desabled, and the application is not root so cannot write to /proc; morever the application can only speak for itself so desabling should be on a per process bias.
there is the setarch command that you can use to disable it on a per process basis.
Quoted 3 lines
. second, my process restart succeeding roughly in 50% cases means that the
randomisation performed is just a toy. A virus assuming fixed memory layout will still succeed 50% of times to install.
actually no.
It just means that half the time the old value was below the current boundary, and half the time above. Eg half the time it was in free space.
Quoted 3 lines
All in all, I'm not concerned about Linux kernel to randomise or not, but I need to have a reliable way to request a memory region and be granted that I can request the same one in a futur run.
glibc also has some randomisations in places (for cache performance) as did kernels before 2.6.11 on p4 hyperthreading machines (granted that was very small randomisation)
The only reliable ways I can think of is to either take a predetermined address, or to mmap a big chunk first, then your real chunk and then free the first chunk. Neither are clean or pretty