]> git.ipfire.org Git - thirdparty/systemd.git/commit
core: pin restrict-fsaccess initramfs_s_dev store width to skeleton field 42705/head
authortunaichao <tunaichao@uniontech.com>
Wed, 24 Jun 2026 06:01:06 +0000 (14:01 +0800)
committertunaichao <tunaichao@uniontech.com>
Wed, 24 Jun 2026 06:01:06 +0000 (14:01 +0800)
commit55fb3fcf994ad6816b1d9a6cb68f8e4d5e0939ce
treee84562be8ff4d802c791ddb95eb9de1dee25c14a
parent2e44ad8dbd78b0004a1c4962411ea1daa6dd1401
core: pin restrict-fsaccess initramfs_s_dev store width to skeleton field

The clear-store in restrict_fsaccess_clear_initramfs_trust() writes a fixed
4 bytes (*(uint32_t *)(p + INITRAMFS_S_DEV_OFF) = 0). INITRAMFS_S_DEV_OFF is
derived from the skeleton, so the offset tracks any field widening, but the
store width does not: were initramfs_s_dev widened (e.g. __u32 -> __u64) in
the BPF program, the store would clear only the low 4 bytes and silently
leave the initramfs trust window partially open. That is exactly the class
of bug the mirror-struct asserts (removed earlier in this branch) guarded
against.

Add a compile-time assert pinning the store width to the skeleton field
width (sizeof_field(typeof_field(struct restrict_fsaccess_bpf, bss[0]),
initramfs_s_dev) == sizeof(uint32_t)), so widening the field fails the build
instead of clearing half of it.
src/core/bpf-restrict-fsaccess.c