Hacker News new | ask | show | jobs
by viraptor 1246 days ago
It's there a good link for the details? I'm guessing this does more than ASLR?
2 comments

Plain, simple and effective as always! The highly complex 'black magic' is 'sort --random' and (re-)link it all again. :)

Makefile.relink: cc -o sshd `echo ${OBJS} | tr ' ' '\n' | sort -R` ${LDADD} ./sshd -V && install -o root -g wheel -m ${BINMODE} sshd /usr/sbin/sshd

https://github.com/openbsd/src/commit/898412097f87ba70d4012f...

Ah, so that will have some features of ASLR missing. Specifically, you can't do this on a read only root and it didn't randomise the stack location as far as I can tell?
For this new feature you pay indeed with the need for r/w and executable tmpfs/overlay somewhere.

This does not replace classic ASLR: OpenBSD 5.7 activated position-independent static binaries (Static-PIE) by default.

https://en.wikipedia.org/wiki/Address_space_layout_randomiza...

Wouldn't the stack location be set at runtime and given by the stack register at the entry point?
I think I've got a better idea now. So openbsd has ASLR which affects data, code/library, and stack positions. Then this solution works on top of it by reordering symbols within the code.

One thing I'm still not sure about is whether the kernel could theoretically do the same reordering at load time using relocatable symbols.

The assembler laid out the code within the sections and generally it's not changed after that (except for targets that do linker relaxation). However with -ffunction-sections the compiler would put each function in its own section which then can be independently relocated.
If each function is in its own section, then all function calls would need to be indirected through the PLT/GOT, even function calls within the same translation unit? Ouch.
Sounds like Amiga HUNK format with the HUNK_OVERLAY hunk. For instance various functions could be loaded anywhere in memory.
The kernel needs a bit more information than that, since chunks of code can refer to each other and if you rearrange them this would break these since they're typically emitted as relative offsets.
It's complimentary to ASLR.