firmware: arm_scmi: Harden shared memory access in fetch_response
authorCristian Marussi <cristian.marussi@arm.com>
Thu, 22 Dec 2022 18:38:20 +0000 (18:38 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 1 Feb 2023 07:34:05 +0000 (08:34 +0100)
commit3463203d109608f24b75b24c90db260c7c192064
treedc44a9e7b23c120e4b0e07d314df875a30899f8b
parentb7863ef8a8f0fee96b4eb41211f4918c0e047253
firmware: arm_scmi: Harden shared memory access in fetch_response

[ Upstream commit ad78b81a1077f7d956952cd8bdfe1e61504e3eb8 ]

A misbheaving SCMI platform firmware could reply with out-of-spec messages,
shorter than the mimimum size comprising a header and a status field.

Harden shmem_fetch_response to properly truncate such a bad messages.

Fixes: 5c8a47a5a91d ("firmware: arm_scmi: Make scmi core independent of the transport type")
Signed-off-by: Cristian Marussi <cristian.marussi@arm.com>
Link: https://lore.kernel.org/r/20221222183823.518856-3-cristian.marussi@arm.com
Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/firmware/arm_scmi/shmem.c