Skip to content

Commit ddfade8

Browse files
Dan Carpentersudeep-holla
authored andcommitted
firmware: arm_ffa: Fix memory corruption in ffa_msg_send2()
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: 02c19d8 ("firmware: arm_ffa: Add support for FFA_MSG_SEND2") Signed-off-by: Dan Carpenter <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Sudeep Holla <[email protected]>
1 parent 02c19d8 commit ddfade8

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/firmware/arm_ffa/driver.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,7 @@ static int ffa_msg_send2(u16 src_id, u16 dst_id, void *buf, size_t sz)
363363
msg->offset = sizeof(*msg);
364364
msg->send_recv_id = src_dst_ids;
365365
msg->size = sz;
366-
memcpy(msg + msg->offset, buf, sz);
366+
memcpy((u8 *)msg + msg->offset, buf, sz);
367367

368368
/* flags = 0, sender VMID = 0 works for both physical/virtual NS */
369369
invoke_ffa_fn((ffa_value_t){

0 commit comments

Comments
 (0)