Re: [PATCH] spi: bcm2835: Fix buffer overflow with CS able to go beyond limit.

From: Lukas Wunner
Date: Tue May 04 2021 - 09:54:01 EST


On Tue, May 04, 2021 at 12:51:30PM +0100, Mark Brown wrote:
> On Sat, May 01, 2021 at 09:51:35PM +0200, Lukas Wunner wrote:
> > I failed to appreciate that when I changed num_chipselects for
> > spi-bcm2835.c with commit 571e31fa60b3. That single line change
> > in the commit ought to be reverted.
>
> > And the kernel-doc ought to be amended because the crucial detail
> > that num_chipselect needs to be set to the maximum *native* chipselects
> > isn't mentioned anywhere.
>
> Can you send patches for these please?

Yup, I've cooked up two patches over the weekend, one bcm2835 short-term
fix for-5.13 and one long-term solution for-5.14, they're on this branch:

https://github.com/l1k/linux/commits/bcm2835_spi_limit

Just needs some more polishing and testing before submission (hopefully
in the second half of this week).


> > Unfortunately that's non-trivial. The slave-specific data is DMA-mapped.
> > It could be DMA-mapped in ->setup but there's no ->unsetup to DMA-unmap
> > the memory once the slave is removed. Note that the slave could be removed
> > dynamically with a DT overlay, not just when the controller is unbound.
>
> > So we'd need a new ->unsetup hook at the very least to make this work.
>
> There's the cleanup() callback which seems to fit?

Right, I initially missed that but found it and then prepared the patch
on the above-linked branch.

Thanks,

Lukas