Re: [PATCH v3] rust: bindgen: Preserve sched_statistics alignment
From: Miguel Ojeda
Date: Thu Dec 03 2026 - 05:50:12 EST
On Mon, Nov 23, 2026 at 5:43 PM Peder Bergan via B4 Relay
<devnull+peder.bergan.gmail.com@xxxxxxxxxx> wrote:
>
> From: Peder Bergan <peder.bergan@xxxxxxxxx>
>
> With CONFIG_SCHEDSTATS disabled, struct sched_statistics is empty but
> still cache-line aligned. Bindgen omits the alignment of the empty
> type. Bindgen 0.73.2 also stopped forcing padding before over-aligned
> fields, so fields following stats can be misplaced in the generated
> task_struct. On the reported arm64 build, Rust Binder reads the wrong
> pointer via CurrentTask::mm() and rejects mmap() with -EINVAL.
>
> Make sched_statistics opaque so bindgen uses the C size and alignment.
> Rust has no callers that access the fields of this type.
>
> Reported-by: Jules Mercier <jules@xxxxxxxxxxxxxx>
> Closes: https://github.com/Rust-for-Linux/linux/issues/1269
> Link: https://github.com/rust-lang/rust-bindgen/issues/3549
> Tested-by: Jules Mercier <jules@xxxxxxxxxxxxxx>
> Cc: stable@xxxxxxxxxxxxxxx # 6.12.x
> Signed-off-by: Peder Bergan <peder.bergan@xxxxxxxxx>
Applied (it has been a couple days in -next) to `rust-fixes` -- thanks everyone!
Cheers,
Miguel