| From f173e99554512c982665c1d5d4b0543421177b09 Mon Sep 17 00:00:00 2001 |
| From: Imre Kis <imre.kis@arm.com> |
| Date: Tue, 26 Jul 2022 17:06:46 +0200 |
| Subject: [PATCH 24/24] Deny 64 bit FF-A messages in FF-A RPC endpoint |
| |
| FF-A RPC protocol only allows 32 bit FF-A direct messages thus deny all |
| 64 bit messages in the RPC endpoint. |
| |
| Signed-off-by: Imre Kis <imre.kis@arm.com> |
| Change-Id: I37c95425f80b6e2821b3f6b8649ceba8aa007bce |
| |
| Upstream-Status: Pending [In review] |
| Signed-off-by: Anton Antonov <Anton.Antonov@arm.com> |
| |
| --- |
| .../rpc/ffarpc/endpoint/ffarpc_call_ep.c | 31 ++++++++++++------- |
| 1 file changed, 20 insertions(+), 11 deletions(-) |
| |
| diff --git a/components/rpc/ffarpc/endpoint/ffarpc_call_ep.c b/components/rpc/ffarpc/endpoint/ffarpc_call_ep.c |
| index c024196..3035c16 100644 |
| --- a/components/rpc/ffarpc/endpoint/ffarpc_call_ep.c |
| +++ b/components/rpc/ffarpc/endpoint/ffarpc_call_ep.c |
| @@ -12,6 +12,7 @@ |
| #include <protocols/rpc/common/packed-c/status.h> |
| #include <trace.h> |
| #include <stddef.h> |
| +#include <string.h> |
| |
| /* TODO: remove this when own ID will be available in libsp */ |
| extern uint16_t own_id; |
| @@ -260,17 +261,25 @@ void ffa_call_ep_receive(struct ffa_call_ep *call_ep, |
| const struct sp_msg *req_msg, |
| struct sp_msg *resp_msg) |
| { |
| - const uint32_t *req_args = req_msg->args.args32; |
| - uint32_t *resp_args = resp_msg->args.args32; |
| - |
| - uint16_t source_id = req_msg->source_id; |
| - uint32_t ifaceid_opcode = req_args[SP_CALL_ARGS_IFACE_ID_OPCODE]; |
| - |
| - if (FFA_CALL_ARGS_EXTRACT_IFACE(ifaceid_opcode) == FFA_CALL_MGMT_IFACE_ID) { |
| - /* It's an RPC layer management request */ |
| - handle_mgmt_msg(call_ep, source_id, req_args, resp_args); |
| + resp_msg->is_64bit_message = req_msg->is_64bit_message; |
| + memset(&resp_msg->args, 0x00, sizeof(resp_msg->args)); |
| + |
| + if (!req_msg->is_64bit_message) { |
| + const uint32_t *req_args = req_msg->args.args32; |
| + uint32_t *resp_args = resp_msg->args.args32; |
| + uint16_t source_id = req_msg->source_id; |
| + uint32_t ifaceid_opcode = req_args[SP_CALL_ARGS_IFACE_ID_OPCODE]; |
| + |
| + if (FFA_CALL_ARGS_EXTRACT_IFACE(ifaceid_opcode) == FFA_CALL_MGMT_IFACE_ID) { |
| + /* It's an RPC layer management request */ |
| + handle_mgmt_msg(call_ep, source_id, req_args, resp_args); |
| + } else { |
| + /* Assume anything else is a service request */ |
| + handle_service_msg(call_ep, source_id, req_args, resp_args); |
| + } |
| } else { |
| - /* Assume anything else is a service request */ |
| - handle_service_msg(call_ep, source_id, req_args, resp_args); |
| + EMSG("64 bit FF-A messages are not supported by the TS RPC layer"); |
| + resp_msg->args.args64[SP_CALL_ARGS_RESP_RPC_STATUS] = |
| + TS_RPC_ERROR_INVALID_PARAMETER; |
| } |
| } |
| -- |
| 2.17.1 |
| |