News for hackers. Stuff that matters.
Re:Hidden dependencies in Linux binaries by quotemstr on Sunday April 14, 2024 @02:03PM (#40033007)
We're in this situation because we're using a model of dynamic linking that's decades out of date. Why aren't we using process-isolated sandboxed components talking over io_uring-based low-latency IPC to express most software dependencies? The vast majority of these dependencies absolutely do not need to be co-located with their users.

Consider liblzma: would liblzma-as-a-service really be that bad, especially if the service client and service could share memory pages for zero-copy data transfer, just as we already do for, e.g. video decode?

Or consider React Native: RN works by having an application thread send a GUI scene to a renderer thread, which then adjusts a native widget tree to match what the GUI thread wants. Why do these threads have to be in the same process? You're doing a thread switch anyway to jump from the GUI thread to the renderer thread: is switching address spaces at the same time going to kill you? Especially if the two threads live on different cores and nothing has to "switch"?

Both dynamic linking and static linking should be rare in modern software ecosystems. We need to instead reinvigorate the idea of agent-based component systems with strongly isolated components.

Re:Hidden dependencies in Linux binaries by magicalhippo on Sunday April 14, 2024 @04:27PM (#40034173)
Think you would have loved Signularity OS[1].

It featured software-isolated processes that communicated via contract-based message passing, which allowed for zero-copy exchange of data.

As a research OS it never became a fully-fledged OS[2], but an interesting attempt IMHO.

[1]: https://www.microsoft.com/en-us/research/wp-content/uploads/...

[2]: https://en.wikipedia.org/wiki/Singularity_%28operating_syste...

Re:Hidden dependencies in Linux binaries by josephg on Sunday April 14, 2024 @04:15PM (#40034073)
If the goal is to put a security boundary within the process between libraries, there might be better ways to do it than process boundaries. One approach is to wasm sandbox library code. Firefox apparently does this - compiling some libraries to wasm, then compiling the wasm back to C and linking it. They get all the benefits of wasm but without any need to JIT compile the code.

Another approach would be to leverage a language like rust. I’d love it if rust provided a way to deny any sensitive access to part of my dependency tree. I want to pull a library but deny it the ability to run unsafe code or make any syscall (or maybe, make syscalls but I’ll whitelist what it’s allowed to call). Restrictions should be transitive to all of that library’s dependencies (optionally with further restrictions).

Both of these approaches would stop the library from doing untoward things. Way more so than you’d get running the library in a separate process.

Re:Hidden dependencies in Linux binaries by marcosdumay on Sunday April 14, 2024 @03:54PM (#40033896)
That's because IPC is not low-latency.

No modern processor architecture has a proper message passing mechanism. All of them expect you to use interruptions; with it's inherent problems of losing cache, disrupting pipelines, and well, interrupting your process flow.

All the modern architectures are also so close to have a proper message passing mechanism that it's unsettling. You actually need this to have uniform memory in a multi-core CPU. They have all the mechanisms for zero copy sharing of memory, enforcing coherence, atomicity, etc. AFAIK, they just lack a userspace mechanism to signal other processes.

Re:Hidden dependencies in Linux binaries by oasisaimlessly on Sunday April 14, 2024 @10:12PM (#40036449)
Futexes allow low-latency signalling to other processes, and FUTEX_SWAP [1, 2] promises to decrease the cost even further.

[1]: https://lore.kernel.org/lkml/20200722234538.166697-1-posk@po...

[2]: https://www.phoronix.com/news/Google-User-Thread-Futex-Swap

Re:Hidden dependencies in Linux binaries by marcosdumay on Monday April 15, 2024 @09:50AM (#40040547)
This doesn't seem to touch on any of the points on my comment.

It does take a lot of unnecessary stuff out of the way. But isn't enough to change the picture at all.

Re:Hidden dependencies in Linux binaries by quotemstr on Tuesday April 16, 2024 @09:58AM (#40051942)
> This doesn't seem to touch on any of the points on my comment.

What points did your comment make? You didn't define "signalling" specifically enough to discuss. Can you elaborate on precisely what kind of "signaling" primitive processors or operating systems should provide?

Re:Hidden dependencies in Linux binaries by otabdeveloper4 on Sunday April 14, 2024 @02:13PM (#40033104)
> is switching address spaces at the same time going to kill you?

The answer is "yes".

I won't stop you, if you want to make React even slower, be my guest. I want off this ride.

Re:Hidden dependencies in Linux binaries by quotemstr on Sunday April 14, 2024 @02:39PM (#40033289)
> The answer is "yes".

And if you have one per core anyway so nothing "switches"? Computers aren't single-core 80486es anymore. We have highly parallel machines nowadays and old intuition about what's expensive and what's cheap decays by the year.

Re:Hidden dependencies in Linux binaries by josephg on Sunday April 14, 2024 @04:07PM (#40034008)
I only have 16 cores. Linux, windows and macOS already load about 50+ processes at startup. If we moved shared libraries into their own processes, we’d be talking hundreds or thousands of processes running all the time. They don’t get a core each.

But, if you’re interested in this architecture, smalltalk did something similar. Fire up a smalltalk vm and play around!

Re:Hidden dependencies in Linux binaries by otabdeveloper4 on Sunday April 14, 2024 @03:45PM (#40033815)
Sorry, not dedicating a whole CPU core for your shitty React app.
Re:Hidden dependencies in Linux binaries by JackSlateur on Sunday April 14, 2024 @02:53PM (#40033403)
You know that process A (the caller) is currently running. You assume that process B (the callee) is running in another core on the same NUMA nodes.
Re:Hidden dependencies in Linux binaries by jcelerier on Sunday April 14, 2024 @02:22PM (#40033175)
currently involved professionally in a software architecture based on pretty much raw shared memory IPC, it's still too slow compared to in-process. See also VST hosts that allow grouping plug-ins together in one process or separating them in distinct processes, like Bitwig: for just a few dozen plug-ins you can very easily get 10+% of CPU impact (and CPU is an extremely dire commodity when making pro audio, it's pretty much a constant fight against high CPU usage in larger music making sessions)
Re:Hidden dependencies in Linux binaries by quotemstr on Sunday April 14, 2024 @02:43PM (#40033321)
> it's still too slow compared to in-process

Why? Relative to the in-process case, properly done multi-process data flow pipelines don't necessarily incur extra copies. Sure, switching to a different process is somewhat more expensive than switching to a different thread due to page table changes, but if you're doing bulk data processing, you amortize any process-separation-driven costs across lots of compute anyway --- and in a many-core world, you can run different parts of your system on different cores anyway and get away with not paying context-switch costs at all.

Also, 10% is actually a pretty modest price to pay for increased software robustness and modularity. We're paying more than that for speculative execution vulnerability anyway. Do you run your fancy low-level audio processing pipeline with "mitigations=off" in /proc/cmdline?

Re:Hidden dependencies in Linux binaries by jcelerier on Sunday April 14, 2024 @08:44PM (#40035895)
> Also, 10% is actually a pretty modest price to pay for increased software robustness and modularity. We're paying more than that for speculative execution vulnerability anyway.

it's a completely crazy price to pay in a field where people routinely spend thousands of $$$ for <5% improvement

> Do you run your fancy low-level audio processing pipeline with "mitigations=off" in /proc/cmdline?

obviously yes! along with power saving CPU C-states or anything throttling-related disabled, specific real-time IRQ and threading configuration (e.g. making sure that the sound card interrupts aren't going to happen on a core handling network interrupts) and two dozen other optimizations (which do make a difference, I regularly set-up new machines from scratch for shows, art installations, etc. and always do this setup step-by-step to see if things are finally "good enough" and they always make a difference, in really a make-or-break sense).

Re:Hidden dependencies in Linux binaries by miniupuchaty on Monday April 15, 2024 @12:48AM (#40037163)
Can you share your checklist for this show set-up? :)
Re:Hidden dependencies in Linux binaries by jcelerier on Monday April 15, 2024 @09:15AM (#40040146)
not for free but we can do consulting for this at my job, feel free to mail at jmcelerier ම sat.qc.ca :)
Re:Hidden dependencies in Linux binaries by zbentley on Sunday April 14, 2024 @04:01PM (#40033965)
This was roughly the dream of DBus. However, outside of desktop-shaped niches it proved to be extremely difficult to secure, standardize, and debug.

Process-level/address-space-level dependency sharing remains both easier to think about and simpler to implement (and capabilities are taking bites out of the security risks entailed by this model as time goes on).

Re:Hidden dependencies in Linux binaries by rini17 on Sunday April 14, 2024 @02:42PM (#40033311)
Someone got a microservice hammer, so everything looks like a nail eh?

What is really needed, is sane memory model where you can easily call any function with buffers (pointer + size) and it is allowed to access only these buffers and nothing else(note). Not this mess coming from C where this is difficult by design.

(note)since HN likes to split hairs: except for its private storage and other well thought exceptions

Re:Hidden dependencies in Linux binaries by ptx on Sunday April 14, 2024 @03:07PM (#40033517)
This would be what's known as software-based fault isolation, right? Here's a paper from 1993: https://dl.acm.org/doi/abs/10.1145/168619.168635

I don't understand why this idea keeps failing to take hold even though it's constantly reintroduced in various forms. Surely now, 30 years after that paper was published, we can bear the "slightly increased execution time for distrusted modules" in return for (as the paper suggests) faster communication between isolated modules?

Re:Hidden dependencies in Linux binaries by o11c on Sunday April 14, 2024 @03:30PM (#40033691)
So basically like that one Rust hardware project that gets posted periodically?

You could probably do it pretty decently in C via `pkey_mprotect` (probably with `dlmopen`).

https://www.man7.org/linux/man-pages/man7/pkeys.7.html

Re:Hidden dependencies in Linux binaries by quotemstr on Sunday April 14, 2024 @05:23PM (#40034604)
It'd be nice if dlmopen weren't broken and made a linker namespace so separate that it couldn't even share pthreads with another.
Re:Hidden dependencies in Linux binaries by bno1 on Sunday April 14, 2024 @02:39PM (#40033290)
A big issue with IPC is thread scheduling. Thread B needs to get scheduled to see the request from thread A and thread A needs to get scheduled to see the response from thread B. I think there are WIP solutions to deal with this [1] this but I'm not up to date.

[1] https://www.phoronix.com/news/Google-User-Thread-Futex-Swap

Re:Hidden dependencies in Linux binaries by pjmlp on Sunday April 14, 2024 @02:52PM (#40033394)
Because hardware resources, 20 years ago doing something like VSCode with tons of external processes per plugin, would drag your computer to a crawl.

Emacs wasn't Eight Megabytes and Constantly Swapping only due to Elisp.

Re:Hidden dependencies in Linux binaries by dosshell on Sunday April 14, 2024 @02:08PM (#40033063)
This is very interesting! Are there any movements to move towards this?

Wouldn't it open up for a new attack vector where process could read each other data?

Re:Hidden dependencies in Linux binaries by rwmj on Sunday April 14, 2024 @02:06PM (#40033036)
Essentially path dependency. It would be almost impossible to change how it works now.
Re:Hidden dependencies in Linux binaries by vlovich123 on Sunday April 14, 2024 @02:14PM (#40033116)
I don't think this stuff is as hard as you make it out to be. Consider that companies like Apple regularly change how things are done successfully. It just requires a good plan, time, & budget. Wayland is one example of what that looks like & it's not a good story. Pulse audio followed by pipewire is another example of migrations happening. I suspect this would probably be slightly worse than Wayland unless some kind of transparent shim could be written for each boundary so that it can be slotted in transparently.
Re:Hidden dependencies in Linux binaries by Analemma_ on Sunday April 14, 2024 @02:50PM (#40033377)
Apple can regularly change how things are done because they have absolute control over their platform and use an "our way or the highway" approach to breaking changes, where developers have to go along or lose access to a lucrative market. This approach really really would not work on Linux: consider that the rollout of systemd was one-tenth as dictatorial as is SOP for changes from Apple, and it caused legions of Linux users to scream for Poettering's head on a stick.
Re:Hidden dependencies in Linux binaries by vlovich123 on Sunday April 14, 2024 @04:59PM (#40034420)
That's not a path dependency though. That's just a critique of the bazaar development model. And honestly I think if the big distros got together and agreed this would be a significant security improvement, they could drag the community kicking & screaming just like they did with systemd (people hated systemd so much at first that they tried to get other init systems to not suck but over time persistent effort wins out).
Re:Hidden dependencies in Linux binaries by ajross on Sunday April 14, 2024 @02:11PM (#40033090)
> Why aren't we using process-isolated sandboxed components talking over io_uring-based low-latency IPC to express most software dependencies?

To some extent we are, if what you do is work on backend RPC or web app frameworks.

But the better answer is because sometimes what you actually want is the ability to put a C function in a separate file that can be versioned and updated on its own, which is what a shared library captures. Trying to replace a function call of 2-3 instructions with your io_uring monstrosity is... suboptimal for a lot of applications.

And in any case, the protocol parsing you'd need to provide to enable all that RPC is going to need to live somewhere, right? What is that going to be, other than a shared library or equivalent?

Re:Hidden dependencies in Linux binaries by JackSlateur on Sunday April 14, 2024 @02:50PM (#40033376)
You would replace function calls with syscalls ? Yeah well, if you omit performance and complexity, why not .. io_uring is nice. Yet my application have to call that lzma function and get the result now : you now add cross-process synchronization (via the kernel => syscall) as well as insert the scheduler in the mix
Re:Hidden dependencies in Linux binaries by zokier on Sunday April 14, 2024 @05:04PM (#40034474)
Dbus is a thing. Bus1 was its still-born spiritual kernel-space successor.