]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
cgroup-util: enforce alignment of f_handle
authorLuca Boccassi <luca.boccassi@gmail.com>
Fri, 25 Jul 2025 14:16:22 +0000 (15:16 +0100)
committerLuca Boccassi <luca.boccassi@gmail.com>
Fri, 25 Jul 2025 19:42:23 +0000 (20:42 +0100)
The change in 4d2e61211df7244fae6aaeb8cae0916b4a0e78bd
broke armv7 where uintptr_t is 4 bytes:

/* test_id */
Assertion '((uintptr_t) _p) % alignof(uint64_t) == 0' failed at src/basic/cgroup-util.c:108, function cg_get_cgroupid_at(). Aborting.

(gdb) p (uintptr_t)fh.file_handle.f_handle % _Alignof(uint64_t)
$9 = 4

Enforce that the structure is aligned as expected

Follow-up for 4d2e61211df7244fae6aaeb8cae0916b4a0e78bd

src/basic/cgroup-util.c

index 0184cbffbecc569129c08e0944c41b37b276e994..0dc13bc958cd40d011776667316fac79f0d68987 100644 (file)
@@ -38,7 +38,7 @@
 typedef union {
         struct file_handle file_handle;
         uint8_t space[offsetof(struct file_handle, f_handle) + sizeof(uint64_t)];
-} cg_file_handle;
+} _alignas_(uint64_t) cg_file_handle;
 
 #define CG_FILE_HANDLE_INIT                                     \
         (cg_file_handle) {                                      \