]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
pidfd-util: force alignment of file_handle union to avoid assert on 32bit
authorLuca Boccassi <luca.boccassi@gmail.com>
Fri, 15 Aug 2025 09:42:39 +0000 (10:42 +0100)
committerLuca Boccassi <luca.boccassi@gmail.com>
Fri, 15 Aug 2025 11:36:20 +0000 (12:36 +0100)
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 9c039ef5ff7f683aa9f7a36cb39bac94a12964b2

src/basic/pidfd-util.c

index 965f0b86da4894ce1e25dca05e37aaa567bd0666..328ed70d5291d4f44bc692a2bca965e19cbd021c 100644 (file)
@@ -239,7 +239,7 @@ int pidfd_get_inode_id_impl(int fd, uint64_t *ret) {
                 union {
                         struct file_handle file_handle;
                         uint8_t space[offsetof(struct file_handle, f_handle) + sizeof(uint64_t)];
-                } fh = {
+                } _alignas_(uint64_t) fh = {
                         .file_handle.handle_bytes = sizeof(uint64_t),
                         .file_handle.handle_type = FILEID_KERNFS,
                 };