Commit Graph
26 Commits
Author SHA1 Message Date
Daan De Meyer cbd2e08f00 pidfd-util: Remove unused include
This snuck in when CI was broken.
2026-02-05 16:18:35 +01:00
Yu Watanabe 2eab8fa1e4 pidfd-util: use fd_to_handle_u64() 2026-02-04 02:45:17 +09:00
Jeff Layton eb2e91b981 pidfd/cgroup-util: use fully-sized filehandle buffers
The current code assumes that FILEID_KERNFS filehandles will never grow
in size. This is not a safe assumption and userland shouldn't be trying
to guess the size of the filehandle it'll get.

We have a macro for that: MAX_HANDLE_SZ.
2026-01-29 00:57:03 +09:00
Yu Watanabe 93378148d4 tree-wide: normalize comment style 2025-12-15 08:50:13 +09:00
Yu Watanabe 0c37508494 pidfd-util: expose pidfd_get_info() 2025-10-19 10:01:46 +09:00
Yu Watanabe 608fc3fa2c pidfd-util: add missing trailing argument for ioctl(PIDFD_GET_*_NAMESPACE)
Otherwise, it always fails with EINVAL.
2025-10-11 00:13:26 +02:00
Lennart Poettering c24f405ace tree-wide: don't play games with alignment around file_handle
The payload of a file_handle structure is not 64bit aligned. So far used
_alignas_() to align it to 64bit as a whole, which by accident has the
side-effect that the payload ends up being aligned to 64bit too, but
this is ugly, because it's really just an accident...

Let's do this properly, and just use proper unaligned 64bit reads to
access the field, and do not assume aligning the structure as a whole
also aligns the payload part of it.

Follow-up for: fd51a7d8b5
2025-08-18 21:50:55 +09:00
Luca Boccassi fd51a7d8b5 pidfd-util: force alignment of file_handle union to avoid assert on 32bit
On 32bit the union won't be aligned automatically, needs to be enforced:

Assertion '((uintptr_t) _p) % alignof(uint64_t) == 0' failed at src/basic/pidfd-util.c:251, function pidfd_get_inode_id_impl(). Aborting.

Follow-up for 9c039ef5ff
2025-08-15 12:36:20 +01:00
Yu Watanabe 3fc2a44043 include: move trivial kernel header wrappers to src/include/override/ 2025-07-11 13:05:46 +09:00
Mike Yuan a842c26be3 pidfd-util: extract pidfd_get_inode_id_impl() and make it thread safe
Preparation for later commits.
2025-06-05 00:28:01 +02:00
Mike Yuan e09b7ced65 pidfd-util: open an internal pidfd if none is passed in pidfd_check_pidfs()
I'd like to introduce a libsystemd helper for acquiring pidfd
inode id, which however means the fd passed to pidfd_check_pidfs()
can no longer be trusted. Let's add back the logic of allocating
a genuine pidfd allocated internally, which was remove in
5dc9d5b4ea.
2025-06-05 00:28:01 +02:00
Daan De Meyer 0c15577abe basic + fundamental: Clean up includes
Split out of #37344.
2025-05-25 10:06:07 +02:00
Jan Vaclav b900a8d827 pidfd-util: avoid alignment warning when accessing f_handle 2025-05-20 12:07:43 +02:00
Mike Yuan d2c4df9e48 pidfd-util: use get_proc_field() for pidfd_get_pid_fdinfo() 2025-05-01 13:10:26 +09:00
Daan De Meyer 93a1f7921a basic: Stop including log.h in macro.h
Now that the necessary functions from log.h have been moved to macro.h,
we can stop including log.h in macro.h. This requires modifying source
files all over the tree to include log.h instead.
2025-04-18 14:19:15 +02:00
Yu Watanabe e75372958d missing_threads.h: threads.h exists since glibc-2.28 2025-03-04 02:24:49 +09:00
Mike Yuan 9c039ef5ff pidfd-util: preferably acquire pidfd inode id through name_to_handle_at()
See rationales described in kernel commit:
https://github.com/torvalds/linux/commit/b3caba8f7a34a2bbaf45ffc6ff3a49b70afeb192
2025-01-22 21:41:44 +01:00
Lennart Poettering afede53ae9 pidfd-util: add helper for getting our own pidfdid
let's start caching our own pidfd id, since it's somewhat involved to
get but a much better identifier for things than the classic PID is.
2025-01-20 21:51:29 +01:00
Lennart Poettering 5dc9d5b4ea pidfd-util: dont open a new pidfd unnecessarily in pidfd_check_pidfs() 2025-01-20 21:49:38 +01:00
Mike Yuan 6e14c46bac tree-wide: drop support for kernels without pidfd_open() and pidfd_send_signal()
Our baseline is v5.4 now.
2025-01-12 00:01:07 +01:00
Mike Yuan 47f64104d1 process-util: port pidref_get_uid() and pidref_is_my_child() to pidfd helpers 2025-01-04 17:48:22 +01:00
Mike Yuan 85e7bbfaa4 pidfd-util: introduce pidfd_get_{ppid,uid,cgroupid} which goes via PIDFD_GET_INFO too 2025-01-04 17:08:01 +01:00
Mike Yuan dcf0ef3f42 pidfd-util: try to translate pidfd -> pid through ioctl(PIDFD_GET_INFO) 2025-01-04 17:08:01 +01:00
Mike Yuan 72661e0091 pidfd-util: introduce helper for obtaining ns fd using PIDFD_GET_*_NAMESPACE directly 2025-01-04 17:07:59 +01:00
Mike Yuan 2fa42318c3 pidref: move generic pidfd_get_inode_id() to pidfd-util
Prompted by https://github.com/systemd/systemd/pull/35224/commits/221d6e54c60389f26c2c79dbfa4e83204d2775d7

Also generalize pidfd_check_pidfs() and expose have_pidfs for later use.
2025-01-04 17:07:58 +01:00
Mike Yuan b234026d09 process-util: extract pidfd-related funcs into pidfd-util.[ch] 2025-01-04 16:58:13 +01:00