From: Lukas Wunner <lukas@wunner.de>
To: Mark Brown <broonie@kernel.org>
Cc: Joe Burmeister <joe.burmeister@devtank.co.uk>,
Florian Fainelli <f.fainelli@gmail.com>,
Ray Jui <rjui@broadcom.com>,
Scott Branden <sbranden@broadcom.com>,
bcm-kernel-feedback-list@broadcom.com, linux-spi@vger.kernel.org,
linux-rpi-kernel@lists.infradead.org,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org, nsaenz@kernel.org,
phil@raspberrypi.com
Subject: Re: [PATCH] spi: bcm2835: Fix buffer overflow with CS able to go beyond limit.
Date: Sat, 1 May 2021 21:51:35 +0200 [thread overview]
Message-ID: <20210501195135.GA18501@wunner.de> (raw)
In-Reply-To: <20210423162055.GE5507@sirena.org.uk>
On Fri, Apr 23, 2021 at 05:20:55PM +0100, Mark Brown wrote:
> Part of the issue here is that there has been some variation in how
> num_chipselect is interpreted with regard to GPIO based chip selects
> over time. It *should* be redundant, I'm not clear why it's in the
> generic bindings at all but that's lost to history AFAICT.
It seems num_chipselect is meant to be set to the maximum number of
*native* chipselects supported by the controller. Which is overwritten
if GPIO chipselects are used.
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.
> The best thing would be to have it not have a single array of chip
> select specific data and instead store everything in the controller_data
> that's there per-device.
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.
The Foundation's downstream kernel now contains a bandaid commit which
raises the limit to 24 and errors out of ->probe if the limit is exceeded.
I would have preferred if it errored out of ->setup. That way only
the slaves exceeding the limit would fail to instantiate:
https://github.com/raspberrypi/linux/commit/05f8d5826e28
Thoughts?
Lukas
next prev parent reply other threads:[~2021-05-01 19:52 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-04-20 8:34 [PATCH] spi: bcm2835: Fix buffer overflow with CS able to go beyond limit Joe Burmeister
2021-04-22 16:42 ` Mark Brown
2021-04-22 16:50 ` Florian Fainelli
2021-04-22 20:10 ` Joe Burmeister
2021-04-22 23:49 ` Florian Fainelli
2021-04-23 10:03 ` Joe Burmeister
2021-04-23 11:57 ` Mark Brown
2021-04-23 14:12 ` Joe Burmeister
2021-04-23 16:20 ` Mark Brown
2021-04-23 17:34 ` Nicolas Saenz Julienne
2021-05-01 19:51 ` Lukas Wunner [this message]
2021-05-04 11:51 ` Mark Brown
2021-05-04 13:53 ` Lukas Wunner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210501195135.GA18501@wunner.de \
--to=lukas@wunner.de \
--cc=bcm-kernel-feedback-list@broadcom.com \
--cc=broonie@kernel.org \
--cc=f.fainelli@gmail.com \
--cc=joe.burmeister@devtank.co.uk \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rpi-kernel@lists.infradead.org \
--cc=linux-spi@vger.kernel.org \
--cc=nsaenz@kernel.org \
--cc=phil@raspberrypi.com \
--cc=rjui@broadcom.com \
--cc=sbranden@broadcom.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).