* [PATCH] firmware: arm_ffa: fix memory corruption in ffa_msg_send2()
@ 2024-04-24 11:40 Dan Carpenter
2024-04-25 11:14 ` Sudeep Holla
0 siblings, 1 reply; 2+ messages in thread
From: Dan Carpenter @ 2024-04-24 11:40 UTC (permalink / raw)
To: Sudeep Holla; +Cc: linux-arm-kernel, linux-kernel, kernel-janitors
The "msg" pointer is a struct and msg->offset is the sizeof(*msg). The
pointer here math means the memcpy() will write outside the bounds.
Cast "msg" to a u8 pointer to fix this.
Fixes: 02c19d84c7c5 ("firmware: arm_ffa: Add support for FFA_MSG_SEND2")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
---
drivers/firmware/arm_ffa/driver.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/firmware/arm_ffa/driver.c b/drivers/firmware/arm_ffa/driver.c
index 9f89ee0aaa6b..363e86936461 100644
--- a/drivers/firmware/arm_ffa/driver.c
+++ b/drivers/firmware/arm_ffa/driver.c
@@ -363,7 +363,7 @@ static int ffa_msg_send2(u16 src_id, u16 dst_id, void *buf, size_t sz)
msg->offset = sizeof(*msg);
msg->send_recv_id = src_dst_ids;
msg->size = sz;
- memcpy(msg + msg->offset, buf, sz);
+ memcpy((u8 *)msg + msg->offset, buf, sz);
/* flags = 0, sender VMID = 0 works for both physical/virtual NS */
invoke_ffa_fn((ffa_value_t){
--
2.43.0
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] firmware: arm_ffa: fix memory corruption in ffa_msg_send2()
2024-04-24 11:40 [PATCH] firmware: arm_ffa: fix memory corruption in ffa_msg_send2() Dan Carpenter
@ 2024-04-25 11:14 ` Sudeep Holla
0 siblings, 0 replies; 2+ messages in thread
From: Sudeep Holla @ 2024-04-25 11:14 UTC (permalink / raw)
To: Dan Carpenter
Cc: Sudeep Holla, linux-arm-kernel, linux-kernel, kernel-janitors
On Wed, 24 Apr 2024 14:40:43 +0300, Dan Carpenter wrote:
> The "msg" pointer is a struct and msg->offset is the sizeof(*msg). The
> pointer here math means the memcpy() will write outside the bounds.
> Cast "msg" to a u8 pointer to fix this.
>
Applied to sudeep.holla/linux (for-next/ffa/updates), thanks!
[1/1] firmware: arm_ffa: fix memory corruption in ffa_msg_send2()
https://git.kernel.org/sudeep.holla/c/ddfade88f49d
--
Regards,
Sudeep
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-04-25 11:15 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-04-24 11:40 [PATCH] firmware: arm_ffa: fix memory corruption in ffa_msg_send2() Dan Carpenter
2024-04-25 11:14 ` Sudeep Holla
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox