augeaufdiewelt
augeaufdiewelt

Reputation: 33

why and how do the addresses returned by 'cat /proc/self/maps' change when it's executed again

I'm trying to understand linux memory management.

Why and how do the addresses returned by 'cat /proc/self/maps' change when it's executed again

user@notebook:/$ cat /proc/self/maps | grep heap

55dc94a7c000-55dc94a9d000 rw-p 00000000 00:00 0 [heap]

user@notebook:/$ cat /proc/self/maps | grep heap

562609879000-56260989a000 rw-p 00000000 00:00 0 [heap]

Upvotes: 1

Views: 579

Answers (1)

that other guy
that other guy

Reputation: 123510

This is due to Address Space Layout Randomization, aka ASLR. Linux will load code and libraries at different locations each time to make it harder to exploit buffer overflows and similar.

You can disable it with

echo 0 > /proc/sys/kernel/randomize_va_space

which will make the addresses the same each time. You can then re-enable it with:

echo 2 > /proc/sys/kernel/randomize_va_space

and the addresses will be randomized again.

Upvotes: 1

Related Questions