Soller: Real hardware breakthroughs, and focusing on rustc
Soller: Real hardware breakthroughs, and focusing on rustc
Posted Dec 3, 2019 12:00 UTC (Tue) by anton (subscriber, #25547)In reply to: Soller: Real hardware breakthroughs, and focusing on rustc by Wol
Parent article: Soller: Real hardware breakthroughs, and focusing on rustc
And saving space by not pulling in all of a megabyte library because they just want to use one routine?Do you mean pulling into the executable file, or pulling into RAM? In either case, what you imply does not happen:
- A shared library is not pulled into the executable file of the program at all.
- If only one routine is used, only the pages that contain the executed code of that routine is demand-paged into RAM.
Your comment about "load the library a couple of times to resolve all the references" is so wrong that I wonder if I misunderstand what you mean.
Finally, if one routine in a library has a vulnerability, that vulnerability can only ever be used by an attacker if the program actually calls it, no matter how the routine was linked. And if the program calls it, it will certainly be there even with static linking.
Posted Dec 3, 2019 14:46 UTC (Tue)
by farnz (subscriber, #17727)
[Link]
There are, however, two real space savings:
Posted Dec 3, 2019 16:41 UTC (Tue)
by excors (subscriber, #95769)
[Link]
That's true, though I think unused code (whether vulnerable or not) can still be useful in exploits when there is a vulnerability in the actively-used parts of the program. A buffer overflow bug might allow a ROP attack, but the attacker needs to find suitable ROP gadgets somewhere in the process's address space. And some Spectre variants trick the CPU into speculatively executing code at attacker-controlled addresses, but that code must contain a gadget to exfiltrate data from the speculative world. If the application is statically linked and the dead code is removed, it becomes harder for an attacker to find suitable gadgets. (But in practice I guess this is only significant for small applications that use large libraries; if it's a large application then it'll probably have enough gadgets already.)
Posted Dec 3, 2019 17:14 UTC (Tue)
by Wol (subscriber, #4433)
[Link] (1 responses)
If I'm distributing a program, I have to include shared libraries. They may already be on the system, but ...
And while only the required routines may be pulled into ram, they are memory-mapped, and depending on your page size rather more may be pulled in than required.
> Static linking does not give you ASLR at all.
Do you mean the locations are randomised every time the application is run? In which case you're right, although there is nothing stopping a static loader from doing the same.
> Your comment about "load the library a couple of times to resolve all the references" is so wrong that I wonder if I misunderstand what you mean.
You may well do. Remember I'M DISCUSSING ALTERNATIVES TO LINUX. When the linker loads the master object, it creates a load of dangling references. When it loads a library to resolve those references, it *only* resolves those references, so if one library routine calls another it may create a new dangling reference - which means the library needs to be loaded again to resolve it! Don't forget - the library is a collection of independent binary blobs and only those blobs that are needed are copied into the executable.
> Finally, if one routine in a library has a vulnerability, that vulnerability can only ever be used by an attacker if the program actually calls it, no matter how the routine was linked.
So you're saying that, even though a dynamic library is memory-mapped, an attacker can't jump to an arbitrary position in that library?
Cheers,
Posted Dec 8, 2019 15:37 UTC (Sun)
by nix (subscriber, #2304)
[Link]
The problem here is that your terminology is so wrong that people who know the terminology can barely understand what you're saying. You're talking about gcc -lfoo -lbar -lfoo, right? That's not loading. That's linking. Loading is what ld.so does at runtime, and it never loads libraries more than once in the common case (modulo very obscure cases like dlmopen() and audit libraries).
Soller: Real hardware breakthroughs, and focusing on rustc
Soller: Real hardware breakthroughs, and focusing on rustc
Soller: Real hardware breakthroughs, and focusing on rustc
Wol
Soller: Real hardware breakthroughs, and focusing on rustc