sizeof() includes trailing struct pad, offsetofend() doesn't. On 32-bit PPC, sched_ext_ops_cid tail-pads 4 bytes past @priv and the assert trips. Use offsetofend() on both sides.
Showing the changes to kernel (1 of 1 file). Show all
Unified · Split
| @@ -10380,9 +10380,11 @@ static int __init scx_init(void) · 10379 unmodified lines | |||
| 10380 | /* | 10380 | /* |
| 10381 | * cid-form must end exactly at @priv - validate_ops() skips | 10381 | * cid-form must end exactly at @priv - validate_ops() skips |
| 10382 | * cpu_acquire/cpu_release for cid-form because reading those fields | 10382 | * cpu_acquire/cpu_release for cid-form because reading those fields |
| 10383 | * past the BPF allocation would be UB. | 10383 | * past the BPF allocation would be UB. offsetofend() on both sides |
| 10384 | * instead of sizeof() on sched_ext_ops_cid to sidestep trailing | ||
| 10385 | * struct padding (e.g. 32-bit PPC tail-pads ops_cid past @priv). | ||
| 10384 | */ | 10386 | */ |
| 10385 | BUILD_BUG_ON(sizeof(struct sched_ext_ops_cid) != | 10387 | BUILD_BUG_ON(offsetofend(struct sched_ext_ops_cid, priv) != |
| 10386 | offsetofend(struct sched_ext_ops, priv)); | 10388 | offsetofend(struct sched_ext_ops, priv)); |
| 10387 | #undef CID_OFFSET_MATCH | 10389 | #undef CID_OFFSET_MATCH |
| 10388 | 10390 | ||