History

sched_ext: Use offsetofend on both sides of the ops_cid layout assert

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.

Tejun Heo committed 6 months ago

Commit ca1d48a1 parent e18002d1 file · +4 −2Browse files

Showing the changes to kernel (1 of 1 file). Show all

Unified · Split

kernel/sched/ext.c+4−2
@@ -10380,9 +10380,11 @@ static int __init scx_init(void) · 10379 unmodified lines
1038010380 /*
1038110381 * cid-form must end exactly at @priv - validate_ops() skips
1038210382 * 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).
1038410386 */
10385− BUILD_BUG_ON(sizeof(struct sched_ext_ops_cid) !=
10387+ BUILD_BUG_ON(offsetofend(struct sched_ext_ops_cid, priv) !=
1038610388 offsetofend(struct sched_ext_ops, priv));
1038710389 #undef CID_OFFSET_MATCH
1038810390