Urm, all of the questions so far have been wrong with Rook's answer being correct.
Disabling ASLR by:
sudo echo 0 > /proc/sys/kernel/randomize_va_space
Followed by
gcc -fno-stack-protector -z execstack -o bug bug.c
Which disables ASLR (which can be brute-forced against), SSP/Propolice and Ubuntu's NoneXec (which was placed in 9.10, and fairly simple to work around see the mprotect(2) technique to map pages as executable and jmp) should help a little, however these "security features" are by no means infallible. Without the `-z execstack' flag, pages have non-executable stack markings.