Re: [PATCH] rust: bindgen: Preserve sched_statistics alignment

From: Jules Mercier

Date: Fri Nov 20 2026 - 07:59:17 EST


On Thu, Nov 19, 2026 at 08:33:07PM +0100, Peder Bergan wrote:
> With CONFIG_SCHEDSTATS disabled, struct sched_statistics is empty but
> still cache-line aligned. Bindgen emits the empty definition without
> that alignment. On affected builds this misplaces fields following
> stats in the generated task_struct. In 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.

Tested on a OnePlus 6T (sdm845, arm64), kernel based on next-20261102,
LLVM=1, bindgen 0.73.2, with CONFIG_SCHEDSTATS=n.

Without this patch, mmap() of the binder devices fails with -EINVAL as
described in the issue, and Waydroid cannot start. With it, binder
works and Waydroid boots.

Tested-by: Jules Mercier <jules@xxxxxxxxxxxxxx>

Thanks!