L
ldpreload
ldpreload.com · Personal blog · on HN since 2015
Geoffrey Thomas writes about Linux internals, kernel and userspace edge cases, Rust kernel modules, SSH and security.
What HN saysCommenters link his Rust kernel module slides, his names-to-reserve list and his SSH ControlMaster post, and use his signalfd article in signal handling discussions.
34HN people shared it
18linked it in comments
19stories submitted
649story points
8 months agolast shared
2015people per year2026
Most-shared posts
- 1Signalfd Is Useless (2015)14 people · 77 points · first shared 2015 · 24 comments on HN
- 2Finding a kernel regression in half an hour with git bisect run (2018)5 people · 214 points · first shared 2018 · 39 comments on HN
- 3Hostnames and usernames to reserve5 people · 212 points · first shared 2015 · 24 comments on HN
- 4Smashing the heap by overflowing the stack3 people · 29 points · first shared 2015 · 2 comments on HN
- 5Nine reasons Python Sucks3 people · 8 points · first shared 2018 · 3 comments on HN
- 6Signalfd is useless2 people · 105 points · first shared 2015 · 43 comments on HN
- 7SSH ControlMaster and ControlPath (2014)2 people · 2 points · first shared 2024 · discussion on HN
- 8Kernel modules in rust lssna2019.pdf2 people · first shared 2019
- 9Stupid tricks at the userspace/kernelspace boundary1 people · 2 points · first shared 2023 · discussion on HN
- 10Usr bin python 231 people · first shared 2018
- 11Homepage1 people · first shared 2022
What HN people wrote when they linked it
geofft · 2021-04-15
Check out out slides 20-21 from Linux Security Summit 2019 - there are specific reasons why Linux didn't like C++ that don't apply to Rust. https://ldpreload.com/p/kernel-modules-in-rust-lssna2019.pdf
Basically, we think (and we hope Linus agrees) that Rust has the relevant benefits of C++ without the downsides that have so far kept C++ from being adopted. (It has other great features that C++ doesn't have like compiler-enforced memory safety, too, but I agree with you that RAII is a pretty important and obvious win for the kernel just by itself.)
ximm · 2020-09-11
I recently rewrote my fork of cplay and got fed up with curses. Boy do I wish I had found this article earlier because it describes everything I painfully had to cobble together. This is great!
Just one nit: Doing stuff in a signal handler is usually a bad idea because it can interrupt your code at any time. The usual work around is a trick called "self-pipe". https://ldpreload.com/blog/signalfd-is-useless
For anyone interested, I created a library in the process: https://github.com/xi/boon (It takes some inspiration from react but bare with me, I think it actually makes sense.)
teddyh · 2026-02-24
Even if you don’t ban all words, there are some you should filter:
• <https://ldpreload.com/blog/names-to-reserve>
• <https://xkcd.com/1963/>
gldrk · 2025-10-20
UNIX signals *do not* queue. If two or more signals with the same number are sent faster than the receiving thread handles them (due to the signal being blocked and/or the thread not being scheduled), all but the last will be lost irrevocably. There is no mechanism to prevent this.
https://ldpreload.com/blog/signalfd-is-useless
znpy · 2025-09-10
One other super-interesting feature is connection multiplexing and keeping connection alive with the ControlMaster and ControlPath directives in your ~/.ssh/config file.
The nice thing is that it makes opening a new ssh connection much faster, which if you make a lot of connections, it can be very handy.
See https://ldpreload.com/blog/ssh-control for some examples
pcwalton · 2024-05-24
"signalfd is useless" is a good article: https://ldpreload.com/blog/signalfd-is-useless
It goes into the problems with Unix signals, and then explains why Linux's attempt to solve them, signalfd, doesn't work well.
iforgotpassword · 2024-03-04
Obligatory https://ldpreload.com/blog/signalfd-is-useless?reposted-on-request post. :)
It's a divisive article, but I generally agree, saving you a thread is basically what it mostly does, and there's already enough boilerplate out there to do that. Plus you sacrifice portability.
mlindner · 2019-09-20
welder · 2018-04-11
This is good, but it's sad that #!/usr/bin/env python will no longer work as the go-to shebang since python won't exist, only python3 will exist by default.
Geofft[1] has a nifty solution but it's not as cross platform as the old tride-n-true #!/usr/bin/env python:
#!/bin/sh
""""type python3 >/dev/null 2>&1 && exec python3 "$(readlink -f "$0")" "$@" #"""
""""exec python "$(readlink -f "$0")" "$@" #"""
[1] https://ldpreload.com/blog/usr-bin-python-23
happyguy43 · 2018-02-07
This is not a good use of EINTR, you can even see it’s fundamentally flawed given this usage introduces a race condition.
pselect() isn’t the right answer given it’s not portable and it’s totally broken on various versions of macOS. signalfd() is also not the answer, it suffers from a broken design: https://ldpreload.com/blog/signalfd-is-useless
To deal with cleanup on a signal while blocking in a robust and portable way, use the self pipe trick and select() (or equivalent).
monocasa · 2017-12-24
https://ldpreload.com/blog/signalfd-is-useless
SignalFD leaves a little to be desired.
floatboth · 2017-09-17
To be fair, cgroups appeared before we got rctl/racct.
More actual disasters though: signalfd (https://ldpreload.com/blog/signalfd-is-useless), ALSA, wireless_tools/iproute2(ip command)/iw (was it SO HARD to just keep improving ifconfig?!), procfs/sysfs & udev.
oconnor663 · 2017-04-27
The "signalfd is useless" article comes up every so often. The title might be an exaggeration, but there are problems to be aware of: https://ldpreload.com/blog/signalfd-is-useless
In fact it looks like geofft is in this thread below :)
ubernostrum · 2017-01-16
Related: a list of names that probably should be reserved (for example, to prevent someone setting up a user-profile page at a URL you don't want them to control):
https://ldpreload.com/blog/names-to-reserve
gue5t · 2023-10-16
There are a few ways to handle this design question ("what happens if something needs to interact with a process while it's blocked in a system call?") more or less sanely, and UNIX chooses the least sane one (making userspace deal with the complexity of system calls possibly doing part or none of the work that was requested). Other operating systems might fully transparently guarantee that the system call completes before the process is notified of said interaction, but this isn't compatible with IPC as "lightweight" (unbuffered and without backpressure) as signals.
The Right Thing is to make system call submission atomic and asynchronous, only waiting on completion by explicit choice, and remove signals entirely in favor of buffered message-passing IPC. This is basically the world we're approaching with io_uring and signalfd, except for ugly interaction with coalescing and signal dispositions (see https://ldpreload.com/blog/signalfd-is-useless), and the fact that many syscalls still can't be performed through io_uring.
If UNIX had a better API for process management, people wouldn't see signals as necessary, but that's its own can of worms with its own Linux-specific partial fix (pidfd) and genre of gripe article (e.g. https://news.ycombinator.com/item?id=35264487).
matheusmoreira · 2022-12-10
> Can you please elaborate on why those two ideas are "horrible"?
The problems with fork are thoroughly explained by this Microsoft paper:
https://www.microsoft.com/en-us/research/uploads/prod/2019/04/fork-hot…
As for asynchronous signals, they are a completely broken concept and implementation.
It's not safe to do pretty much anything in a signal handler other than setting a flag and returning. You cannot use any non-reentrant function which eliminates pretty much everything useful, including the vast majority of standard library functions.
The system drops events. Signals are essentially a pending delivery flag in the kernel, signaling a process just sets the flag to 1 so there's no difference between doing it once and 10000 times.
Was in a system call when your process was signaled? It will be interrupted or cancelled. It returns EINTR and your code needs robust retrying logic to handle such a case. I've seen code that couldn't handle it and crashed.
There's race conditions everywhere. Signals can arrive while you're handling other signals, you need to block block them if you don't want that. Every thread has its own signal handling behavior. Signals sent to a process are handled by "any" thread. I remember reading in some standard that using signals in multithreaded programs was undefined behavior. Who even knows what's going to happen?
The only borderline sane way to handle signals is with file descriptors: you block traditional signal handling on all…
takoid · 2022-09-17
https://jrock.us/
https://jgc.org/
http://kaledavis.com/
https://aegir.sexy/
https://www.gwern.net/
https://jacquesmattheij.com/
https://danwin.com/
https://www.kalzumeus.com/
https://www.magic.do/
https://edweissman.com/
https://jakeseliger.com/
http://www.fogus.me/
https://www.stavros.io/
https://jasonlefkowitz.net/
https://minimaxir.com/
https://www.robinwhittleton.com/
https://ciexinc.com/
https://rongarret.info/
https://williampietri.com/
https://bpier.re/
https://joshtriplett.org/
https://ooer.com/
https://feross.org/resume/
https://www.brandons.me/
https://benjaminpbreen.com/
http://hokstad.com/
https://www.scott-a-s.com/
https://www.bermita.com/
http://tlrobinson.net/
https://ldpreload.com/
https://dotat.at/
http://xavvy.com/
https://correa.in/
https://adriann.github.io/
https://leclan.ch/
https://joeyespo.com/
https://pius.me/
https://adamierymenko.com/
https://drewdevault.com/
https://battlepenguin.com/
https://chris.improbable.org/
https://www.snellman.net/
https://ocdtrekkie.com/
https://www.cryptolotus.com/
https://www.gregkogan.com/
https://david.kitchen/
In no particular order. From: https://jessimekirk.com/blog/hn_users_links/. I went through about half of the list looking for personal websites to use as inspiration for my own.
Twirrim · 2020-03-28
There was a bug in a released kernel I ended up having to hunt down back last summer. It required a very specific set of circumstances to actually trigger the bug, but luckily for us we found some obvious side effects from the bug such that it was possible to get the relevant information via a very simple statically compiled C program (there would be a certain value under /sys).
I used that C program as the initramfs for qemu, with it spinning up an instance based on the test kernel, and could grep for what I wanted in the output to get a relevant exit code.
Combine that git bisect's automatic bisecting process, and I was able to automatically git bisect through a few thousand commits in the kernel to find the cause. It only took it about 50 minutes to find it in the end, which was helped a bunch by ccache (and the sheer build parallelism granted by building on a 52 core system).
That was a fun, somewhat out of the blue, task.
The process I took was based on https://ldpreload.com/blog/git-bisect-run, with various adaptations to suit the needs and the relevant build environment.