Live data from Hacker News

Fun with Gentoo: Why don't we just shuffle those ROP gadgets away?

quitesimple.org

31–40 of 84 posts

Re: Fun with Gentoo: Why don't we just shuffle those ROP gadgets away?

#31
post #19
post #17

Don't try this with C++, unless you're certain that there are no interdependencies or side-effects in global variable initialisation. The link order (usually) affects the order in which initialisers are executed.

On the contrary: do do this and if you observe your program crashing due to linking order, fix the damn bug.

Developer PoV vs User/Distro PoV here :P you're not wrong, though...

Re: Fun with Gentoo: Why don't we just shuffle those ROP gadgets away?

#32
post #16

Earlier quoted context omitted.

You can bootstrap the compiler. It's a chore but not impossible. More usefully, you can check that your builds are identical to other people's, so at least your compiler isn't uniquely compromised.

> You can bootstrap the compiler. It's a chore but not impossible. And specifically, only one person needs to do this once... I'm surprised there isn't some project doing this...

There is: https://savannah.nongnu.org/projects/stage0/

Re: Fun with Gentoo: Why don't we just shuffle those ROP gadgets away?

#33
post #16

Earlier quoted context omitted.

You can bootstrap the compiler. It's a chore but not impossible. More usefully, you can check that your builds are identical to other people's, so at least your compiler isn't uniquely compromised.

I don’t think it’s possible since you’d need the original compilers from the 70’s and bootstrap other compilers up to a modern one. Otherwise your existing compiler could taint your new one.

Many years ago I wrote a C compiler in assembly language. It wasn't hard, and C hasn't changed that much. The complexity in modern compilers is in the optimisation, which you don't need if you're bootstrapping. It's not impossible.

Re: Fun with Gentoo: Why don't we just shuffle those ROP gadgets away?

#35
post #23
post #15

Earlier quoted context omitted.

It's pretty much what OpenBSD is doing at bootup. Truthfully though you're right, using typical linkers, this would be pretty slow; at least a few seconds for large binaries, to minutes for things as large as web browsers. However, for many binaries, linking can be done much faster; mold claims to be only 50% the runtime of using `cp` on the object files, which is fast enough to even re-link Firefox on-the-fly withou…

I thought openbsd did it after boot?

OpenBSD relinks sshd. Which is relatively small thing that is linked from relatively large objects (ie. it is the typical modern C code). Relinking thing like glibc on demand is going to be problematic, because it is structured as to allow small binary sizes for static linking and thus almost every function that is part of glibc API is a separate compilation unit and object file. Linking that into .so is slow, no mater what kind of optimalization tricks you implement in the linker.

Re: Fun with Gentoo: Why don't we just shuffle those ROP gadgets away?

#37

Earlier quoted context omitted.

For binary distributions, how about shipping object files and linking them on install with mold? This should be faster than compiling from source, just marginally slower than installing pre-linked binaries, and each build will be as unique as it gets.

The size of the distributed binary gets very large because you're shipping a lot of code that ends up getting eliminated by the linker. Also if you want to do any kind of LTO, then I don't see how you do it in your model. (which is significant for the larger applications like Chrome that have the likely attack surface). Not every binary on the system actually needs this either. Finally, the main problem with this ide…

Randomizing the link order per release does not solve anything, for this to really work as an mitigation layer, you need to have few different randomly linked versions and randomly give these to the end users. Just randomizing the build does not solve anything as there still is exactly one layout that everyone uses.

On another note: automating this on gentoo is cool exercise, but almost certainly if you just build everything locally, the memory layout will be random enough that writing shellcode blindly presents an interesting challenge. (different compiler flags, various probabilistic optimization passes… all that leads to the functions in same object file having different sizes)

Re: Fun with Gentoo: Why don't we just shuffle those ROP gadgets away?

#38

I remember my Gentoo days freshman year in college. I spent more time compiling updates than actually using the computer.

Same thing for me. 2003 it was .. and gentoo was a well good entry vehicle into linux

We're the same age! I remember printing off a ~20 page runbook of instructions to manually build and configure grub and gentoo. Took hours to set up.

Re: Fun with Gentoo: Why don't we just shuffle those ROP gadgets away?

#39

I remember my Gentoo days freshman year in college. I spent more time compiling updates than actually using the computer.

I used to keep using the boxes whilst steam billowed out the sides until things started crashing.

I recall gcc3 -> 4. The prevailing "wisdom" was emerge --deep (etc) world ... twice! My laptop was left for around a week trundling through 1500 odd packages. I think I did system first, twice too. I left it running on a glass table in an unheated study, propped up to allow some better airflow.

One of the great things about Gentoo is that a completely fragged system doesn't faze you anymore. Screwed glibc? Never mind. Broken python? lol! Scrambled portage? Hold my beer.

I have a VM running in the attic that got a bit behind. OK it was around eight? years out of date. I ended up putting in a new portage tree under git and reverting it into the past and then winding it forwards after getting the thing up to date at that point in time. It took quite a while. I could have started again but it was fun to do as an exercise.

Re: Fun with Gentoo: Why don't we just shuffle those ROP gadgets away?

#40
post #16

Earlier quoted context omitted.

You can bootstrap the compiler. It's a chore but not impossible. More usefully, you can check that your builds are identical to other people's, so at least your compiler isn't uniquely compromised.

I don’t think it’s possible since you’d need the original compilers from the 70’s and bootstrap other compilers up to a modern one. Otherwise your existing compiler could taint your new one.

It'd be a fun exercise to write a tiny Forth in machine code (sans assembler) and use it to write enough of a C compiler to build tcc, or something along those lines. From there I think you can chain old (but accessible) gcc versions up to modern gcc.
Post reply on HN