mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] soc: qcom: smd-rpm: Avoid out-of-bounds write on empty error message
@ 2026-11-18 12:49 Sneh Mankad
  2026-11-30  6:21 ` Maulik Shah
  0 siblings, 1 reply; 2+ messages in thread
From: Sneh Mankad @ 2026-11-18 12:49 UTC (permalink / raw)
  To: Bjorn Andersson, Konrad Dybcio, Abel Vesa, Andy Gross
  Cc: linux-arm-msm, linux-kernel, Sneh Mankad

For an error response the RPM driver copies the error string from IO
memory into a fixed size stack buffer and NUL terminates it at
msgbuf[len - 1].

The copy length is derived from the message length advertised by the
RPM firmware, so a message that carries no payload leaves len at zero
and the NUL termination writes one byte before the buffer.

Treat such a message as an error without inspecting its payload.

Fixes: 936f14cf4e67 ("soc: qcom: Driver for the Qualcomm RPM over SMD")
Signed-off-by: Sneh Mankad <sneh.mankad@oss.qualcomm.com>
---
 drivers/soc/qcom/smd-rpm.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/drivers/soc/qcom/smd-rpm.c b/drivers/soc/qcom/smd-rpm.c
index 7037d9845d98a2859c9c368e9737e73622b08277..1ab615080ed4b4a00212faaedfc27a8e54bad018 100644
--- a/drivers/soc/qcom/smd-rpm.c
+++ b/drivers/soc/qcom/smd-rpm.c
@@ -174,6 +174,11 @@ static int qcom_smd_rpm_callback(struct rpmsg_device *rpdev,
 			break;
 		case RPM_MSG_TYPE_ERR:
 			len = min_t(u32, ALIGN(msg_length, 4), sizeof(msgbuf));
+			if (!len) {
+				status = -EINVAL;
+				break;
+			}
+
 			memcpy_fromio(msgbuf, msg->message, len);
 			msgbuf[len - 1] = 0;
 

---
base-commit: 20eef29b7c8465ac98d7dd6d6f2ac07a8d8056ca
change-id: 20261118-smd_rpm_oob_fix-124d19996e86

Best regards,
-- 
Sneh Mankad <sneh.mankad@oss.qualcomm.com>


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-11-30  6:21 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-18 12:49 [PATCH] soc: qcom: smd-rpm: Avoid out-of-bounds write on empty error message Sneh Mankad
2026-11-30  6:21 ` Maulik Shah

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®