Task: ASLR

Navigate to labs/lab-05/tasks/aslr.

Use the Makefile.aslr file to compile the labs/lab-05/tasks/aslr/support/aslr.c file:

student@os:~/.../drills/tasks/aslr/support/$ make -f Makefile.aslr

By default, ASLR and PIC are enabled. Observe the results. Next, we disable ASLR:

student@os:~/.../drills/tasks/aslr/support/$ echo 0 | sudo tee /proc/sys/kernel/randomize_va_space

Even though the code is compiled with PIC, both library and user functions have the same address between runs. Re-enable ASLR:

student@os:~/.../drills/tasks/aslr/support/$ echo 2 | sudo tee /proc/sys/kernel/randomize_va_space

Disable PIC by uncommenting the -fno-PIC and LDFLAGS lines.

We observe that for randomization to work, we need to instruct the OS to randomize the program sections and the compiler to generate code that is position independent.

If you’re having difficulties solving this exercise, go through this reading material.

Checker

To run the checker, go into the tests directory located in src, then type make check. A successful output of the checker should look like this :

student@os:~/.../drills/tasks/aslr/support/src/tests make check
test_aslr                        ........................ passed ... 100

========================================================================

Total:                                                           100/100