News for hackers. Stuff that matters.
Re:Win32 Is the Only Stable ABI on Linux? by wmf on Monday August 15, 2022 @01:33PM (#32472691)
I assume Flatpak fixes this by locking your app to a compatible version of glibc.
Re:Win32 Is the Only Stable ABI on Linux? by mananaysiempre on Monday August 15, 2022 @01:55PM (#32473013)
Surprisingly, that seems correct—a Flatpak bundle includes a glibc; though that only leaves me with more questions:

- On one hand, only one version of ld.so can exist in a single address space (duh). Glibc requires carnal knowledge of ld.so, thus only one version of glibc can exist in a single address space. In a Flatpak you have (?) to assume the system glibc is incompatible with the bundled one either way, thus you can’t assume you can load host libraries.

- On the other hand, a number of system services on linux-gnu depend on loading host libraries. Even if we ignore NSS (or exile it into a separate server process as it should have been in the first place), that leaves accelerated graphics: whether you use Wayland or X, ultimately an accelerated graphics driver amounts to a change in libGL and libEGL / libGLX (directly or through some sort of dispatch mechanism). These libraries require carnal knowledge of the kernel-space driver, thus emphatically cannot be bundled; but the previous point means that you can’t load them from the host system either.

- Modern toolkits basically live on accelerated graphics. Flatpak was created to distribute graphical applications built on modern toolkits.

- ... Wait, what?

Re:Win32 Is the Only Stable ABI on Linux? by anon291 on Monday August 15, 2022 @02:02PM (#32473099)
There is no 'system' glibc. Linux doesn't care. The Linux kernel loads up the ELF interpreter specified in the ELF file based on the existing file namespace. If that ELF interpreter is the system one, then linux will likely remap it from existing page cache. If it's something else, linux will load it and then it will parse the remaining ELF sections. Linux kernel is incredibly stable ABI-wise. You can have any number of dynamic linkers happily co-existing on the machine. With Linux-based operating systems like NixOS, this is a normal day-to-day thing. The kernel doesn't care.

> These libraries require carnal knowledge of the kernel-space driver, thus emphatically cannot be bundled; but the previous point means that you can’t load them from the system either.

No they don't. The Linux kernel ABI doesn't really ever break. Any open-source driver shouldn't require any knowledge of internals from user-space. User-space may use an older version of the API, but it will still work.

> whether you use Wayland or X, ultimately an accelerated graphics driver amounts to a change in libGL and libEGL / libGLX (directly or through some sort of dispatch mechanism)

OpenGL is even more straightforwards because it is typically consumed as a dynamically loaded API, thus as long as the symbols match, it's fairly straightforwards to replace the system libGL.

Re:Win32 Is the Only Stable ABI on Linux? by mananaysiempre on Monday August 15, 2022 @02:12PM (#32473250)
I know, I both run NixOS and have made syscalls from assembly :) Sorry, slipped a bit in my phrasing. In the argument above, instead of “the system glibc” read “the glibc targeted by the compiler used for the libGL that corresponds to the graphics driver loaded into the running kernel”. (Unironically, the whole point of the list above was to avoid this sort of monster, but it seems I haven’t managed it.)
Re:Win32 Is the Only Stable ABI on Linux? by kmeisthax on Monday August 15, 2022 @03:35PM (#32474252)
> No they don't. The Linux kernel ABI doesn't really ever break. Any open-source driver shouldn't require any knowledge of internals from user-space.

[laughs in Nvidia]

Re:Win32 Is the Only Stable ABI on Linux? by anon291 on Monday August 15, 2022 @04:42PM (#32475086)
NVIDIA is not an open-source driver [1], and if you look in your dmesg logs, your kernel will complain about how it's tainted. That doesn't change the truth value about what I said about 'open-source' drivers.

[1] I think this may have changed very very recently.

Re:Win32 Is the Only Stable ABI on Linux? by eklitzke on Monday August 15, 2022 @04:46PM (#32475134)
This is all correct and I'd also add that ld.so doesn't need to have any special knowledge of glibc (or the kernel) in the first place. From the POV of ld.so, glibc is just another regular ELF shared object that uses the same features as everything else. There's nothing hard-coded in ld.so that loads libc.so.6 differently from anything else. And the only thing ld.so needs to know about the kernel is how to make a handful of system calls to open files and mmap things, and those system calls that have existed in Linux/Unix for eternity.
Re:Win32 Is the Only Stable ABI on Linux? by mananaysiempre on Monday August 15, 2022 @05:43PM (#32475810)
Needs to have? In an ideal world, probably not. Has and uses? Definitely. For one thing, they need to agree about userland ABI particulars like the arrangement of thread-local storage and so on, which have not stayed still since the System V days; but most importantly, as a practical matter, ld.so lives in the same source tree as glibc, exports unversioned symbols marked GLIBC_PRIVATE to it[1], and the contract between the two has always been considered private and unstable.

[1] https://sourceware.org/git/?p=glibc.git;a=blob;f=elf/Version...

Re:Win32 Is the Only Stable ABI on Linux? by vetinari on Monday August 15, 2022 @03:08PM (#32473894)
> On one hand, only one version of ld.so can exist in a single address space (duh). Glibc requires carnal knowledge of ld.so, thus only one version of glibc can exist in a single address space.

Yes

> In a Flatpak you have (?) to assume the system glibc is incompatible with the bundled one either way, thus you can’t assume you can load host libraries.

Not exactly. You must assume that the host glibc is incompatible with the bundled one, that's right.

But that does not mean you cannot load host libraries. You can load them (provided you got them somehow inside the container namespace, including their dependencies) using the linker inside the container.

> hether you use Wayland or X, ultimately an accelerated graphics driver amounts to a change in libGL and libEGL / libGLX (directly or through some sort of dispatch mechanism).

In Wayland, your app tells the server to render a bitmap. How you got that bitmap rendered is up to you.

The optimization is that you send dma-buf handle instead of a bitmap. This is a kernel construct, not userspace driver one. This allows also cross-API app/compositor (i.e. Vulkan compositor and OpenGL app, or vice-versa). This also means you can use different version of the userspace driver with compositor than inside the container and they share the kernel driver.

> These libraries require carnal knowledge of the kernel-space driver, thus emphatically cannot be bundled; but the previous point means that you can’t load them from the host system either.

Yes and no; Intel and AMD user space drivers have to work with variety of kernel versions, so they cannot be too tight. Nvidia driver has tightly coupled user space and kernel space, but with the recent open-sourcing the kernel part, this will also change.

> but the previous point means that you can’t load them from the host system either.

You actually can -- bind mount that single binary into the container. You will use binary from the host, but load it using ld.so from inside container.

Re:Win32 Is the Only Stable ABI on Linux? by mananaysiempre on Monday August 15, 2022 @06:45PM (#32476496)
>> In a Flatpak you have (?) to assume the system glibc is incompatible with the bundled one either way, thus you can’t assume you can load host libraries.

> Not exactly. You must assume that the host glibc is incompatible with the bundled one, that's right.

> But that does not mean you cannot load host libraries. You can load them (provided you got them somehow inside the container namespace, including their dependencies) using the linker inside the container.

I meant that the glibcs are potentially ABI-incompatible both ways, not just that they’ll fight if you try to load both of them at once. Specifically, if the bundled (thus loaded) glibc is old, 2.U, and you try to load a host library wants a new frobnicate@GLIBC_2_V, V > U, you lose, right? I just don’t see any way around it.

>> These libraries require carnal knowledge of the kernel-space driver, thus emphatically cannot be bundled; but the previous point means that you can’t load them from the host system either.

> Yes and no; Intel and AMD user space drivers have to work with variety of kernel versions, so they cannot be too tight. Nvidia driver has tightly coupled user space and kernel space, but with the recent open-sourcing the kernel part, this will also change.

My impression of out-of-tree accelerated is mainly from fighting fglrx for the Radeon 9600 circa 2008, so extremely out of date. Intel is in-tree, so I’m willing to believe it has some degree of ABI stability, at least if an i915 blog post[1] is to be believed. Apparently AMD is also in-tree these days. Nvidia is binary-only, so the smart thing for them would probably be to build against an ancient Glibc so that it runs on everything.

But suppose the year is 2025, and a shiny new GPU architecture has come out, so groundbreaking no driver today can even lay down command buffers for it. The vendor is kind enough to provide an open-source driver that gets into every distro, and the userspace portion compiled against a distro-current Glibc ends up referencing an AVX-512 memcpy@GLIBC_3000 (or something).

I load a flatpak using Gtk3 GtkGLArea from 2015.

What happens?

[1] https://blog.ffwll.ch/2013/11/botching-up-ioctls.html

Re:Win32 Is the Only Stable ABI on Linux? by vetinari on Tuesday August 16, 2022 @05:24AM (#32480779)
> I meant that the glibcs are potentially ABI-incompatible both ways, not just that they’ll fight if you try to load both of them at once. Specifically, if the bundled (thus loaded) glibc is old, 2.U, and you try to load a host library wants a new frobnicate@GLIBC_2_V, V > U, you lose, right? I just don’t see any way around it.

Yup. So the answer is to minimize the amount of loaded host libraries, ideally 0. If that cannot be done, the builder of that host library will have to make sure it is backward compatible.

> But suppose the year is 2025, and a shiny new GPU architecture has come out, so groundbreaking no driver today can even lay down command buffers for it. The vendor is kind enough to provide an open-source driver that gets into every distro, and the userspace portion compiled against a distro-current Glibc ends up referencing an AVX-512 memcpy@GLIBC_3000 (or something).

> I load a flatpak using Gtk3 GtkGLArea from 2015.

Ideally, that driver would be build as an extension of the runtime your flatpak uses. I.e. everything based on org.freedesktop.Platform (or derivatives like org.gnome.Platform and org.kde.Platform) has extensions maintained with appropriate Mesa and Nvidia user space drivers.

So if new open source driver, if it is not part of Mesa, or you are not using above mentioned runtimes, would need to be build against the 2015 runtime. The nice thing is, that the platforms have corresponding sdks, so it is not a problem targeting specific/old version.

Re:Win32 Is the Only Stable ABI on Linux? by captainmuon on Monday August 15, 2022 @02:04PM (#32473142)
Does graphics on Linux work by loading the driver into your process? I assumed it works via writing a protocol to shared memory in case of Wayland, or over a socket (or some byzantine shared memory stuff that is only defined in the Xorg source) in case of X11.

From my experience, if you have the kernel headers and have all the required options compiled into your kernel, then you can go really far back and build a modern glibc and Gtk+ Stack, and use a modern application on an old system. If you do some tricks with Rpath, everything is self-contained. I think it should work the other way around, with old apps on a new kernel + display server, as well.

Re:Win32 Is the Only Stable ABI on Linux? by bnieuwen on Monday August 15, 2022 @03:30PM (#32474178)
So there are two parts to this: the app producing the image in the application window and then the windowing system combining multiple windows together to form the final image you see on screen.

The former gets done in process (using e.g. GL/vulkan) and then that final image gets passed onto the windowing system which is a separate process and could run outside the container.

As an aside, with accelerated graphics you mostly pass a file descriptor to the GPU memory containing the image, rather than mucking around with traditional shared memory.

Re:Win32 Is the Only Stable ABI on Linux? by wmf on Monday August 15, 2022 @02:13PM (#32473256)
Does graphics on Linux work by loading the driver into your process?

Yes, it's called Direct Rendering (DRI) and it allows apps to drive GPUs with as little overhead as possible. The output of the GPU goes into the shared memory so that the compositor can see it.

Re:Win32 Is the Only Stable ABI on Linux? by AshamedCaptain on Monday August 15, 2022 @01:41PM (#32472813)
Static linking -- always the ready-to-go response for anything ABI-related. But does it really help? What use is a statically linked glibc+Xlib when your desktop no longer sets resolv.conf in the usual place and no longer speaks the X11 protocol (perhaps in the name of security) ?
Re:Win32 Is the Only Stable ABI on Linux? by Beltalowda on Monday August 15, 2022 @02:16PM (#32473302)
I guess that kind of proves the point that there is no "stable", well, anything on Linux. Something like /etc/resolv.conf is part of the user-visible API on Linux; if you change that, you're going to break applications.

/etc/sysctl.conf is a good example; on some systems it just works, on some systems you need to enable a systemd service thingy for it, but on some systems the systemd thingy doesn't read /etc/sysctl.conf and only /etc/sysctl.d.

So a simple "if you're running Linux, edit /etc/sysctl.conf to make these changes persist" has now become a much more complicated story. Writing a script to work on all Linux distros is much harder than it needs to be.

Re:Win32 Is the Only Stable ABI on Linux? by vetinari on Monday August 15, 2022 @03:13PM (#32473956)
> Something like /etc/resolv.conf is part of the user-visible API on Linux; if you change that, you're going to break applications.

Apps were not supposed to open /etc/resolv.conf by themselves. If they did, they are broken. Just because the file is available, transparently, doesn't mean it is not a part of the internal implementation.

Even golang runtime checks nsswitch for known, good configuration before using resolv.conf instead of thunking to glibc.

Re:Win32 Is the Only Stable ABI on Linux? by Beltalowda on Monday August 15, 2022 @04:04PM (#32474686)
The point was that if you're statically linking something that paths such as /etc/resolv.conf become "hard-coded", so that seems like an unimportant detail; something needs to check it, whether that's an application or an application through a library call: it's the same thing. /etc/nsswitch.conf is just kicking the can down the road from /etc/resolv.conf to /etc/nsswitch.conf.
Re:Win32 Is the Only Stable ABI on Linux? by vetinari on Tuesday August 16, 2022 @05:15AM (#32480748)
What would exactly be that "something"?

Statically linking glibc was always strongly discouraged. Even if you did it, nss and iconv are always dynamically loaded, and they need symbols from glibc itself, so your statically-glibc-linked binary would need to load dynamic libc anyway!

No, something doesn't need to check it, today it exists only to serve broken applications (and systems broken by their admins). Its semantic doesn't allow to express the needs of resolvers today (like per-interface or per-zone resolving or other mechanisms, like mDNS).

How the resolver is configured is its internal issue; apps should just use getnameinfo().

Re:Win32 Is the Only Stable ABI on Linux? by gabereiser on Monday August 15, 2022 @01:54PM (#32472999)
Even statically linked, the problems you just described are valid. The issue is x11 isn’t holding up and no one wants to change. Wayland was that promise of change but has taken 15+ years to develop (and still developing).

Linux desktop is a distro concern now. Not an ecosystem concern. It’s long left the realm of an linux concern when MacOS went free (with paid hardware of course) and Windows was giving away free windows 10 licenses to anyone who asked for it.

Deepin desktop and elementary are on the top of my list for elegance and ease of use. Apps and games need a solid ABI and this back and forth between gnome and kde doesn’t help.

With so many different wm’s and desktop environments, x11 is still the only method of getting a window with an opengl context in any kind of standard way. Wayland, X12, whatever it is, we need a universal ABI for window dressing for Linux to be taken seriously on the desktop.

Re:Win32 Is the Only Stable ABI on Linux? by cogman10 on Monday August 15, 2022 @02:10PM (#32473220)
With the rise of WSL, I have a real hard time justifying wanting a linux desktop.

I've got a VM with a full linux distro at my fingertips. Virtualization has gotten more than fast enough. And now, with windows 11, I get an X server integrated with my WSL instance so even if I WANTED a linux app, I can launch it just like I would if I were using linux as my host.

It does suck that the WSL1 notion of "not a vm" didn't take off, but at the same time, when the VM looks and behaves like a regular bash terminal, what more could you realistically want?

Re:Win32 Is the Only Stable ABI on Linux? by blibble on Monday August 15, 2022 @02:17PM (#32473306)
> what more could you realistically want?

some privacy, no telemetry, no ads, and the computer only applying updates that I choose and only rebooting when I ask it to?

(I know it's a lot to ask for these days...)

Re:Win32 Is the Only Stable ABI on Linux? by CoolCold on Thursday August 18, 2022 @08:24AM (#32508603)
I opted in telemetry to ensure OS vendor has data on usage, issues, crashes. The same for say Firefox.

I believe providing it helps vendors to improve and fix issues quicker.

Re:Win32 Is the Only Stable ABI on Linux? by gabereiser on Monday August 15, 2022 @02:17PM (#32473317)
:pulls out wallet: where?
Re:Win32 Is the Only Stable ABI on Linux? by vetinari on Monday August 15, 2022 @03:19PM (#32474031)
WSL2 is very limited; from not having a "proper init" to having NAT-ed network, it is fine for running simple docker containers, but proper linux it is not.

Comparing it to the real linux is like comparing powershell prompt to full windows.

Re:Win32 Is the Only Stable ABI on Linux? by pxc on Monday August 15, 2022 @10:12PM (#32478456)
> [WSL] is fine for running simple docker containers

WSL is passable for running Docker containers, and that is if you add a ton of complicated socket forwarding machinery and Window-side service management automation to it, which is what Docker Desktop does.

Without that, WSL2's lack of a proper init system means that you literally don't even have a way to automatically start `dockerd`. And you have the same story for the integration of that Docker daemon with the other Linux WSL hosts.

> Comparing it to the real linux is like comparing powershell prompt to full windows.

True, although in a way this comparison is unflattering to Linux because PowerShell is generally better made, better documented, and less hostile to automation or customization than most software that comes with Windows.

Re:Win32 Is the Only Stable ABI on Linux? by vetinari on Tuesday August 16, 2022 @05:27AM (#32480797)
> WSL is passable for running Docker containers, and that is if you add a ton of complicated socket forwarding machinery and Window-side service management automation to it, which is what Docker Desktop does.

That's exactly the reason why I mentioned simple docker containers.

Once I needed to make some of them work with macvlan/ipvlan, and docker desktop on mac and windows were both completely unusable.

Re:Win32 Is the Only Stable ABI on Linux? by CoolCold on Thursday August 18, 2022 @08:27AM (#32508632)
Say I'm webdev (I'm not) and proper Linux for me is that one which can start Flask dev env, and I can copypaste things from stackoverflow. Totally fine for my needs to call it proper Linux.
Re:Win32 Is the Only Stable ABI on Linux? by vetinari on Friday August 19, 2022 @12:55PM (#32523437)
Webdev is about the only scenario, in which it would be ok; funny how you mentioned exactly this one.

However, for webdev, native linux would be fine as well.

Re:Win32 Is the Only Stable ABI on Linux? by pxc on Monday August 15, 2022 @09:59PM (#32478388)
WSL is really only a viable alternative to dual-booting for Windows people who have merely dabbled in Linux desktop usage. Admittedly, this is likely the only case Microsoft cares about.

But if you're used to Linux, Windows is not only borderline unbearable in a cultural way, but you're likely to notice that a ton of important pieces of WSL (and the wider Windows CLI environment) are broken, inadequate, missing, or just different in a way that makes them unattractive to longtime Linux users.

> I've got a VM with a full linux distro at my fingertips. [...] when the VM looks and behaves like a regular bash terminal, what more could you realistically want?

To name a few, things, limited strictly to WSL:

  - your distro's normal init system / a standard way to configure persistent services
  - binfmt_misc interop that works consistently (for example, some applications cause hangs for unclear reasons, when I pipe them into `clip.exe`
  - integration for services that involve running agents and/or hardware access (e.g., Docker, GnuPG, SSH)
  - WSLg support on Windows 10,  whose absence is purely artificial (what version of Windows my corporate laptop runs is not up to me)
  - passable performance with files on the Windows side so that basic amenities like a Git prompt in your shell don't suck
  - bridged networking or some other advanced networking configuration
Re:Win32 Is the Only Stable ABI on Linux? by CoolCold on Thursday August 18, 2022 @08:32AM (#32508698)
> - your distro's normal init system / a standard way to configure persistent services

> - bridged networking or some other advanced networking configuration

Sounds like something in sysadmin's language.

I hope WSL will keep within the current paradigm, not trying to replace your Proxmox test lab.

Re:Win32 Is the Only Stable ABI on Linux? by gabereiser on Monday August 15, 2022 @02:17PM (#32473309)
Yeah, WSL(2) was a huge huge win for Microsoft. It seems silly, but it’s kept thousands of devs from dual booting…
Re:Win32 Is the Only Stable ABI on Linux? by blibble on Monday August 15, 2022 @02:19PM (#32473337)
I dunno

it's quite possible it'll work out as well as IBM's OS/2 running Windows apps did

Re:Win32 Is the Only Stable ABI on Linux? by CoolCold on Thursday August 18, 2022 @08:35AM (#32508722)
Since when saving time and increasing productivity became silly? Not even saying getting rid of Linux VMs, shared folders and similar annoying things is a good thing overall.
Re:Win32 Is the Only Stable ABI on Linux? by pengaru on Monday August 15, 2022 @02:05PM (#32473152)
> Linux desktop is a distro concern now. Not an ecosystem concern. It’s long left the realm of an linux concern when MacOS went free (with paid hardware of course) and Windows was giving away free windows 10 licenses to anyone who asked for it.

You seem fixated on the Free Beer misinterpretation of Free Software.

Re:Win32 Is the Only Stable ABI on Linux? by gabereiser on Monday August 15, 2022 @02:14PM (#32473276)
No, but it sounds that way I guess. It’s more about where the developer en-masse focus lays. Few developers are interested in the desktop for Linux because they are supported on windows or Mac and during the time period I mentioned, it didn’t cost them anything monetary.

There were indications that windows and Linux May converge. Instead we got WSL2. A lot of times we decide to develop something because of the pain of using the other thing. Sometimes we develop something as a “me too”. Sometimes we develop something that is just better. Sometimes, it’s worse.

My point is the fight for a foothold in Linux desktop looked promising for a bit. SteamOS looked like it was gaining, steam…

The reality is there are complexities at that level that people don’t want to deal with and we all have opinions on how it should work, should look, and should be called.

Red Hat (former RH’er myself) should take this on and really standardize something outside of core and server land. And no, it should not be Gnome.

Re:Win32 Is the Only Stable ABI on Linux? by layer8 on Monday August 15, 2022 @01:41PM (#32472808)
…also locking in any security vulnerabilities.
Re:Win32 Is the Only Stable ABI on Linux? by rtontic on Monday August 15, 2022 @01:50PM (#32472941)
I mean, we are talking about videogames here.
Re:Win32 Is the Only Stable ABI on Linux? by formerly_proven on Monday August 15, 2022 @02:00PM (#32473080)
Multiplayer is a thing, where both crashing servers and also attacking other clients (even in non-p2p titles) is not that uncommon. Many titles don't permit community servers any more, of course.
Re:Win32 Is the Only Stable ABI on Linux? by maeln on Monday August 15, 2022 @02:00PM (#32473081)
Wasn't it Elden Ring or another From Software game that had a RCE ? This article talks about it : https://wccftech.com/dark-souls-rce-exploit-fixed-elden-ring...

A lot of games have multiplayer functionalities these days. That make them a potential target for RCE and related vulnerabilities. Granted, if you don't play video game as root, the impact should be limited, but it is still something to be aware of.

Re:Win32 Is the Only Stable ABI on Linux? by Beltalowda on Monday August 15, 2022 @02:37PM (#32473546)
Skimming over the details, that seems like a bunch of bugs in the game code. I don't think dynamic linking would help there.
Re:Win32 Is the Only Stable ABI on Linux? by spicybright on Monday August 15, 2022 @01:45PM (#32472868)
If you're never going to update your program and don't care about another heartbleed effecting your product and users, then sure.
Re:Win32 Is the Only Stable ABI on Linux? by lanstin on Monday August 15, 2022 @05:39PM (#32475760)
Would you rather run a statically linked go or rust binary with the native crypto implementations of ssl or a dynamically linked OpenSSL that is easier to upgrade? (Honest question)