linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Cristian Marussi <cristian.marussi@arm.com>
To: Dan Carpenter <dan.carpenter@linaro.org>
Cc: Cristian Marussi <cristian.marussi@arm.com>,
	"Peng Fan (OSS)" <peng.fan@oss.nxp.com>,
	Sudeep Holla <sudeep.holla@arm.com>,
	Shawn Guo <shawnguo@kernel.org>,
	Sascha Hauer <s.hauer@pengutronix.de>,
	Pengutronix Kernel Team <kernel@pengutronix.de>,
	Fabio Estevam <festevam@gmail.com>,
	linux-kernel@vger.kernel.org, arm-scmi@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org, imx@lists.linux.dev,
	Peng Fan <peng.fan@nxp.com>
Subject: Re: [PATCH 2/5] firmware: arm_scmi: imx: Add i.MX95 CPU Protocol
Date: Wed, 22 Jan 2025 12:55:45 +0000	[thread overview]
Message-ID: <Z5Dq0Yb6wsIJQYF4@pluto> (raw)
In-Reply-To: <ac1a1ebe-ef97-42a2-a2be-529a656a7706@stanley.mountain>

On Wed, Jan 22, 2025 at 03:41:41PM +0300, Dan Carpenter wrote:
> On Wed, Jan 22, 2025 at 12:22:18PM +0000, Cristian Marussi wrote:
> > > > +struct scmi_msg_imx_cpu_attributes_out {
> > > > +	__le32 attributes;
> > > > +#define	CPU_MAX_NAME	16
> > > > +	u8 name[CPU_MAX_NAME];
> > > 
> > > char is always unsigned in the kernel these days but strings should
> > > still always be char.  Same thing in patch 1, there were a couple u8
> > > names.
> > > 
> > 

Hi Dan,

> > While it is certainly true that char is the way to go for strings and, as
> > such, it is used elsewhere to hold the resource names across all SCMI
> > protocols, in this context it is a field of structure representing
> > exactly the layout of message reply coming from the server, and defined
> > in the SCMI spec as a uint8 array, so, we have generally preferred to
> > used u8 to represent such fixed size array all across the SCMI stack
> > protocols implementation....
> > 
> > .... not saying that it is necessarily completelt right, but that is the
> > reason we are guilty :D
> 
> Fine.  I don't have intense emotions about this.
> 
> It does slightly bother me when we assume that the SCMI server NUL
> terminates these when we do things like:
> 
> 	dev_info(ph->dev, "i.MX CPU: name: %s\n", out->name);
> 

Hang on...I have not really done a proper review still on this series...
...and this printout above straight out of the message payload seems very
wrong to me too..

> But from a practical perspective we have to trust the SCMI server.
>

....nope we should NEVER trust the server...and instead assume it can
kill us (kernel) all the time :P

...despite what the spec says, we tend to assume tha the server can be
maliciously wrong (or just crappy), so in other protocols where we do used
an u8[] to describe the resource name field in a message, we have also always
(hopefully :D) taken care to use it ONLY after having processed that field like...

   strscpy(dom_info->name, attr->name, SCMI_SHORT_NAME_MAX_SIZE);

...to remove any possible bad outcome from a misbehaving SCMI fw server.

Thanks,
Cristian


  reply	other threads:[~2025-01-22 12:59 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-01-21 15:08 [PATCH 0/5] firmware: scmi/imx: Add i.MX95 LMM/CPU Protocol Peng Fan (OSS)
2025-01-21 15:08 ` [PATCH 1/5] firmware: arm_scmi: imx: Add i.MX95 LMM protocol Peng Fan (OSS)
2025-01-24  2:43   ` kernel test robot
2025-01-21 15:08 ` [PATCH 2/5] firmware: arm_scmi: imx: Add i.MX95 CPU Protocol Peng Fan (OSS)
2025-01-22  8:48   ` Dan Carpenter
2025-01-22 12:22     ` Cristian Marussi
2025-01-22 12:41       ` Dan Carpenter
2025-01-22 12:55         ` Cristian Marussi [this message]
2025-01-22 13:59         ` Sudeep Holla
2025-01-24  4:11   ` kernel test robot
2025-01-21 15:08 ` [PATCH 3/5] firmware: arm_scmi: imx: Add LMM and CPU documentation Peng Fan (OSS)
2025-01-22 12:14   ` Sudeep Holla
2025-01-23  1:30     ` Peng Fan
2025-02-25 10:21       ` Sudeep Holla
2025-02-25 12:42         ` Peng Fan
2025-02-25 11:49           ` Sudeep Holla
2025-02-26  3:11             ` Peng Fan
2025-01-21 15:08 ` [PATCH 4/5] firmware: imx: Add i.MX95 SCMI LMM driver Peng Fan (OSS)
2025-01-21 15:08 ` [PATCH 5/5] firmware: imx: Add i.MX95 SCMI CPU driver Peng Fan (OSS)
2025-01-21 15:31 ` [PATCH 0/5] firmware: scmi/imx: Add i.MX95 LMM/CPU Protocol Cristian Marussi
2025-01-22  5:31   ` Peng Fan
2025-01-25  1:00 ` Peng Fan
2025-02-06  2:40 ` Peng Fan

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=Z5Dq0Yb6wsIJQYF4@pluto \
    --to=cristian.marussi@arm.com \
    --cc=arm-scmi@vger.kernel.org \
    --cc=dan.carpenter@linaro.org \
    --cc=festevam@gmail.com \
    --cc=imx@lists.linux.dev \
    --cc=kernel@pengutronix.de \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=peng.fan@nxp.com \
    --cc=peng.fan@oss.nxp.com \
    --cc=s.hauer@pengutronix.de \
    --cc=shawnguo@kernel.org \
    --cc=sudeep.holla@arm.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).