Re: [PATCH v3 9/9] firmware: arm_scmi: Validate PCC shared memory signature

Jonathan Cameron <[email protected]>
Newsgroups org.infradead.lists.linux-arm-kernel,org.kernel.vger.arm-scmi
Organization Qualcomm
Message-ID <[email protected]>
On Thu, 13 Aug 2026 12:33:04 +0100
Sudeep Holla <[email protected]> wrote:

> Validate the PCC shared memory signature when setting up an SCMI PCC
> channel.
> 
> Reject channels whose shared memory signature does not encode
> PCC_SIGNATURE combined with the PCC subspace ID, so misconfigured
> firmware is caught before the transport starts using the shared memory
> region.
> 
> Signed-off-by: Sudeep Holla <[email protected]>
Interesting there aren't more checks on this in the various PCC users.
Question for another day perhaps.

Seems correct to me.

Reviewed-by: Jonathan Cameron <[email protected]>

> ---
>  drivers/firmware/arm_scmi/transports/pcc.c | 12 ++++++++++--
>  1 file changed, 10 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/firmware/arm_scmi/transports/pcc.c b/drivers/firmware/arm_scmi/transports/pcc.c
> index 337d551e3ad8..0ead0ec77162 100644
> --- a/drivers/firmware/arm_scmi/transports/pcc.c
> +++ b/drivers/firmware/arm_scmi/transports/pcc.c
> @@ -623,8 +623,11 @@ static void rx_callback(struct mbox_client *cl, void *m)
>  }
>  
>  static int pcc_chan_validate_shmem(struct scmi_chan_info *cinfo,
> -				   struct scmi_pcc *smbox)
> +				   struct scmi_pcc *smbox, int ss_id)
>  {
> +	struct pcc_shared_mem __iomem *shmem = smbox->pchan->shmem;
> +	u32 valid_signature = ss_id + PCC_SIGNATURE;
> +
>  	if (smbox->pchan->shmem_size < SCMI_PCC_SHMEM_OVERHEAD ||
>  	    smbox->pchan->shmem_size - SCMI_PCC_SHMEM_OVERHEAD <
>  	    cinfo->max_msg_size) {
> @@ -632,6 +635,11 @@ static int pcc_chan_validate_shmem(struct scmi_chan_info *cinfo,
>  		return -ENOSPC;
>  	}
>  
> +	if (ioread32(&shmem->header.signature) != valid_signature) {
> +		dev_err(cinfo->dev, "invalid PCC shared memory signature\n");
> +		return -EINVAL;
> +	}
> +
>  	return 0;
>  }
>  
> @@ -667,7 +675,7 @@ static int pcc_chan_setup(struct scmi_chan_info *cinfo, struct device *dev,
>  		return ret;
>  	}
>  
> -	ret = pcc_chan_validate_shmem(cinfo, smbox);
> +	ret = pcc_chan_validate_shmem(cinfo, smbox, ss_id);
>  	if (ret) {
>  		pcc_mbox_free_channel(smbox->pchan);
>  		return ret;
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.