Method, device and electronic device for isolating tenants
By establishing an independent language interpreter and stack area for each tenant, limiting system calls and resource usage, the problem of tenant isolation in the edge computing environment is solved, and a safe and efficient tenant execution environment is achieved.
Patent Information
- Application Number
- CN202211031942.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-08-26
- Publication Date
- 2024-11-22
- Estimated Expiration
- 2042-08-26
AI Technical Summary
In an edge computing environment, existing FaaS technologies are difficult to achieve large-scale deployment tenant isolation, container or virtual machine solutions consume high resources, high costs and difficult to ensure security.
By establishing independent language interpreters and stack areas for each tenant, mapping to the address space of the host environment, limiting system calls, controlling memory and CPU time slices, setting restart time and security levels, providing a safe and lightweight execution environment .
It realizes secure isolation between tenants, reduces the system attack surface, improves security and resource utilization efficiency, and is suitable for a large-scale scalable edge computing environment.
Smart Images

Figure CN115422530B_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of computer technology, and more particularly to a method, device, and electronic device for isolating tenants. Background Art
[0002] Function as a Service (or FaaS) is a new type of service that allows developers to build, compute, run, and manage these application packages in the form of functions without having to maintain their own infrastructure. FaaS is an event-driven execution model that runs in stateless containers. These functions will use the services of FaaS providers to manage server-side logic and state. FaaS products have certain development prospects because of their low threshold, high scalability, and pay-as-you-go features. Summary of the invention
[0003] This disclosure section is provided to introduce concepts in a brief form, which will be described in detail in the detailed description section below. This disclosure section is not intended to identify key features or essential features of the claimed technical solution, nor is it intended to limit the scope of the claimed technical solution.
[0004] In a first aspect, an embodiment of the present disclosure provides a method for isolating tenants, the method comprising: based on a registration request of the tenant, establishing a language interpreter corresponding to the tenant, wherein the language interpreter is bound to a stack area, and a mapping relationship exists between the stack area and the address space of the electronic device; based on the language interpreter, running the code corresponding to the tenant.
[0005] In a second aspect, an embodiment of the present disclosure provides a device for isolating tenants, comprising: an establishment unit, for establishing a language interpreter corresponding to the tenant based on a registration request of the tenant, wherein the language interpreter is bound to a stack area, and a mapping relationship exists between the stack area and the address space of the electronic device; and an operation unit, for running the code corresponding to the tenant based on the language interpreter.
[0006] In a third aspect, an embodiment of the present disclosure provides an electronic device, comprising: at least one processor; a storage device for storing at least one program, when the at least one program is executed by the at least one processor, the at least one processor implements the method for isolating tenants as described in the first aspect.
[0007] In a fourth aspect, an embodiment of the present disclosure provides a computer-readable medium having a computer program stored thereon, which, when executed by a processor, implements the steps of the method for isolating tenants as described in the first aspect. BRIEF DESCRIPTION OF THE DRAWINGS
[0008] The above and other features, advantages and aspects of the embodiments of the present disclosure will become more apparent with reference to the following detailed description in conjunction with the accompanying drawings. Throughout the accompanying drawings, the same or similar reference numerals represent the same or similar elements. It should be understood that the drawings are schematic and the originals and elements are not necessarily drawn to scale.
[0009] Figure 1 is a flow chart of one embodiment of a method for isolating tenants according to the present disclosure;
[0010] Figure 2 is a flow chart of one embodiment of a method for isolating tenants according to the present disclosure;
[0011] Figure 3 is a flow chart of one embodiment of a method for isolating tenants according to the present disclosure;
[0012] Figure 4 is a flow chart of one embodiment of a method for isolating tenants according to the present disclosure;
[0013] Figure 5 is a structural schematic diagram of an embodiment of a device for isolating tenants according to the present disclosure;
[0014] Figure 6 is an exemplary system architecture in which a method for isolating tenants according to an embodiment of the present disclosure may be applied;
[0015] Figure 7 It is a schematic diagram of the basic structure of an electronic device provided according to an embodiment of the present disclosure. DETAILED DESCRIPTION
[0016] Embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. Although certain embodiments of the present disclosure are shown in the accompanying drawings, it should be understood that the present disclosure can be implemented in various forms and should not be construed as being limited to the embodiments described herein, which are instead provided for a more thorough and complete understanding of the present disclosure. It should be understood that the drawings and embodiments of the present disclosure are only for exemplary purposes and are not intended to limit the scope of protection of the present disclosure.
[0017] It should be understood that the various steps described in the method embodiments of the present disclosure may be performed in different orders and / or in parallel. In addition, the method embodiments may include additional steps and / or omit the steps shown. The scope of the present disclosure is not limited in this respect.
[0018] The term "including" and its variations used herein are open inclusions, i.e., "including but not limited to". The term "based on" means "based at least in part on". The term "one embodiment" means "at least one embodiment"; the term "another embodiment" means "at least one additional embodiment"; the term "some embodiments" means "at least some embodiments". The relevant definitions of other terms will be given in the following description.
[0019] It should be noted that the concepts such as "first" and "second" mentioned in the present disclosure are only used to distinguish different devices, modules or units, and are not used to limit the order or interdependence of the functions performed by these devices, modules or units.
[0020] It should be noted that the modifications of "one" and "plurality" mentioned in the present disclosure are illustrative rather than restrictive, and those skilled in the art should understand that unless otherwise clearly indicated in the context, it should be understood as "at least one".
[0021] The names of the messages or information exchanged between multiple devices in the embodiments of the present disclosure are only used for illustrative purposes and are not used to limit the scope of these messages or information.
[0022] Please refer to Figure 1 , which shows the process of an embodiment of the method for isolating tenants according to the present disclosure. Figure 1 The method for isolating tenants includes the following steps:
[0023] Step 101: Based on the registration request of the tenant, a language interpreter corresponding to the tenant is established.
[0024] In this embodiment, the execution subject (eg, server and / or terminal device) of the method for isolating tenants may establish a language interpreter corresponding to the tenant based on the registration request of the tenant.
[0025] Here, tenants can be understood as follows: after each of us or an enterprise registers an account on the platform, the platform considers us to be a tenant. Resources will be allocated to us based on tenants. Tenants are actually a collection of accessible resources in various services. These resource collections can be used by multiple users, which is why users are usually bound to certain tenants. Users access computing management resources through tenants, which means that they need to specify a corresponding tenant before they can apply for services.
[0026] Here, the stack area bound to the language interpreter and the stack area bound to the speech interpreter can be understood as the stack of the process, which can indicate that during the process running, if a function call occurs, the context of the function is saved in a memory area in a first-in-last-out manner. There is a mapping relationship between the stack area and the address space of the electronic device. For example, the stack area can be mapped to the address space of the host environment (physical device of the execution subject) in a random manner.
[0027] Here, the stack areas of different tenants are independent of each other.
[0028] Optionally, the stack area includes a heap area and / or a stack area.
[0029] As an example, the language interpreter used in this embodiment may be, for example, a V8-type language interpreter.
[0030] As an example, the stack area may correspond one-to-one with the speech interpreter.
[0031] Step 102: Run the code corresponding to the tenant based on the language interpreter.
[0032] Here, you can use the language interpreter to interpret the code corresponding to the tenant.
[0033] Here, a language interpreter can read a program and convert it into computer instructions for immediate execution. That is, a language interpreter can read a program and convert it into an intermediate form. And directly execute this intermediate form of the program. Interpreted languages go through this process every time they are executed.
[0034] Optionally, the code corresponding to the tenant may be a code corresponding to the request of the tenant, or may be a code corresponding to the context of the tenant.
[0035] Optionally, the code corresponding to the tenant may include but is not limited to at least one of the following types: JavaScript, WebAssembly.
[0036] It should be noted that the method for isolating tenants in this embodiment provides an address space isolation method based on a language virtual machine. Each tenant establishes a separate language interpreter, and each language interpreter has an independent stack area. The stack area corresponding to the tenant is mapped to the address space of the host environment, so that each tenant's script code does not have the ability to directly manipulate memory addresses. Thus, a safe execution environment is provided for each tenant. In other words, each tenant does not have the ability to directly manipulate memory addresses. Even if the tenant's entire device environment is dangerous, the tenant can be isolated from other tenants to ensure the safety of the tenant's execution environment.
[0037] In addition, using language interpreters as a means of isolation can provide a secure, lightweight execution environment suitable for large-scale scalability. In other words, language interpreters take up fewer resources and are easy to deploy. New tenants only need to register and establish the corresponding language interpreter. Due to large-scale scalability and efficient resource utilization, the cost of this solution is an order of magnitude higher than that of container-based isolation. In some related technologies, FaaS technical solutions mostly use containers or virtual machines to provide tenant isolation. However, in edge computing environments, due to the small amount of resources on edge nodes, solutions using containers or virtual machines are often difficult to deploy and use on a large scale.
[0038] In some embodiments, step 102 may include: in response to receiving a pending request from the tenant, interpreting a code corresponding to the pending request using the language interpreter on a target thread corresponding to the tenant.
[0039] Here, when executing code (such as JavaScript, JS) for each tenant, all JS executions of the tenant can be isolated to a group of threads, that is, the JS code of each tenant can only be executed on a specific thread.
[0040] As a result, threads of different tenants are isolated from each other, and the script code execution of tenants can be isolated, thereby achieving safe execution of tenant codes.
[0041] In some embodiments, the method further includes: allowing the target thread to make a first type of system call; and restricting the target thread from making a second type of system call.
[0042] Here, the system kernel of the electronic device packages some special hardware instructions and hardware states that can realize specific functions, namely kernel functions, and presents them to the user through a set of interfaces called system calls.
[0043] Here, the first type includes at least one of the following: a memory usage class and a communication class, and the second type includes a system call type other than the first type.
[0044] In some related technologies, threads can interact with the system and implement corresponding functions using system calls. Various functions provided by the system calls are open to threads.
[0045] In this implementation, system calls are classified, and the first type of system calls are reserved for use by threads corresponding to tenants; and the target thread is restricted from making system calls of the second type.
[0046] Optionally, limiting the second type of system calls may include disabling the second type of system calls, or may include processing the second type of system calls and then providing corresponding functions to the target thread.
[0047] As an example, a set of system calls required for operation can be allowed, for memory usage, communication, synchronization, etc. The rest of the system calls are restricted, such as the system call to close almost all file systems, and the socket system call is restricted to only support the TCP protocol.
[0048] It should be noted that compared with hundreds of system calls, the number of system calls after restriction is only dozens, which greatly reduces the possible attack surface of the system. Therefore, the possibility of being attacked can be reduced and the system security can be improved.
[0049] In some embodiments, the second type includes a device file type. The limiting the target thread to the second type of system call includes: generating a virtual address of a device file for the target thread; and directing the device file call of the target thread to the virtual address.
[0050] As an example, for each JS running thread, we randomly generate a virtual address, and the virtual address points to a device file. Optionally, the device file pointed to by the virtual address includes the device files required for the thread to run, such as / dev / null / dev / random and tmpfs, and the device files in other file systems may not be set in the device file pointed to by the virtual address.
[0051] It should be noted that the device file that the target thread needs to call is pointed to by the virtual address, so that when the target thread calls the device file, the device file cannot be directly operated, thereby ensuring the security of the device file.
[0052] In some embodiments, the limiting the target thread to a second type of system call includes: in response to the target thread issuing a system call, encapsulating the system call as a remote call request, and sending the remote call request to a second thread, the second thread obtaining a request result of the system call request, and returning the request result to the target thread.
[0053] As an example, the system call of the target thread may be encapsulated into a remote procedure call (RPC), and the target thread sends the RPC work event to a second thread supporting the system call for execution, and the second thread returns the result after completion.
[0054] It should be noted that by sending the system call to another thread for execution and the thread returning the result, the tenant's target thread can be prevented from making direct system calls, reducing the risk of the system being attacked.
[0055] In some embodiments, the method also includes: determining the amount of memory occupied by the current running process of the tenant's code; in response to the amount of occupied memory being greater than a first memory threshold and not greater than a second memory threshold, stopping receiving new pending requests from the tenant; in response to the amount of occupied memory being greater than the second memory threshold, stopping the tenant's current running process.
[0056] As an example, each tenant has an independent logical memory allocator. The allocation of the tenant's runtime data structure occurs in the tenant's independent memory allocator, and the allocator records the memory usage. When the memory allocation is overused, it will trigger the determination of the amount of memory occupied by the tenant's current running process and provide a solution.
[0057] For example, if the memory overuse is not high, we will allow the tenant's code to continue to execute, but during this period, the tenant's runtime environment cannot accept new requests. When all existing requests in the runtime environment are executed, the runtime environment is recycled. If the memory overuse is too high, we will directly cancel all running requests immediately.
[0058] It should be noted that by controlling the tenant's memory resource consumption, statistics are collected and over-usage solutions are implemented every time the tenant's memory limit is triggered, which can not only ensure the execution of tenant requests, but also avoid a single tenant occupying too many content resources and affecting the execution of other tenants' code.
[0059] In some embodiments, the method further includes: determining whether the CPU time slice corresponding to the request being processed by the tenant is greater than a time slice threshold; if the CPU time slice is greater than the time slice threshold, stopping execution of the pending request.
[0060] Here, the CPU time slice indicates the length of time that the tenant's code is scheduled to be executed on the CPU.
[0061] Optionally, the time slice threshold corresponds to a tenant. In other words, different time slice thresholds can be set for different tenants.
[0062] For example, CPU time slice refers to the time that a tenant's JavaScript code is scheduled to execute on the CPU. Each request of each tenant has an independent CPU time slice quota. If the execution quota of the request is exceeded, the request will be canceled.
[0063] It should be noted that by limiting the CPU time slice for each tenant's request each time, it is possible to avoid a single request occupying the CPU for a long time and to avoid affecting the processing of other requests, thereby improving the overall processing efficiency of requests from different tenants.
[0064] In some embodiments, the method further includes: determining whether a response time corresponding to a request being processed by the tenant is greater than a response time threshold; if the response time is greater than the response time threshold, stopping execution of the pending request.
[0065] Here, the response time indication includes the duration from the start of execution to the completion of execution.
[0066] As an example, the response time (RT time) refers to the time from the start of each request to the completion of its execution. The RT time can include CPU time and the time waiting for the interface response. If the execution of the request exceeds the response time threshold, the request will be canceled.
[0067] It should be noted that by limiting the response time of each tenant's request, it is possible to avoid a single request occupying the CPU or interface for a long time and to avoid affecting the processing of other requests, thereby improving the overall processing efficiency of requests from different tenants.
[0068] In some embodiments, the method further includes: for each tenant, setting a running restart time of the tenant; in response to the running restart time arriving, resetting the address space mapping of the tenant.
[0069] As an example, for each tenant, a random runtime restart time can be set. Whenever the random time comes, the tenant's context will be automatically reloaded; each reload will have a new memory address space mapping. In addition, for each tenant, we will independently maintain each tenant's IO resources, and connections between tenants will not be shared.
[0070] It should be noted that by resetting the memory address mapping, the address space corresponding to the tenant can be changed, further reducing the impact of the tenant on the address space, avoiding the adverse impact of individual tenants on the system, and improving the overall security of the system.
[0071] In some embodiments, the method further includes: according to the security level of the tenant, setting the language interpreter corresponding to the tenant in the execution engine corresponding to the security level.
[0072] Here, execution engines corresponding to different security levels are physically isolated.
[0073] As examples, an execution engine may include a language interpreter, a just-in-time compiler, a garbage collector.
[0074] Optionally, the execution engine can be the execution engine of a physical machine or a virtual machine. The execution engine of a physical machine is directly built on the processor, cache, instruction set and operating system level. The execution engine of a virtual machine is implemented by software itself, and the structure of the instruction set and execution engine can be customized without being restricted by physical conditions, and can execute instruction set formats that are not directly supported by hardware.
[0075] As an example, security level ratings can be set for tenants, and different security levels are assigned to different physically isolated runtime execution engines for execution.
[0076] As an example, the security rating of a tenant may be determined based on the tenant's behavior. For example, factors affecting the security rating of a tenant may include, but are not limited to, at least one of the following: the tenant has multiple Out Of Memory (OOM) within a short period of time, the tenant's DNS resolved IP address points to a blacklisted IP address, the tenant repeatedly attempts to use an unsafe API, and the network attack monitoring of the requested website is triggered.
[0077] It should be noted that different execution engines are set to correspond to different security levels, and execution engines of different security levels are physically isolated. Thus, tenants are graded for security levels so that tenants of different security levels do not affect each other. As an example, a tenant with a lower security level may be dangerous to the system. Physically isolating the tenant with a lower security level from the tenant with a higher security level can ensure the security of the tenant with a higher security level even if the tenant with a lower security level attacks the system.
[0078] Further references Figure 2 , the present disclosure provides an embodiment of a method for isolating tenants.
[0079] Step 201: Based on the registration request of the tenant, a language interpreter corresponding to the tenant is established.
[0080] Step 202: In response to receiving the pending request of the tenant, interpreting the code corresponding to the pending request by using the language interpreter on the target thread corresponding to the tenant.
[0081] Step 203: Allow the target thread to make a system call of the first type.
[0082] Step 204: restrict the target thread from making system calls of the second type.
[0083] It should be noted that the method for isolating tenants provided in this embodiment can limit the system calls of the target thread. Compared with hundreds of system calls, the limited system calls are only dozens, which greatly reduces the possible attack surface of the system. Therefore, the possibility of being attacked can be reduced and the system security can be improved.
[0084] Further references Figure 3 , the present disclosure provides an embodiment of a method for isolating tenants.
[0085] Step 301: Based on the registration request of the tenant, a language interpreter corresponding to the tenant is established.
[0086] Step 302: Run the code corresponding to the tenant based on the language interpreter.
[0087] Step 303: determine the amount of memory occupied by the current running process of the tenant's code.
[0088] Step 304: In response to the amount of occupied memory being greater than the first memory threshold and not greater than the second memory threshold, stop receiving new pending requests of the tenant.
[0089] Step 305: In response to the amount of occupied memory being greater than a second memory threshold, stopping the current running process of the tenant.
[0090] It should be noted that the method for isolating tenants provided in this embodiment controls the memory resource consumption of tenants. Every time the memory limit of the tenant is triggered, statistics are taken and an over-usage solution is implemented. This can not only ensure the execution of tenant requests, but also avoid a single tenant occupying too many content resources and affecting the execution of other tenants' code.
[0091] Further references Figure 4 , the present disclosure provides an embodiment of a method for isolating tenants.
[0092] Step 401: Based on the registration request of the tenant, a language interpreter corresponding to the tenant is established.
[0093] Step 402, according to the security level of the tenant, the language interpreter corresponding to the tenant is set in the execution engine corresponding to the security level.
[0094] Step 403: For each tenant, set the operation restart time of the tenant.
[0095] Step 404: in response to the arrival of the restart time, reset the address space mapping of the tenant.
[0096] Step 405: Run the code corresponding to the tenant based on the language interpreter.
[0097] It should be noted that the method for isolating tenants provided in this embodiment can change the address space corresponding to the tenant by resetting the memory address mapping, further reduce the impact of the tenant on the address space, avoid the adverse impact of individual tenants on the system, and improve the overall security of the system. In addition, different execution engines are set to correspond to different security levels, and execution engines of different security levels are physically isolated. Thus, the tenants are graded for security levels so that tenants with different security levels do not affect each other. As an example, tenants with lower security levels may be dangerous to the system. Physically isolating tenants with lower security levels from tenants with higher security levels can ensure the security of tenants with higher security levels even if tenants with lower security levels attack the system.
[0098] Further references Figure 5 As an implementation of the methods shown in the above figures, the present disclosure provides an embodiment of a device for isolating tenants. Figure 1 Corresponding to the method embodiment shown, the device can be specifically applied to various electronic devices.
[0099] like Figure 5 As shown, the device for isolating tenants in this embodiment includes: an establishing unit 501 and an operating unit 502. The establishing unit is used to establish a language interpreter corresponding to the tenant based on the registration request of the tenant, wherein the language interpreter is bound to a stack area, and there is a mapping relationship between the stack area and the address space of the electronic device; the operating unit is used to operate the code corresponding to the tenant based on the language interpreter.
[0100] In this embodiment, the specific processing of the establishing unit 501 and the operating unit 502 of the device for isolating tenants and the technical effects thereof can be referred to in Figure 1 The relevant descriptions of step 101 and step 102 in the corresponding embodiment are not repeated here.
[0101] In some embodiments, running the code corresponding to the tenant based on the language interpreter includes: in response to receiving a pending request from the tenant, using the language interpreter to interpret the code corresponding to the pending request on a target thread corresponding to the tenant.
[0102] In some embodiments, the device is also used to: allow the target thread to make system calls of a first type; restrict the target thread from making system calls of a second type; wherein the first type includes at least one of the following: memory usage class, communication class, and the second type includes system call types other than the first type.
[0103] In some embodiments, the second type includes a device file type; and limiting the target thread's system call to the second type includes: generating a virtual address of a device file for the target thread; and directing the target thread's device file call to the virtual address.
[0104] In some embodiments, limiting the target thread to a second type of system call includes: in response to the target thread issuing a system call, encapsulating the system call as a remote call request, and sending the remote call request to a second thread, the second thread obtaining a result of the system call request, and returning the result to the target thread.
[0105] In some embodiments, the device is also used to: determine the amount of memory occupied by the current running process of the tenant's code; in response to the amount of occupied memory being greater than a first memory threshold and not greater than a second memory threshold, stop receiving new pending requests from the tenant; in response to the amount of occupied memory being greater than the second memory threshold, stop the tenant's current running process.
[0106] In some embodiments, the device is also used to: determine whether the CPU time slice corresponding to the request being processed by the tenant is greater than a time slice threshold, wherein the CPU time slice indicates the length of time it takes to schedule the tenant's script code to execute on the CPU; if the CPU time slice is greater than the time slice threshold, stop executing the pending request.
[0107] In some embodiments, the device is also used to: determine whether the response time corresponding to the request being processed by the tenant is greater than a response time threshold, wherein the response time indication includes the time from the start of execution to the completion of execution; if the response time is greater than the time slice threshold, stop executing the pending request.
[0108] In some embodiments, the device is further used to: set a running restart time for each tenant; and reset the address space mapping of the tenant in response to the arrival of the running restart time.
[0109] In some embodiments, the device is also used to: according to the security level of the tenant, set the language interpreter corresponding to the tenant in the execution engine corresponding to the security level, wherein the execution engines of different security levels are physically isolated.
[0110] Please refer to Figure 6 , Figure 6 An exemplary system architecture is shown in which the method for isolating tenants according to an embodiment of the present disclosure can be applied.
[0111] like Figure 6As shown, the system architecture may include terminal devices 601, 602, 603, a network 604, and a server 605. The network 604 is used to provide a medium for communication links between the terminal devices 601, 602, 603 and the server 605. The network 604 may include various connection types, such as wired, wireless communication links or optical fiber cables, etc.
[0112] The terminal devices 601, 602, and 603 can interact with the server 605 through the network 604 to receive or send messages, etc. Various client applications, such as web browser applications, search applications, and news information applications, can be installed on the terminal devices 601, 602, and 603. The client applications in the terminal devices 601, 602, and 603 can receive user instructions and perform corresponding functions according to the user instructions, such as adding corresponding information to the information according to the user instructions.
[0113] Terminal devices 601, 602, and 603 can be hardware or software. When terminal devices 601, 602, and 603 are hardware, they can be various electronic devices with display screens and supporting web browsing, including but not limited to smart phones, tablet computers, e-book readers, MP3 players (Moving Picture Experts Group Audio Layer III, Moving Picture Experts Group Audio Layer 3), MP4 (Moving Picture Experts Group Audio Layer IV, Moving Picture Experts Group Audio Layer 4) players, laptop computers, and desktop computers, etc. When terminal devices 601, 602, and 603 are software, they can be installed in the electronic devices listed above. It can be implemented as multiple software or software modules (for example, software or software modules used to provide distributed services), or it can be implemented as a single software or software module. No specific limitation is made here.
[0114] The server 605 may be a server that provides various services, such as receiving information acquisition requests sent by the terminal devices 601, 602, and 603, acquiring display information corresponding to the information acquisition requests in various ways according to the information acquisition requests, and sending the relevant data of the display information to the terminal devices 601, 602, and 603.
[0115] It should be noted that the method for isolating tenants provided in the embodiment of the present disclosure can be executed by a terminal device, and accordingly, the device for isolating tenants can be set in the terminal devices 601, 602, and 603. In addition, the method for isolating tenants provided in the embodiment of the present disclosure can also be executed by a server 605, and accordingly, the device for isolating tenants can be set in the server 605.
[0116] It should be understood that Figure 6 The number of terminal devices, networks and servers in the embodiment is only for illustration. Any number of terminal devices, networks and servers may be provided according to implementation requirements.
[0117] Reference below Figure 7 , which shows an electronic device (eg, Figure 6 The terminal device in the embodiment of the present disclosure may include but is not limited to mobile terminals such as mobile phones, notebook computers, digital broadcast receivers, PDAs (personal digital assistants), PADs (tablet computers), PMPs (portable multimedia players), vehicle-mounted terminals (such as vehicle-mounted navigation terminals), etc., and fixed terminals such as digital TVs, desktop computers, etc. Figure 7 The electronic device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present disclosure.
[0118] like Figure 7 As shown, the electronic device may include a processing device (e.g., a central processing unit, a graphics processor, etc.) 701, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 702 or a program loaded from a storage device 708 into a random access memory (RAM) 703. In the RAM 703, various programs and data required for the operation of the electronic device 700 are also stored. The processing device 701, the ROM 702, and the RAM 703 are connected to each other via a bus 704. An input / output (I / O) interface 705 is also connected to the bus 704.
[0119] Typically, the following devices may be connected to the I / O interface 705: input devices 706 including, for example, a touch screen, a touch pad, a keyboard, a mouse, a camera, a microphone, an accelerometer, a gyroscope, etc.; output devices 707 including, for example, a liquid crystal display (LCD), a speaker, a vibrator, etc.; storage devices 708 including, for example, a magnetic tape, a hard disk, etc.; and communication devices 709. The communication devices 709 may allow the electronic device to communicate with other devices wirelessly or by wire to exchange data. Although Figure 7 An electronic device having various devices is shown, but it should be understood that it is not required to implement or possess all the devices shown. More or fewer devices may be implemented or possessed instead.
[0120] In particular, according to an embodiment of the present disclosure, the process described above with reference to the flowchart can be implemented as a computer software program. For example, an embodiment of the present disclosure includes a computer program product, which includes a computer program carried on a non-transitory computer-readable medium, and the computer program contains program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from a network through a communication device 709, or installed from a storage device 708, or installed from a ROM 702. When the computer program is executed by the processing device 701, the above-mentioned functions defined in the method of the embodiment of the present disclosure are executed.
[0121] It should be noted that the computer-readable medium mentioned above in the present disclosure may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with at least one wire, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present disclosure, a computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in combination with an instruction execution system, device or device. In the present disclosure, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, in which a computer-readable program code is carried. This propagated data signal may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. The computer readable signal medium may also be any computer readable medium other than a computer readable storage medium, which may send, propagate or transmit a program for use by or in conjunction with an instruction execution system, apparatus or device. The program code contained on the computer readable medium may be transmitted using any suitable medium, including but not limited to: wires, optical cables, RF (radio frequency), etc., or any suitable combination of the above.
[0122] In some embodiments, the client and the server may communicate using any currently known or future developed network protocol such as HTTP (HyperText Transfer Protocol), and may be interconnected with any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include a local area network ("LAN"), a wide area network ("WAN"), an internet (e.g., the Internet), and a peer-to-peer network (e.g., an ad hoc peer-to-peer network), as well as any currently known or future developed network.
[0123] The computer-readable medium may be included in the electronic device, or may exist independently without being incorporated into the electronic device.
[0124] The above-mentioned computer-readable medium carries one or more programs. When the above-mentioned one or more programs are executed by the electronic device, the electronic device: establishes a language interpreter corresponding to the tenant based on the tenant's registration request, wherein the language interpreter is bound to a stack area, and there is a mapping relationship between the stack area and the address space of the electronic device; based on the language interpreter, runs the code corresponding to the tenant.
[0125] In some embodiments, running the code corresponding to the tenant based on the language interpreter includes: in response to receiving a pending request from the tenant, using the language interpreter to interpret the code corresponding to the pending request on a target thread corresponding to the tenant.
[0126] In some embodiments, the device is also used to: allow the target thread to make system calls of a first type; restrict the target thread from making system calls of a second type; wherein the first type includes at least one of the following: memory usage class, communication class, and the second type includes system call types other than the first type.
[0127] In some embodiments, the second type includes a device file type; and limiting the target thread's system call to the second type includes: generating a virtual address of a device file for the target thread; and directing the target thread's device file call to the virtual address.
[0128] In some embodiments, limiting the target thread to a second type of system call includes: in response to the target thread issuing a system call, encapsulating the system call as a remote call request, and sending the remote call request to a second thread, the second thread obtaining a result of the system call request, and returning the result to the target thread.
[0129] In some embodiments, the device is also used to: determine the amount of memory occupied by the current running process of the tenant's code; in response to the amount of occupied memory being greater than a first memory threshold and not greater than a second memory threshold, stop receiving new pending requests from the tenant; in response to the amount of occupied memory being greater than the second memory threshold, stop the tenant's current running process.
[0130] In some embodiments, the device is also used to: determine whether the CPU time slice corresponding to the request being processed by the tenant is greater than a time slice threshold, wherein the CPU time slice indicates the length of time it takes to schedule the tenant's script code to execute on the CPU; if the CPU time slice is greater than the time slice threshold, stop executing the pending request.
[0131] In some embodiments, the device is also used to: determine whether the response time corresponding to the request being processed by the tenant is greater than a response time threshold, wherein the response time indication includes the time from the start of execution to the completion of execution; if the response time is greater than the time slice threshold, stop executing the pending request.
[0132] In some embodiments, the device is further used to: set a running restart time for each tenant; and reset the address space mapping of the tenant in response to the arrival of the running restart time.
[0133] In some embodiments, the device is also used to: according to the security level of the tenant, set the language interpreter corresponding to the tenant in the execution engine corresponding to the security level, wherein the execution engines of different security levels are physically isolated.
[0134] Computer program code for performing the operations of the present disclosure may be written in one or more programming languages or a combination thereof, including, but not limited to, object-oriented programming languages, such as Java, Smalltalk, C++, and conventional procedural programming languages, such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a separate software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving a remote computer, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., through the Internet using an Internet service provider).
[0135] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present disclosure. In this regard, each box in the flow chart or block diagram can represent a module, a program segment or a part of a code, and the module, the program segment or a part of the code contains at least one executable instruction for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a sequence different from that marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram and / or flow chart, and the combination of the boxes in the block diagram and / or flow chart can be implemented with a dedicated hardware-based system that performs the specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0136] The units involved in the embodiments described in the present disclosure may be implemented by software or hardware. The name of a unit does not limit the unit itself in some cases. For example, a selection unit may also be described as a "unit for selecting a first type of pixel".
[0137] The functions described above herein may be performed at least in part by at least one hardware logic component. For example, without limitation, exemplary types of hardware logic components that may be used include: field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chip (SOCs), complex programmable logic devices (CPLDs), and the like.
[0138] In the context of the present disclosure, a machine-readable medium may be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, device, or equipment. A machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or equipment, or any suitable combination of the foregoing. A more specific example of a machine-readable storage medium may include an electrical connection based on at least one line, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0139] The above description is only a preferred embodiment of the present disclosure and an explanation of the technical principles used. Those skilled in the art should understand that the scope of disclosure involved in the present disclosure is not limited to the technical solutions formed by a specific combination of the above technical features, but should also cover other technical solutions formed by any combination of the above technical features or their equivalent features without departing from the above disclosed concept. For example, the above features are replaced with the technical features with similar functions disclosed in the present disclosure (but not limited to) by each other to form a technical solution.
[0140] In addition, although each operation is described in a specific order, this should not be understood as requiring these operations to be performed in the specific order shown or in a sequential order. Under certain circumstances, multitasking and parallel processing may be advantageous. Similarly, although some specific implementation details are included in the above discussion, these should not be interpreted as limiting the scope of the present disclosure. Some features described in the context of a separate embodiment can also be implemented in a single embodiment in combination. On the contrary, the various features described in the context of a single embodiment can also be implemented in multiple embodiments individually or in any suitable sub-combination mode.
[0141] Although the subject matter has been described in language specific to structural features and / or methodological logical actions, it should be understood that the subject matter defined in the appended claims is not necessarily limited to the specific features or actions described above. On the contrary, the specific features and actions described above are merely example forms of implementing the claims.
Claims
1. A method for isolating tenants, characterized in that: include: Based on the registration request of the tenant, establish a language interpreter corresponding to the tenant, wherein the language interpreter is bound to a stack area, and a mapping relationship exists between the stack area and the address space of the electronic device; Based on the tenant's security level, the language interpreter corresponding to the tenant is set in the execution engine corresponding to the security level, wherein the execution engines of different security levels are physically isolated; For each tenant, set the running restart time of the tenant; In response to the arrival of the operation restart time, resetting the address space mapping of the tenant; Based on the language interpreter, run the code corresponding to the tenant.
2. The method according to claim 1, characterized in that The running of the code corresponding to the tenant based on the language interpreter includes: In response to receiving the pending request of the tenant, the code corresponding to the pending request is interpreted by using the language interpreter on the target thread corresponding to the tenant.
3. The method according to claim 2, characterized in that The method further comprises: Allowing the target thread to make a system call of the first type; Restricting the target thread from making system calls of a second type; The first type includes at least one of the following: a memory usage type and a communication type; and the second type includes system call types other than the first type.
4. The method according to claim 3, characterized in that The second type comprises a device file type; and The limiting the target thread to the second type of system call includes: For the target thread, generating a virtual address of a device file; The device file call of the target thread is directed to the virtual address.
5. The method according to claim 3, characterized in that The limiting the target thread to the second type of system call includes: In response to the target thread issuing a system call, the system call is encapsulated into a remote call request, and the remote call request is sent to the second thread. The second thread obtains a result of the system call request and returns the result to the target thread.
6. The method according to any one of claims 1 to 5, characterized in that The method further comprises: Determine the amount of memory currently occupied by the tenant's code; In response to the amount of occupied memory being greater than a first memory threshold and not greater than a second memory threshold, stopping receiving new pending requests from the tenant; In response to the amount of occupied memory being greater than a second memory threshold, stopping a currently running process of the tenant.
7. The method according to any one of claims 1 to 5, characterized in that The method further comprises: Determine whether the CPU time slice corresponding to the request being processed by the tenant is greater than the time slice threshold, where the CPU time slice indicates the duration for scheduling the tenant's script code to be executed on the CPU; If the CPU time slice is greater than the time slice threshold, the execution of the pending request of the tenant is stopped.
8. The method according to any one of claims 1 to 5, characterized in that The method further comprises: Determine whether the response time corresponding to the request being processed by the tenant is greater than a response time threshold, wherein the response time indication includes the length of time from the start of execution to the completion of execution; If the response time is greater than the time slice threshold, the execution of the pending request of the tenant is stopped.
9. A device for isolating tenants, characterized in that: include: an establishing unit, configured to establish a language interpreter corresponding to the tenant based on the registration request of the tenant, wherein the language interpreter is bound to a stack area, and a mapping relationship exists between the stack area and the address space of the electronic device; An execution unit, configured to execute the code corresponding to the tenant based on the language interpreter; The device is also used to: set the language interpreter corresponding to the tenant in the execution engine corresponding to the security level according to the tenant's security level, wherein the execution engines of different security levels are physically isolated; set the running restart time of each tenant; and reset the address space mapping of the tenant in response to the running restart time being reached.
10. An electronic device, characterized in that: include: at least one processor; a storage device for storing at least one program, When the at least one program is executed by the at least one processor, the at least one processor implements the method according to any one of claims 1 to 8.
11. A computer-readable medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the method according to any one of claims 1 to 8 is implemented.
