Files
systemd/src/basic
Lennart Poettering 6fb749e6aa pidfd-util: flush cached pidfd ID in child after fork()/clone()
pidfd_get_inode_id_self_cached() keys its cache on the PID only. This is
not sufficient to detect that we are in a different process: if we are
PID 1 of a PID namespace and fork off a child into a new PID namespace,
the child will be PID 1 too, and would then continue to use the parent's
cached pidfd ID. For example, a nested nspawn running as PID 1 would fill
the cache in sd_listen_fds() (which checks $LISTEN_PIDFDID), and then
pass its own ID to the payload, which would in turn drop the fds passed
to it.

Fix this by explicitly flushing the cache from reset_cached_pid(), i.e.
the pthread_atfork() child handler and from raw_clone(), the same way we
already flush the cached PID.

Also add a test that covers the PID 1 → PID 1 case.

(cherry picked from commit b7ab919eba)
(cherry picked from commit 69af528fed)
2026-11-05 14:48:10 +00:00
..
2026-01-06 10:34:02 +01:00
2026-04-26 21:21:49 +02:00
2026-03-03 22:18:26 +01:00
2026-03-31 18:30:40 +02:00
2026-04-09 22:47:10 +02:00
2026-04-09 22:47:10 +02:00
2025-12-15 08:50:13 +09:00
…
2026-07-19 22:34:06 +01:00
2026-09-09 10:08:20 +01:00