• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2022 Huawei Technologies Co., Ltd.
3  * Licensed under the Mulan PSL v2.
4  * You can use this software according to the terms and conditions of the Mulan PSL v2.
5  * You may obtain a copy of Mulan PSL v2 at:
6  *     http://license.coscl.org.cn/MulanPSL2
7  * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
8  * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
9  * PURPOSE.
10  * See the Mulan PSL v2 for more details.
11  */
12 
13 #include "drvcall_dyn_conf_mgr.h"
14 #include <tee_log.h>
15 #include <libdrv_frame.h>
16 #include <tee_mem_mgmt_api.h>
17 #include <ipclib.h>
18 #include <ta_framework.h>
19 #include <dyn_conf_dispatch_inf.h>
20 #include <drv_thread.h>
21 #include "drv_fd_ops.h"
22 #include "drv_param_ops.h"
23 #include "task_mgr.h"
24 
receive_perm_apply_list(struct drvcall_perm_apply_t * drvcall_perm_apply)25 int32_t receive_perm_apply_list(struct drvcall_perm_apply_t *drvcall_perm_apply)
26 {
27     if (drvcall_perm_apply == NULL) {
28         tloge("invalid drvcall perm param\n");
29         return -1;
30     }
31 
32     if (drvcall_perm_apply->base_perm)
33         return TEE_SUCCESS;
34 
35     if (drvcall_perm_apply->drvcall_perm_apply_list_size == 0 ||
36         drvcall_perm_apply->drvcall_perm_apply_list_size >= MAX_IMAGE_LEN) {
37         tloge("invalied params while receive perm apply list\n");
38         return TEE_ERROR_BAD_PARAMETERS;
39     }
40 
41     /* drvcall_perm_apply->drvcall_perm_apply_list_size < MAX_IMAGE_LEN means tmp_size cannot larger than 0xFFFFFFFF */
42     uint32_t tmp_size = drvcall_perm_apply->drvcall_perm_apply_list_size * sizeof(struct drvcall_perm_apply_item_t);
43     struct drvcall_perm_apply_item_t *drvcall_perm_apply_list = malloc(tmp_size);
44     if (drvcall_perm_apply_list == NULL) {
45         tloge("malloc drvcall_perm_apply_list failed\n");
46         return TEE_ERROR_GENERIC;
47     }
48 
49     if (copy_from_client((uint64_t)(uintptr_t)drvcall_perm_apply->drvcall_perm_apply_list, tmp_size,
50                          (uintptr_t)drvcall_perm_apply_list, tmp_size) != 0) {
51         tloge("copy_from_client drvcall_perm_apply_list failed\n");
52         free(drvcall_perm_apply_list);
53         return TEE_ERROR_GENERIC;
54     }
55 
56     drvcall_perm_apply->drvcall_perm_apply_list = drvcall_perm_apply_list;
57 
58     return TEE_SUCCESS;
59 }
60