From c529d393a50dcc795bff368ab32dcde8574b815f Mon Sep 17 00:00:00 2001 From: chen zheng Date: Fri, 3 Nov 2023 11:42:56 +0800 Subject: [PATCH] change agent buffer in ccos --- core/agent.c | 4 +++- core/tc_client_driver.c | 20 ++++++++++++++++++-- tc_ns_client.h | 4 ++++ 3 files changed, 25 insertions(+), 3 deletions(-) diff --git a/core/agent.c b/core/agent.c index cae297b..5918a8d 100644 --- a/core/agent.c +++ b/core/agent.c @@ -53,6 +53,7 @@ #include "ko_adapt.h" #include "internal_functions.h" #include "auth_base_impl.h" +#include "tee_compat_check.h" #ifdef CONFIG_CMS_CAHASH_AUTH #define HASH_FILE_MAX_SIZE CONFIG_HASH_FILE_SIZE @@ -808,8 +809,9 @@ err_out: static bool is_valid_agent(unsigned int agent_id, unsigned int buffer_size, bool user_agent) { + unsigned int agent_buffer_threshold = is_ccos() ? SZ_512K : SZ_4K; (void)agent_id; - if (user_agent && (buffer_size > SZ_4K)) { + if (user_agent && (buffer_size > agent_buffer_threshold)) { tloge("size: %u of user agent's shared mem is invalid\n", buffer_size); return false; diff --git a/core/tc_client_driver.c b/core/tc_client_driver.c index efe4906..3100399 100644 --- a/core/tc_client_driver.c +++ b/core/tc_client_driver.c @@ -92,7 +92,7 @@ #endif #include "tee_info.h" - +#include "tee_compat_check.h" static struct class *g_driver_class; static struct device_node *g_dev_node; @@ -700,6 +700,19 @@ static int ioctl_check_agent_owner(const struct tc_ns_dev_file *dev_file, return 0; } +static int ioctl_check_is_ccos(void __user *argp) +{ + int ret = 0; + unsigned int check_ccos = is_ccos() ? 1 : 0; + if (!argp) { + tloge("error input parameter\n"); + return -EINVAL; + } + if (copy_to_user(argp, &check_ccos, sizeof(unsigned int)) != 0) + ret = -EFAULT; + return ret; +} + /* ioctls for the secure storage daemon */ int public_ioctl(const struct file *file, unsigned int cmd, unsigned long arg, bool is_from_client_node) { @@ -738,8 +751,11 @@ int public_ioctl(const struct file *file, unsigned int cmd, unsigned long arg, b case TC_NS_CLIENT_IOCTL_LOAD_APP_REQ: ret = tc_ns_load_secfile(file->private_data, argp, NULL, is_from_client_node); break; + case TC_NS_CLIENT_IOCTL_CHECK_CCOS: + ret = ioctl_check_is_ccos(argp); + break; default: - tloge("invalid cmd!"); + tloge("invalid cmd! 0x%x", cmd); return ret; } tlogd("client ioctl ret = 0x%x\n", ret); diff --git a/tc_ns_client.h b/tc_ns_client.h index bb66146..1152a32 100644 --- a/tc_ns_client.h +++ b/tc_ns_client.h @@ -209,4 +209,8 @@ struct tc_ns_log_pool { #endif #define TC_NS_CLIENT_IOCTL_GET_TEE_INFO \ _IOWR(TC_NS_CLIENT_IOC_MAGIC, 26, struct tc_ns_tee_info) + +#define TC_NS_CLIENT_IOCTL_CHECK_CCOS \ + _IOWR(TC_NS_CLIENT_IOC_MAGIC, 32, unsigned int) + #endif -- Gitee