From: "Clément Le Goffic" <clegoffic@baylibre.com>
To: Cristian Marussi <cristian.marussi@arm.com>
Cc: Sudeep Holla <sudeep.holla@kernel.org>,
Linus Walleij <linusw@kernel.org>, Peng Fan <peng.fan@nxp.com>,
Oleksii Moisieiev <oleksii_moisieiev@epam.com>,
Andy Shevchenko <andy@kernel.org>, Dhruva Gole <d-gole@ti.com>,
Bartosz Golaszewski <brgl@kernel.org>,
arm-scmi@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 05/11] firmware: arm_scmi: stop reading past PINCTRL_LIST_ASSOCIATIONS replies
Date: Tue, 10 Nov 2026 15:44:10 +0100 [thread overview]
Message-ID: <9ab69228-a9f7-442b-9a2a-2e012f37668e@baylibre.com> (raw)
In-Reply-To: <avLxpUd6cXuqUCbd@pluto>
Hi Cristian,
On 11/10/26 11:27 AM, Cristian Marussi wrote:
> On Fri, Oct 30, 2026 at 04:58:36PM +0100, Clément Le Goffic wrote:
>> The transport cuts a reply larger than the receive buffer, but the iterator
>> still reads every identifier the reply announces. Use only the identifiers
>> that were copied and ask again for the others.
>
> Hi Clement,
>
> thanks for these fixes...I'll start from this since it really intersects
> my current work....
>
>>
>> Fixes: 2145af01b9cb ("firmware: arm_scmi: Add basic support for SCMI v3.2 pincontrol protocol")
>> Signed-off-by: Clément Le Goffic <clegoffic@baylibre.com>
>> ---
>> drivers/firmware/arm_scmi/pinctrl.c | 12 ++++++++++++
>> 1 file changed, 12 insertions(+)
>>
>> diff --git a/drivers/firmware/arm_scmi/pinctrl.c b/drivers/firmware/arm_scmi/pinctrl.c
>> index 42cb1aef1fe1..69645ce73d9d 100644
>> --- a/drivers/firmware/arm_scmi/pinctrl.c
>> +++ b/drivers/firmware/arm_scmi/pinctrl.c
>> @@ -261,10 +261,22 @@ static int iter_pinctrl_assoc_update_state(struct scmi_iterator_state *st,
>> const void *response, void *priv)
>> {
>> const struct scmi_resp_pinctrl_list_assoc *r = response;
>> + unsigned int nr_fit = 0;
>>
>> st->num_returned = RETURNED(r->flags);
>> st->num_remaining = REMAINING(r->flags);
>>
>> + if (st->rx_len > sizeof(*r))
>> + nr_fit = (st->rx_len - sizeof(*r)) / sizeof(r->array[0]);
>
> As Sashiko kindly pointed out to me a few other zillion times O_o in my
> Telemetry series, there were a couple of missing sanity checks in the
> iterators core so in my last series there is upfront a generic fix
>
> https://lore.kernel.org/arm-scmi/avLTkAtQQSzpgu2A@pluto/T/#me258191dd55db99d53b570be7c51901c31bc70cf
>
> ...so we could at least avoid to check here and everywhere else in SCMI
> iterators that you have at least a minimum size messages to work on.
>
>> +
>> + if (st->num_returned > nr_fit) {
>> + if (!nr_fit)
>> + return -EPROTO;
>
> My core fix above will discard the iteration upfront in an equivalent way
> to this check togateher with the rx_len check above If I get this wrong...BUT..
Right, v2 keeps only your check below
>
>> +
>> + st->num_remaining += st->num_returned - nr_fit;
>> + st->num_returned = nr_fit;
>
> ...why are you fixing and carry on ?
> I dont feel that you can safely proceed at this point by just fixing the
> returned and the remaining...
Each request carries the index to restart from, so it stays in sync but it hides the DT misconfiguration
>
> ...the check is of course needed, but it should be an hard check
>
> if (st->rx_len < (sizeof(*r) + sizeof(r->array[0]) * st->num_returned))
> return -EINVAL;
>
> ...because something is clearly wrong...indeed, learning from my current
> telemetry madness the above scenario could be due not only to a buggy FW
> BUT more easily to a misconfigured transport...if the transport size is
> misconfigured (as it is mostly NOT negotiated, simply configured) any
> message long enough will be silently truncated, so the fact especially
> that you guess remaining it can happen to be completely out of sync with
> the platform side...
I've seen your serie but didn't check such details. I'll use this hard check in the v2.
>
> Are you fixing an existent known FW bug here ? in that case I would opt
> for a quirk...
No firmware bug, just the DT that had no arm,max-msg-size. Linux was using its default value that was not sync with my SCMI server value.
Setting it fixed it, no quirk needed.
Best regards,
Clément
next prev parent reply other threads:[~2026-11-10 14:44 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-30 15:58 [PATCH 00/11] pinctrl: scmi: fixes and GPIO function support Clément Le Goffic
2026-10-30 15:58 ` [PATCH 01/11] pinctrl: scmi: send the drive strength in microamperes Clément Le Goffic
2026-11-10 11:01 ` Cristian Marussi
2026-10-30 15:58 ` [PATCH 02/11] pinctrl: scmi: map the schmitt trigger enable to its SCMI type Clément Le Goffic
2026-11-10 11:04 ` Cristian Marussi
2026-10-30 15:58 ` [PATCH 03/11] pinctrl: scmi: send the settings without argument as enabled Clément Le Goffic
2026-11-10 11:05 ` Cristian Marussi
2026-10-30 15:58 ` [PATCH 04/11] pinctrl: scmi: report an off setting as not set Clément Le Goffic
2026-11-03 11:38 ` Andy Shevchenko
2026-11-04 9:32 ` Clément Le Goffic
2026-11-10 11:24 ` Cristian Marussi
2026-11-10 14:47 ` Clément Le Goffic
2026-11-10 15:35 ` Cristian Marussi
2026-10-30 15:58 ` [PATCH 05/11] firmware: arm_scmi: stop reading past PINCTRL_LIST_ASSOCIATIONS replies Clément Le Goffic
2026-11-10 10:27 ` Cristian Marussi
2026-11-10 14:44 ` Clément Le Goffic [this message]
2026-10-30 15:58 ` [PATCH 06/11] firmware: arm_scmi: report the pin-only and GPIO flags of functions Clément Le Goffic
2026-10-30 15:58 ` [PATCH 07/11] pinctrl: scmi: give no groups to pin-only functions Clément Le Goffic
2026-11-10 11:48 ` Cristian Marussi
2026-10-30 15:58 ` [PATCH 08/11] pinctrl: scmi: mark the GPIO functions Clément Le Goffic
2026-11-10 13:16 ` Cristian Marussi
2026-10-30 15:58 ` [PATCH 09/11] pinctrl: scmi: report whether a function is GPIO Clément Le Goffic
2026-10-30 15:58 ` [PATCH 10/11] firmware: arm_scmi: add an operation to set the function of a single pin Clément Le Goffic
2026-11-10 13:20 ` Cristian Marussi
2026-10-30 15:58 ` [PATCH 11/11] pinctrl: scmi: select the GPIO function on GPIO requests Clément Le Goffic
2026-11-03 11:41 ` Andy Shevchenko
2026-11-04 9:38 ` Clément Le Goffic
2026-11-04 10:55 ` Andy Shevchenko
2026-11-05 12:58 ` Clément Le Goffic
2026-11-10 13:49 ` Cristian Marussi
2026-11-10 14:09 ` Andy Shevchenko
2026-11-10 14:45 ` Clément Le Goffic
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=9ab69228-a9f7-442b-9a2a-2e012f37668e@baylibre.com \
--to=clegoffic@baylibre.com \
--cc=andy@kernel.org \
--cc=arm-scmi@vger.kernel.org \
--cc=brgl@kernel.org \
--cc=cristian.marussi@arm.com \
--cc=d-gole@ti.com \
--cc=linusw@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=oleksii_moisieiev@epam.com \
--cc=peng.fan@nxp.com \
--cc=sudeep.holla@kernel.org \
/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
all inboxes | Powered by JetHome®