Buffer Overflow Prevention
To prevent buffer overflow attacks, you are advised to use the address space layout randomization (ASLR) technology to randomize the layout of linear areas such as the heap, stack, and shared library mapping to make it more difficult for attackers to predict target addresses and locate code. This technology can be applied to heaps, stacks, and memory mapping areas (mmap base addresses, shared libraries, and vDSO pages).
How to enable ASLR:
echo 2 >/proc/sys/kernel/randomize_va_space
Parent topic: Security Hardening