Live data from Hacker News

32-bit x86 Position Independent Code – It's That Bad

ewontfix.com

51–60 of 104 posts

Re: 32-bit x86 Position Independent Code – It's That Bad

#51
post #2

The more I play around with musl (the author's C library) the more I'm convinced dynamic linking was not worth the trouble.

Can you give more details? Isn't this particular issue pretty much x86 specific anyway? I think it's not a problem anymore on x86_64.

Re: 32-bit x86 Position Independent Code – It's That Bad

#52
post #50
post #5

Earlier quoted context omitted.

As a programmer who unfortunately is suckered into doing devops at times, the more I get to just update the openssl library instead of the whole OS whenever a security flaw in openssl is announced, the more I'm convinced that dynamic linking was very well worth the trouble. Funny how perceptions change depending on the angle you're looking at a problem.

There are no problems with updates anymore. You don't have to download everything to update a bunch of static binaries. There are things, like bsdiff, that allow you to download and patch only tiny differences related to a security flaw. There is no need for dynamic linking for updates. Really.

What if you have binaries compiled from proprietary code bases from umpteen vendors using different compilers and compiler options and what-not, and they all use the Internet for self-updating and stuff and they all need to be patched? How are you going to do that?

Also - weakly related - what if you want to use a plugin from vendor A inside the program of vendor B, and they live in the same address space - how are you doing it without dynamic loading?

Re: 32-bit x86 Position Independent Code – It's That Bad

#53
post #21

Earlier quoted context omitted.

IMHO, static linking, be it using a mechanism alike what npm is doing or be it plain-old static linking of binaries also means "you link it, you own it". For every package, you link statically, you as the parent package owner become responsible for all security flaws of all the packages you link statically. And by "responsible" I mean: Every dependent security announcement of a dependent package also becomes your sec…

For every package, you link statically, you as the parent package owner become responsible for all security flaws of all the packages you link statically Well, speaking as an administrator rather than a developer: a developer shouldn't be making that kind of policy decision (time of symbol resolution) to begin with barring a strong technical need (plug-in based architecture, etc.). I mean, 90% of packages don't care…

The embedded glib inside pkg-config solves the chicken-egg problem: pkg-config requires glib and glib requires pkg-config. This way, you can build pkg-config first with its embedded glib, then glib itself and then go solve your own problems, instead of butchering the build system to make them build at all.

Re: 32-bit x86 Position Independent Code – It's That Bad

#54
post #52
post #50

Earlier quoted context omitted.

There are no problems with updates anymore. You don't have to download everything to update a bunch of static binaries. There are things, like bsdiff, that allow you to download and patch only tiny differences related to a security flaw. There is no need for dynamic linking for updates. Really.

What if you have binaries compiled from proprietary code bases from umpteen vendors using different compilers and compiler options and what-not, and they all use the Internet for self-updating and stuff and they all need to be patched? How are you going to do that? Also - weakly related - what if you want to use a plugin from vendor A inside the program of vendor B, and they live in the same address space - how are y…

I don't see a problem with proprietary code bases.

Re: 32-bit x86 Position Independent Code – It's That Bad

#55
post #52
post #50

Earlier quoted context omitted.

There are no problems with updates anymore. You don't have to download everything to update a bunch of static binaries. There are things, like bsdiff, that allow you to download and patch only tiny differences related to a security flaw. There is no need for dynamic linking for updates. Really.

What if you have binaries compiled from proprietary code bases from umpteen vendors using different compilers and compiler options and what-not, and they all use the Internet for self-updating and stuff and they all need to be patched? How are you going to do that? Also - weakly related - what if you want to use a plugin from vendor A inside the program of vendor B, and they live in the same address space - how are y…

> What if you have binaries compiled from proprietary code bases…

Then don't do that. Seriously, RMS, ESR and others have written a plethora of well-reasoned essays indicating why proprietary software is a poor choice.

Re: 32-bit x86 Position Independent Code – It's That Bad

#56
post #29

Earlier quoted context omitted.

I believe that what you describe is the remaining argument in favor of dynamic linking. That said, I'd like to point out that it is convenient for the developer - since customers are ultimately interested to know if your software is vulnerable, and you'll have to explain how the vulnerability affects it -. It's also a double edged sword: openssl has a good ascending compatibility record, but that can't be said about…

Dynamic linking is required for anything resembling a plugin architecture (such as PAM).

Not really—one could use processes and some form of IPC (shared memory, pipes, whatever). The efficiency could be pretty bad, but the safety and reliability could be better.

Re: 32-bit x86 Position Independent Code – It's That Bad

#57
post #13

There was a time when shared libraries were a necessity. Not to mention supporting myriad architectures. That was a different era. Conditions have changed. Of course, the designs and implementations have not. They are still in heavy use, 20 years later. What "just works" is never questioned. I am glad to see some people questioning the old assumptions. Unrelated question: Why does Linux pass arguments in registers in…

What makes you say conditions have changed? Why should I have to wait for everything that consumes OpenSSL downstream to be updated/recompiled to fully patch my system?

Playing Devil's advocate, why do you need to wait for others to recompile the software?

Re: 32-bit x86 Position Independent Code – It's That Bad

#58
post #18

Earlier quoted context omitted.

registers are much faster than stack, assuming you immediately make use of them; to use them from the stack you have to load them into registers anyway in most cases

In theory passing args in registers is faster because you avoid one copy in simple/small routines (the ones that perform a very simple op on the reg arguments and return). In practice there are way more complex routines than simple routines and the arg from register is copied back on the stack in the local variables area of the routine because it needs that register to perform some op or simply because it needs that…

Except in leaf functions, where the win materializes. Leaf functions are a healthy fraction of calls, counting dynamically, so passing args in registers is a good idea.

It's true that the benefit isn't enormous.

Re: 32-bit x86 Position Independent Code – It's That Bad

#59
post #39
post #2

The more I play around with musl (the author's C library) the more I'm convinced dynamic linking was not worth the trouble.

There is however, an important security benefit from PIC: ASLR. It's not a silver bullet, but can stop a range of vulnerabilities from being reliably exploitable usable unless an memory leak is also available. Even if you so far as control the instruction pointer as an attacker, you might just not know where to jump to in the target address space...

OpenBSD now has ASLR for static executables. There was some discussion of it on #musl so it might happen.

Re: 32-bit x86 Position Independent Code – It's That Bad

#60
post #3

I always wondered why Linux can't just use the same thing as windows for DLLs: Instead of PIC, a big tables of places to patch with the final position. It looks really terrible to lose one precious register and have all this PIC overhead. I don't use mono's ahead of time compilation because it also creates PIC. The JIT has one register more available. But I haven't measured it yet

> Instead of PIC, a big tables of places to patch with the final position. Among other things, because that means the text section has to be writeable, and can't have a shared mapping across processes unless it's mapped in the same place in every process, which breaks address-space layout randomization (ASLR).

Off topic, but does anybody know if there's a way to turn off ASLR e.g. while debugging (honestly, i'd be interested if you can do this on any platform)? I'm pretty confident the answer is no, but it can really be a pain sometimes...
Post reply on HN