System call processing method and device for trusted execution environment

By configuring the shared memory area and IO request queue outside the trusted execution environment to process system call requests, the problem of long OCall time-consuming is solved and the performance of the application is improved.

CN114661380BActive Publication Date: 2024-10-01ALIPAY (HANGZHOU) INFORMATION TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202210396789.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-12-31
Publication Date
2024-10-01
Estimated Expiration
2040-12-31

AI Technical Summary

Technical Problem

In a trusted execution environment, system calls through OCall take a long time, resulting in a large negative impact on the performance of applications running in the Enclave.

Method used

By configuring the shared memory area and IO request queue outside the trusted execution environment, the system kernel is allowed to process system call requests and poll the processing results in the application, avoiding the direct calling process of OCall.

Benefits of technology

It improves the performance of applications in the trusted execution environment when making system calls, reduces the waste of CPU cycles, and improves overall performance.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114661380B_ABST
    Figure CN114661380B_ABST
Patent Text Reader

Abstract

In the embodiments of the present specification, a system call processing method and device for a trusted execution environment are provided. The method may include: receiving an IO type system call request initiated by an application running in a trusted execution environment. Then, the system call request is written to a shared memory area outside the trusted execution environment, and an IO request event is written to an IO request queue outside the trusted execution environment, wherein the IO request event includes a first address of the system call request in the shared memory area and a second address in the shared memory area for storing business data. In this way, the system kernel can process the system call request according to the IO request event, and write an IO completion event to an IO completion queue outside the trusted execution environment, wherein the IO completion event includes the processing result of the IO request by the system kernel. Finally, the processing result in the IO completion event is returned to at least the application in the trusted execution environment.
Need to check novelty before this filing date? Find Prior Art

Description

[0001] This application is a divisional application of the invention patent application with application number 202011638265.6 filed on December 31, 2020 and named “System call processing method and device for a trusted execution environment”. Technical Field

[0002] One or more embodiments of the present specification relate to the computer field, and in particular, to a system call processing method and apparatus for a trusted execution environment. Background Art

[0003] Software guard extensions (SGX) are a security extension of the Intel chip architecture. SGX allows applications to run in a trusted execution environment (TEE) called an enclave. An enclave is a trusted memory area. All contents in the enclave are encrypted and can only be decrypted inside the central processing unit (CPU) to provide confidentiality. In addition, the integrity of the contents in the enclave is measured to provide integrity. Based on the integrity and confidentiality provided by SGX, a TEE can be provided for applications to perform security-sensitive calculations.

[0004] Computer programs running in the Enclave are called trusted code, and computer programs running outside the Enclave are called untrusted code. Trusted code and untrusted code can call each other to implement program functions while ensuring confidential computing. Trusted code calling untrusted code is usually called OCall. Since the Enclave is in user mode, applications running in the Enclave often need to call external systems to implement program functions, that is, they need to use untrusted code to implement program functions. When an application in the Enclave makes a system call, it is necessary to perform OCall, copy the call parameters outside the Enclave, exit the Enclave through the EEXIT instruction, and then execute the system call through untrusted code. After execution, it returns to the Enclave, copies the call results to the Enclave, and provides the call results in the Enclave to the application.

[0005] It usually takes about 8300-14100 CPU cycles to perform an OCall, and about 150 CPU cycles to perform a typical system call. Therefore, it takes a lot of processing time to process system call requests initiated by applications running in a trusted execution environment through OCall. However, applications running in an enclave often need to make high-frequency system calls, so implementing system calls through OCall will have a significant negative impact on the overall performance of applications running in the enclave.

[0006] It is hoped that there will be a new technical solution to reduce OCalls when applications running in the Enclave make system calls, thereby improving the overall performance of applications running in the Enclave. Summary of the invention

[0007] One or more embodiments of the present specification provide a system call processing method and apparatus for a trusted execution environment.

[0008] In a first aspect, a system call processing method for a trusted execution environment is provided. The method can be executed by a system call processing device deployed in a trusted execution environment. The method comprises: first receiving a system call request initiated by an application running in a trusted execution environment, wherein the system call request is used to request to write business data to a target file, or to request to read business data from a target file. Then, the system call request is written to a shared memory area outside the trusted execution environment, and an IO request event is written to an IO request queue stored outside the trusted execution environment, wherein the IO request event includes a first address of the system call request in the shared memory area and a second address in the shared memory area for storing business data. In this way, the system kernel can process the system call request according to the IO request event, and write an IO completion event to an IO completion queue stored outside the trusted execution environment, wherein the IO completion event includes the processing result of the IO request by the system kernel. Finally, the processing result in the IO completion event is returned to at least the application in the trusted execution environment.

[0009] In a possible implementation, when the system call request is used to request writing business data to a target file, the method further includes: writing business data to the second address of the shared memory area according to the system call request; wherein the system kernel is specifically used to read the system call request from the first address of the shared memory area according to the IO request event, and read the business data from the second address, and write the business data to the target file according to the system call request.

[0010] In a possible implementation manner, when the system call request is used to request to read service data from a target file, the system kernel is specifically used to read the system call request from the first address of the shared memory area according to the IO request event, read the service data from the target file according to the system call request, and write the service data to the shared memory area according to the second address;

[0011] The method further includes: providing the service data in the shared memory area to the application program.

[0012] In a possible implementation, the method further includes: generating a unique identifier for the system call request, wherein the IO request event and the IO completion event further include the unique identifier; and polling the IO completion event in the IO completion queue according to the unique identifier.

[0013] In a possible implementation, before receiving a system call request initiated by an application running in a trusted execution environment, it also includes: initializing the IO request queue, the IO completion queue, and the shared memory area through a business program running outside the trusted execution environment, and triggering the system kernel to start a polling thread for polling the IO request queue.

[0014] In a possible implementation, the method further includes: obtaining configuration information for accessing the IO request queue, the IO completion queue, and the shared memory area through a service program running outside the trusted execution environment.

[0015] In a possible implementation, writing the IO request event to the IO request queue stored outside the trusted execution environment specifically includes: acquiring a thread lock for accessing the IO request queue stored outside the trusted execution environment, and writing the IO request event to the IO request queue through the thread lock.

[0016] In a possible implementation, the type of the system call request is any one of the following types: read, write, readv, writev, fsync, poll, send_msg, recv_msg, openat, close, accept, connect, epoll_ctl, send, and recv.

[0017] In a second aspect, a system call processing device for a trusted execution environment is provided, which can be deployed in a trusted execution environment. The device at least includes: a request receiving unit, which is used to receive a system call request initiated by an application running in a trusted execution environment; wherein the system call request is used to request to write business data to a target file, or to request to read business data from a target file. A data writing unit, which is used to write the system call request to a shared memory area outside the trusted execution environment, and to write an IO request event to an IO request queue stored outside the trusted execution environment; wherein the IO request event includes a first address of the system call request in the shared memory area and a second address for storing business data in the shared memory area, so that the system kernel processes the system call request according to the IO request event, and writes an IO completion event to an IO completion queue stored outside the trusted execution environment, wherein the IO completion event includes the processing result of the IO request by the system kernel. A data providing unit, which is used to provide at least the processing result in the IO completion event to the application.

[0018] In a possible implementation, when the system call request is used to request writing business data to a target file, the data writing unit is also used to write the business data to the shared memory area according to the system call request; wherein the system kernel is specifically used to read the system call request and the business data from the shared memory area according to the IO request event, and write the business data to the target file according to the system call request.

[0019] In a possible implementation manner, when the system call request is used to request to read service data from a target file, the system kernel is specifically used to read the system call request from the shared memory area according to the IO request event, read the service data from the target file according to the system call request, and write the service data to the shared memory area according to the second address;

[0020] The data providing unit is further configured to provide the service data in the shared memory area to the application program.

[0021] In a possible implementation, the device further includes: an identification management unit, configured to generate a unique identification of the system call request; wherein the IO request event and the IO completion event also include the unique identification; and a queue polling unit, configured to poll the IO completion event in the IO completion queue according to the unique identification.

[0022] In a possible implementation, the device further includes: an initialization configuration unit, configured to initialize the IO request queue, the IO completion queue, and the shared memory area by running a business program outside the trusted execution environment, and trigger the system kernel to start a polling thread for polling the IO request queue.

[0023] In a possible implementation, the initialization configuration unit is further configured to obtain configuration information for accessing the IO request queue, the IO completion queue, and the shared memory area through a service program running outside the trusted execution environment.

[0024] In a possible implementation manner, the data writing unit is specifically configured to acquire a thread lock for accessing an IO request queue stored outside the trusted execution environment, and write the IO request event to the IO request queue through the thread lock.

[0025] In a possible implementation, the type of the system call request is any one of the following types: read, write, readv, writev, fsync, poll, send_msg, recv_msg, openat, close, accept, connect, epoll_ctl, send, and recv.

[0026] In a third aspect, a system call processing method for a trusted execution environment is provided, which can be executed by a system call processing device deployed in a trusted execution environment. The method at least includes: obtaining a first address of a virtual dynamic shared object (VDSO) in a memory area outside the trusted execution environment, wherein the memory area also includes a data segment for storing a plurality of time data, and the VDSO includes a plurality of system call functions for accessing the data segment; then loading the VDSO in the trusted execution environment according to the first address, and modifying the addressing mode of the VDSO in the trusted execution environment for the data segment according to the first address and the second address of the VDSO in the trusted execution environment; finally, receiving a system call request initiated by an application in the trusted execution environment through the modified VDSO, reading the current time data from the plurality of time data stored in the data segment according to the system call request, and providing the current time data read by the application in the trusted execution environment.

[0027] In a possible implementation manner, before modifying the VDSO in the trusted execution environment, the method further includes: determining whether the VDSO in the trusted execution environment is trusted.

[0028] In a possible implementation, determining whether a VDSO in a trusted execution environment is trusted specifically includes: recursively disassembling a number of system call functions included in the VDSO in the trusted execution environment to obtain instruction sets corresponding to each of the number of system call functions; wherein, during the process of recursively disassembling any current system call function among the number of system call functions, when a current instruction obtained at a current moment satisfies any one of at least one preset condition, determining that the VDSO in the trusted execution environment is not trusted.

[0029] In a possible implementation, the at least one preset condition includes one or more of the following preset conditions: the current instruction is a control transfer instruction other than a RET instruction, the addressing mode of the current instruction is direct addressing, the current instruction is an unallowed instruction, and there is an error in the disassembly of the current instruction.

[0030] In a possible implementation, determining whether the VDSO in the trusted execution environment is trusted further includes: traversing any current instruction set in each of the instruction sets, using the instructions included in the current instruction set to construct a control flow graph with basic blocks as nodes and control transfers as edges; wherein the basic block is a group of continuous instructions with one entry and one exit. Traversing and processing the control flow graph by a predetermined algorithm to determine whether the system call function corresponding to the current instruction set is a trusted function; when there is no untrusted function, determining that the VDSO in the trusted execution environment is trusted.

[0031] In one possible implementation, the control flow graph is traversed and processed by a predetermined algorithm to determine whether the system call function corresponding to the current instruction set is a trusted function, specifically including: in the process of traversing and processing the control flow graph by a predetermined algorithm, for any current node in the control flow graph, if the stack structures of the output states of several predecessor nodes of the current node are not exactly the same, determining that the system call function corresponding to the current instruction set is an untrusted function.

[0032] In one possible implementation, the control flow graph is traversed and processed by a predetermined algorithm to determine whether the system call function corresponding to the current instruction set is a trusted function, specifically including: in the process of traversing and processing the control flow graph by a predetermined algorithm, for any current node in the control flow graph, if the memory access of the current node is illegal, determining that the system call function corresponding to the current instruction set is an untrusted function.

[0033] In a possible implementation, several system call functions included in the VDSO in the trusted execution environment are recursively disassembled, specifically including: recursively disassembling several system call functions included in the VDSO in the trusted execution environment according to address information corresponding to each of the several system call functions included in the VDSO in the trusted execution environment.

[0034] In a possible implementation, based on the first address and the second address of the VDSO in the trusted execution environment, modifying the addressing mode of the data segment by the VDSO in the trusted execution environment specifically includes: determining the address offset of the first address and the second address; writing the address offset into the FS segment register and / or the GS segment register; and modifying the addressing mode of the data segment by the VDSO in the trusted execution environment to addressing through the FS segment register or the GS segment register.

[0035] In a possible implementation, the types of the system call request include clock_gettime, gettimeofday, and time.

[0036] In a fourth aspect, a system call processing device for a trusted execution environment is provided, and the device is deployed in a trusted execution environment. The device at least includes: an information acquisition unit, which is used to obtain a first address of a VDSO in a memory area outside the trusted execution environment; wherein the memory area also includes a data segment for storing a number of time data, and the VDSO includes a number of system call functions for accessing the data segment. A loading processing unit, which is used to load the VDSO in the trusted execution environment according to the first address. A modification processing unit, which is used to modify the VDSO in the trusted execution environment according to the first address and the second address of the VDSO in the trusted execution environment; wherein the modified VDSO is specifically used to receive a system call request initiated by an application in the trusted execution environment, read the current time data from the several time data stored in the data segment according to the system call request, and provide the current time data read by the application to the application.

[0037] In a possible implementation, the system further includes: a trusted verification unit, configured to determine whether the VDSO in the trusted execution environment is trusted.

[0038] In a possible implementation, the trusted verification unit is specifically used to: recursively disassemble several system call functions included in the VDSO in the trusted execution environment to obtain instruction sets corresponding to each of the several system call functions; wherein, during the process of recursively disassembling any current system call function among the several system call functions, when the current instruction obtained at the current moment satisfies any one of at least one preset condition, it is determined that the VDSO in the trusted execution environment is untrustworthy.

[0039] In a possible implementation, the at least one preset condition includes one or more of the following preset conditions: the current instruction is a control transfer instruction other than a RET instruction, the addressing mode of the current instruction is direct addressing, the current instruction is an unallowed instruction, and there is an error in the disassembly of the current instruction.

[0040] In a possible implementation, the trusted verification unit is specifically used to traverse any current instruction set in each of the instruction sets, and use the instructions included in the current instruction set to construct a control flow graph with basic blocks as nodes and control transfers as edges, wherein the basic block is a group of continuous instructions with one entry and one exit; traverse and process the control flow graph through a predetermined algorithm to determine whether the system call function corresponding to the current instruction set is a trusted function; when there is no untrusted function, determine that the VDSO in the trusted execution environment is trusted.

[0041] In one possible implementation, the trusted verification unit is specifically used to determine that the system call function corresponding to the current instruction set is an untrusted function for any current node in the control flow graph if the stack structures of the output states of several predecessor nodes of the current node are not exactly the same during the process of traversing and processing the control flow graph through a predetermined algorithm.

[0042] In one possible implementation, the trusted verification unit is specifically used to determine that the system call function corresponding to the current instruction set is an untrusted function for any current node in the control flow graph if the memory access of the current node is illegal during the process of traversing the control flow graph through a predetermined algorithm.

[0043] In a possible implementation, the trusted verification unit is specifically configured to recursively disassemble the system call functions included in the VDSO in the trusted execution environment according to the address information corresponding to each of the system call functions included in the VDSO in the trusted execution environment.

[0044] In a possible implementation, the modification processing unit is specifically used to determine the address offset of the first address and the second address; write the address offset into the FS segment register and / or the GS segment register; and modify the addressing mode of the data segment by the VDSO in the trusted execution environment to address through the FS segment register or the GS segment register.

[0045] In a possible implementation, the types of the system call request include clock_gettime, gettimeofday, and time.

[0046] In a fifth aspect, a computer-readable storage medium is provided, on which a computer program / instruction is stored. When the computer program / instruction is executed in a computing device, the computing device executes the method as described in any one of the first aspect or the third aspect.

[0047] In a sixth aspect, a computing device is provided, comprising a memory and a processor, wherein the memory stores a computer program / instructions, and the processor executes the computer program / instructions to implement a method as described in any one of the first aspect or the third aspect.

[0048] Through the method and apparatus provided in one or more embodiments of the present specification, on the one hand, when an application running in a trusted execution environment initiates an IO type system call request and a time type system call request, that is, when an application running in a trusted execution environment initiates a system call request for requesting to write business data to a target file or for requesting to read business data from a target file, and initiates a system call request for requesting to read time data, the program function that the system call request expects to achieve can be completed more quickly without performing an OCALL, which is beneficial to improving the performance of the application running in the trusted execution environment. BRIEF DESCRIPTION OF THE DRAWINGS

[0049] In order to more clearly illustrate the technical solutions of the embodiments of this specification, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0050] Figure 1 It is one of the system frameworks of the technical solution provided in the embodiments of this specification;

[0051] Figure 2 A flowchart of a system call processing method for a trusted execution environment provided in an embodiment of this specification;

[0052] Figure 3A flowchart of another system call processing method for a trusted execution environment provided in an embodiment of this specification;

[0053] Figure 4 A schematic diagram of the structure of a system call processing device for a trusted execution environment provided in an embodiment of this specification;

[0054] Figure 5 This is the second system framework of the technical solution provided in the embodiments of this specification;

[0055] Figure 6 A flowchart of another system call processing method for a trusted execution environment provided in an embodiment of this specification;

[0056] Figure 7 A flowchart of another system call processing method for a trusted execution environment provided in an embodiment of this specification;

[0057] Figure 8 A schematic diagram of a process of modifying a VDSO in a trusted execution environment in an embodiment of this specification;

[0058] Fig. 9 This is a schematic diagram of the structure of another system call processing device for a trusted execution environment provided in an embodiment of this specification. DETAILED DESCRIPTION

[0059] Each non-limiting embodiment provided in this specification is described in detail below in conjunction with the accompanying drawings.

[0060] Figure 1 This is one of the system framework diagrams of the technical solution provided in the embodiments of this specification. Figure 1 As shown, in order to improve the security of the system kernel of the operating system used by the computing device or virtual computing node, the operating system usually needs to divide the memory resources into two parts: kernel space and user space. The system kernel is independent of the ordinary computer program running in the user space. It can access the protected kernel space and has all the permissions to access the underlying hardware devices, such as reading / writing target files stored in non-volatile memory, or reading / writing temporary target files on memory resources. Among them, the trusted execution environment is a trusted memory area in the user space. For the convenience of description, the user space other than the trusted execution environment is usually called the process space.

[0061] An application running in a trusted execution environment can initiate a system call request to the system kernel, requesting the system kernel to provide services that require higher permissions to run. The system call request may include, but is not limited to, IO-type system call requests and time-type system call requests. Among them, IO-type system call requests refer to various system call requests used to request the system kernel to perform network reading and writing, disk reading and writing, such as requesting to write business data to a target file or read business data from a target file. The target file can be a local file stored on a disk / non-volatile memory, or a temporary / network file on a memory resource. A time-type system call request refers to a system call request used to request to read time data and related information.

[0062] As mentioned above, when an application running in a trusted execution environment implements a system call through OCall, OCall takes a long time, and applications running in a trusted execution environment often need to make high-frequency system calls, which has a greater impact on the overall performance of applications running in the trusted execution environment.

[0063] In a possible technical solution, a shared memory area can be configured outside the trusted execution environment, and several working threads can be run outside the trusted execution environment. When an application in the trusted execution environment needs to make a system call, the system call request can be written into the shared memory area, and the execution status of the system call request in the shared memory area can be continuously checked; the working thread outside the trusted execution environment will continuously check whether there is a system call request in the shared memory area, and if a system call request is found, the found system call request will be processed and the processing result will be written into the shared memory area. After the application in the trusted execution environment checks that the system call request has been successfully processed, it reads the processing result from the shared memory area to complete a system call.

[0064] In this technical solution, both the worker threads and the applications in the trusted execution environment will poll the shared memory area. However, it is difficult to determine the number of worker threads. Too few worker threads will result in the system call request not being executed quickly, which will cause the overall performance of the application to decline; too many worker threads will waste computing resources and may also cause the overall performance of the application to decline.

[0065] In view of the above problems, the embodiments of this specification at least provide a system call processing method and device for a trusted execution environment.

[0066] Figure 2 The present invention is a flowchart of a system call processing method for a trusted execution environment provided in an embodiment of the present specification. The method can be executed by a system call processing device deployed in a trusted execution environment.

[0067] like Figure 2 As shown, the method may include: step 201, receiving a system call request initiated by an application running in a trusted execution environment; wherein the system call request is used to request to write business data to a target file, or to request to read business data from a target file. Step 202, writing a system call request to a shared memory area outside the trusted execution environment, and writing an IO request event to an IO request queue stored outside the trusted execution environment, wherein the IO request event includes a first address of the system call request in the shared memory area and a second address in the shared memory area for storing business data, so that the system kernel processes the system call request according to the IO request event, and writes an IO completion event to an IO completion queue stored outside the trusted execution environment, wherein the IO completion event includes the processing result of the IO request by the system kernel. Step 203, at least providing the processing result in the IO completion event to the application.

[0068] Through the technical solution provided in the embodiments of this specification, when an application running in a trusted execution environment initiates an IO type system call request, that is, when a system call request is initiated for requesting to write business data to a target file or for requesting to read business data from a target file, the program function that the system call request expects to achieve can be completed more quickly without performing an OCALL, which is beneficial to improving the performance of the application running in the trusted execution environment.

[0069] Combine the following Figure 1 The system framework shown in FIG. exemplarily describes a system call processing method for a trusted execution environment. Figure 1 As shown, a system call processing device is deployed in the trusted execution environment, and the business program that cooperates with the system call processing device runs in the process space outside the trusted execution environment.

[0070] Figure 3 FIG. 1 is a flow chart of another system processing method for a trusted execution environment provided in an embodiment of this specification. The method may include: Figure 3 Part or all of steps 3011 to 3112 shown.

[0071] First, in step 3011, the system call processing device sends a call request to the business program running in the process space.

[0072] Next, the business program executes steps 3012 to 3014 in response to the received call request: Step 3012, initialize the shared memory area, IO request queue and IO completion queue in the process space; Step 3013, trigger the system kernel to start a polling thread for polling the IO request queue; Step 3014, send the configuration information of the shared memory area, IO request queue and IO completion queue to the system call processing device.

[0073] The shared memory area can also be called a data buffer. In the subsequent process, it will be used to store the system call request (or the data structure of the system call request) initiated by the application in the trusted execution environment to the system call processing device, the business data that the system call request expects to write to the target file, and the business data that the system call request expects to read. The usage of the memory address in the shared memory area will be managed by the system call processing device.

[0074] The service program can use the existing interface device of the system kernel to initialize the IO completion queue and the IO request queue, and trigger the system kernel to start the polling thread for polling the IO request queue. Alternatively, the corresponding interface device can be extended in the system kernel, and the service program uses the extended interface device to initialize the IO completion queue and the IO request queue, and trigger the system kernel to start the polling thread for polling the IO request queue.

[0075] For example, the system kernel of the operating system used by the computing device or virtual computing node is the Linux system kernel. The Linux system kernel provides an asynchronous IO interface device io_uring. After the business program completes the initialization of the shared memory area, io_uring can be initialized according to the working mechanism of io_uring, and io_uring is used to maintain the IO request queue and IO completion queue in the process space. Then, the working mode of io_uring is configured to IORING_SETUP_SQPOLL mode. The io_uring whose working mode is configured to IORING_SETUP_SQPOLL mode will request the system kernel to start a kernel thread (i.e., a polling thread) for polling the IO request queue.

[0076] When the system kernel processing device receives the configuration information of the shared memory area, the IO request queue and the IO completion queue, it can configure the data structure of the shared memory area, the IO request queue and the IO completion queue, so as to access and manage the shared memory area, the IO request queue and the IO completion queue through the configured data structure. It should be noted that when the IO request queue and the IO completion queue are initialized through io_uring, the configuration information of the IO request queue and the IO completion queue is the configuration information of io_uring, and the data structure of the IO request queue and the IO completion queue is the data structure of io_uring.

[0077] The system call processing device can work in single-thread mode or multi-thread mode. When the system call processing device works in multi-thread mode, thread locks can be configured for the IO request queue, IO completion queue and shared memory area respectively. Among them, the thread lock is a code block used to access its corresponding business object (IO request queue, IO completion queue or shared memory area), and only a single thread that obtains the thread lock is allowed to access its corresponding business object at the same time.

[0078] After completing the related processing of the aforementioned steps 3011 to 3014, the application running in the trusted execution environment can initiate a system call request to the system call processing device. Correspondingly, in step 302, the system call processing device receives the system call request initiated by the application running in the trusted execution environment.

[0079] System call requests from applications include IO system call requests that are expected to complete program functions such as network reading and writing, disk reading and writing, etc., which are specifically used to request to write business data to the target file or read business data from the target file. The target file can be a local file stored on a non-volatile storage device such as a disk, or a temporary file on a memory resource.

[0080] Specifically, the type of the system call request may include: read, write, readv, writev, fsync, poll, send_msg, recv_msg, openat, close, accept, connect, epoll_ctl, send or recv.

[0081] Next, in step 3031, the system call processing device writes the received system call request into the shared memory area.

[0082] Specifically, the system call processing device may allocate a first address for storing the system call request and a second address for storing service data in the shared memory area, and then write the system call request to the allocated first address.

[0083] When the system call request is used to request to read business data from the target file, the system call processing device directly executes step 304 or step 305 after completing step 3031.

[0084] When the system call request is used to request writing business data to the target file, the system call processing device may further execute step 3032 , and after completing step 3032 , execute step 304 or step 305 .

[0085] In step 3032, the system call processing device writes the service data to the shared memory area.

[0086] The system call processing device can write the business data in the trusted execution environment into the second address for storing business data in the shared memory area according to the instruction of the system call request.

[0087] In step 304, the system call processing device generates a unique identifier for the system call request.

[0088] Next, in step 305, the system call processing device writes an IO request event corresponding to the system call request into the IO request queue.

[0089] The IO request event includes a first address of the system call request in the shared memory area, and a second address in the shared memory area for storing service data, and optionally includes a unique identifier of the system call request.

[0090] Taking the initialization of the IO request queue by io_uring as an example, the system call processing device can form an IO request event including the first address and the second address according to the data structure required by io_uring, and record the unique identifier of the system call request (or the IO request event) in the user data field (user_data) of the IO request event, and finally submit the IO request event to the IO request queue initialized by io_uring.

[0091] It should be noted that when the system call processing device operates in a multi-threaded mode, the thread receiving the IO completion event may first obtain a thread lock for accessing the IO request queue, and write the IO request event to the IO request queue through the thread lock.

[0092] It should be noted that part or all of the information included in the system call request may be included in the IO request event. For example, the request type of the system call request and / or the file descriptor used to access the target file may be included in the IO request event.

[0093] It should be noted that for some specific kernel versions of io_uring, if an application requests access to a target file for the first time, it is also necessary to register the target file in the set of files allowed by io_uring.

[0094] Since the system kernel has started the polling thread for polling the IO request queue, the system kernel can discover the IO request event written into the IO request queue by the system call device through the polling thread. Accordingly, when the system kernel discovers the IO request event in the IO request queue through the polling thread, step 306 can be executed to read the IO request event from the IO request queue.

[0095] Next, in step 3071, the system kernel reads the system call request from the shared memory area according to the first address in the IO request event read by it.

[0096] When the system call request is used to request to read business data from the target file, the system kernel can directly execute step 308 after completing step 3071.

[0097] The system call request is used to request to write business data to the target file. After the system kernel completes execution of step 3071, it can also execute step 3072. After completing execution of step 3072, it executes step 308.

[0098] In step 3072, the service data is read from the shared memory area according to the second address in the read IO request event.

[0099] In step 308, the system kernel processes the read system call request and obtains a processing result.

[0100] Specifically, when the system call request is used to request to write business data to the target file, the system kernel can write the business data read from the shared memory area to the target file according to the system call request to obtain the processing result of the system call request. When the system call request is used to request to read business data from the target file, the system kernel can read business data from the target file according to the system call request to obtain the processing result of the system call request.

[0101] The processing result is used to indicate the processing status of the system kernel on the system call request, for example, it is used to indicate the number of bytes of business data successfully read / written by the system kernel.

[0102] Next, in step 3091, the system kernel writes an IO completion event to the IO completion queue.

[0103] The IO completion event includes the processing result of the system call request, and optionally also includes a unique identifier of the system call request.

[0104] When the system call request is used to request to read business data from the target file, the system kernel may further execute step 3092 to write the read business data into the shared memory area according to the second address in the read IO request event.

[0105] Next, in step 3101, the system call processing device reads the IO completion event from the IO completion queue.

[0106] Specifically, after the system call processing device completes writing the IO request event to the IO request queue, it polls the IO completion queue. Wherein, when the system call processing device works in single-threaded mode, the system call processing device only submits one IO request event to the IO request queue each time, and then starts to poll the IO completion queue to wait for the system call to be processed by the system kernel. There is at most one IO completion event in the IO completion queue, and the system call processing device will definitely read the IO completion event corresponding to the previously submitted IO request event / system call request. When the system call processing device works in multi-threaded mode, the IO request queue may include multiple IO request events, and the IO completion queue may include multiple IO completion events, and the arrangement order of the multiple IO request events may not be consistent with the arrangement order of the multiple IO completion events. At this time, it is necessary to set a thread lock for accessing the IO completion queue; any current thread among the multiple threads corresponding to the system call processing device can, after obtaining the thread lock for accessing the IO completion queue, read the corresponding IO completion event from the IO request queue through the acquired thread lock according to the unique identifier of the corresponding system call request.

[0107] The system call request is used to request to write business data to the target file. After the system call processing device completes the reading IO completion event, it can continue to execute step 3111 to complete the processing of the system call request. In addition, the first address and the second address in the shared memory area can be released.

[0108] When the system call request is used to request to read service data from the target file, the system kernel can execute step 3102, and then execute steps 3111 and 3112 to complete the processing of the system call request. In addition, the first address and the second address in the shared memory area can be released.

[0109] In step 3102, the system call processing device reads service data from the shared memory area according to the second address.

[0110] In step 3111, the system call processing device provides the processing result to the application.

[0111] In step 3112, the system call processing device provides the application with the service data it has read.

[0112] It should be noted that step 3111 and step 3112 can be combined into one step, and the system call processing device provides the system call result to the application. When the system call request is used to request to read business data from the target file, the system call result may include the processing result, and the business data read by the system call processing device or the address information of the business data in the trusted execution environment. When the system call request is used to request to write business data to the target file, the system call result may include the processing result.

[0113] It should be noted that after the application in the trusted execution environment is finished running, the system call processing device can also release the shared memory area, IO request queue and IO completion queue through the business program, such as closing io_uring and releasing the shared memory area through the business program.

[0114] based on Figure 2 and Figure 3 In the illustrated embodiment, when the IO request queue and the IO completion queue are initialized through io_uring, since an adaptive workload mechanism is provided internally in io_uring, it is possible to save computing resources while improving efficiency.

[0115] based on Figure 2 and Figure 3 In the illustrated embodiment, when the IO request queue and the IO completion queue are initialized through io_uring, since io_uring hides the complex mechanism inside, the developer does not need to implement the complex mechanism by himself, but only needs to use the standard interface of io_uring, and the technical solution is easy to implement.

[0116] based on Figure 2 and Figure 3 In the illustrated embodiment, when the IO request queue and the IO completion queue are initialized through io_uring, io_uring itself is an asynchronous IO mechanism of the Linux system kernel. When processing IO system calls in asynchronous IO mode, the technical solution based on io_uring is significantly better than the synchronous IO solution or other asynchronous IO solutions in performance, especially in the case of single-core, multi-device, and 4KB random read, the technical solution based on io_uring has significant performance advantages.

[0117] and Figure 2 and Figure 3 The method embodiment shown is based on the same concept, and the embodiment of this specification also provides a system call processing device for a trusted execution environment, and the system call processing device is deployed in a trusted execution environment. Figure 4As shown, the device includes: a request receiving unit 401, which is used to receive a system call request initiated by an application running in a trusted execution environment; wherein the system call request is used to request to write business data to a target file, or to request to read business data from a target file. A data writing unit 402, which is used to write the system call request to a shared memory area outside the trusted execution environment, and to write an IO request event to an IO request queue stored outside the trusted execution environment; wherein the IO request event includes a first address of the system call request in the shared memory area and a second address for storing business data in the shared memory area, so that the system kernel processes the system call request according to the IO request event, and writes an IO completion event to an IO completion queue stored outside the trusted execution environment, wherein the IO completion event includes the processing result of the IO request by the system kernel. A data providing unit 403, which is used to provide the processing result in the IO completion event to the application.

[0118] In a possible implementation, when the system call request is used to request writing business data to a target file, the data writing unit 402 is further used to write business data to the second address of the shared memory area according to the system call request; wherein the system kernel is specifically used to read the system call request from the first address of the shared memory area according to the IO request event, read the business data according to the second address, and write the business data to the target file according to the system call request.

[0119] In a possible implementation, when the system call request is used to request to read service data from a target file, the system kernel is specifically used to read the system call request from the first address in the shared memory area according to the IO request event, read service data from the target file according to the system call request, and write the service data to the shared memory area according to the second address. The data providing unit 403 is also used to provide the service data in the shared memory area to the application.

[0120] In a possible implementation, the device further includes: an identification management unit 404, configured to generate a unique identification of the system call request; wherein the IO request event and the IO completion event also include the unique identification. A queue polling unit 405, configured to poll the IO completion event in the IO completion queue according to the unique identification.

[0121] In a possible implementation, the device also includes: an initialization configuration unit 406, which is used to initialize the IO request queue, the IO completion queue and the shared memory area through a business program running outside the trusted execution environment, and trigger the system kernel to start a polling thread for polling the IO request queue.

[0122] In a possible implementation, the initialization configuration unit 406 is further configured to obtain configuration information for accessing the IO request queue, the IO completion queue, and the shared memory area through a service program running outside the trusted execution environment.

[0123] In a possible implementation, the data writing unit 402 is specifically configured to acquire a thread lock for accessing an IO request queue stored outside the trusted execution environment, and write the IO request event to the IO request queue through the thread lock.

[0124] In a possible implementation, the type of the system call request is any one of the following types: read, write, readv, writev, fsync, poll, send_msg, recv_msg, openat, close, accept, connect, epoll_ctl, send, and recv.

[0125] Figure 5 This is the second system framework diagram of the technical solution provided in the embodiments of this specification. Figure 5 As shown, in order to improve the security of the system kernel of the operating system used by the computing device or virtual computing node, the operating system usually needs to divide the memory resources into two parts: kernel space and user space. The system kernel is independent of the ordinary computer program running in the user space. It can access the protected kernel space and has all the permissions to access the underlying hardware devices, such as reading / writing target files stored in non-volatile memory, or reading / writing temporary target files on memory resources. Among them, the trusted execution environment is a trusted memory area in the user space. For the convenience of description, the user space other than the trusted execution environment is usually called the process space.

[0126] When a computing device or a virtual computing node is running, a virtual dynamic shared object (VDSO) can be run in a process space, and the process space also includes a data segment of the VDSO, which is used to store some time data. The system kernel can update some time data stored in the data segment.

[0127] As mentioned above, when an application running in a trusted execution environment implements a system call through OCall, OCall takes a long time, and applications running in a trusted execution environment often need to make high-frequency system calls, which has a greater impact on the overall performance of applications running in the trusted execution environment.

[0128] In a possible technical solution, the VDSO supported by the system kernel can be directly transplanted into the trusted execution environment, and at the same time, the data segment of the VDSO is maintained on the memory resources outside the trusted execution environment, and a number of time data are stored in the data segment. The system kernel is responsible for updating the time data in the data segment in real time. The VDSO in the trusted execution environment can receive a time-type system call request initiated by an application running in the trusted execution environment, and read the time data from the data segment outside the trusted execution environment according to the received system call request, and return it to the application to complete a system call.

[0129] In this technical solution, VDSO is originally a component of the system kernel and will change with the changes of the system kernel version. Directly porting VDSO to the trusted execution environment requires porting different versions of VDSO according to the version of the system kernel used by the computing device or virtual computing node, and it is necessary to constantly update the VDSO ported to the trusted execution environment for the new version of the system kernel, which has extremely poor maintainability.

[0130] In view of the above problems, a system call processing method and device for a trusted execution environment are provided in the embodiments of this specification.

[0131] Figure 6 This is a flowchart of another system call processing method for a trusted execution environment provided in an embodiment of this specification. The method can be executed by a system call processing device in a trusted execution environment.

[0132] like Figure 6 As shown, the method includes: step 601, obtaining a first address of a VDSO in a memory area outside a trusted execution environment; wherein the memory area also includes a data segment for storing a number of time data, and the VDSO includes a number of system call functions for accessing the data segment. Step 602, loading the VDSO in the trusted execution environment according to the first address. Step 603, modifying the addressing mode of the VDSO in the trusted execution environment for the data segment according to the first address and the second address of the VDSO in the trusted execution environment. Step 604, receiving a system call request initiated by an application in the trusted execution environment through the modified VDSO, reading the current time data from the several time data stored in the data segment according to the system call request, and providing the current time data read by the application to the application.

[0133] Through the technical solution provided in the embodiments of this specification, when an application running in a trusted execution environment initiates a time-type system call request, that is, when a system call request for requesting to read time data is initiated, the program function that the system call request expects to achieve can be completed more quickly without performing OCALL, which is beneficial to improving the performance of applications running in a trusted execution environment.

[0134] Combine the following Figure 5 The system framework shown in FIG. exemplarily describes a system call processing method for a trusted execution environment. Figure 5 As shown, a system call processing device is deployed in the trusted execution environment, and the business program that cooperates with the system call processing device runs in the process space outside the trusted execution environment. The system kernel can update the data segment of the VDSO running in the process space, specifically, the system kernel can update some time data stored in the data segment in the process space.

[0135] Figure 7 FIG. 1 is a flow chart of another system processing method for a trusted execution environment provided in an embodiment of this specification. The method may include: Figure 7 Part or all of steps 701 to 7065 shown.

[0136] First, in step 701, the system call processing device sends a call request to the service program running in the process space.

[0137] Next, the service program executes step 702 in response to the received call request, and sends the first address of the VDSO in the process space to the system call processing device.

[0138] The process space also includes a data segment for storing some time data.

[0139] VDSO includes several system call functions for accessing the data segment, wherein the several system call functions may include one or more of the following system call functions: vdso_clock_gettime, vdso_gettimeofday(), and vdso_time().

[0140] Next, in step 703, the system call processing apparatus loads the VDSO in the trusted execution environment according to the first address, and obtains address information corresponding to each of several system call functions included in the VDSO in the trusted execution environment.

[0141] Specifically, VDSO is usually in ELF format, and VDSO can be loaded in the trusted execution environment according to ELF format information and the first address of VDSO in the process space. In addition, the ".dynsym" symbol table can be obtained from the ELF dynamic link library, and then the address information corresponding to the several system call functions included in the VDSO in the trusted execution environment can be extracted from the ".dynsym" symbol table. The address information can be the starting address and address length of the corresponding system call function in the trusted execution environment.

[0142] Next, in step 704, the system call processing device determines whether the VDSO in the trusted execution environment is trusted. If the VDSO in the trusted execution environment is trusted, step 7051 is executed.

[0143] In other words, it is necessary to ensure that the VDSO in the trusted execution environment is not a malicious computer program that may bring security risks to the trusted execution environment. When it is determined that the VDSO in the trusted execution environment is not a malicious computer program, the VDSO in the trusted execution environment is determined to be trustworthy.

[0144] After analyzing a large number of versions of VDSO, the inventors found that the assembly instructions corresponding to the trusted VDSO need to meet the following conditions: the instructions are relatively simple, usually only including some instructions and some instruction modes; except for the RET instruction, no other indirect control transfer instructions are included; direct memory addresses are not used for memory access, and usually only three modes of memory access are included: reading or writing function parameters, reading the data segment of VDSO, and reading / writing a legal stack; loops or internal function calls can modify the stack pointer inside the loop or function, but the stack pointer must be restored internally after being modified; no buffer access to the stack is included, otherwise there may be a buffer overflow or stack overflow when running VDSO.

[0145] Based on the above findings, several preset conditions can be configured for the assembly instructions of VDSO to determine whether VDSO is credible. Figure 8 As shown, step 704 may at least include step 7041: recursively disassembling several system call functions included in the VDSO in the trusted execution environment to obtain instruction sets corresponding to the several system call functions. Step 7042: during the process of recursively disassembling any current system call function among the several system call functions, when the current instruction obtained at the current moment satisfies any one of at least one preset condition, determining that the VDSO in the trusted execution environment is not trusted.

[0146] In an example, the system call functions included in the VDSO in the trusted execution environment may be recursively disassembled according to the address information corresponding to each of the system call functions included in the VDSO in the trusted execution environment.

[0147] In one example, at least one preset condition includes one or more of the following preset conditions: the current instruction is a control transfer instruction other than the RET instruction, the addressing mode of the current instruction is direct addressing (that is, the current instruction uses a direct memory address to access memory), the current instruction is an unallowed instruction / instruction mode (that is, an instruction or instruction mode not included in the VDSO discovered during the aforementioned analysis process), and there is an error in the disassembly of the current instruction (for example, the program control flow jumps to an instruction that has been disassembled).

[0148] When the instruction sets corresponding to the system call functions are successfully obtained and the VDSO is not determined to be untrustworthy, the instruction sets corresponding to the system call functions can be further analyzed to determine whether the VDSO is trustworthy. Figure 8 Step 704 may also include:

[0149] Step 7043, traverse any current instruction set in each instruction set, and use the instructions included in the current instruction set to construct a control flow graph (CFG) with basic blocks as nodes and control transfers as edges.

[0150] A basic block is a group of consecutive instructions that has one entry and one exit.

[0151] The entries of all possible basic blocks in the current instruction set may include: a function start address, a target instruction of a direct control transfer instruction, a target instruction of a conditional control transfer instruction, a next instruction of a conditional control transfer instruction, and a function call instruction.

[0152] All possible exits of the basic block in the current instruction set may include: the previous instruction of the entry of the basic block, a control transfer instruction, a function call instruction, and a program return instruction.

[0153] Based on the characteristics of the basic blocks described above, the control flow graph can be constructed in step 7043 by traversing the current instruction set once or multiple times. For example, the current instruction set is first traversed to mark the entrances of all possible basic blocks; then the current instruction set is traversed for the second time to mark the exits of all possible basic blocks; then the third traversal is performed to connect all possible basic blocks according to the control transfer information; finally, the entry basic block Entry is connected to the basic block where the start instruction of the current instruction set (that is, the start instruction of the system call function corresponding to the current instruction set) is located, and the exit basic block Exit is connected to the basic block where the function return instruction in the current instruction set is located.

[0154] Step 7044, traverse the control flow graph through a predetermined algorithm to determine whether the system call function corresponding to the current instruction set is a trusted function.

[0155] For each basic block that is a node in the control flow graph, the basic block has an input state IN and an output state OUT. The input state IN is the state when entering the basic block, and the output state OUT is the state when exiting the basic block. The input state and the output state include the state of each register and the state of the stack. The state of the register is a set of possible values ​​and types, and the state of the stack is a set of possible values ​​and types for each position in the stack. In the initial state, the output state OUT of the entry basic block Entry is initialized, the register state is initialized to the initial value of each register, and the stack state is initialized to empty; in the initial state, the state of the register and the stack is safe because the state at this time is provided by the computer program in the trusted execution environment when calling the system call function contained in the VDSO.

[0156] In a more specific example, the predetermined algorithm may include an improved work list algorithm (Work list Algorithm). That is, in step 7044, the control flow graph of the current instruction set may be analyzed by the improved work list algorithm, so as to detect whether the system call function corresponding to the current instruction set is a trusted function. The algorithm flow of the improved work list algorithm is as follows:

[0157]

[0158] Referring to the aforementioned algorithm flow, it can be seen that in each cycle of the improved work list algorithm, it is necessary to check the state of the stack of the output state OUT of all predecessor nodes of the basic block BB to ensure that the stack structure of the output state OUT of all its predecessor nodes is consistent. If it is inconsistent, the verification fails, and it can be determined that the system call function corresponding to the current instruction set is an untrusted function. In other words, for any current node in the control flow graph, if the stack structure of the output state of several predecessor nodes of the current node is not exactly the same, it can be determined that the system call function corresponding to the current instruction set is an untrusted function.

[0159] When simulating the execution of basic blocks, it is necessary to check whether the memory access is legal based on the register status information and the stack status information. If it is illegal, the verification fails, and it can be determined that the system call function corresponding to the current instruction set is an untrusted function. In other words, in the process of traversing the control flow graph through a predetermined algorithm, for any current node in the control flow graph, if the memory access of the current node is illegal, it can be determined that the system call function corresponding to the current instruction set is an untrusted function.

[0160] It should be noted that when checking the current node, it may not be possible to get a direct conclusion on whether the memory is legal or not, which means that the memory access may be illegal. If the memory access may be illegal, the memory access type (reading or writing function parameters, reading VDSO data segments, or reading / writing legal stacks) is inferred from the register status information and stack status information, and the current node is recorded so that the current node can be instrumented when the VDSO is rewritten later, and the memory address range check instruction is added.

[0161] If the improved work list algorithm runs successfully, the state of the exit basic block Exit is checked to determine whether the system call function corresponding to the current instruction set returns correctly. If so, it can be determined that the system call function corresponding to the current instruction set is a trusted function, otherwise it is determined that the system call function corresponding to the current instruction set is an untrusted function.

[0162] Step 7045: When there is no untrusted function, determine that the VDSO in the trusted execution environment is trusted.

[0163] In other words, if each system call function included in the VSDO in the trusted execution environment is not determined to be an untrusted function, it can be determined that the VDSO in the trusted execution environment is trusted.

[0164] When the VDSO in the trusted execution environment is determined to be trustworthy, return to Figure 7In step 7051, an address offset between the first address and the second address of the VDSO in the trusted execution environment is determined. In step 7052, the address offset is written into the FS segment register and / or the GS segment register. In step 7053, the addressing mode of the data segment of the VDSO in the trusted execution environment is modified to address through the FS segment register or the GS segment register.

[0165] Through the aforementioned steps 7051 to 7053, rewriting the VDSO in the process space according to the first address of the VDSO in the process space and the second address of the VDSO in the trusted execution environment is completed.

[0166] Specifically, after VDSO is loaded into the trusted execution environment, the address offset between each system call function contained in the VDSO in the trusted execution environment and the data segment in the process space is changed. The FS segment register and / or the GS segment register are set to the address difference / address offset between the VDSO in the trusted execution environment and the VDSO in the process space, and the addressing mode of the data segment of the VDSO in the trusted execution environment is modified to address through the FS segment register or the GS segment register, so as to ensure that each system call function contained in the modified VDSO can normally access the data segment in the process space.

[0167] It should be noted that if the aforementioned step 7044 marks that there may be illegal memory access, then when modifying the VDSO, the code segment / instruction segment corresponding to the marked basic block (node) can also be inserted, and before the code segment performs memory access, it is checked whether the memory address to be accessed is within the legal range, and subsequent processing can only be performed when it is ensured that the memory address to be accessed is within the legal range, otherwise the current business process is terminated.

[0168] It should be noted that rewriting the VDSO in the trusted execution environment (for example, rewriting the addressing mode of the VDSO in the trusted execution environment) may change the size of each system call function included in the VDSO. Therefore, the ELF structure information of the rewritten VDSO may be further modified, such as updating the size of each system call function included in the VDSO in the trusted execution environment in the ELF structure information.

[0169] It should be noted that since applications in a trusted execution environment are usually developed based on system libraries provided by the operating system (such as the C standard library), the calling method of the rewritten VDSO can be configured so that applications running in the trusted execution environment can initiate time-type system call requests to the rewritten VDSO through the system library.

[0170] In some embodiments, the application in the trusted execution environment can also directly call the rewritten VDSO through the system call processing device. Figure 7 .

[0171] In step 7061, the system call processing device receives a system call request initiated by an application running in a trusted execution environment.

[0172] The system call request is used to request to read time data.

[0173] In step 7062, the system call processing device sends a system call request to the rewritten VDSO.

[0174] In step 7063, the rewritten VDSO reads the current time data from the time data stored in the data segment according to the system call request.

[0175] In step 7064, the rewritten VDSO returns the current time data to the system call processing device.

[0176] In step 7065, the system call processing device provides the current time data to the application.

[0177] based on Figure 6 and Figure 7 In the illustrated embodiment, the VDSO supported by the system kernel is adaptively modified in a trusted execution environment, and there is no need to continuously update the computer program according to the version of the system kernel. The system kernel is compatible with the released system kernel or the system kernel updated in the future, and the maintainability of the technical solution is excellent.

[0178] based on Figure 6 and Figure 7 In the illustrated embodiment, the rewritten VDSO is trustworthy and can run normally in a trusted execution environment without bringing security risks to the trusted execution environment.

[0179] and Figure 6 and Figure 7 The method embodiment shown is based on the same concept, and the embodiment of this specification also provides a system call processing device for a trusted execution environment, and the system call processing device is deployed in a trusted execution environment. Fig. 9As shown, the device includes: an information acquisition unit 901, which is used to obtain the first address of the VDSO in the memory area outside the trusted execution environment; wherein the memory area also includes a data segment for storing a number of time data, and the VDSO includes a number of system call functions for accessing the data segment. A loading processing unit 902, which is used to load the VDSO in the trusted execution environment according to the first address. A modification processing unit 903, which is used to modify the addressing method of the VDSO in the trusted execution environment for the data segment according to the first address and the second address of the VDSO in the trusted execution environment; wherein the modified VDSO is specifically used to receive a system call request initiated by an application in the trusted execution environment, read the current time data from the several time data stored in the data segment according to the system call request, and provide the current time data read by the application to the application.

[0180] In a possible implementation, the system further includes: a trusted verification unit 904, configured to determine whether the VDSO in the trusted execution environment is trusted.

[0181] In a possible implementation, the trusted verification unit 904 is specifically used to: recursively disassemble several system call functions included in the VDSO in the trusted execution environment to obtain instruction sets corresponding to each of the several system call functions; wherein, during the process of recursively disassembling any current system call function among the several system call functions, when the current instruction obtained at the current moment satisfies any one of at least one preset condition, it is determined that the VDSO in the trusted execution environment is untrustworthy.

[0182] In a possible implementation, the at least one preset condition includes one or more of the following preset conditions: the current instruction is a control transfer instruction other than a RET instruction, the addressing mode of the current instruction is direct addressing, the current instruction is an unallowed instruction, and there is an error in the disassembly of the current instruction.

[0183] In a possible implementation, the trusted verification unit 904 is further used to traverse any current instruction set in each of the instruction sets, and use the instructions included in the current instruction set to construct a control flow graph with basic blocks as nodes and control transfers as edges, wherein the basic block is a group of continuous instructions with one entry and one exit; traverse and process the control flow graph through a predetermined algorithm to determine whether the system call function corresponding to the current instruction set is a trusted function; when there is no untrusted function, determine that the VDSO in the trusted execution environment is trusted.

[0184] In one possible implementation, the trusted verification unit 904 is specifically used to, during the process of traversing and processing the control flow graph through a predetermined algorithm, determine that, for any current node in the control flow graph, if the stack structures of the output states of several predecessor nodes of the current node are not exactly the same, the system call function corresponding to the current instruction set is an untrusted function.

[0185] In one possible implementation, the trusted verification unit 904 is specifically used to determine that the system call function corresponding to the current instruction set is an untrusted function for any current node in the control flow graph if the memory access of the current node is illegal during the process of traversing the control flow graph through a predetermined algorithm.

[0186] In a possible implementation, the trusted verification unit 904 is specifically configured to recursively disassemble the system call functions included in the VDSO in the trusted execution environment according to the address information corresponding to each of the system call functions included in the VDSO in the trusted execution environment.

[0187] In a possible implementation, the modification processing unit 903 is specifically used to determine the address offset of the first address and the second address; write the address offset into the FS segment register and / or the GS segment register; and modify the addressing mode of the data segment by the VDSO in the trusted execution environment to address through the FS segment register or the GS segment register.

[0188] In a possible implementation, the types of the system call request include clock_gettime, gettimeofday, and time.

[0189] Those skilled in the art should be aware that in one or more of the above examples, the functions described in this specification can be implemented by hardware, software, firmware, or any combination thereof. When implemented by software, the computer programs corresponding to these functions can be stored in a computer-readable medium or transmitted as one or more instructions / codes on a computer-readable medium, so that when the computer programs corresponding to these functions are executed by a computer, the method described in any embodiment of this specification is implemented by the computer.

[0190] A computer-readable storage medium is also provided in an embodiment of the present specification, on which a computer program is stored. When the computer program is executed in a computing device, the computing device executes a system call processing method for a trusted execution environment provided in any embodiment of the present specification.

[0191] A computing device is also provided in an embodiment of the present specification, including a memory and a processor, wherein the memory stores executable code, and when the processor executes the executable code, the system call processing method for a trusted execution environment provided in any embodiment of the present specification is implemented.

[0192] Each embodiment in this specification is described in a progressive manner, and the same or similar parts of each embodiment can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the device embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.

[0193] The above is a description of a specific embodiment of the specification. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recorded in the claims can be performed in an order different from that in the embodiments and still achieve the desired results. In addition, the processes depicted in the drawings do not necessarily require the specific order or continuous order shown to achieve the desired results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.

[0194] The specific implementation methods described above further illustrate the objectives, technical solutions and beneficial effects of the present invention in detail. It should be understood that the above description is only a specific implementation method of the present invention and is not intended to limit the scope of protection of the present invention. Any modifications, equivalent substitutions, improvements, etc. made on the basis of the technical solution of the present invention should be included in the scope of protection of the present invention.

Claims

1. A system call processing method for a trusted execution environment, comprising: Receiving a system call request initiated by an application running in a trusted execution environment; wherein the system call request is used to request to write business data to a target file, or to request to read business data from a target file; Writing the system call request to a shared memory area outside the trusted execution environment, and writing an IO request event to an IO request queue stored outside the trusted execution environment; wherein the IO request event includes a first address of the system call request in the shared memory area and a second address for storing business data in the shared memory area, so that the system kernel processes the system call request according to the IO request event, and writes an IO completion event to an IO completion queue stored outside the trusted execution environment, wherein the IO completion event includes a processing result of the IO request by the system kernel; At least the processing result in the IO completion event is provided to the application.

2. The method according to claim 1, wherein: When the system call request is used to request writing business data to a target file, the method further includes: writing the business data to the second address of the shared memory area according to the system call request; wherein the system kernel is specifically used to read the system call request from the first address of the shared memory area according to the IO request event, and read the business data from the second address, and write the business data to the target file according to the system call request.

3. The method according to claim 1, wherein: When the system call request is used to request to read service data from a target file, the system kernel is specifically used to read the system call request from the first address of the shared memory area according to the IO request event, read the service data from the target file according to the system call request, and write the service data to the shared memory area according to the second address; The method further includes: providing the service data in the shared memory area to the application program.

4. The method according to claim 1, wherein: Also includes: Generate a unique identifier for the system call request; wherein the IO request event and the IO completion event also include the unique identifier; The IO completion event is polled in the IO completion queue according to the unique identifier.

5. The method according to claim 1, wherein: Before receiving a system call request initiated by an application running in a trusted execution environment, the method also includes: initializing the IO request queue, the IO completion queue and the shared memory area through a business program running outside the trusted execution environment, and triggering the system kernel to start a polling thread for polling the IO request queue.

6. The method according to claim 5, wherein: Also includes: The configuration information for accessing the IO request queue, the IO completion queue and the shared memory area is obtained by running a service program outside the trusted execution environment.

7. The method according to claim 1, wherein: The writing of the IO request event to the IO request queue stored outside the trusted execution environment specifically includes: acquiring a thread lock for accessing the IO request queue stored outside the trusted execution environment, and writing the IO request event to the IO request queue through the thread lock.

8. The method according to any one of claims 1 to 7, wherein: The type of the system call request is any one of the following types: read, write, readv, writev, fsync, poll, send_msg, recv_msg, openat, close, accept, connect, epoll_ctl, send and recv.

9. A system call processing device for a trusted execution environment, comprising: A request receiving unit, configured to receive a system call request initiated by an application running in a trusted execution environment; wherein the system call request is used to request to write business data to a target file, or to request to read business data from a target file; a data writing unit, configured to write the system call request to a shared memory area outside the trusted execution environment, and to write an IO request event to an IO request queue stored outside the trusted execution environment; wherein the IO request event includes a first address of the system call request in the shared memory area and a second address for storing service data in the shared memory area, so that the system kernel processes the system call request according to the IO request event, and writes an IO completion event to an IO completion queue stored outside the trusted execution environment, wherein the IO completion event includes a processing result of the IO request by the system kernel; A data providing unit is used to provide at least the processing result in the IO completion event to the application.

10. The device according to claim 9, wherein: When the system call request is used to request writing business data to a target file, the data writing unit is also used to write the business data to the second address of the shared memory area according to the system call request; wherein the system kernel is specifically used to read the system call request from the first address of the shared memory area according to the IO request event, and read the business data from the second address, and write the business data to the target file according to the system call request.

11. The device according to claim 9, wherein: When the system call request is used to request to read service data from a target file, the system kernel is specifically used to read the system call request from the first address of the shared memory area according to the IO request event, read the service data from the target file according to the system call request, and write the service data to the shared memory area according to the second address; The data providing unit is further configured to provide the service data in the shared memory area to the application program.

12. The device according to claim 9, wherein: Also includes: An identification management unit, used to generate a unique identification of the system call request; wherein the IO request event and the IO completion event also include the unique identification; A queue polling unit is used to poll the IO completion event in the IO completion queue according to the unique identifier.

13. The device according to claim 9, wherein: Also includes: The initialization configuration unit is used to initialize the IO request queue, the IO completion queue and the shared memory area through a business program running outside the trusted execution environment, and trigger the system kernel to start a polling thread for polling the IO request queue.

14. The device according to claim 13, wherein: The initialization configuration unit is further used to obtain configuration information for accessing the IO request queue, the IO completion queue and the shared memory area through a business program running outside the trusted execution environment.

15. The device according to claim 9, wherein: The data writing unit is specifically used to obtain a thread lock for accessing an IO request queue stored outside the trusted execution environment, and write the IO request event to the IO request queue through the thread lock.

16. The device according to any one of claims 9 to 15, wherein: The type of the system call request is any one of the following types: read, write, readv, writev, fsync, poll, send_msg, recv_msg, openat, close, accept, connect, epoll_ctl, send and recv.

17. A computer-readable storage medium having a computer program stored thereon, wherein when the computer program is executed in a computing device, the computing device executes the method according to any one of claims 1 to 8.

18. A computing device comprising a memory and a processor, wherein the memory stores executable codes, and when the processor executes the executable codes, the method according to any one of claims 1 to 8 is implemented.