I checked if ASLR is enabled as follows and I think it is:
[user@localhost test]$ cat /proc/sys/kernel/randomize_va_space
2
I tried testing it with the following program:
test.c:
#include <stdio.h>
int main(void)
{
printf("%p\n", main);
return 1;
}
I expected, if ASLR is active, to a different address for each run, right? But I got the same each time. I tested both for 64bit and 32bit executables. I am using a 64bit Arch Linux system to test this:
[user@localhost test]$ gcc test.c -o test
[user@localhost test]$ ./test
0x4004c6
[user@localhost test]$ ./test
0x4004c6
[user@localhost test]$ ./test
0x4004c6
[user@localhost test]$ ./test
0x4004c6
[user@localhost test]$ gcc -m32 test.c -o test
[user@localhost test]$ ./test
0x80483eb
[user@localhost test]$ ./test
0x80483eb
[user@localhost test]$ ./test
0x80483eb
[user@localhost test]$ ./test
0x80483eb
As you can see, the address is the same for every run. Doesn't this mean that ASLR is off?