WO2018214850A1 - 用于访问安全世界的方法、装置和系统 - Google Patents

用于访问安全世界的方法、装置和系统 Download PDF

Info

Publication number
WO2018214850A1
WO2018214850A1 PCT/CN2018/087699 CN2018087699W WO2018214850A1 WO 2018214850 A1 WO2018214850 A1 WO 2018214850A1 CN 2018087699 W CN2018087699 W CN 2018087699W WO 2018214850 A1 WO2018214850 A1 WO 2018214850A1
Authority
WO
WIPO (PCT)
Prior art keywords
virtual machine
user program
hash value
event
kernel
Prior art date
Application number
PCT/CN2018/087699
Other languages
English (en)
French (fr)
Inventor
杜小强
Original Assignee
华为技术有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 华为技术有限公司 filed Critical 华为技术有限公司
Priority to EP18806666.6A priority Critical patent/EP3637288B1/en
Publication of WO2018214850A1 publication Critical patent/WO2018214850A1/zh
Priority to US16/690,310 priority patent/US20200089918A1/en

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F21/00Security arrangements for protecting computers, components thereof, programs or data against unauthorised activity
    • G06F21/30Authentication, i.e. establishing the identity or authorisation of security principals
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F21/00Security arrangements for protecting computers, components thereof, programs or data against unauthorised activity
    • G06F21/70Protecting specific internal or peripheral components, in which the protection of a component leads to protection of the entire computer
    • G06F21/71Protecting specific internal or peripheral components, in which the protection of a component leads to protection of the entire computer to assure secure computing or processing of information
    • G06F21/74Protecting specific internal or peripheral components, in which the protection of a component leads to protection of the entire computer to assure secure computing or processing of information operating in dual or compartmented mode, i.e. at least one secure mode
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F21/00Security arrangements for protecting computers, components thereof, programs or data against unauthorised activity
    • G06F21/30Authentication, i.e. establishing the identity or authorisation of security principals
    • G06F21/44Program or device authentication
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F21/00Security arrangements for protecting computers, components thereof, programs or data against unauthorised activity
    • G06F21/50Monitoring users, programs or devices to maintain the integrity of platforms, e.g. of processors, firmware or operating systems
    • G06F21/52Monitoring users, programs or devices to maintain the integrity of platforms, e.g. of processors, firmware or operating systems during program execution, e.g. stack integrity ; Preventing unwanted data erasure; Buffer overflow
    • G06F21/53Monitoring users, programs or devices to maintain the integrity of platforms, e.g. of processors, firmware or operating systems during program execution, e.g. stack integrity ; Preventing unwanted data erasure; Buffer overflow by executing in a restricted environment, e.g. sandbox or secure virtual machine
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/455Emulation; Interpretation; Software simulation, e.g. virtualisation or emulation of application or operating system execution engines
    • G06F9/45533Hypervisors; Virtual machine monitors
    • G06F9/45558Hypervisor-specific management and integration aspects
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L9/00Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols
    • H04L9/32Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols including means for verifying the identity or authority of a user of the system or for message authentication, e.g. authorization, entity authentication, data integrity or data verification, non-repudiation, key authentication or verification of credentials
    • H04L9/3236Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols including means for verifying the identity or authority of a user of the system or for message authentication, e.g. authorization, entity authentication, data integrity or data verification, non-repudiation, key authentication or verification of credentials using cryptographic hash functions
    • H04L9/3239Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols including means for verifying the identity or authority of a user of the system or for message authentication, e.g. authorization, entity authentication, data integrity or data verification, non-repudiation, key authentication or verification of credentials using cryptographic hash functions involving non-keyed hash functions, e.g. modification detection codes [MDCs], MD5, SHA or RIPEMD
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/455Emulation; Interpretation; Software simulation, e.g. virtualisation or emulation of application or operating system execution engines
    • G06F9/45533Hypervisors; Virtual machine monitors
    • G06F9/45558Hypervisor-specific management and integration aspects
    • G06F2009/45587Isolation or security of virtual machine instances
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2221/00Indexing scheme relating to security arrangements for protecting computers, components thereof, programs or data against unauthorised activity
    • G06F2221/03Indexing scheme relating to G06F21/50, monitoring users, programs or devices to maintain the integrity of platforms
    • G06F2221/034Test or assess a computer or a system

Definitions

  • the present application relates to the field of computers and, more particularly, to a method, apparatus and system for accessing the world of security.
  • the Advanced RISC Machine (ARM) processor introduced the concept of TrustZone from the v6 architecture.
  • TrustZone is a processor mode unique to ARM processors.
  • TrustZone technology physically isolates computer systems into a secure world and a non-secure world.
  • TrustZone is a safe world and TrustZone is a non-secure world.
  • a user application (CA) (also referred to as a user program, etc.) can access the secure world by calling a public Secure Monitor Call (SMC) driver.
  • CA user application
  • SMC Public Secure Monitor Call
  • the following describes the method for the user program in the non-secure world to access the security world in combination with the architecture shown in FIG. 1, wherein the security service flow can be completed through the secure service channel, and the architecture shown in FIG. 1 can be utilized by non-secure
  • the SMC driver in the world, the SMC command in the non-secure world, the runtime firmware, the security service distribution and scheduling module of the kernel in the security world, and the secure service channel built by the secure user program are completed.
  • Step 1 The CA program (for example, CA1, CA2 or CA3) invokes an application programming interface (API) provided by the public SMC driver to pass parameters to the Rich Execution Environment (REE) operating system.
  • API application programming interface
  • REE Rich Execution Environment
  • OS Operating System
  • Step 2 The SMC driver writes the parameters into the register and calls the SMC instruction to trigger an abnormal event.
  • Step 3 After running the firmware to take over the abnormal event, switch the system mode and call the function related to the security service distribution and scheduling module in the Trusted Execution Environment (TEE) OS kernel.
  • TEE Trusted Execution Environment
  • Step 4 The security service distribution and scheduling module further parses the parameters and decomposes the parameter parsing results to schedule a related Trusted Application (TA) program.
  • TA Trusted Application
  • Step 5 The TA program (for example, TA1, TA2, or TA3 shown in FIG. 1) confirms the legality by using a Universally Unique Identifier (UUID) transmitted by the non-secure world application, and completes related security services.
  • UUID Universally Unique Identifier
  • the public SMC driver can be used by any program (including malicious programs), so that malicious programs can access the security world, thereby reducing the security of the security world.
  • the present application provides a method, apparatus, and system for accessing the world of security that enhances the security of the world of security.
  • a method for accessing a secure world comprising: creating a first virtual machine (VM) in a non-secure world; loading a plurality of programs in the non-secure world to the first
  • the plurality of programs include a kernel and at least one user program, wherein the kernel runs in a first level mode, and the at least one user program runs in a second level mode, the a level higher than the second level; creating a second in the non-secure world to create a mode running in the first level when determining that the first user program in the at least one user program needs to access the secure world a virtual machine; stripping the first user program from the first virtual machine and loading it to the second virtual machine, so that the first user program accesses the secure world through the second virtual machine .
  • VM virtual machine
  • the public SMC driver is no longer deployed in the kernel of the operating system of the non-secure world, and ordinary programs (including malicious programs) cannot obtain the security service call by calling the public SMC driver, and at the same time, for the convenience of the user.
  • the program accesses the security world and creates virtual machines of the same level as the kernel, so that user programs that need to access the secure world can access the secure world through virtual machines of the same level as the kernel, eliminating the need to access the secure world through a common SMC driver. This makes it possible to improve the security of the security world while achieving secure world access.
  • the level of the second virtual machine is the same as the level of the kernel, the information returned by the program of the secure world to the first user program can be directly received by the first user program via the second virtual machine without going through the shared kernel. It greatly avoids that the returned information is snooped or tampered with by the kernel, or prevents other malicious programs from using the kernel to snoop or tamper with the returned information.
  • the method further includes: setting a virtualization list to disable all programs in the first virtual machine (excluding the first user program among the multiple programs) Other programs than the other) continue to access the memory page belonging to the first user program being stripped.
  • the page table corresponding to the first user program may be deleted in the secondary page table to implement the program in the first virtual machine to access the memory page of the first user program.
  • malware programs can use these vulnerabilities to perform some operations (such as lifting rights) to destroy or steal data from normal user programs for the purpose of attack.
  • some operations such as lifting rights
  • the malicious program in the first virtual machine cannot access the memory page of the first user program, that is, This means that the first user program cannot be attacked (if you want to attack a program, you will inevitably access the program's memory page), so this implementation further enhances the security of the application.
  • the creating, in the non-secure world, creating a second mode in the mode of the first level includes: allocating resources exclusive to the first user program to the second virtual machine.
  • the exclusive resource optionally includes at least one of a central processing unit (CPU) resource, a peripheral device, and a memory.
  • Some resources will be used when the first user program accesses the security world. If these resources are used by other programs, the information obtained by accessing the security world will be leaked, for example, if the memory resources in the second virtual machine are in the non-secure world. Other programs are shared, and information from the secure world stored in the memory may be stolen by other programs. Therefore, allocating resources exclusive to the first user program to the second virtual machine can prevent other programs from stealing information related to the security world by using the first user program to access resources used by the security world.
  • multiple virtual machines working in the first level mode may be created, and one of the plurality of virtual machines corresponds to multiple user programs for corresponding The user program accesses the security world, and the resources of the multiple virtual machines are exclusive.
  • each legitimate user program is exclusively deployed in a separate virtual machine, so that each user program can enjoy a unique security service channel, so that the user program accesses the secure world's secure service channel without being used by other user programs. This prevents malicious programs from using the service channel to access the secure world.
  • the exclusive resource includes memory.
  • the memory in the second virtual machine can be used as a first user program to share memory with a program in the secure world.
  • the shared memory of the non-secure world user program communicates with the program in the secure world to achieve virtual machine level isolation, the first virtual machine
  • the malicious program inside cannot steal and destroy the data in the shared memory of the user program in the second virtual machine and the user program in the secure world.
  • the multiple program further includes an agent corresponding to the first user program, where After the first user program is stripped from the first virtual machine, the agent acts as a proxy of the first user program in the first virtual machine to trigger the kernel to process a process to be processed by the kernel. Processing the event, wherein the pending event is generated when the first user program is running on the second virtual machine.
  • the user program when the first user program runs in the second virtual machine, when an event that needs to be processed by the kernel is generated, the user program can be replaced by the agent corresponding to the first user program in the first virtual machine, thereby creating The first user program still operates in an environment under the first virtual machine such that the operating kernel of the first virtual machine can process the events that need to be processed by the kernel.
  • the method further includes: acquiring the to-be-processed event, the to-be-processed event needs to be Kernel processing, and is generated when the first user program runs in the second virtual machine; saves a context of the second virtual machine; restores a context of the agent in the first virtual machine, The pending event is processed by the kernel for triggering the loading of the first virtual machine.
  • the operation of the first virtual machine is interrupted by saving the context of the second virtual machine, and the context of the agent is restored, and the first user program can be directly switched to In the case of the first virtual machine, an environment in which the first user program is still operating under the first virtual machine is created, so that the operating kernel of the first virtual machine can process the event that needs to be processed by the kernel.
  • the method further includes: after the first virtual machine processes the to-be-processed event, Recovering the first user program in the second virtual machine.
  • the first virtual machine processes the pending event
  • the first user program is restored in the second virtual machine, and the operation of the first user program in the second virtual machine can be continued.
  • the to-be-processed event is an interrupt event, a page fault exception event, or a system call event.
  • the interrupt event, the page fault exception event, or the system call event is an event that needs to be processed by the kernel
  • the first virtual machine can pass the The agent corresponding to the first user program replaces the user program, creating an environment in which the first user program still works under the first virtual machine, so that the operation kernel of the first virtual machine can process the events.
  • the method before the first user program is detached from the first virtual machine, the method further includes determining that the first user program is a secure user program.
  • determining that the first user program is a secure user program can avoid loading the malicious program into the virtual machine in the second level mode, thereby avoiding malicious program access security. world.
  • the determining that the first user program is a secure user program comprises: acquiring a first hash value group And a second hash value group, the first hash value set including at least one first hash value, the second hash value set including at least one second hash value, wherein each first hash a value corresponding to each of the at least one data object in the first user program, the hash value being a current hash value of the data object; each second hash value Each of the at least one data object in the first user program is in one-to-one correspondence, the second hash value is a hash value of the data object at the factory; in the first hash value group When the second hash value group is the same, the first user program is determined to be a secure user program.
  • the hash value of the data object of the user program Since the hash value of the data object of the user program is unchanged under normal conditions, if it is tampered with or utilized, the hash value of the data object will be different from the hash value at the factory, so by comparing the user program The current hash value of the data object and the factory hash value can accurately determine whether the user program is a secure user program.
  • the method is implemented by an ARM processor, where the first level mode is a privilege level 1 (Exception Level 1, EL1) mode, the second level mode is Exception Level 0 (EL0) mode.
  • the first level mode is a privilege level 1 (Exception Level 1, EL1) mode
  • the second level mode is Exception Level 0 (EL0) mode.
  • a Virtual Machine Monitor (VMM) is provided, which can include a module or unit for performing the method of the first aspect or any alternative implementation of the first aspect.
  • VMM Virtual Machine Monitor
  • an apparatus for accessing a secure world comprising a memory and a processor having program code stored thereon for indicating execution of the first aspect or any optional implementation thereof, when The processor may implement the method of the first aspect or any of the alternative implementations of the first aspect when the code is executed.
  • a system for accessing a secure world comprising: a hardware layer of a non-secure world; a virtual machine monitor running on the hardware layer of the non-secure world, by the virtual machine monitor a first virtual machine and a second virtual machine that are created and controlled; wherein the first virtual machine is configured to load a plurality of programs of the non-secure world, the plurality of programs including a kernel and at least one user program, wherein The kernel runs in a first level mode, the at least one user program runs in a second level mode, the first level is higher than the second level; and the second virtual machine is used to load a location Determining, in the at least one user program, a first user program stripped from the first virtual machine for the first user program to access a secure world through the second virtual machine, wherein the second virtual machine runs on In the second level mode.
  • the virtual machine monitor can perform the method in the first aspect or any of the optional implementations of the first aspect.
  • a computer storage medium the program storage code storing program code for causing a computer to perform the method of any of the first aspect or the first aspect of the first aspect.
  • a computer program product comprising instructions which, when run on a computer, cause the computer to perform the method of any of the first aspect or the optional implementation of the first aspect.
  • Figure 1 is a schematic block diagram of a current TrustZone architecture
  • FIG. 2 is a schematic block diagram of a TrustZone architecture according to an embodiment of the present invention.
  • FIG. 3 is a schematic flowchart of a method for accessing a secure world according to an embodiment of the present invention
  • FIG. 4 is a process of creating a second virtual machine and performing a migration of a user program according to an embodiment of the present invention
  • FIG. 5 is a schematic flow chart of processing an interrupt event under the architecture shown in FIG. 2;
  • FIG. 6 is a schematic flow chart of processing system scheduling events under the architecture shown in FIG. 2;
  • FIG. 7 is a schematic flow chart of processing a page fault exception event under the architecture shown in FIG. 2;
  • FIG. 8 is a schematic block diagram of a virtual machine monitor according to an embodiment of the present invention.
  • FIG. 9 is a schematic block diagram of an apparatus for accessing a secure world, in accordance with an embodiment of the present invention.
  • FIG. 10 is a schematic block diagram of a system for accessing a secure world, in accordance with an embodiment of the present invention.
  • An embodiment of the present invention provides a TrustZone architecture as shown in FIG. 2.
  • TrustZone technology physically isolates computer systems into a secure world and a non-secure world.
  • TrustZone is a safe world and TrustZone is a non-secure world.
  • TEE Trusted Execution Environment
  • TEE OS is responsible for hardware resource abstraction management and security service program scheduling in the security world. After receiving the service request from the non-secure world, after the parameter is parsed, the corresponding TA program is scheduled to complete the relevant security task processing; Specifically, a program that provides specific security service functions, running in TrustZone as a secure world process.
  • TrustZone technology provides a complete physical isolation operating environment including a central processing unit (CPU), registers, bus, memory, cache, translation lookaside buffer (LTB) and peripherals.
  • CPU central processing unit
  • registers registers
  • bus memory
  • cache translation lookaside buffer
  • LTB translation lookaside buffer
  • the secure world and the non-secure world have their own memory space. Programs in the non-secure world cannot access the memory of the secure world, while programs in the secure world can access the memory of the mapped non-secure world.
  • non-secure world needs to transfer large chunks of data to the secure world (for example, data sizes that cannot be passed through registers), it is passed through shared memory.
  • EL0 Exception Level 0
  • EL1 Exception Level 1
  • EL2 Privilege Level 2
  • EL1 Exception Level 1
  • EL2 Privilege Level 2
  • the EL0 mode refers to the mode for running the user program
  • the EL1 mode refers to the mode of the kernel for running the operating system
  • the EL2 mode refers to the mode used to run the virtual machine monitor.
  • the EL1 mode has a higher privilege level than the EL0 mode
  • the EL2 mode has a higher privilege level than the EL1 mode.
  • Exception Level 3 (EL3) mode
  • Secure Exception Level 1 SEL1 mode
  • Secure Exception Level 0 Secure Exception Level
  • SEL0 SEL0
  • the VMM shown in Figure 2 can be used to manage the resources and context of the VM. Specifically, it can be used for generation of a VM, destruction of a VM, initialization of a VM, and switching of a user program in a VM, and the like.
  • the SMC driver is no longer deployed in the kernel of the operating system of the non-secure world.
  • a virtual machine working in the same level mode as the kernel is created, thus requiring access security.
  • User programs in the world can access the secure world through newly created virtual machines, and ordinary programs (including malicious programs) cannot obtain security service calls by calling a public SMC driver, thereby improving the security of the security world.
  • FIG. 2 should not be construed as limiting the embodiments of the present invention.
  • the number of CAs and the number of VMs in the non-secure world, as well as the number of TAs in the secure world should not be specifically limited by this application.
  • embodiments of the present invention may be applied to an architecture of an ARM processor architecture, for example, an ARMv8 Cortex A series processor, but the embodiment of the present invention is not limited thereto.
  • FIG. 3 shows a schematic flow diagram of a method 100 for accessing a secure world.
  • the method 100 can optionally be performed by a virtual machine monitor as shown in FIG.
  • the method 100 includes at least some of the following.
  • the virtual machine monitor creates a first virtual machine in a non-secure world.
  • the first virtual machine may be VM0 as shown in FIG. 2.
  • the first virtual machine can be established in a system initialization phase.
  • a virtual machine monitor loads a plurality of programs in a non-secure world into a first virtual machine, the plurality of programs including a kernel and at least one user program.
  • the plurality of programs include an OS kernel, CA1, CA2, and CA3 as shown in FIG. 2.
  • the kernel runs in a first level mode
  • at least one user program runs in a second level mode, the first level being higher than the second level.
  • the mode of the first level may be the EL1 mode shown in FIG. 2, and the mode of the second level may be the EL0 mode shown in FIG. 2.
  • the OS kernel can operate in EL1 mode, and CA1, CA2, and CA3 can operate in EL0 mode.
  • a virtual machine monitor creates a second virtual machine in a non-secure world when it is determined that the first user program in the at least one user program needs to access the secure world.
  • the VMM when a user program, such as CA3, needs to access the secure world, the VMM can create VM 1 operating in EL1 mode and can strip the user program CA3 from VM0 and load it on VM 1 in.
  • the virtual machine monitor allocates resources exclusive to the first user program to the second virtual machine.
  • the exclusive resource optionally includes at least one of a CPU resource, a peripheral device, and a memory.
  • Some resources will be used when the first user program accesses the security world. If these resources are used by other programs, the information obtained by accessing the security world will be leaked, for example, if the memory resources in the second virtual machine are in the non-secure world. Other programs are shared, and information from the secure world stored in the memory may be stolen by other programs. Therefore, allocating resources exclusive to the first user program to the second virtual machine can prevent other programs from stealing information related to the security world by using the first user program to access resources used by the security world.
  • multiple virtual machines working in the first level mode may be created, and one of the plurality of virtual machines corresponds to multiple user programs for corresponding The user program accesses the security world, and the resources of the multiple virtual machines are exclusive.
  • each legitimate user program is exclusively deployed in a separate virtual machine, so that each user program can enjoy a unique security service channel, so that the user program accesses the secure world's secure service channel without being used by other user programs. This prevents malicious programs from using the service channel to access the secure world.
  • the security service channel of each user program is independent, and all user programs are used to access the security world by using the same security service channel, so as to prevent malware from occupying the same security service channel for a long time (for example, occupying public The way SMC drives) comes with security services for other user programs.
  • the exclusive resource includes memory.
  • the memory in the second virtual machine can be used as a first user program to share memory with a program in the secure world.
  • the shared memory of the non-secure world user program communicates with the program in the secure world to achieve virtual machine level isolation, the first virtual machine
  • the malicious program inside cannot steal and destroy the data in the shared memory of the user program in the second virtual machine and the user program in the secure world.
  • the virtual machine monitor can set a virtualization list to prohibit stripping of kernel pages and other user programs loaded in the first virtual machine from accessing memory pages in the second virtual machine.
  • the kernel, CA1, and CA2 in VM0 will disable access to the memory pages in VM1.
  • the page table corresponding to the first user program may be deleted in the secondary page table to implement the program of the first virtual machine to access the memory page of the first user program.
  • malware programs can use these vulnerabilities to perform some operations (such as lifting rights) to destroy or steal data from normal user programs for the purpose of attack.
  • some operations such as lifting rights
  • the malicious program in the first virtual machine cannot access the memory page of the first user program, that is, This means that the first user program cannot be attacked (if you want to attack a program, you will inevitably access the program's memory page), so this implementation further enhances the security of the application.
  • the virtual machine monitor determines whether the first user program is a secure user program, and when determining that the first user program is a secure user program, the virtual machine monitor A user program is stripped from the first virtual machine and loaded into the created second virtual machine. .
  • the first virtual machine can be trapped in the virtual machine monitor, and the virtual machine monitor can save the context of the first virtual machine and trigger the dynamic measurement function of the security world. Measure the integrity and legitimacy of the user program to ensure security.
  • the act of determining that the first user program is a secure user program may be performed prior to stripping the first user program from the first virtual machine.
  • determining that the first user program is a secure user program may be performed before the first user program is detached from the first virtual machine, and in the non-secure world creation run at the first The second virtual machine in the level mode is executed later.
  • determining that the first user program is a security user program may also create a second virtual machine running in the first level mode in the non-secure world, and loading the first user program Executed after the first virtual machine.
  • the integrity and legitimacy of other programs can be measured, for example, the integrity and security of agents and/or other user programs can be measured. Sex.
  • the dynamic metric is a dynamic security monitoring function deployed in the TrustZone. It can be used to verify the data objects that do not change during the running of the program. By checking the hash value of the object, it is ensured that no illegal tampering occurs during the running.
  • the virtual machine monitor may obtain the first hash value group (including at least one first hash value) and the second hash value group (including at least one second hash value), where the first The hash value is a current hash value of at least one of the first user program (eg, a user program code segment or a dynamic link library required for the user program to run), the second hash The value is the hash value of the data object at the factory (for security, it will be placed in the memory area of the secure world); the first hash value group is the same as the second hash value group (ie each The hash value of the data object is the same), and the first user program is determined to be a secure user program.
  • the first hash value group including at least one first hash value
  • the second hash value group including at least one second hash value
  • the first The hash value is a current hash value of at least one of the first user program (eg, a user program code segment or a dynamic link library required for the user program to run)
  • the hash value of the data object of the user program Since the hash value of the data object of the user program is unchanged under normal conditions, if it is tampered with or utilized, the hash value of the data object will be different from the hash value at the factory, so by comparing the user program The current hash value of the data object and the factory hash value can accurately determine whether the user program is a secure user program.
  • the process in the EL0 mode can be trapped into the VMM of the EL2 mode by accessing the ID register, for example, the CTR_EL0 register in the ID register Group 2 (where CRT_EL0 is The register in the ID register Group2, CTR is accessed by the Count Register (CTR) to trigger the trap.
  • CTR Count Register
  • the VMM can set the corresponding bit of the HCR_EL2 register (the HCR_EL2 register is the virtualization control register in the VMM control, and the HCR is the hypervisor configuration register (HCR)), for example, The TID2 bit of HCR_EL2 is set in the VMM.
  • the program in the EL1 mode (for example, the kernel of the operating system) can be triggered by the instruction to trigger the VMM, and the ELVC mode can be trapped into the EL2 mode by accessing the HVC instruction.
  • the program in the EL1 mode for example, the kernel of the operating system
  • the ELVC mode can be trapped into the EL2 mode by accessing the HVC instruction.
  • VMM the kernel of the operating system
  • the first user program is stripped from the first virtual machine and loaded into the second virtual machine to facilitate access by the first user program to the secure world through the second virtual machine.
  • the first user program may be migrated, that is, stripped from the first virtual machine, and loaded into the second virtual machine, thereby
  • the first user program can invoke the SMC driver in the second virtual machine to access the secure world. For example, you can apply for shared memory through the SMC driver and interact with the TA in the secure world through shared memory.
  • the second virtual machine can access the secure world by calling the SMC instruction.
  • peeling in the present application means "removing” and "removing", and the essence is that the first user program is not run in the first virtual machine, and the first user program is in the second virtual machine. Running, can be seen as “cutting" the code segment in the first virtual machine to the second virtual machine.
  • the first user program is stripped from the first virtual machine and loaded into the second virtual machine by using multiple implementation manners.
  • the virtual machine monitor may copy the memory page of the first user program in the first virtual machine (including the code segment of each program itself or a dynamic link library required for running, etc.) to the second virtual In the machine, and modifying the mapping relationship of the memory pages of the first virtual machine, so that the memory pages of the first user program in the first virtual machine are recycled.
  • the virtual machine monitor can directly map the memory page of the first user program in the first virtual machine to the second virtual machine (ie, map the address of the memory page in the physical memory to the second virtual The address in the machine).
  • the embodiment of the present invention may further implement the stripping and loading of the user program in the virtual machine by using other methods.
  • FIG. 2 For the sake of understanding, the scenario shown in FIG. 2 is taken as an example, and how to create the second virtual machine and migrate the user program is described in conjunction with FIG. 4.
  • CA3 calls the initialization interface of the agent.
  • the agent triggers the CPU to trap into the VMM of the EL2 mode by reading the CTR_EL0 register in ID group 2.
  • the VMM saves the VM0 virtual machine context and triggers the dynamic measurement function of the security world to measure the integrity and legality of CA3 to ensure security.
  • the VMM creates a new virtual machine VM1, which migrates CA3 into the EL1 mode of virtual machine VM1 to continue running CA3.
  • the multiple programs loaded to the first virtual machine further include an agent corresponding to the user program, and after the user program is stripped from the first virtual machine, the user program is in the A proxy of a virtual machine to facilitate execution of pending events generated while the user program is running on the second virtual machine.
  • the agent program may correspond to the user process one-to-one.
  • the agent can act as a proxy for the corresponding user process. Specifically, when the user program is loaded in the second virtual machine, the agent can proxy as the user program.
  • the virtual machine monitor may further acquire a pending event for the first user program, where the pending event needs to be processed by the kernel; save the context of the second virtual machine; and restore the context of the agent, So that the kernel should handle the processing of events.
  • the virtual machine monitor restores the first user program in the second virtual machine.
  • the agent can be in a second level mode.
  • the agent can be in a second level mode.
  • the pending event is an interrupt event, a page fault exception event, or a system call event.
  • the user program when the virtual machine where the currently running user program is located does not have an operating system kernel, the user program may be proxied by the agent, and the interrupt event and page fault abnormality may be implemented through the operation kernel of the original virtual machine.
  • the processing of an event or system call event when the virtual machine where the currently running user program is located does not have an operating system kernel, the user program may be proxied by the agent, and the interrupt event and page fault abnormality may be implemented through the operation kernel of the original virtual machine. The processing of an event or system call event.
  • FIG. 2 will be taken as an example to describe the processing flow when the event to be processed is an interrupt event, a page fault exception event, and a system call event, respectively, in conjunction with FIG. 5-7.
  • FIG. 5 is a schematic diagram of a processing flow when an event to be processed is an interrupt event.
  • the VMM acquires an interrupt signal triggered by hardware, at which point the current system is running CA3.
  • the VMM triggers a virtual interrupt and resumes the operation of the CA3 agent.
  • the system switches to the agent and the virtual interrupt reaches virtual machine VM0, interrupting the preemption of the agent's operation.
  • the VM 0 core processes the virtual interrupt.
  • the VMM restores the context of the interrupted VM 1.
  • the VMM in the case where the current system is running in the VM 1, when the hardware triggers the interrupt signal, the VMM can resume the processing of the agent, using the agent as a proxy for the first user program, and Interrupt processing is then performed and the agent is resumed after the interrupt is processed, so that even in the new architecture, the virtual machine on which the running program is located does not have an operating system kernel and can still be interrupted.
  • FIG. 6 is a schematic diagram of a processing flow when a pending event is a system scheduling event.
  • the VMM restores the context of VM0, switches CA3 to the agent run, and forwards the virtual interrupt to VM0.
  • the kernel scheduling module executes the related process according to its own scheduling policy.
  • the agent self-traps into the VMM when the agent is rescheduled.
  • VMM resumes VM1, which is also to switch CA3 to VM1.
  • the VM1 where the CA1 is located has no operating system kernel and cannot be self-scheduled. For example, it is impossible to determine the time slice for performing CA 1, and CA1 needs to comply with the scheduling policy of VM0, so as shown in FIG. In the scenario, the scheduling of the VM0 kernel to CA1 can be done through an agent.
  • FIG. 7 is a schematic diagram showing a processing flow when a pending event is a page fault abnormal event.
  • the VMM identifies that CA3 has a page fault exception, and then the CA3's recovery agent context.
  • the agent triggers a page fault exception event to re-enter the VM0 kernel.
  • the kernel page fault handler performs page fault related processing.
  • FIG. 8 is a schematic block diagram of a virtual machine monitor 200 in accordance with an embodiment of the present invention. As shown in FIG. 8, the virtual machine monitor 200 includes a creating unit 210 and a loading unit 220.
  • the creating unit 210 is configured to: create a first virtual machine in a non-secure world; the loading unit 220 is configured to: load multiple programs in the non-secure world into the first virtual machine, where The plurality of programs include a kernel and at least one user program, wherein the kernel runs in a first level mode, the at least one user program runs in a second level mode, the first level is higher than the a second level; the creating unit 210 is further configured to: when the first user program in the at least one user program needs to access the secure world, create a mode running in the first level in the non-secure world a second virtual machine; the loading unit 220 is further configured to: strip the first user program from the first virtual machine, and load the second virtual machine, so that the first user program passes The second virtual machine accesses the secure world.
  • the virtual machine monitor 200 further includes a setting unit 230, configured to: set a virtualization list to prohibit the first virtual machine from being stripped of the first user program A program other than the first user program accesses a memory page of the first user program stripped from the first virtual machine.
  • a setting unit 230 configured to: set a virtualization list to prohibit the first virtual machine from being stripped of the first user program A program other than the first user program accesses a memory page of the first user program stripped from the first virtual machine.
  • the creating unit 210 is further configured to allocate, by the second virtual machine, resources that are exclusive to the first user program.
  • the plurality of programs further include an agent, wherein the agent is the first user program in the first virtual after the first user program is stripped from the first virtual machine
  • the virtual machine monitor 200 further includes a processing unit 240, configured to: when the first user program is running, acquire the to-be-processed event for the first user program The processing event needs to be processed by the kernel; saving the context of the second virtual machine; restoring the running of the agent in the first virtual machine to trigger the kernel to process the pending event that needs to be processed by the kernel The pending event is generated when the first user program runs on the second virtual machine.
  • a processing unit 240 configured to: when the first user program is running, acquire the to-be-processed event for the first user program The processing event needs to be processed by the kernel; saving the context of the second virtual machine; restoring the running of the agent in the first virtual machine to trigger the kernel to process the pending event that needs to be processed by the kernel
  • the pending event is generated when the first user program runs on the second virtual machine.
  • the processing unit 240 is further configured to: after the first virtual machine processes the to-be-processed event, restore the first user program in the second virtual machine.
  • the to-be-processed event is an interrupt event, a page fault exception event, or a system call event.
  • the virtual machine monitor 200 further includes a determining unit 250, configured to: determine that the first user program is a secure user program.
  • the determining unit 250 is further configured to: obtain a first hash value group and a second hash value group, where the first hash value group includes at least one first hash value, the second The hash value group includes at least one second hash value, wherein each first hash value is in one-to-one correspondence with each of the at least one data object in the first user program, the each hash a value is a current hash value of the data object; each second hash value is in one-to-one correspondence with each of the at least one data object in the first user program, the second hash value being Determining a hash value of the data object at the factory; determining that the first user program is a secure user program when the first hash value group is the same as the second hash value group.
  • FIG. 9 shows a schematic block diagram of an apparatus 300 for accessing a secure world provided by an embodiment of the present invention.
  • the apparatus 300 includes a processor 310 and a memory 320.
  • a memory 320 configured to store a program, the program comprising code
  • the processor 310 is configured to execute program code in the memory 320.
  • the processor 310 can implement various operations performed by the virtual machine monitor in the method 100 in FIG. 3, and details are not described herein for brevity.
  • FIG. 10 shows a schematic block diagram of a system 400 for accessing a secure world.
  • the system 400 includes: a hardware layer 410 of a non-secure world; a virtual machine monitor 420 running on the hardware layer of the non-secure world, created and controlled by the virtual machine monitor.
  • the first virtual machine 430 is configured to load a plurality of programs of the non-secure world, the plurality of programs including a kernel and at least one user program, wherein the kernel runs in a first level mode, the at least a user program running in a second level mode, the first level being higher than the second level; the second virtual machine being configured to load the stripped from the first virtual machine in the at least one user program a first user program for accessing the secure world by the second virtual machine for the first user program, wherein the second virtual machine is running in a second level mode.
  • the hardware layer 410 can include a processor, a communication interface, a memory, and the like.
  • the corresponding descriptions of the virtual machine monitor 420, the first virtual machine 430, and the second virtual machine 440 may refer to the method 100 shown in FIG. 3, and details are not described herein for brevity.
  • the processor may be a central processing unit (CPU), and the processor may also be another general-purpose processor, a digital signal processor (DSP), and a dedicated processor.
  • DSP digital signal processor
  • ASIC Application Specific Integrated Circuit
  • FPGA Field-Programmable Gate Array
  • the general purpose processor may be a microprocessor or the processor or any conventional processor or the like.
  • the memory can include read only memory and random access memory and provides instructions and data to the processor.
  • a portion of the memory may also include a non-volatile random access memory.
  • the memory can also store information of the device type.
  • the communication interface can be used to implement signal transmission and reception functions, such as frequency modulation and demodulation functions or up-conversion and down-conversion functions.
  • the communication device can be a chip or chipset.
  • the steps of the method disclosed in the embodiments of the present invention may be directly implemented as a hardware processor, or may be performed by a combination of hardware and software modules in the processor.
  • the software module can be located in a conventional storage medium such as random access memory, flash memory, read only memory, programmable read only memory or electrically erasable programmable memory, registers, and the like.
  • the storage medium is located in the memory, and the processor reads the information in the memory and combines the hardware to complete the steps of the above method. To avoid repetition, it will not be described in detail here.
  • the above embodiments it may be implemented in whole or in part by software, hardware, firmware, or any combination thereof.
  • software it may be implemented in whole or in part in the form of a computer program product.
  • the computer program product includes one or more computer instructions.
  • the computer program instructions When the computer program instructions are loaded and executed on a computer, the processes or functions in accordance with embodiments of the present invention are generated in whole or in part.
  • the computer can be a general purpose computer, a special purpose computer, a computer network, or other programmable device.
  • the computer instructions can be stored in a computer readable storage medium or transferred from one computer readable storage medium to another computer readable storage medium, for example, the computer instructions can be wired from a website site, computer, server or data center (For example, coaxial cable, optical fiber, (Digital Subscriber Line (DSL))) or wireless (such as infrared, wireless, microwave, etc.) to another website site, computer, server or data center.
  • the computer readable storage medium can be any available media that can be accessed by a computer or a data storage device such as a server, data center, or the like that includes one or more available media.
  • the usable medium may be a magnetic medium (for example, a floppy disk, a hard disk, a magnetic tape), an optical medium (for example, a digital video disk (DVD)), or a semiconductor medium (such as a solid state disk (SSD)).
  • a magnetic medium for example, a floppy disk, a hard disk, a magnetic tape
  • an optical medium for example, a digital video disk (DVD)
  • a semiconductor medium such as a solid state disk (SSD)
  • the size of the serial numbers of the above processes does not mean the order of execution, and the order of execution of each process should be determined by its function and internal logic, and should not be taken to the embodiments of the present invention.
  • the implementation process constitutes any limitation.

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Computer Security & Cryptography (AREA)
  • Software Systems (AREA)
  • Physics & Mathematics (AREA)
  • Computer Hardware Design (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Mathematical Physics (AREA)
  • Signal Processing (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Storage Device Security (AREA)
  • Stored Programmes (AREA)

Abstract

一种用于访问安全世界的方法(100)、装置(300)和系统(400),能够提升安全世界的安全性。该方法包括:虚拟机监控器(200)在非安全世界创建第一虚拟机(110);虚拟机监控器(200)将所述非安全世界中的多个程序加载到所述第一虚拟机中,多个程序包括内核和至少一个用户程序(120);在确定至少一个用户程序中的第一用户程序需要访问安全世界时,虚拟机监控器(200)在非安全世界创建第二虚拟机(130);虚拟机监控器(200)将第一用户程序从第一虚拟机中剥离,并加载到第二虚拟机,以便于第一用户程序通过第二虚拟机访问所述安全世界(140)。

Description

用于访问安全世界的方法、装置和系统
本申请要求于2017年05月22日提交中国专利局、申请号为201710364027.2、申请名称为“用于访问安全世界的方法、装置和系统”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。
技术领域
本申请涉及计算机领域,并且更具体地,涉及一种用于访问安全世界的方法、装置和系统。
背景技术
高级精简指令集计算机(Reduced Instruction Set Computer,RISC)制造公司(Advanced RISC Machine,ARM)处理器自v6架构开始引入了信任区(TrustZone)的概念。TrustZone为ARM处理器独有的一种处理器模式。
如图1所示,TrustZone技术将计算机系统物理隔离为安全世界和非安全世界。其中,TrustZone内为安全世界,TrustZone外为非安全世界。
在如图1所示的架构中,用户应用(Client Application,CA)(也可以称为用户程序等)可以通过调用公用的安全监控调用(Secure Monitor Call,SMC)驱动来进行安全世界的访问。
为了便于理解,以下结合图1所示的架构,描述非安全世界的用户程序访问安全世界的方法,其中,可以通过安全服务通道来完成安全服务流程,图1所示的架构可以利用由非安全世界的SMC驱动、非安全世界的SMC指令、运行固件(runtime firmware)、安全世界的内核的安全服务分发及调度模块、以及安全用户程序所构建的安全服务通道来完成。
步骤一、CA程序(例如,CA1,CA2或CA3)调用基于公用的SMC驱动提供的应用程序编程接口(Application Programming Interface,API),将参数传递给富执行环境(Rich Execution Environment,REE)操作系统(Operation System,OS)内核的SMC驱动。
步骤二、SMC驱动将参数写入寄存器,调用SMC指令,触发异常事件。
步骤三、运行固件接管该异常事件后,切换系统模式,调用可信执行环境(Trusted Execution Environment,TEE)OS内核中安全服务分发及调度模块相关的函数。
步骤四、安全服务分发及调度模块进一步解析参数,并分解参数解析结果,以调度相关的安全应用(Trusted Application,TA)程序。
步骤五、TA程序(例如,图1所示的TA1、TA2或TA3)通过非安全世界应用传递的通用唯一识别码(Universally Unique Identifier,UUID)来确认合法性,并完成相关的安全服务。
在以上的CA程序获取安全服务的流程中,公用的SMC驱动可被任意程序(包括恶 意程序)所使用,从而使得恶意程序可以访问安全世界,从而降低了安全世界的安全性。
发明内容
本申请提供一种用于访问安全世界的方法、装置和系统,能够提升安全世界的安全性。
第一方面,提供了一种用于访问安全世界的方法,包括:在非安全世界创建第一虚拟机(Virtual Machine,VM);将所述非安全世界中的多个程序加载到所述第一虚拟机中,所述多个程序包括内核和至少一个用户程序,其中,所述内核运行在第一等级的模式下,所述至少一个用户程序运行在第二等级的模式下,所述第一等级高于所述第二等级;在确定所述至少一个用户程序中的第一用户程序需要访问安全世界时,在所述非安全世界创建运行在所述第一等级的模式下的第二虚拟机;将所述第一用户程序从所述第一虚拟机中剥离,并加载到所述第二虚拟机,以便于所述第一用户程序通过所述第二虚拟机访问所述安全世界。
因此,在此方案中,非安全世界的操作系统的内核中不再部署公用的SMC驱动,普通程序(包括恶意程序)无法通过调用公用的SMC驱动的方式获取安全服务调用,同时,为了便于用户程序访问安全世界,可以创建与内核相同等级的虚拟机,从而需要访问安全世界的用户程序可以通过与该内核具有相同等级的虚拟机访问安全世界,无需再通过公用的SMC驱动来访问安全世界,从而可以在实现安全世界访问的同时,提高安全世界的安全性。
并且,由于第二虚拟机的等级与内核的等级相同,因此,安全世界的程序返回给第一用户程序的信息可以经过第二虚拟机直接被第一用户程序接收到,不需要经过共享内核,极大地避免了该返回的信息被内核所窥探或篡改,或避免其他恶意程序利用内核对该返回的信息进行窥探或篡改。
结合第一方面,在第一方面的一种可能的实现方式中,所述方法还包括:设置虚拟化列表,以禁止第一虚拟机中的所有程序(该多个程序中除第一用户程序之外的其他程序)继续访问属于被剥离的所述第一用户程序的内存页。可选地,可以在二级页表中将对应第一用户程序的页表删除,来实现第一虚拟机中的程序访问第一用户程序的内存页。
由于操作系统可能会出现一些漏洞,恶意程序会利用这些漏洞执行一些操作(如提权)后破坏或者窃取正常用户程序的数据,以达到攻击的目的。而通过设置虚拟化列表禁止第一虚拟机中的所有程序访问属于被剥离的第一用户程序的内存页后,第一虚拟机中的恶意程序也无法访问第一用户程序的内存页,也就意味着无法对第一用户程序进行攻击(如果要攻击某个程序,必然会访问到该程序的内存页),因此,这种实现方式进一步增强了应用程序的安全性。
结合第一方面或其上述任一种可能的实现方式,在第一方面的一种可能的实现方式中,所述在所述非安全世界创建运行在所述第一等级的模式下的第二虚拟机,包括:为所述第二虚拟机分配由所述第一用户程序独享的资源。其中,该独享的资源可选的包括中央处理单元(Center Processing Unit,CPU)资源、外设和内存中的至少一种。
在第一用户程序访问安全世界时将要采用一些资源,如果这些资源被其它程序所利用,则会泄露访问安全世界得到的信息,例如,如果第二虚拟机中的内存资源与非安全世界中的其他程序是共享的,则存储在该内存中的来自安全世界的信息将有可能被其他程序 所窃取。因此,为所述第二虚拟机分配由所述第一用户程序独享的资源,可以避免其它程序利用该第一用户程序访问安全世界所采用的资源而窃取与安全世界相关的信息。
可选地,在多个用户程序均需要访问安全世界时,可以创建多个工作在第一等级的模式下的虚拟机,该多个虚拟机中一一对应于多个用户程序,用于对应的用户程序访问安全世界,该多个虚拟机各自的资源是独享的。
因此,每个合法的用户程序都独占地部署在一个独立虚拟机中,从而每个用户程序可以独享安全服务通道,从而用户程序访问安全世界的安全服务通道可以不被其他用户程序所利用,从而可以避免恶意程序利用该服务通道访问安全世界。
并且进一步地,由于每个用户程序的安全服务通道都是独立的,摈弃了所有的用户程序利用相同的安全服务通道访问安全世界,避免恶意软件通过长期占用该相同的安全服务通道(例如,占用公用的SMC驱动的方式)来瘫痪其他用户程序的安全服务。
可选地,该独享的资源包括内存。其中,第二虚拟机中的内存可以作为第一用户程序与安全世界的程序共享内存。
因此,由于为第一用户程序创建的第二虚拟机的内存是独享的,非安全世界的用户程序跟安全世界的程序间通信用的共享内存做到了虚拟机级别的隔离,第一虚拟机内的恶意程序无法窃取和破坏第二虚拟机中的用户程序和安全世界的用户程序通信的共享内存中的数据。
结合第一方面或其上述任一种可能的实现方式,在第一方面的一种可能的实现方式中,所述多个程序还包括所述第一用户程序对应的代理程序,其中,在所述第一用户程序从所述第一虚拟机剥离之后,所述代理程序作为所述第一用户程序在所述第一虚拟机的代理,以触发所述内核处理需要由所述内核处理的待处理事件,其中,所述待处理事件是在所述第一用户程序在所述第二虚拟机运行时产生的。
因此,在第一用户程序在第二虚拟机中运行时,产生了需要由内核处理的事件时,可以通过第一虚拟机中的由该第一用户程序对应的代理程序替代用户程序,营造了该第一用户程序仍旧工作在第一虚拟机下的环境,从而可以使得第一虚拟机的操作内核处理该需要由内核处理的事件。
结合第一方面或其上述任一种可能的实现方式,在第一方面的一种可能的实现方式中,所述方法还包括:获取所述待处理事件,所述待处理事件需要由所述内核处理,且是在所述第一用户程序在所述第二虚拟机中运行时产生的;保存所述第二虚拟机的上下文;恢复所述第一虚拟机中所述代理程序的上下文,以用于触发所述第一虚拟机加载的所述内核对所述待处理事件进行处理。
因此,在获取到需要由内核处理的待处理事件时,通过保存第二虚拟机的上下文来中断第一用户程序的运行,并且恢复代理程序的上下文,可以在不将第一用户程序直接切换到第一虚拟机的情况下,营造了该第一用户程序仍旧工作在第一虚拟机下的环境,从而可以使得第一虚拟机的操作内核处理该需要由内核处理的事件。
结合第一方面或其上述任一种可能的实现方式,在第一方面的一种可能的实现方式中,所述方法还包括:在所述第一虚拟机处理完所述待处理事件之后,在所述第二虚拟机中恢复所述第一用户程序。
因此,在第一虚拟机处理完待处理事件之后,在第二虚拟机中恢复第一用户程序,可 以继续第一用户程序在第二虚拟机的运行。
结合第一方面或其上述任一种可能的实现方式,在第一方面的一种可能的实现方式中,所述待处理事件为中断事件、缺页异常事件或系统调用事件。
由于中断事件、缺页异常事件或系统调用事件为需要由内核处理的事件,在第一用户程序在第二虚拟机中运行时,产生了这些事件时,可以通过第一虚拟机中的由该第一用户程序对应的代理程序替代用户程序,营造了该第一用户程序仍旧工作在第一虚拟机下的环境,从而可以使得第一虚拟机的操作内核处理该这些事件。
结合第一方面或其上述任一种可能的实现方式,在第一方面的一种可能的实现方式中,在将所述第一用户程序从所述第一虚拟机中剥离之前,所述方法还包括:确定所述第一用户程序为安全用户程序。
因此,在第一用户程序需要访问安全世界的情况下,确定所述第一用户程序为安全用户程序,可以避免将恶意程序加载在第二等级的模式下的虚拟机,从而避免恶意程序访问安全世界。
结合第一方面或其上述任一种可能的实现方式,在第一方面的一种可能的实现方式中,所述确定所述第一用户程序为安全用户程序包括:获取第一哈希值组和第二哈希值组,所述第一哈希值组包括至少一个第一哈希值,所述第二哈希值组包括至少一个第二哈希值,其中,每个第一哈希值与所述第一用户程序中的至少一个数据对象中的每个数据对象一一对应,所述每一哈希值为数据对象的当前的哈希值;每个第二哈希值与所述第一用户程序中的至少一个数据对象中的每个数据对象一一对应,所述第二哈希值是所述数据对象在出厂时的哈希值;在所述第一哈希值组与第二哈希值组相同时,确定所述第一用户程序为安全用户程序。
由于用户程序的数据对象的哈希值在正常情况下是不变的,如果被篡改或利用,则会导致数据对象的哈希值与出厂时的哈希值不相同,因此,通过比较用户程序的数据对象的当前的哈希值与出厂时的哈希值,可以准确的判断该用户程序是否是安全用户程序。
结合第一方面或其上述任一种可能的实现方式,在第一方面的一种可能的实现方式中,所述方法由ARM处理器实现,所述第一等级的模式为特权等级1(Exception Level 1,EL1)模式,所述第二等级的模式为特权等级0(Exception Level 0,EL0)模式。
第二方面,提供了一种虚拟机监控器(Virtual Machine Monitor,VMM),可以包括用于执行第一方面或第一方面的任一可选的实现方式中的方法的模块或者单元。
第三方面,提供了一种用于访问安全世界的装置,包括存储器和处理器,该存储器上存储有可以用于指示执行上述第一方面或其任意可选的实现方式的程序代码,当该代码被执行时,该处理器可以实现第一方面或第一方面的任一可选的实现方式中的方法。
第四方面,提供了一种用于访问安全世界的系统,包括:非安全世界的硬件层;运行在非安全世界的所述硬件层之上的虚拟机监控器,由所述虚拟机监控器创建和控制的第一虚拟机和第二虚拟机;其中,所述第一虚拟机用于加载所述非安全世界的多个程序,所述多个程序包括内核和至少一个用户程序,其中,所述内核运行在第一等级的模式下,所述至少一个用户程序运行在第二等级的模式下,所述第一等级高于所述第二等级;所述第二虚拟机用于加载所述至少一个用户程序中从所述第一虚拟机剥离的第一用户程序,以用于所述第一用户程序通过所述第二虚拟机访问安全世界,其中,所述第二虚拟机运行在第二 等级的模式下。其中,虚拟机监控器可以执行第一方面或第一方面的任一可选的实现方式中的方法。
第五方面,提供了一种计算机存储介质,该计算机存储介质中存储有程序代码,该程序代码用于使得计算机执行上述第一方面或第一方面的任一种可能的实现方式中的方法。
第六方面,提供了一种包括指令的计算机程序产品,当其在计算机上运行时,使得计算机执行上述第一方面或第一方面的任一可选的实现方式中的方法。
附图说明
图1是当前一种TrustZone架构的示意性框图;
图2是根据本发明实施例的一种TrustZone架构的示意性框图;
图3是根据本发明实施例的一种访问安全世界的方法的示意性流程图;
图4是根据本发明实施例的进行第二虚拟机的创建以及进行用户程序的迁移;
图5是在图2所示的架构下,处理中断事件的示意性流程图;
图6是在图2所示的架构下,处理系统调度事件的示意性流程图;
图7是在图2所示的架构下,处理缺页异常事件的示意性流程图;
图8是根据本发明实施例的一种虚拟机监控器的示意性框图;
图9是根据本发明实施例的一种用于访问安全世界的装置的示意性框图;
图10是根据本发明实施例的一种用于访问安全世界的系统的示意性框图。
具体实施方式
下面将结合附图,对本申请中的技术方案进行描述。
本发明实施例提供了一种如图2所示的TrustZone架构。
如图2所示,TrustZone技术将计算机系统物理隔离为安全世界和非安全世界。其中,TrustZone内为安全世界,TrustZone外为非安全世界。
对于非安全世界,存在富执行环境(Rich Execution Environment,REE)操作系统(Operation System,OS),以及用户应用(Client Application,CA)(也可以称为用户程序等),例如,如图2所示的CA1、CA2和CA3。
相对应于非安全世界,在安全世界内,存在可信执行环境(Trusted Execution Environment,TEE)OS,以及TA,例如,如图2所示的TA1、TA2和TA3。
其中,TEE OS负责安全世界的硬件资源抽象管理以及安全服务程序调度,如接收到来自非安全世界的服务请求后,通过参数的解析后,调度相应的TA程序完成相关的安全任务处理;而TA则特指提供特定安全服务功能的程序,以安全世界进程的方式运行在TrustZone中。
TrustZone技术可以提供包括中央处理单元(Center Processing Unit,CPU)、寄存器、总线、内存、缓存(cache)、后备缓冲器(Translation Lookaside Buffer,LTB)和外设在内的完整的物理隔离运行环境。
针对内存而言,安全世界与非安全世界有各自的内存空间,非安全世界的程序无法访问安全世界的内存,而安全世界的程序可访问已映射的非安全世界的内存。
如果非安全世界需要往安全世界传输大块数据(例如,无法通过寄存器传递的数据尺 寸),则通过共享内存来传递。
如图2所示,在非安全世界,可以存在三种工作模式,即特权等级0(Exception Level 0,EL0)模式,特权等级1(Exception Level 1,EL1)模式和特权等级2(Exception Level 2,EL2)模式。其中,EL0模式是指用于运行用户程序的模式,EL1模式是指用于运行操作系统的内核的模式。EL2模式是指用于运行虚拟机监控器的模式。其中,EL1模式的特权等级高于EL0模式,EL2模式的特权等级高于EL1模式。
可选地,在安全世界存在三种工作模式,即,特权等级3(Exception Level 3,EL3)模式、安全特权等级1(Secure Exception Level 1,SEL1)模式,和安全特权等级0(Secure Exception Level 0,SEL0)模式。
如图2所示的VMM可以用于管理VM的资源以及上下文。具体地,可以用于VM的生成、VM的销毁、VM的初始化,以及用户程序在VM中的切换等。
在如图2所示的架构中,非安全世界的操作系统的内核中不再部署SMC驱动,为了便于用户程序访问安全世界,创建工作在与内核相同等级模式下的虚拟机,从而需要访问安全世界的用户程序可以通过新创建的虚拟机访问安全世界,而普通程序(包括恶意程序)无法通过调用公用的SMC驱动的方式获取安全服务调用,从而可以提高安全世界的安全性。
应理解,图2所示的架构不应对本发明实施例构成限定。例如,非安全世界中CA的数量和VM的数量,以及安全世界中TA的数量,不应对本申请构成特别的限定。
为了便于理解,以下以图2所示的场景为例,结合图3,对本发明实施例的用于访问安全世界的方法进行说明。
应理解,本发明实施例可以应用于ARM处理器架构下,例如,ARMv8 Cortex A系列处理器的架构,但是本发明实施例并不限于此。
图3示出了一种用于访问安全世界的方法100的示意性流程图。该方法100可选地可以由如图2所示的虚拟机监控器执行。如图3所示,该方法100包括以下内容中的至少部分内容。
在110中,虚拟机监控器在非安全世界创建第一虚拟机。
例如,该第一虚拟机可以是如图2所示的VM0。其中,该第一虚拟机可以在系统初始化阶段建立的。
在120中,虚拟机监控器将非安全世界中的多个程序加载到第一虚拟机中,该多个程序包括内核和至少一个用户程序。
例如,该多个程序包括如图2所示的OS内核、CA1、CA2以及CA3。
可选地,在第一虚拟机中,内核运行在第一等级的模式下,至少一个用户程序运行在第二等级的模式下,第一等级高于第二等级。
可选地,第一等级的模式可以为图2所示的EL1模式,第二等级的模式可以是图2所示的EL0模式。
例如,如图2所示,OS内核可以工作在EL1模式,CA1、CA2和CA3可以工作在EL0模式。
在130中,在确定至少一个用户程序中的第一用户程序需要访问安全世界时,虚拟机监控器在非安全世界创建的第二虚拟机。
例如,如图2所示,在某一用户程序,例如CA3,需要访问安全世界时,VMM可以创建工作在EL1模式的VM 1,并可以将该用户程序CA3从VM0剥离,并加载在VM 1中。
可选地,虚拟机监控器为所述第二虚拟机分配由所述第一用户程序独享的资源。其中,该独享的资源可选的包括CPU资源、外设和内存中的至少一种。
在第一用户程序访问安全世界时将要采用一些资源,如果这些资源被其它程序所利用,则会泄露访问安全世界得到的信息,例如,如果第二虚拟机中的内存资源与非安全世界中的其他程序是共享的,则存储在该内存中的来自安全世界的信息将有可能被其他程序所窃取。因此,为所述第二虚拟机分配由所述第一用户程序独享的资源,可以避免其它程序利用该第一用户程序访问安全世界所采用的资源而窃取与安全世界相关的信息。
可选地,在多个用户程序均需要访问安全世界时,可以创建多个工作在第一等级的模式下的虚拟机,该多个虚拟机中一一对应于多个用户程序,用于对应的用户程序访问安全世界,该多个虚拟机各自的资源是独享的。
因此,每个合法的用户程序都独占地部署在一个独立虚拟机中,从而每个用户程序可以独享安全服务通道,从而用户程序访问安全世界的安全服务通道可以不被其他用户程序所利用,从而可以避免恶意程序利用该服务通道访问安全世界。
并且进一步地,每个用户程序的安全服务通道都是独立的,摈弃了所有的用户程序利用相同的安全服务通道访问安全世界,避免恶意软件通过长期占用该相同的安全服务通道(例如,占用公用的SMC驱动的方式)来瘫痪其他用户程序的安全服务。
可选地,该独享的资源包括内存。其中,第二虚拟机中的内存可以作为第一用户程序与安全世界的程序共享内存。
因此,由于为第一用户程序创建的第二虚拟机的内存是独享的,非安全世界的用户程序跟安全世界的程序间通信用的共享内存做到了虚拟机级别的隔离,第一虚拟机内的恶意程序无法窃取和破坏第二虚拟机中的用户程序和安全世界的用户程序通信的共享内存中的数据。
可选地,虚拟机监控器可以设置虚拟化列表,以禁止剥离第一虚拟机中加载的内核和其他用户程序访问第二虚拟机中的内存页。
例如,如图2所示,VM0中的内核、CA1和CA2将禁止访问VM1中的内存页。
可选地,可以在二级页表中将对应第一用户程序的页表删除,来实现第一虚拟机种的程序访问第一用户程序的内存页。
由于操作系统可能会出现一些漏洞,恶意程序会利用这些漏洞执行一些操作(如提权)后破坏或者窃取正常用户程序的数据,以达到攻击的目的。而通过设置虚拟化列表禁止第一虚拟机中的所有程序访问属于被剥离的第一用户程序的内存页后,第一虚拟机中的恶意程序也无法访问第一用户程序的内存页,也就意味着无法对第一用户程序进行攻击(如果要攻击某个程序,必然会访问到该程序的内存页),因此,这种实现方式进一步增强了应用程序的安全性。
可选地,在第一用户程序需要访问安全世界的情况下,虚拟机监控器确定第一用户程序是否为安全用户程序,在确定第一用户程序为安全用户程序时,虚拟机监控器将第一用户程序从第一虚拟机中剥离,并加载到创建的第二虚拟机。。
具体地说,在某一用户程序需要访问安全世界时,第一虚拟机可以自陷到虚拟机监控器,虚拟机监控器可以保存第一虚拟机的上下文,并触发安全世界的动态度量功能,度量该用户程序的完整性及合法性,以确保安全。
可选地,确定所述第一用户程序为安全用户程序的动作可以在将所述第一用户程序从所述第一虚拟机中剥离之前执行。
具体地,确定所述第一用户程序为安全用户程序的动作可以在将所述第一用户程序从所述第一虚拟机中剥离之前,以及在所述非安全世界创建运行在所述第一等级的模式下的第二虚拟机之后执行。
或者,确定所述第一用户程序为安全用户程序的动作也可以在所述非安全世界创建运行在所述第一等级的模式下的第二虚拟机之前,以及将所述第一用户程序加载到所述第一虚拟机之后执行。
进一步地,除了需要度量当前需要访问安全世界的用户程序的完整性和安全性,还可以度量其他程序的完整性和合法性,例如,可以度量代理程序和/或其他用户程序的完整性和安全性。
可选地,动态度量为部署在TrustZone中的动态安全监控功能,可以用于校验程序运行中不发生变化的数据对象,通过校验对象的哈希值确保运行过程中没有发生非法的篡改。
具体地,虚拟机监控器可以获取第一哈希值组(包括至少一个第一哈希值)和第二哈希值组(包括至少一个第二哈希值),其中,所述第一哈希值为所述第一用户程序中的至少一个数据对象(例如,为用户程序代码段,或者还包括用户程序运行所需的动态链接库)的当前的哈希值,所述第二哈希值是所述数据对象在出厂时的哈希值(为了安全,会被放置在安全世界的内存区里);在所述第一哈希值组与第二哈希值组相同(即每个数据对象的哈希值相同),确定所述第一用户程序为安全用户程序。
由于用户程序的数据对象的哈希值在正常情况下是不变的,如果被篡改或利用,则会导致数据对象的哈希值与出厂时的哈希值不相同,因此,通过比较用户程序的数据对象的当前的哈希值与出厂时的哈希值,可以准确的判断该用户程序是否是安全用户程序。
可选地,在如图2所示的架构中,处于EL0模式的进程可以通过访问ID寄存器的方式自陷到EL2模式的VMM,例如,对ID寄存器Group 2中的CTR_EL0寄存器(其中,CRT_EL0是ID寄存器Group2中的寄存器,CTR为计数寄存器(Count Register,CTR))进行访问来触发自陷。可选地,至此之前,VMM中可以对HCR_EL2寄存器(HCR_EL2寄存器为在VMM控制的虚拟化控制寄存器,HCR为管理程序配置寄存器(Hypervisor Configuration Register,HCR))的对应比特位进行设置,例如,在VMM中将HCR_EL2的TID2位置位。
可选地,在如图2所示的架构中,处于EL1模式的程序(例如,操作系统的内核)自陷到VMM可以采取指令触发的方式,通过访问HVC指令,可自陷到EL2模式的VMM中。
在140中,将第一用户程序从第一虚拟机中剥离,并加载到第二虚拟机,以便于第一用户程序通过第二虚拟机访问安全世界。
具体地说,在虚拟机监控器确定第一用户程序为合法且安全的程序之后,可以对第一 用户程序进行迁移,即从第一虚拟机中剥离,并加载到第二虚拟机,从而该第一用户程序可以调用第二虚拟机中的SMC驱动以访问安全世界。例如,可以通过SMC驱动申请共享内存,并通过共享内存,与安全世界中的TA进行交互。
可选地,第二虚拟机可以通过调用SMC指令的方式,访问安全世界。
本申请中的“剥离”顾名思议是指“去除”、“移除”的意思,其实质是不在第一虚拟机中运行第一用户程序,而让第一用户程序在第二虚拟机中运行,可看作将第一虚拟机中的代码段“剪切”到了第二虚拟机。
可选地,本发明实施例可以采用多种实现方式实现第一用户程序从第一虚拟机中剥离,并加载到第二虚拟机。
在一种实现方式中,虚拟机监控器可以将第一用户程序在第一虚拟机中的内存页(包括各种程序本身的代码段或者运行所需的动态链接库等)拷贝到第二虚拟机中,并修改第一虚拟机的内存页的映射关系,使得第一用户程序在第一虚拟机中的内存页被回收。
在另一种实现方式中,虚拟机监控器可以将在第一用户程序在第一虚拟机中的内存页直接映射到第二虚拟机(即将内存页在物理内存中的地址映射到第二虚拟机中的地址)。
本发明实施例还可以通过其他方式实现用户程序在虚拟机中的剥离和加载,具体可以参考现有技术,在此不再赘述。
为了便于理解,以下以图2所示的场景为例,结合图4描述如何进行第二虚拟机的创建以及进行用户程序的迁移。
在141中,CA3调用代理程序的初始化接口。
在142中,代理程序通过读取ID组2中的CTR_EL0寄存器,触发CPU自陷到EL2模式的VMM中。
在143中,在CPU自陷到VMM后,VMM保存VM0虚拟机上下文,并触发安全世界的动态度量功能,度量CA3的完整性及合法性,以确保安全。
在144中,VMM创建新的虚拟机VM1,VMM将CA3迁移到虚拟机VM 1的EL1模式中,以继续运行CA3。
可选地,在本发明实施例中,加载到第一虚拟机的多个程序还包括用户程序对应的代理程序,在用户程序从第一虚拟机剥离之后,作为所述用户程序在所述第一虚拟机的代理,以便于在所述用户程序在所述第二虚拟机运行时所产生的待处理事件被执行。
可选地,在本发明实施例中,代理程序可以与用户进程一一对应。代理程序可以作为对应的用户进程的代理。具体地,在用户程序加载在第二虚拟机中时,代理程序可以代理作为该用户程序。
可选地,在本发明实施例中,虚拟机监控器还可以获取针对第一用户程序的待处理事件,待处理事件需要由内核处理;保存第二虚拟机的上下文;恢复代理程序的上下文,以便于内核对待处理事件进行处理。
可选地,在本发明实施例中,在第一虚拟机处理完待处理事件之后,虚拟机监控器在第二虚拟机中恢复第一用户程序。
可选地,该代理程序可以处于第二等级的模式。例如,如图2所示的EL0模式。
可选地,待处理事件为中断事件、缺页异常事件或系统调用事件。
因此,在本发明实施例中,在当前运行的用户程序所在的虚拟机没有操作系统内核时, 可以通过代理程序代理该用户程序,通过原有的虚拟机的操作内核实现中断事件、缺页异常事件或系统调用事件的处理。
为了便于理解,以下将以图2所示的架构为例,分别结合图5-7描述待处理事件为中断事件、缺页异常事件和系统调用事件时的处理流程。
图5所示的为在待处理事件为中断事件时的处理流程的示意性图。
在151中,VMM获取由硬件触发的中断信号,此时,当前系统正在运行CA3。
在152中,VMM触发虚拟中断,并恢复该CA3的代理程序的运行。
在153中,系统切换到代理程序,且虚拟中断到达虚拟机VM0,中断抢占了代理程序的运行。
在154中,VM 0内核处理虚拟中断。
在155中,VM 0完成中断处理后,恢复代理程序的运行。
在156中,代理程序自陷到VMM。
在157中,VMM恢复被中断的VM 1的上下文。
因此,在如图5所示的方案中,在当前系统运行在VM 1的情况下,在硬件触发中断信号时,VMM可以恢复代理程序的处理,将代理程序作为第一用户程序的代理,并随后执行中断处理,并在中断处理后恢复代理程序,从而即使在新的架构中,正在运行的程序所在的虚拟机没有操作系统内核,仍然可以进行中断处理。
图6所示的为在待处理事件为系统调度事件时的处理流程的示意性图。
在161中,当系统运行CA3时,如发生调度中断,则中断被VMM捕获。
在162中,VMM恢复VM0的上下文,将CA3切换到代理程序运行,同时转发虚拟中断到VM0。
在163中,中断抢占代理程序后,进入VM0的内核。
在164中,由内核调度模块,根据自身的调度策略执行相关的进程进行运行。
在165中,当重新调度代理程序后,代理程序自陷到VMM。
在166中,VMM恢复VM1,也即将切换CA3切换到VM1。
因此,由于在本申请架构中,CA1所在的VM1没有操作系统内核,无法自调度,例如,无法确定执行CA 1的时间分片,且CA1需遵从VM0的调度策略,从而在如图6所示的方案中,VM0内核对CA1的调度,可以通过代理程序来完成。
图7示出的为在待处理事件为缺页异常事件时的处理流程的示意性图。
在171中,CA1缺页后,触发的异常,由VMM接管。
在172中,VMM识别CA3发生缺页异常,则该CA3的恢复代理程序的上下文。
在173中,代理程序触发缺页异常事件重新进入VM0内核。
在174中,内核缺页处理程序执行缺页相关处理。
在175中,内核恢复代理程序的处理。
在176中,代理程序自陷到VMM。
在177中,VMM设置相应的内存页后,恢复VM1,也即将CA 3切换到VM1中。
因此,在如图7所示的方案中,在当前系统运行在VM1的情况下,在VM1中的CA3出现缺页异常事件后,可以恢复VM0中的CA3的代理程序,由VM0的操作系统内核进行缺页异常事件的处理,从而即使在新的架构中,正在运行的程序所在的虚拟机没有操作 系统内核,仍然可以进行缺页异常事件的处理。
图8是根据本发明实施例的虚拟机监控器200的示意性框图。如图8所示,该虚拟机监控器200包括创建单元210和加载单元220。
其中,所述创建单元210用于:在非安全世界创建第一虚拟机;所述加载单元220用于:将所述非安全世界中的多个程序加载到所述第一虚拟机中,所述多个程序包括内核和至少一个用户程序,其中,所述内核运行在第一等级的模式下,所述至少一个用户程序运行在第二等级的模式下,所述第一等级高于所述第二等级;所述创建单元210进一步用于:在所述至少一个用户程序中的第一用户程序需要访问安全世界时,在所述非安全世界创建运行在所述第一等级的模式下的第二虚拟机;所述加载单元220进一步用于:将所述第一用户程序从所述第一虚拟机中剥离,并加载到所述第二虚拟机,以便于所述第一用户程序通过所述第二虚拟机访问所述安全世界。
可选地,如图8所示,所述虚拟机监控器200还包括设置单元230用于:设置虚拟化列表,以禁止剥离所述第一用户程序后的所述第一虚拟机中除所述第一用户程序之外的其他程序访问从所述第一虚拟机剥离的所述第一用户程序的内存页。
可选地,所述创建单元210进一步用于:为所述第二虚拟机分配由所述第一用户程序独享的资源。
可选地,所述多个程序还包括代理程序,其中,在所述第一用户程序从所述第一虚拟机剥离之后,所述代理程序作为所述第一用户程序在所述第一虚拟机对应的代理,以触发所述内核处理需要由所述内核处理的待处理事件,其中,所述待处理事件是在所述第一用户程序在所述第二虚拟机运行时产生的。
可选地,如图8所示,所述虚拟机监控器200还包括处理单元240,用于:在所述第一用户程序运行时,获取针对所述第一用户程序的所述待处理事件,所述处理事件需要由内核处理;保存所述第二虚拟机的上下文;恢复所述第一虚拟机中的代理程序的运行,以触发所述内核处理需要由所述内核处理的待处理事件,其中,所述待处理事件是在所述第一用户程序在所述第二虚拟机运行时产生的。
可选地,所述处理单元240进一步用于:在所述第一虚拟机处理完所述待处理事件之后,在所述第二虚拟机中恢复所述第一用户程序。
可选地,所述待处理事件为中断事件、缺页异常事件或系统调用事件。
可选地,如图8所示,所述虚拟机监控器200还包括确定单元250,用于:确定所述第一用户程序为安全用户程序。
可选地,所述确定单元250进一步用于:获取第一哈希值组和第二哈希值组,所述第一哈希值组包括至少一个第一哈希值,所述第二哈希值组包括至少一个第二哈希值,其中,每个第一哈希值与所述第一用户程序中的至少一个数据对象中的每个数据对象一一对应,所述每一哈希值为数据对象的当前的哈希值;每个第二哈希值与所述第一用户程序中的至少一个数据对象中的每个数据对象一一对应,所述第二哈希值是所述数据对象在出厂时的哈希值;在所述第一哈希值组与第二哈希值组相同时,确定所述第一用户程序为安全用户程序。
应理解,根据本发明实施例的一种虚拟及监控器200中的各个单元的上述和其它操作和/或功能分别为了实现图3中的方法100中虚拟机监控器的相应流程,为了简洁,在此 不再赘述。
图9示出了本发明实施例提供的用于访问安全世界的装置300的示意性框图,该装置300包括处理器310和存储器320。
存储器320,用于存储程序,该程序包括代码;
处理器310,用于执行存储器320中的程序代码。
可选地,当该代码被执行时,该处理器310可以实现图3中的方法100中由虚拟机监控器执行的各个操作,为了简洁,在此不再赘述。
图10示出了一种用于访问安全世界的系统400的示意性框图。如图10所示,该系统400包括:非安全世界的硬件层410;运行在非安全世界的所述硬件层之上的虚拟机监控器420,由所述虚拟机监控器创建和控制的第一虚拟机430和第二虚拟机440。
所述第一虚拟机430用于加载所述非安全世界的多个程序,所述多个程序包括内核和至少一个用户程序,其中,所述内核运行在第一等级的模式下,所述至少一个用户程序运行在第二等级的模式下,所述第一等级高于所述第二等级;所述第二虚拟机用于加载所述至少一个用户程序中从所述第一虚拟机剥离的第一用户程序,以用于所述第一用户程序通过所述第二虚拟机访问安全世界,其中,所述第二虚拟机运行在第二等级的模式下。
可选地,该硬件层410可以包括处理器、通信接口和存储器等。
应理解,该虚拟机监控器420,第一虚拟机430和第二虚拟机440的相应描述可以参考图3所示的方法100,为了简洁,在此不再赘述。
应理解,在本发明实施例中,该处理器可以是中央处理单元(Central Processing Unit,CPU),该处理器还可以是其他通用处理器、数字信号处理器(Digital Signal Processor,DSP)、专用集成电路(Application Specific Integrated Circuit,ASIC)、现场可编程门阵列(Field-Programmable Gate Array,FPGA)或者其他可编程逻辑器件、分立门或者晶体管逻辑器件、分立硬件组件等。通用处理器可以是微处理器或者该处理器也可以是任何常规的处理器等。
该存储器可以包括只读存储器和随机存取存储器,并向处理器提供指令和数据。存储器的一部分还可以包括非易失性随机存取存储器。例如,存储器还可以存储设备类型的信息。
通信接口可以是用于实现信号发送和接收功能,例如频率调制和解调功能或叫上变频和下变频功能。
在实现过程中,上述方法的至少一个步骤可以通过处理器中的硬件的集成逻辑电路完成,或该集成逻辑电路可在软件形式的指令驱动下完成该至少一个步骤。因此,通信装置可以是个芯片或者芯片组。结合本发明实施例所公开的方法的步骤可以直接体现为硬件处理器执行完成,或者用处理器中的硬件及软件模块组合执行完成。软件模块可以位于随机存储器,闪存、只读存储器,可编程只读存储器或者电可擦写可编程存储器、寄存器等本领域成熟的存储介质中。该存储介质位于存储器,处理器读取存储器中的信息,结合其硬件完成上述方法的步骤。为避免重复,这里不再详细描述。
在上述实施例中,可以全部或部分地通过软件、硬件、固件或者其任意组合来实现。当使用软件实现时,可以全部或部分地以计算机程序产品的形式实现。该计算机程序产品包括一个或多个计算机指令。在计算机上加载和执行该计算机程序指令时,全部或部分地 产生按照本发明实施例该的流程或功能。该计算机可以是通用计算机、专用计算机、计算机网络、或者其他可编程装置。该计算机指令可以存储在计算机可读存储介质中,或者从一个计算机可读存储介质向另一个计算机可读存储介质传输,例如,该计算机指令可以从一个网站站点、计算机、服务器或数据中心通过有线(例如同轴电缆、光纤、(数字用户线(Digital Subscriber Line,DSL)))或无线(例如红外、无线、微波等)方式向另一个网站站点、计算机、服务器或数据中心进行传输。该计算机可读存储介质可以是计算机能够存取的任何可用介质或者是包含一个或多个可用介质集成的服务器、数据中心等数据存储设备。该可用介质可以是磁性介质,(例如,软盘、硬盘、磁带)、光介质(例如,数字化视频光盘(Digital Video Disk,DVD))或者半导体介质(例如固态硬盘(Solid State Disk,SSD))等。
应理解,在本申请的各种实施例中,上述各过程的序号的大小并不意味着执行顺序的先后,各过程的执行顺序应以其功能和内在逻辑确定,而不应对本发明实施例的实施过程构成任何限定。
所属领的技术人员可以清楚地了解到,为描述的方便和简洁,上述描述的系统、装置和单元的具体工作过程,可以参考前述方法实施例中的对应过程,在此不再赘述。
以上所述,仅为本申请的具体实施方式,但本申请的保护范围并不局限于此,任何熟悉本技术领的技术人员在本申请揭露的技术范围内,可轻易想到变化或替换,都应涵盖在本申请的保护范围之内。因此,本申请的保护范围应以该权利要求的保护范围为准。

Claims (29)

  1. 一种用于访问安全世界的方法,其特征在于,包括:
    在非安全世界创建第一虚拟机;
    将所述非安全世界中的多个程序加载到所述第一虚拟机中,所述多个程序包括内核和至少一个用户程序,其中,所述内核运行在第一等级的模式下,所述至少一个用户程序运行在第二等级的模式下,所述第一等级高于所述第二等级;
    在确定所述至少一个用户程序中的第一用户程序需要访问安全世界时,在所述非安全世界创建运行在所述第一等级的模式下的第二虚拟机;
    将所述第一用户程序从所述第一虚拟机中剥离,并加载到所述第二虚拟机,以便于所述第一用户程序通过所述第二虚拟机访问所述安全世界。
  2. 根据权利要求1所述的方法,其特征在于,所述方法还包括:
    设置虚拟化列表,以禁止所述多个程序中除所述第一用户程序之外的其他程序访问属于被剥离的所述第一用户程序的内存页。
  3. 根据权利要求1或2所述的方法,其特征在于,所述在所述非安全世界创建运行在所述第一等级的模式下的第二虚拟机,包括:
    为所述第二虚拟机分配由所述第一用户程序独享的资源。
  4. 根据权利要求1至3中任一项所述的方法,其特征在于,所述多个程序还包括所述第一用户程序对应的代理程序,其中,在所述第一用户程序从所述第一虚拟机剥离之后,所述代理程序作为所述第一用户程序在所述第一虚拟机的代理,以触发所述内核处理需要由所述内核处理的待处理事件,其中,所述待处理事件是在所述第一用户程序在所述第二虚拟机运行时产生的。
  5. 根据权利要求4所述的方法,其特征在于,所述方法还包括:
    获取所述待处理事件,所述待处理事件需要由所述内核处理,且是在所述第一用户程序在所述第二虚拟机中运行时产生的;
    保存所述第二虚拟机的上下文;
    恢复所述第一虚拟机中所述代理程序的上下文,以用于触发所述第一虚拟机加载的所述内核对所述待处理事件进行处理。
  6. 根据权利要求5所述的方法,其特征在于,所述方法还包括:
    在所述第一虚拟机处理完所述待处理事件之后,在所述第二虚拟机中恢复所述第一用户程序。
  7. 根据权利要求4至6中任一项所述的方法,其特征在于,所述待处理事件为中断事件、缺页异常事件或系统调用事件。
  8. 根据权利要求1至7中任一项所述的方法,其特征在于,在所述将所述第一用户程序从所述第一虚拟机中剥离之前,所述方法还包括:
    确定所述第一用户程序为安全用户程序。
  9. 根据权利要求8所述的方法,其特征在于,所述确定所述第一用户程序为安全用户程序包括:
    获取第一哈希值组和第二哈希值组,所述第一哈希值组包括至少一个第一哈希值,所述第二哈希值组包括至少一个第二哈希值,其中,
    每个第一哈希值与所述第一用户程序中的至少一个数据对象中的每个数据对象一一对应,所述每一哈希值为数据对象的当前的哈希值;
    每个第二哈希值与所述第一用户程序中的至少一个数据对象中的每个数据对象一一对应,所述第二哈希值是所述数据对象在出厂时的哈希值;
    在所述第一哈希值组与第二哈希值组相同时,确定所述第一用户程序为安全用户程序。
  10. 根据权利要求1至9中任一项所述的方法,其特征在于,所述方法由高级精简指令集计算机制造公司ARM处理器实现,所述第一等级的模式为特权等级EL1模式,所述第二等级的模式为EL0模式。
  11. 一种虚拟机监控器,其特征在于,包括创建单元以及加载单元;其中,
    所述创建单元用于:在非安全世界创建第一虚拟机;
    所述加载单元用于:将所述非安全世界中的多个程序加载到所述创建单元创建的所述第一虚拟机中,所述多个程序包括内核和至少一个用户程序,其中,所述内核运行在第一等级的模式下,所述至少一个用户程序运行在第二等级的模式下,所述第一等级高于所述第二等级;
    所述创建单元进一步用于:在所述至少一个用户程序中的第一用户程序需要访问安全世界时,在所述非安全世界创建运行在所述第一等级的模式下的第二虚拟机;
    所述加载单元进一步用于:将所述第一用户程序从所述第一虚拟机中剥离,并加载到所述创建单元创建的所述第二虚拟机,以便于所述第一用户程序通过所述第二虚拟机访问所述安全世界。
  12. 根据权利要求11所述的虚拟机监控器,其特征在于,所述虚拟机监控器还包括设置单元用于:
    设置虚拟化列表,以禁止所述多个程序中除所述第一用户程序之外的其他程序访问被剥离的所述第一用户程序的内存页。
  13. 根据权利要求11或12所述的虚拟机监控器,其特征在于,所述创建单元进一步用于:
    为所述第二虚拟机分配由所述第一用户程序独享的资源。
  14. 根据权利要求11至13中任一项所述的虚拟机监控器,其特征在于,所述多个程序还包括所述第一用户程序对应的代理程序,其中,在所述第一用户程序从所述第一虚拟机剥离之后,所述代理程序作为所述第一用户程序在所述第一虚拟机的代理,以触发所述内核处理需要由所述内核处理的待处理事件,其中,所述待处理事件是在所述第一用户程序在所述第二虚拟机运行时产生的。
  15. 根据权利要求14所述的虚拟机监控器,其特征在于,所述虚拟机监控器还包括处理单元,用于:
    获取所述待处理事件,所述待处理事件需要由所述内核处理,且是在所述第一用户程序在所述第二虚拟机中运行时产生的;
    保存所述第二虚拟机的上下文;
    恢复所述第一虚拟机中所述代理程序的上下文,以用于触发所述第一虚拟机加载的所述内核对所述待处理事件进行处理。
  16. 根据权利要求15所述的虚拟机监控器,其特征在于,所述处理单元进一步用于:
    在所述第一虚拟机处理完所述待处理事件之后,在所述第二虚拟机中恢复所述第一用户程序。
  17. 根据权利要求14至16中任一项所述的虚拟机监控器,其特征在于,所述待处理事件为中断事件、缺页异常事件或系统调用事件。
  18. 根据权利要求11至17中任一项所述的虚拟机监控器,其特征在于,所述虚拟机监控器还包括确定单元,用于:
    确定所述第一用户程序为安全用户程序。
  19. 根据权利要求18所述的虚拟机监控器,其特征在于,所述确定单元进一步用于:
    获取第一哈希值组和第二哈希值组,所述第一哈希值组包括至少一个第一哈希值,所述第二哈希值组包括至少一个第二哈希值,其中,
    每个第一哈希值与所述第一用户程序中的至少一个数据对象中的每个数据对象一一对应,所述每一哈希值为数据对象的当前的哈希值;
    每个第二哈希值与所述第一用户程序中的至少一个数据对象中的每个数据对象一一对应,所述第二哈希值是所述数据对象在出厂时的哈希值;
    在所述第一哈希值组与第二哈希值组相同时,确定所述第一用户程序为安全用户程序。
  20. 根据权利要求11至19中任一项所述的虚拟机监控器,其特征在于,所述虚拟机监控器由高级精简指令集计算机制造公司ARM处理器控制实现,所述第一等级的模式为特权等级EL1模式,所述第二等级的模式为EL0模式。
  21. 一种用于访问安全世界的系统,其特征在于,包括:
    非安全世界的硬件层;
    运行在非安全世界的所述硬件层之上的虚拟机监控器,由所述虚拟机监控器创建和控制的第一虚拟机和第二虚拟机;其中,
    所述第一虚拟机用于加载所述非安全世界的多个程序,所述多个程序包括内核和至少一个用户程序,其中,所述内核运行在第一等级的模式下,所述至少一个用户程序运行在第二等级的模式下,所述第一等级高于所述第二等级;
    所述第二虚拟机用于加载所述至少一个用户程序中从所述第一虚拟机剥离的第一用户程序,以用于所述第一用户程序通过所述第二虚拟机访问安全世界,其中,所述第二虚拟机运行在第二等级的模式下。
  22. 根据权利要求21所述的系统,其特征在于,所述虚拟机监控器还用于:设置虚拟化列表,以禁止所述多个程序中除所述第一用户程序之外的其他程序访问访问被剥离的所述第一用户程序的内存页。
  23. 根据权利要求21或22所述的系统,其特征在于,所述第二虚拟机的资源是由所述第一用户程序独享的资源。
  24. 根据权利要求21至23中任一项所述的系统,其特征在于,所述多个程序还包括所述第一用户程序对应的代理程序,其中,在所述第一用户程序从所述第一虚拟机剥离之 后,所述代理程序作为所述第一用户程序在所述第一虚拟机的代理,以触发所述内核处理需要由所述内核处理的待处理事件,其中,所述待处理事件是在所述第一用户程序在所述第二虚拟机运行时产生。
  25. 根据权利要求24所述的系统,其特征在于,所述待处理事件为中断事件、缺页异常事件或系统调用事件。
  26. 根据权利要求21至25中任一项所述的系统,其特征在于,在所述虚拟机监控器创建所述第二虚拟机之前,所述虚拟机监控器还用于:确定所述第一用户程序为安全用户程序。
  27. 根据权利要求26所述的系统,其特征在于,所述虚拟机监控器具体用于:
    获取第一哈希值组和第二哈希值组,所述第一哈希值组包括至少一个第一哈希值,所述第二哈希值组包括至少一个第二哈希值,其中,
    每个第一哈希值与所述第一用户程序中的至少一个数据对象中的每个数据对象一一对应,所述每一哈希值为数据对象的当前的哈希值;
    每个第二哈希值与所述第一用户程序中的至少一个数据对象中的每个数据对象一一对应,所述第二哈希值是所述数据对象在出厂时的哈希值;
    在所述第一哈希值组与第二哈希值组相同时,确定所述第一用户程序为安全用户程序。
  28. 根据权利要求21至27中任一项所述的系统,其特征在于,所述虚拟机监控器由高级精简指令集计算机制造公司ARM处理器控制实现,所述第一等级的模式为特权等级EL1模式,所述第二等级的模式为EL0模式。
  29. 一种用于访问安全世界的装置,其特征在于,包括处理器和存储器,其中,存储器用于存储指令,所述处理器用于调用所述存储器存储的指令,以执行根据权利要求1-10中任一项所述的方法。
PCT/CN2018/087699 2017-05-22 2018-05-21 用于访问安全世界的方法、装置和系统 WO2018214850A1 (zh)

Priority Applications (2)

Application Number Priority Date Filing Date Title
EP18806666.6A EP3637288B1 (en) 2017-05-22 2018-05-21 Method, apparatus and systems for accessing secure world
US16/690,310 US20200089918A1 (en) 2017-05-22 2019-11-21 Secure world access method, apparatus, and system

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201710364027.2 2017-05-22
CN201710364027.2A CN108959916B (zh) 2017-05-22 2017-05-22 用于访问安全世界的方法、装置和系统

Related Child Applications (1)

Application Number Title Priority Date Filing Date
US16/690,310 Continuation US20200089918A1 (en) 2017-05-22 2019-11-21 Secure world access method, apparatus, and system

Publications (1)

Publication Number Publication Date
WO2018214850A1 true WO2018214850A1 (zh) 2018-11-29

Family

ID=64396212

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2018/087699 WO2018214850A1 (zh) 2017-05-22 2018-05-21 用于访问安全世界的方法、装置和系统

Country Status (4)

Country Link
US (1) US20200089918A1 (zh)
EP (1) EP3637288B1 (zh)
CN (1) CN108959916B (zh)
WO (1) WO2018214850A1 (zh)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113703924A (zh) * 2021-09-22 2021-11-26 上海交通大学 基于可信执行环境的安全虚拟机系统设计方法及系统

Families Citing this family (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112528288A (zh) * 2019-08-30 2021-03-19 华为技术有限公司 可信应用的运行方法、信息处理和内存分配方法及装置
CN111224867B (zh) * 2020-01-03 2021-10-15 清华大学深圳国际研究生院 一种基于多核异构硬件虚拟化的智能网关方法
US11556346B2 (en) * 2020-06-10 2023-01-17 Qualcomm Incorporated Security enhancement in hierarchical protection domains
CN113849261A (zh) * 2020-06-28 2021-12-28 华为技术有限公司 处理数据的方法、主机及装置
CN113867828A (zh) * 2020-06-30 2021-12-31 华为技术有限公司 一种运行进程的方法及装置
CN115509677A (zh) * 2021-06-23 2022-12-23 华为技术有限公司 一种虚拟机与安全隔离区间的通信方法及相关装置
CN117708822A (zh) * 2022-09-09 2024-03-15 华为技术有限公司 数据处理方法、代理装置及相关设备

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102214277A (zh) * 2010-04-01 2011-10-12 中国科学院计算技术研究所 创建多核处理器虚拟机系统可信环境的方法及装置
CN105022954A (zh) * 2015-07-07 2015-11-04 中国人民解放军国防科学技术大学 飞腾cpu上三态操作系统安全内核服务动态运行方法
CN105630534A (zh) * 2015-04-27 2016-06-01 宇龙计算机通信科技(深圳)有限公司 基于TrustZone架构的应用程序执行方法、装置和终端
CN105723375A (zh) * 2013-11-15 2016-06-29 甲骨文国际公司 用于管理授权设备上操作的令牌的系统和方法
CN105787391A (zh) * 2014-12-22 2016-07-20 中国科学院信息工程研究所 基于TrustZone硬件的面向任务的安全操作系统

Family Cites Families (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US8375221B1 (en) * 2011-07-29 2013-02-12 Microsoft Corporation Firmware-based trusted platform module for arm processor architectures and trustzone security extensions
US10198572B2 (en) * 2013-09-17 2019-02-05 Microsoft Technology Licensing, Llc Virtual machine manager facilitated selective code integrity enforcement
KR102183852B1 (ko) * 2013-11-22 2020-11-30 삼성전자주식회사 전자 장치의 무결성 검증을 위한 방법, 저장 매체 및 전자 장치
CN104899506B (zh) * 2015-05-08 2018-01-12 深圳市雪球科技有限公司 基于可信执行环境中虚拟安全元件的安全系统实现方法
CN106657358A (zh) * 2016-12-29 2017-05-10 北京奇虎科技有限公司 一种安卓应用的服务代理方法和装置

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102214277A (zh) * 2010-04-01 2011-10-12 中国科学院计算技术研究所 创建多核处理器虚拟机系统可信环境的方法及装置
CN105723375A (zh) * 2013-11-15 2016-06-29 甲骨文国际公司 用于管理授权设备上操作的令牌的系统和方法
CN105787391A (zh) * 2014-12-22 2016-07-20 中国科学院信息工程研究所 基于TrustZone硬件的面向任务的安全操作系统
CN105630534A (zh) * 2015-04-27 2016-06-01 宇龙计算机通信科技(深圳)有限公司 基于TrustZone架构的应用程序执行方法、装置和终端
CN105022954A (zh) * 2015-07-07 2015-11-04 中国人民解放军国防科学技术大学 飞腾cpu上三态操作系统安全内核服务动态运行方法

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
See also references of EP3637288A4

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113703924A (zh) * 2021-09-22 2021-11-26 上海交通大学 基于可信执行环境的安全虚拟机系统设计方法及系统

Also Published As

Publication number Publication date
CN108959916A (zh) 2018-12-07
EP3637288B1 (en) 2022-04-06
CN108959916B (zh) 2022-01-14
US20200089918A1 (en) 2020-03-19
EP3637288A1 (en) 2020-04-15
EP3637288A4 (en) 2020-04-22

Similar Documents

Publication Publication Date Title
WO2018214850A1 (zh) 用于访问安全世界的方法、装置和系统
US11200080B1 (en) Late load technique for deploying a virtualization layer underneath a running operating system
US11347542B2 (en) Data migration method and apparatus
CN109918919B (zh) 认证变量的管理
JP6073482B2 (ja) セキュアディスクアクセス制御
US8694738B2 (en) System and method for critical address space protection in a hypervisor environment
US8495750B2 (en) Filesystem management and security system
EP3281146A1 (en) Isolating guest code and data using multiple nested page tables
US10719346B2 (en) Disk encryption
US20210049112A1 (en) Kernel integrity protection method and apparatus
US20190034218A1 (en) Disk encryption
CN110348224B (zh) 基于双体系结构可信计算平台的动态度量方法
US9824225B1 (en) Protecting virtual machines processing sensitive information
US11442770B2 (en) Formally verified trusted computing base with active security and policy enforcement
CN110348223B (zh) 基于双体系结构可信计算平台的静态度量方法
WO2016164424A1 (en) Isolating guest code and data using multiple nested page tables
US9734325B1 (en) Hypervisor-based binding of data to cloud environment for improved security
CN108241801B (zh) 处理系统调用的方法和装置
US11301282B2 (en) Information protection method and apparatus
US11513825B2 (en) System and method for implementing trusted execution environment on PCI device
US20230289204A1 (en) Zero Trust Endpoint Device
US20230025126A1 (en) Virtualization layer assisted upgrading of in-guest agents
US20230098991A1 (en) Systems, methods, and media for protecting applications from untrusted operating systems
CN118235125A (zh) 使用健康票据的安全包围区中的活性保证
WO2019148447A1 (zh) 数据保护方法和数据保护装置

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 18806666

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

ENP Entry into the national phase

Ref document number: 2018806666

Country of ref document: EP

Effective date: 20191203