Skip to content

Commit 122839b

Browse files
cris-masudeep-holla
authored andcommitted
firmware: arm_scmi: Relax base protocol sanity checks on the protocol list
Even though malformed replies from firmware must be treated carefully to avoid memory corruption in the kernel, some out-of-spec SCMI replies can be tolerated to avoid breaking existing deployed system, as long as they won't cause memory issues. Relax the sanity checks on the recieved protocol list in the base protocol to avoid breaking one of the deployed platform whose firmware is not easily upgradable currently. Link: https://lore.kernel.org/r/[email protected] Cc: Etienne Carriere <[email protected]> Cc: Sudeep Holla <[email protected]> Reported-by: Nicolas Frattaroli <[email protected]> Tested-By: Frank Wunderlich <[email protected]> Acked-by: Michael Riesch <[email protected]> Acked-by: Etienne Carriere <[email protected]> Signed-off-by: Cristian Marussi <[email protected]> Signed-off-by: Sudeep Holla <[email protected]>
1 parent f2906aa commit 122839b

File tree

1 file changed

+11
-5
lines changed
  • drivers/firmware/arm_scmi

1 file changed

+11
-5
lines changed

drivers/firmware/arm_scmi/base.c

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -221,11 +221,17 @@ scmi_base_implementation_list_get(const struct scmi_protocol_handle *ph,
221221
calc_list_sz = (1 + (loop_num_ret - 1) / sizeof(u32)) *
222222
sizeof(u32);
223223
if (calc_list_sz != real_list_sz) {
224-
dev_err(dev,
225-
"Malformed reply - real_sz:%zd calc_sz:%u\n",
226-
real_list_sz, calc_list_sz);
227-
ret = -EPROTO;
228-
break;
224+
dev_warn(dev,
225+
"Malformed reply - real_sz:%zd calc_sz:%u (loop_num_ret:%d)\n",
226+
real_list_sz, calc_list_sz, loop_num_ret);
227+
/*
228+
* Bail out if the expected list size is bigger than the
229+
* total payload size of the received reply.
230+
*/
231+
if (calc_list_sz > real_list_sz) {
232+
ret = -EPROTO;
233+
break;
234+
}
229235
}
230236

231237
for (loop = 0; loop < loop_num_ret; loop++)

0 commit comments

Comments
 (0)