On Wed, Nov 25, 2026 at 04:19:30PM +0000, Gary Guo wrote: > On Fri Nov 13, 2026 at 8:25 PM GMT, Priya Bala Govindasamy wrote: > > `Chip::new()` does not check the alignment of the driver data type `T`. > > This allows a Rust kernel module to choose an arbitrary alignment for `T`. > > > > `pwmchip_alloc()` reserves `size_of::()` bytes for the driver's > > private data. `pwmchip_priv()` aligns this storage to `PWMCHIP_ALIGN`, > > which is defined as `ARCH_DMA_MINALIGN`. But, `PwmOps` does not restrict > > the alignment of `T`, so a caller may provide a `T` whose required > > alignment is greater than `ARCH_DMA_MINALIGN`. > > The commit message is overly verbose slop, please simplify it. Just state the > issue (`pwmchip_alloc` aligns to `PWMCHIP_ALIGN` only) and the fix (reject > drvdata with higher alignment with const_assert). > > > > > This can result in `drvdata_ptr` pointing to misaligned storage for `T` > > in the underlying C allocation. > > If `drvdata_ptr` is misaligned for `T`, that breaks the safety > > requirements of `pin_init::raw_try_init()` which requires a valid, > > aligned pointer as an argument. This is undefined behavior. > > > > Additionally, `Chip::drvdata()` can be called using the `Chip` produced by > > `Chip::new()`. It creates a reference to `T` from the misaligned storage > > which is also undefined behavior. > > These all follows from underalignments and there's no need to do this > explicitly. > > > > > Reject over-aligned types at compile time by asserting that T's alignment > > does not exceed ARCH_DMA_MINALIGN. > > > > This issue was detected by FerroLens, an LLM-assisted analysis tool, and > > was then manually analyzed and reproduced. > > This should be a note and not commit message. Move it below the ---. FTR: While I agree that the commit log is very verbose (and being only half Rust-literate I still don't understand it completely :-), but I like the info that this was found using a tool (in contrast to being a real problem triggering with mainline) in the commit log. Best regards Uwe