WO2017036376A1 - Data access method, code calling method, and virtual machine monitor - Google Patents

Data access method, code calling method, and virtual machine monitor Download PDF

Info

Publication number
WO2017036376A1
WO2017036376A1 PCT/CN2016/097246 CN2016097246W WO2017036376A1 WO 2017036376 A1 WO2017036376 A1 WO 2017036376A1 CN 2016097246 W CN2016097246 W CN 2016097246W WO 2017036376 A1 WO2017036376 A1 WO 2017036376A1
Authority
WO
WIPO (PCT)
Prior art keywords
space
kernel
page table
vmm
target
Prior art date
Application number
PCT/CN2016/097246
Other languages
French (fr)
Chinese (zh)
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 华为技术有限公司
Publication of WO2017036376A1 publication Critical patent/WO2017036376A1/en

Links

Images

Classifications

    • 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

Definitions

  • the invention relates to the technical field of computer memory management, and particularly relates to a data access method, a code calling method and a virtual machine monitor VMM.
  • Modern operating systems almost support dynamic insertion and unloading of modules, which allows the operating system kernel to extend functionality as needed.
  • the target kernel module When the target kernel module is inserted into the operating system kernel, its behavior is no longer monitored and restricted.
  • the loaded target kernel module runs at the same privilege level as the operating system kernel.
  • the target kernel module can arbitrarily call the code provided by the operating system kernel and modify the operating system kernel data, thus causing the operating system kernel integrity to face security threats.
  • driver isolation layer between the operating system kernel and the driver module to achieve the purpose of isolating the operating system kernel and the driver module, but
  • the driver isolation layer is located in the operating system kernel space and is at the same privilege level as the driver module in the operating system kernel space. Therefore, the driver module can modify the permission mapping relationship in the page table of the driver module, and the modified permission.
  • the mapping relationship can disable the isolation function of the driver isolation layer, making the operating system in an unsafe state, and the driver isolation layer will isolate the driver modules of each core device, which will seriously affect the system performance.
  • the embodiment of the invention provides a data access method, a code calling method and a VMM, so as to improve the security of the system kernel data access and code calling.
  • a first aspect of the embodiments of the present invention discloses a data access method, including:
  • the virtual machine monitor VMM captures a page table interrupt event, which is determined by the central processing unit CPU after detecting the access request for the kernel data in the kernel space K-SPACE sent by the target kernel module.
  • the virtual page kernel space corresponding to the kernel data in the K-SPACE is not created in the space page table MPGT, wherein the virtual machine kernel space corresponding to the VMM includes the K-SPACE and An isolation space M-SPACE, the M-SPACE including the target kernel module and the MPGT, the MPGT being used to support operation of the target kernel module;
  • the VMM determines, by using a pre-stored page table interrupt processing function, whether the target kernel module has permission to access kernel data in the K-SPACE;
  • the VMM determines, by the pre-stored page table interrupt processing function, that the target kernel module has permission to access kernel data in the K-SPACE
  • the VMM creates the target kernel module in the MPGT to
  • the access rights mapping of kernel data in K-SPACE is such that the target kernel module has access to the kernel data in the K-SPACE.
  • the VMM determines, by using a pre-stored page table interrupt processing function, whether the target kernel module has the right to access the kernel data in the K-SPACE, including:
  • the VMM obtains a preset permission judgment policy corresponding to the page table interrupt event by using a pre-stored page table interrupt function, and acquires virtual address distribution information of the kernel data in the K-SPACE;
  • the VMM determines, according to the preset authority determination policy, the virtual address distribution information, and the event type, whether the target kernel module has permission to access kernel data in the K-SPACE.
  • the method is configured before the VMM captures a page table interrupt event. Also includes:
  • the VMM according to the pre-stored space page table of the virtual machine kernel space, the target kernel module
  • the virtual address distribution information of the block is mapped to physical address distribution information, wherein the target kernel module is a kernel module selected from N kernel modules inserted in the virtual machine kernel space and needs to be isolated, and the N is positive Integer
  • the VMM separates the virtual machine kernel space into the M-SPACE and the K-SPACE based on the physical address distribution information
  • the VMM marks a space page table of the virtual machine kernel space as a kernel space page table KPGT, and creates the MPGT based on the physical address distribution information, wherein the KPGT is used to support a kernel in the K-SPACE
  • the operation of the module, the kernel module in the K-SPACE includes a base kernel module in the virtual machine kernel space and a kernel module other than the target kernel module among the N kernel modules
  • the target is created in the MPGT
  • the kernel module maps access rights to the kernel data in the M-SPACE such that the target kernel module has access to the kernel data in the M-SPACE.
  • a second aspect of the embodiment of the present invention discloses a VMM, including:
  • An event capture unit configured to capture a page table interrupt event, where the page table interrupt event is determined by the CPU after detecting an access request for kernel data in the kernel space K-SPACE sent by the target kernel module, and determining an isolated space page
  • the file MPGT is generated without creating an access authority mapping of the target kernel module to the kernel data in the K-SPACE, wherein the virtual machine kernel space corresponding to the VMM includes the K-SPACE and the isolation space.
  • M-SPACE the M-SPACE includes the target kernel module and the MPGT, the MPGT is used to support operation of the target kernel module;
  • a permission determining unit configured to determine, by using a pre-stored page table interrupt processing function, whether the target kernel module has permission to access kernel data in the K-SPACE;
  • a permission creation unit configured to create the target in the MPGT when the permission determination unit determines that the target kernel module has permission to access kernel data in the K-SPACE through a pre-stored page table interrupt processing function
  • the kernel module maps access rights to the kernel data in the K-SPACE such that the target kernel module has access to the kernel data in the K-SPACE.
  • the authority determining unit is specific Used for:
  • the VMM further includes:
  • An address mapping unit configured to map virtual address distribution information of the target kernel module to physical address distribution information according to a pre-stored space page table of the virtual machine kernel space before the event capture unit captures a page table interrupt event
  • the target kernel module is a kernel module selected from N kernel modules inserted in the virtual machine kernel space, and the N is a positive integer;
  • a space separating unit configured to separate the virtual machine kernel space into the M-SPACE and the K-SPACE based on the physical address distribution information
  • a page table creation unit configured to mark a space page table of the virtual machine kernel space as a kernel space page table KPGT, and create the MPGT based on the physical address distribution information, wherein the KPGT is used to support the K-
  • the kernel module in the SPACE includes a base kernel module in the virtual machine kernel space and a kernel module other than the target kernel module among the N kernel modules.
  • the MPGT is created in the MPGT.
  • the target kernel module maps access rights to the kernel data in the M-SPACE such that the target kernel module has access to the kernel data in the M-SPACE.
  • the VMM first captures the page table interrupt event, and secondly, the VMM determines whether the target kernel module has access to the kernel data in the K-SPACE through the pre-stored page table interrupt processing function, and finally, when the VMM passes the pre-stored page table.
  • the VMM creates the target kernel module in the MPGT for K-SPACE.
  • the access rights mapping of the kernel data is such that the target kernel module has access to the kernel data in the K-SPACE.
  • the CPU detects the access request for the kernel data in the kernel space K-SPACE sent by the target kernel module, and determines that the target kernel module is not created in the isolated space page table MPGT, the K- In the case of the access rights mapping of kernel data in SPACE, it can be seen that the target kernel module has no permission to directly access the kernel data in the K-SPACE space, thereby avoiding the target kernel module from accessing K-SPACE without security.
  • the kernel data in the kernel helps to improve the security of system kernel data access.
  • the VMM with higher privilege level is isolated from the virtual machine in execution permission, and is not directly attacked by the virtual machine. .
  • VMM has client platform independence, it can isolate kernel modules of several different types of guest operating systems at the same time.
  • a third aspect of the embodiment of the present invention discloses a code calling method, including:
  • the virtual machine monitor VMM captures a page table interrupt event, which is determined by the central processing unit CPU after detecting the target kernel module's call request for the kernel code in the kernel space K-SPACE, and determines the isolated space page
  • the table MPGT is generated without creating the call permission mapping of the target kernel module to the kernel code in the K-SPACE, wherein the virtual machine kernel space corresponding to the VMM includes the K-SPACE and the isolation space.
  • M-SPACE the M-SPACE includes the target kernel module and the MPGT
  • the MPGT is used to support operation of the target kernel module;
  • the VMM determines, by using a pre-stored page table interrupt processing function, whether the target kernel module has permission to invoke the kernel code in the K-SPACE;
  • the VMM determines, by the pre-stored page table interrupt processing function, that the target kernel module has permission to invoke the kernel code in the K-SPACE
  • the VMM is configured according to the target kernel module in the K-SPACE a call permission mapping of kernel code, performing a page table switching operation and a stack switching operation to switch the stack of the virtual machine kernel space from the isolated space stack M-STACK to a kernel space stack K-STACK, such that the target kernel module is based on The switched K-STACK calls the kernel code in the K-SPACE.
  • the VMM determines, by using a pre-stored page table interrupt processing function, whether the target kernel module has permission to invoke the kernel code in the K-SPACE, including:
  • the VMM obtains a preset permission judgment policy corresponding to the page table interrupt event by using a pre-stored page table interrupt function, and acquires virtual address distribution information of the kernel code in the K-SPACE;
  • the VMM determines, according to the obtained preset permission judgment policy and the virtual address distribution information, whether the target kernel module has permission to access the kernel code in the K-SPACE.
  • the VMM performs a page table page table switching operation, including:
  • the VMM switches the page table currently loaded by the VMM from the MPGT to a kernel space page table KPGT, wherein the KPGT is used to support operation of a kernel module in the K-SPACE, in the K-SPACE And including the basic kernel module in the virtual machine kernel space, a kernel module other than the target kernel module among the N kernel modules inserted in the virtual machine kernel space, and the KPGT, where the N is greater than 1.
  • KPGT is used to support operation of a kernel module in the K-SPACE, in the K-SPACE And including the basic kernel module in the virtual machine kernel space, a kernel module other than the target kernel module among the N kernel modules inserted in the virtual machine kernel space, and the KPGT, where the N is greater than 1.
  • the VMM performs a stack switching operation, including :
  • the VMM copies the code parameters stored in the M-STACK for transferring the kernel code in the K-SPACE and the return address RIP for calling the kernel code in the K-SPACE;
  • the VMM converts a stack currently used by the virtual machine kernel space from an esp-old location to an esp-new location, where the esp-old location is a storage location of the RIP in the M-STACK, The esp-new location is the storage location of the RIP in the K-STACK.
  • the VMM capture page Before the table interrupt event the method further includes:
  • the VMM sets the target kernel module according to the pre-stored space page table of the virtual machine kernel space.
  • the virtual address distribution information is mapped to physical address distribution information, wherein the target kernel module is a kernel module selected from N kernel modules inserted in the virtual machine kernel space and needs to be isolated, and the N is greater than 1. Positive integer
  • the VMM separates the virtual machine kernel space into the M-SPACE and the K-SPACE based on the physical address distribution information
  • the VMM marks the space page table of the virtual machine kernel space as a kernel space page table KPGT, and creates the MPGT based on the physical address distribution information.
  • the calling privilege mapping of the target kernel module to the kernel code in the M-SPACE is created in the MPGT, so that the target kernel module has permission to invoke the kernel code in the M-SPACE.
  • a fourth aspect of the embodiment of the present invention discloses a VMM, including:
  • An event capture unit configured to capture a page table interrupt event, wherein the page table interrupt event is determined by the central processing unit CPU after detecting a call request of the target kernel module for kernel code in the kernel space K-SPACE
  • the page table MPGT is generated without creating a call permission mapping of the target kernel module to the kernel code in the K-SPACE, wherein the virtual machine kernel space corresponding to the VMM includes the K-SPACE and isolation a space M-SPACE, the M-SPACE including the target kernel module and the MPGT, the MPGT being used to support operation of the target kernel module;
  • a permission determining unit configured to determine, by using a pre-stored page table interrupt processing function, whether the target kernel module has permission to invoke the kernel code in the K-SPACE;
  • a switching unit configured to: when the authority determining unit determines, by using a pre-stored page table interrupt processing function, that the target kernel module has permission to invoke the kernel code in the K-SPACE, according to the target kernel module, the K a call permission mapping of kernel code in -SPACE, performing a page table switching operation and a stack switching operation to switch the stack of the virtual machine kernel space from the isolated space stack M-STACK to a kernel space stack K-STACK, such that The target kernel module calls the kernel code in the K-SPACE based on the K-STACK after the handover.
  • the authority determining unit is specific Used for:
  • the switching unit is specifically configured to:
  • KPGT Converting a page table currently loaded by the VMM from the MPGT to a kernel space page table KPGT, wherein the KPGT is configured to support operation of a kernel module in the K-SPACE, the K-SPACE including the The base kernel module in the virtual machine kernel space, the kernel module other than the target kernel module among the N kernel modules inserted in the virtual machine kernel space, and the KPGT, the N is a positive integer greater than 1.
  • the switching unit is specifically configured to:
  • the VMM further includes :
  • An address mapping unit configured to: before the event capture unit captures the page table interrupt event, map the virtual address distribution information of the target kernel module to the physical address distribution information according to the pre-stored space page table of the virtual machine kernel space, where
  • the target kernel module is a kernel module selected from N kernel modules inserted in the virtual machine kernel space, and the N is a positive integer greater than 1.
  • a space separating unit configured to separate the virtual machine kernel space into the M-SPACE and the K-SPACE based on the physical address distribution information
  • a page table creation unit that marks a space page table of the virtual machine kernel space as a kernel space page table KPGT, and creates the MPGT based on the physical address distribution information.
  • the fifth possible implementation manner of the fourth aspect of the embodiment of the present invention The calling privilege mapping of the target kernel module to the kernel code in the M-SPACE is created in the MPGT, so that the target kernel module has permission to invoke the kernel code in the M-SPACE.
  • the VMM first captures the page table interrupt event, and secondly, when the VMM determines that the target kernel module has permission to invoke the kernel code in the K-SPACE through the pre-stored page table interrupt processing function, the VMM is based on the target kernel module pair K. Calling permission mapping of kernel code in -SPACE, performing page table switching operation and stack switching operation to switch stack of virtual machine kernel space from isolation space stack M-STACK to kernel space stack K-STACK, so that the target kernel The module calls the kernel code in the K-SPACE based on the K-STACK after switching.
  • the page table interrupt event is that after the CPU detects the call request of the target kernel module for the kernel code in the kernel space K-SPACE, and determines that the target kernel module is not created in the isolated space page table MPGT in the K-SPACE
  • the kernel code is generated by the call permission mapping. It can be seen that the target kernel module has no permission to directly call the kernel code, which can avoid the target kernel module inadvertently calling the kernel code in K-SPACE if the security is unknown, which is beneficial to the system. The security of the kernel code call.
  • the VMM with higher privilege level is isolated from the virtual machine in execution permission, and is not directly attacked by the virtual machine. .
  • VMM has client platform independence, it can isolate kernel modules of several different types of guest operating systems at the same time.
  • FIG. 1.1 is a schematic structural diagram of a typical bare metal mode virtualization platform deployment according to an embodiment of the present invention.
  • FIG. 1.2 is a schematic structural diagram of a typical host mode virtualization platform deployed according to an embodiment of the present invention.
  • FIG. 2 is a schematic flowchart of a data access method according to an embodiment of the present invention.
  • FIG. 3 is a schematic flowchart diagram of another data access method according to an embodiment of the present invention.
  • FIG. 4 is a schematic flowchart of a data access method according to an embodiment of the present invention.
  • FIG. 5 is a schematic flowchart diagram of a code calling method according to an embodiment of the present invention.
  • FIG. 6 is a schematic flowchart diagram of another code calling method disclosed in an embodiment of the present invention.
  • FIG. 7 is a schematic flowchart diagram of still another code calling method according to an embodiment of the present invention.
  • FIG. 8 is a schematic structural diagram of a VMM for controlling access to kernel data in a K-SPACE by a target kernel module in an M-SPACE according to an embodiment of the present invention
  • FIG. 9 is a schematic structural diagram of a VMM for controlling a kernel code in a K-SPACE by a target kernel module in an M-SPACE according to an embodiment of the present invention.
  • FIG. 10 is a schematic structural diagram of a physical device of a VMM according to an embodiment of the present invention.
  • FIG. 11 is a schematic structural diagram of a physical device of a VMM according to an embodiment of the present invention.
  • the embodiment of the invention provides a data access method, a code calling method and a virtual machine monitor (VMM), so as to improve the security of the system kernel data access and code call.
  • VMM virtual machine monitor
  • FIG. 1.1 is a schematic diagram of a typical bare-machine mode virtualization platform deployment architecture disclosed in the embodiment of the present invention
  • FIG. 1.2 is a typical host mode virtualization flat disclosed in the embodiment of the present invention.
  • Platform deployment architecture diagram As shown in Figure 1.1 and Figure 1.2, the virtual machine operating systems in both modes run on the VMM. The VMM has higher execution privileges than the virtual machine operating system, and the two are isolated from each other.
  • the virtual machine operating system kernel can be further divided into code parts, data parts, stacks required for kernel operations, and dynamically loadable kernel modules.
  • the VMM runs directly on the physical machine, operates on physical hardware, and provides services to the virtual machine upwards.
  • the VMM runs on the host operating system, and its virtualization function needs to be implemented by means of the host. The host directly controls the underlying hardware resources.
  • FIG. 2 is a schematic flowchart of a data access method according to an embodiment of the present invention. As shown in FIG. 2, the data access method is described from one side of the VMM, and specifically includes the following steps:
  • the VMM captures a page table interrupt event, where the page table interrupt event is determined by the CPU after detecting the access request for the kernel data in the kernel space K-SPACE sent by the target kernel module, and determining the isolation space page table MPGT
  • the target kernel module is not created with the access authority mapping of the kernel data in the K-SPACE, wherein the virtual machine kernel space corresponding to the VMM includes the K-SPACE and the isolation space M-SPACE
  • the M-SPACE includes the target kernel module and the MPGT, and the MPGT is configured to support operation of the target kernel module;
  • the access authority mapping of the target kernel module to the kernel data in the M-SPACE is created in the MPGT, so that the target kernel module has the right to access the kernel data in the M-SPACE. .
  • the VMM determines, by using a pre-stored page table interrupt processing function, whether the target kernel module has permission to access kernel data in the K-SPACE.
  • the specific manner in which the VMM determines whether the target kernel module has the right to access the kernel data in the K-SPACE through the pre-stored page table interrupt processing function is:
  • the VMM first acquires a preset permission judgment policy corresponding to the page table interrupt event by using a pre-stored page table interrupt function, and acquires virtual address distribution information of the kernel data in the K-SPACE; secondly, the VMM determines the page. The event type of the table interrupt event; finally, the VMM determines, according to the preset authority judgment policy, the virtual address distribution information, and the event type, whether the target kernel module has permission to access kernel data in the K-SPACE.
  • the VMM determines, by using a pre-stored page table interrupt processing function, that the target kernel module has permission to access kernel data in the K-SPACE, the VMM creates the target kernel module pair in the MPGT.
  • the access rights mapping of the kernel data in the K-SPACE is such that the target kernel module has access to the kernel data in the K-SPACE.
  • the VMM first captures the page table interrupt event, and secondly, the VMM determines whether the target kernel module has access to the kernel data in the K-SPACE through the pre-stored page table interrupt processing function, and finally, when the VMM passes
  • the VMM creates an access authority mapping of the target kernel module to the kernel data in the K-SPACE in the MPGT, so that the target kernel module Have access to kernel data in K-SPACE.
  • the CPU detects the access request for the kernel data in the kernel space K-SPACE sent by the target kernel module, and determines that the target kernel module is not created in the isolated space page table MPGT, the K- In the case of the access rights mapping of kernel data in SPACE, it can be seen that the target kernel module has no permission to directly access the kernel data in the K-SPACE space, thereby avoiding the target kernel module from accessing K-SPACE without security.
  • the kernel data in the kernel helps to improve the security of system kernel data access.
  • the VMM with higher privilege level is isolated from the virtual machine in execution permission, and is not directly attacked by the virtual machine. .
  • VMM has client platform independence, it can isolate kernel modules of several different types of guest operating systems at the same time.
  • the following operations may also be performed to create a kernel space isolation mechanism for the target kernel module:
  • the VMM maps virtual address distribution information of the target kernel module to physical address distribution information according to a pre-stored space page table of the virtual machine kernel space, where the target kernel module is from the virtual machine kernel space a kernel module selected to be isolated among the inserted N kernel modules, where N is a positive integer;
  • the VMM separates the virtual machine kernel space into the M-SPACE and the K-SPACE based on the physical address distribution information
  • the VMM marks a space page table of the virtual machine kernel space as a kernel space page table KPGT, and creates the MPGT based on the physical address distribution information, wherein the KPGT is used to support a kernel in the K-SPACE
  • the operation of the module, the kernel module in the K-SPACE includes a base kernel module in the virtual machine kernel space and a kernel module other than the target kernel module among the N kernel modules.
  • FIG. 3 is a schematic flowchart of a data access method according to an embodiment of the present invention. As shown in FIG. 3, the data access method is described from one side of the VMM, and specifically includes the following steps:
  • the virtual machine monitor VMM captures a page table interrupt event, and the page table interrupt event is determined by the central processing unit CPU after detecting the access request for the kernel data in the kernel space K-SPACE sent by the target kernel module. And generating, in the isolated space page table MPGT, the access authority mapping of the target kernel module to the kernel data in the K-SPACE, wherein the virtual machine kernel space corresponding to the VMM includes the K- SPACE and an isolated space M-SPACE, the M-SPACE including the target kernel module and the MPGT, the MPGT being used to support operation of the target kernel module;
  • the access authority mapping of the target kernel module to the kernel data in the M-SPACE is created in the MPGT, so that the target kernel module has the right to access the kernel data in the M-SPACE. .
  • the VMM acquires a preset permission judgment policy corresponding to the page table interrupt event by using a pre-stored page table interrupt function, and acquires virtual address distribution information of the kernel data in the K-SPACE;
  • the VMM determines an event type of the page table interrupt event.
  • the VMM determines, according to the preset permission determination policy, the virtual address distribution information, and the event type, whether the target kernel module has permission to access kernel data in the K-SPACE.
  • the VMM determines, by using a pre-stored page table interrupt processing function, that the target kernel module has permission to access kernel data in the K-SPACE, the VMM creates the target kernel module pair in the MPGT.
  • the access rights mapping of the kernel data in the K-SPACE is such that the target kernel module has access to the kernel data in the K-SPACE.
  • the VMM first captures the page table interrupt event, and secondly, the VMM The pre-stored page table interrupt processing function determines whether the target kernel module has permission to access the kernel data in K-SPACE. Finally, when the VMM uses the pre-stored page table interrupt processing function to determine that the target kernel module has permission to access the kernel in K-SPACE. In the case of data, the VMM creates an access authority mapping of the target kernel module to the kernel data in the K-SPACE in the MPGT, so that the target kernel module has access to the kernel data in the K-SPACE.
  • the CPU detects the access request for the kernel data in the kernel space K-SPACE sent by the target kernel module, and determines that the target kernel module is not created in the isolated space page table MPGT, the K- In the case of the access rights mapping of kernel data in SPACE, it can be seen that the target kernel module has no permission to directly access the kernel data in the K-SPACE space, thereby avoiding the target kernel module from accessing K-SPACE without security.
  • the kernel data in the kernel helps to improve the security of system kernel data access.
  • the VMM with higher privilege level is isolated from the virtual machine in execution permission, and is not directly attacked by the virtual machine. .
  • VMM has client platform independence, it can isolate kernel modules of several different types of guest operating systems at the same time.
  • the following operations may also be performed to create a kernel space isolation mechanism for the target kernel module:
  • the VMM maps virtual address distribution information of the target kernel module to physical address distribution information according to a pre-stored space page table of the virtual machine kernel space, where the target kernel module is from the virtual machine kernel space a kernel module selected to be isolated among the inserted N kernel modules, where N is a positive integer;
  • the VMM separates the virtual machine kernel space into the M-SPACE and the K-SPACE based on the physical address distribution information
  • the VMM marks a space page table of the virtual machine kernel space as a kernel space page table KPGT, and creates the MPGT based on the physical address distribution information, wherein the KPGT is used to support a kernel in the K-SPACE
  • the operation of the module, the kernel module in the K-SPACE includes a base kernel module in the virtual machine kernel space and a kernel module other than the target kernel module among the N kernel modules.
  • the following operations may also be performed to create a kernel space isolation mechanism for the target kernel module:
  • the VMM maps virtual address distribution information of the target kernel module to physical address distribution information according to a pre-stored space page table of the virtual machine kernel space, where the target kernel module is from the virtual machine kernel space a kernel module selected to be isolated among the inserted N kernel modules, where N is a positive integer;
  • the VMM separates the virtual machine kernel space into the M-SPACE and the K-SPACE based on the physical address distribution information
  • the VMM marks a space page table of the virtual machine kernel space as a kernel space page table KPGT, and creates the MPGT based on the physical address distribution information, wherein the KPGT is used to support a kernel in the K-SPACE
  • the operation of the module, the kernel module in the K-SPACE includes a base kernel module in the virtual machine kernel space and a kernel module other than the target kernel module among the N kernel modules.
  • FIG. 4 is a schematic flowchart of a data access method according to an embodiment of the present invention. As shown in FIG. 4, the data access method is described from one side of the VMM, and specifically includes the following steps:
  • the VMM maps virtual address distribution information of the target kernel module to physical address distribution information according to a pre-stored space page table of the virtual machine kernel space, where the target kernel module is from the virtual machine kernel space.
  • a kernel module selected to be isolated among the inserted N kernel modules, where N is a positive integer;
  • the VMM separates the virtual machine kernel space into the M-SPACE and the K-SPACE based on the physical address distribution information
  • the VMM marks a space page table of the virtual machine kernel space as a kernel space page table KPGT, and creates the MPGT based on the physical address distribution information, where the KPGT is used to support the K-SPACE.
  • the kernel module in the K-SPACE includes a base kernel module in the virtual machine kernel space and a kernel module other than the target kernel module among the N kernel modules;
  • an access authority mapping of the target kernel module to the kernel data in the M-SPACE is created in the MPGT, so that the target kernel module has the right to access the Kernel data in M-SPACE.
  • the VMM captures a page table interrupt event, where the page table interrupt event is determined by the CPU after detecting the access request for the kernel data in the kernel space K-SPACE sent by the target kernel module, and determining the isolation space page table MPGT
  • the target kernel module is not created with the access authority mapping of the kernel data in the K-SPACE, wherein the virtual machine kernel space corresponding to the VMM includes the K-SPACE and the isolation space M-SPACE
  • the M-SPACE includes the target kernel module and the MPGT, and the MPGT is configured to support operation of the target kernel module;
  • the VMM acquires a preset permission judgment policy corresponding to the page table interrupt event by using a pre-stored page table interrupt function, and acquires virtual address distribution information of the kernel data in the K-SPACE;
  • the VMM determines an event type of the page table interrupt event.
  • the VMM determines, according to the preset permission determination policy, the virtual address distribution information, and the event type, whether the target kernel module has permission to access kernel data in the K-SPACE.
  • the foregoing authority judgment policy may be preset and stored in the memory space by the user, and the event type corresponding to the page table interrupt event includes a data read type and a data write type.
  • the target kernel module has the following sub-policy in the authority judging policy corresponding to the data read type of the kernel data in the K-SPACE: if the target kernel module requests the core data of the data read from the memory management unit of the CPU as In the interrupt vector table in K-SPACE, the memory management unit rejects the current data read request of the target kernel module.
  • the VMM when the VMM determines, by using a pre-stored page table interrupt processing function, that the target kernel module has permission to access kernel data in the K-SPACE, the VMM creates the target kernel module pair in the MPGT.
  • the access rights mapping of the kernel data in the K-SPACE is such that the target kernel module has access to the kernel data in the K-SPACE.
  • the VMM first captures the page table interrupt event, and secondly, the VMM determines whether the target kernel module has access to the kernel data in the K-SPACE through the pre-stored page table interrupt processing function, and finally, when the VMM passes
  • the VMM creates an access authority mapping of the target kernel module to the kernel data in the K-SPACE in the MPGT, so that the target kernel module Have access to Kernel data in K-SPACE.
  • the CPU detects the access request for the kernel data in the kernel space K-SPACE sent by the target kernel module, and determines that the target kernel module is not created in the isolated space page table MPGT, the K- In the case of the access rights mapping of kernel data in SPACE, it can be seen that the target kernel module has no permission to directly access the kernel data in the K-SPACE space, thereby avoiding the target kernel module from accessing K-SPACE without security.
  • the kernel data in the kernel helps to improve the security of system kernel data access.
  • the VMM with higher privilege level is isolated from the virtual machine in execution permission, and is not directly attacked by the virtual machine. .
  • VMM has client platform independence, it can isolate kernel modules of several different types of guest operating systems at the same time.
  • the VMM may also perform the following operations:
  • the VMM obtains virtual address distribution information of the target kernel module sent by the client proxy module in the virtual machine kernel space in the virtual machine kernel space.
  • the client agent module is configured in the K-SAPCE, and is configured to obtain virtual address distribution information of the target kernel module in the virtual machine kernel space, and send the obtained virtual address distribution information to the VMM, so that the VMM is based on the virtual
  • the address distribution information establishes an isolated address space of the above target kernel module.
  • the specific implementation manners for obtaining the virtual address distribution information by the foregoing client agent include the following two types:
  • the client agent module intercepts the related system call invoked when the target kernel module is inserted, and the related system call invoked when the target kernel module is inserted is detected.
  • the client agent module obtains the virtual address distribution information ⁇ virt1, virt2 ⁇ of the target kernel module after loading into the virtual machine kernel space.
  • the Windows virtual machine can obtain a memory image insertion event in the virtual machine by registering a callback function, and determine whether the target kernel module is loaded into the virtual machine kernel space according to the image name.
  • the above client proxy module is detected when it is detected that the target kernel module has started running in the virtual machine.
  • the block needs to traverse the kernel module linked list in the virtual machine kernel space to obtain the virtual address distribution information ⁇ virt1, virt2 ⁇ of the target kernel module in the virtual machine kernel space.
  • the client agent module is located in the K-SPACE, and the target kernel module in the M-SPACE runs in a different kernel space, and thus is not attacked by the target kernel module, which is beneficial to further improve.
  • the security of the system kernel is beneficial to further improve.
  • the VMM may further perform the following operations:
  • the VMM deletes an access authority mapping of kernel data in the M-SPACE of the kernel module in the K-SPACE stored in the KPGT, so that the kernel module in the K-SPACE cannot directly access the M-SPACE
  • the kernel data in the library further enhances the security of the system kernel data access.
  • FIG. 5 is a schematic flowchart of a code invoking method according to an embodiment of the present invention. As shown in FIG. 5, the code calling method is described from one side of the VMM, and specifically includes the following steps:
  • the virtual machine monitor VMM captures a page table interrupt event, and the page table interrupt event is determined by the central processing unit CPU after detecting the target kernel module calling request for the kernel code in the kernel space K-SPACE
  • the virtual page kernel space corresponding to the kernel code in the K-SPACE is not created in the space page table MPGT, wherein the virtual machine kernel space corresponding to the VMM includes the K-SPACE and An isolation space M-SPACE, the M-SPACE including the target kernel module and the MPGT, the MPGT being used to support operation of the target kernel module;
  • a call permission mapping of the target kernel module to the kernel code in the M-SPACE is created in the MPGT, so that the target kernel module has permission to invoke the kernel in the M-SPACE. Code.
  • the VMM determines, by using a pre-stored page table interrupt processing function, whether the target kernel module has permission to invoke the kernel code in the K-SPACE.
  • the VMM determines, by using a pre-stored page table interrupt processing function, whether the target kernel module has permission to invoke the kernel code in the K-SPACE:
  • the VMM acquires a preset right corresponding to the page table interrupt event by using a pre-stored page table interrupt function Limiting the judgment strategy, and obtaining virtual address distribution information of the kernel code in the K-SPACE;
  • the VMM determines, according to the obtained preset permission judgment policy and the virtual address distribution information, whether the target kernel module has permission to access the kernel code in the K-SPACE.
  • the VMM determines, by using a pre-stored page table interrupt processing function, that the target kernel module has permission to invoke the kernel code in the K-SPACE, the VMM according to the target kernel module to the K-SPACE a call permission mapping of the kernel code in the table, performing a page table switching operation and a stack switching operation to switch the stack of the virtual machine kernel space from the isolated space stack M-STACK to the kernel space stack K-STACK, such that the target core
  • the module calls the kernel code in the K-SPACE based on the K-STACK after switching.
  • the specific implementation manner of the VMM performing the page table page table switching operation is:
  • the VMM switches the page table currently loaded by the VMM from the MPGT to a kernel space page table KPGT, wherein the KPGT is used to support operation of a kernel module in the K-SPACE, in the K-SPACE And including the basic kernel module in the virtual machine kernel space, a kernel module other than the target kernel module among the N kernel modules inserted in the virtual machine kernel space, and the KPGT, where the N is greater than 1.
  • KPGT is used to support operation of a kernel module in the K-SPACE, in the K-SPACE And including the basic kernel module in the virtual machine kernel space, a kernel module other than the target kernel module among the N kernel modules inserted in the virtual machine kernel space, and the KPGT, where the N is greater than 1.
  • the VMM copies the code parameters stored in the M-STACK for transferring the kernel code in the K-SPACE and the return address RIP for calling the kernel code in the K-SPACE;
  • the VMM converts a stack currently used by the virtual machine kernel space from an esp-old location to an esp-new location, where the esp-old location is a storage location of the RIP in the M-STACK, The esp-new location is the storage location of the RIP in the K-STACK.
  • the VMM first captures the page table interrupt event, and secondly, when the VMM determines that the target kernel module has permission to invoke the kernel code in the K-SPACE through the pre-stored page table interrupt processing function, the VMM is based on the target.
  • the kernel module calls the permission mapping of the kernel code in the K-SPACE, performs a page table switching operation and a stack switching operation to switch the stack of the virtual machine kernel space from the isolated space stack M-STACK to the kernel space stack K-STACK, so that The target kernel module invokes the kernel code in the K-SPACE based on the K-STACK after the handover.
  • the interrupt event is that the CPU detects the call request of the target kernel module for the kernel code in the kernel space K-SPACE, and determines that the target kernel module does not create the call permission of the kernel code in the K-SPACE in the isolated space page table MPGT.
  • mapping it can be seen that the target kernel module has no permission to directly call the kernel code in K-SPACE, which can avoid the target kernel module inadvertently calling the kernel code in K-SPACE if the security is unknown, which is beneficial to the system.
  • the security of the kernel code call is that the CPU detects the call request of the target kernel module for the kernel code in the kernel space K-SPACE, and determines that the target kernel module does not create the call permission of the kernel code in the K-SPACE in the isolated space page table MPGT.
  • the VMM with higher privilege level is isolated from the virtual machine in execution permission, and is not directly attacked by the virtual machine. .
  • VMM has client platform independence, it can isolate kernel modules of several different types of guest operating systems at the same time.
  • the following operations may also be performed to create an isolation mechanism for the target kernel module:
  • the VMM maps virtual address distribution information of the target kernel module to physical address distribution information according to a pre-stored space page table of the virtual machine kernel space, where the target kernel module is inserted from the virtual machine kernel space a kernel module selected from the N kernel modules to be isolated, wherein N is a positive integer greater than one;
  • the VMM separates the virtual machine kernel space into the M-SPACE and the K-SPACE based on the physical address distribution information
  • the VMM marks the space page table of the virtual machine kernel space as a kernel space page table KPGT, and creates the MPGT based on the physical address distribution information.
  • FIG. 6 is a schematic flowchart of a code invoking method according to an embodiment of the present invention. As shown in FIG. 6 , the code calling method is described from one side of the VMM, and specifically includes the following steps:
  • the virtual machine monitor VMM captures a page table interrupt event, and the page table interrupt event is determined by the central processing unit CPU after detecting the target kernel module calling request for the kernel code in the kernel space K-SPACE
  • the virtual page kernel space corresponding to the kernel code in the K-SPACE is not created in the space page table MPGT, wherein the virtual machine kernel space corresponding to the VMM includes the K-SPACE and Isolated space M-SPACE, said The M-SPACE includes the target kernel module and the MPGT, and the MPGT is configured to support operation of the target kernel module;
  • a call permission mapping of the target kernel module to the kernel code in the M-SPACE is created in the MPGT, so that the target kernel module has permission to invoke the kernel in the M-SPACE. Code.
  • the VMM acquires a preset permission judgment policy corresponding to the page table interrupt event by using a pre-stored page table interrupt function, and acquires virtual address distribution information of the kernel code in the K-SPACE;
  • the VMM determines, according to the obtained preset permission judgment policy and the virtual address distribution information, whether the target kernel module has permission to access the kernel code in the K-SPACE;
  • the VMM determines, by using a pre-stored page table interrupt processing function, that the target kernel module has permission to invoke the kernel code in the K-SPACE
  • the VMM is configured according to the target kernel module to the K-SPACE. a call permission mapping of the kernel code in the table, performing a page table switching operation and a stack switching operation to switch the stack of the virtual machine kernel space from the isolated space stack M-STACK to the kernel space stack K-STACK, such that the target core
  • the module calls the kernel code in the K-SPACE based on the K-STACK after switching.
  • the specific implementation manner of the VMM performing the page table page table switching operation is:
  • the VMM switches the page table currently loaded by the VMM from the MPGT to a kernel space page table KPGT, wherein the KPGT is used to support operation of a kernel module in the K-SPACE, in the K-SPACE And including the basic kernel module in the virtual machine kernel space, a kernel module other than the target kernel module among the N kernel modules inserted in the virtual machine kernel space, and the KPGT, where the N is greater than 1.
  • KPGT is used to support operation of a kernel module in the K-SPACE, in the K-SPACE And including the basic kernel module in the virtual machine kernel space, a kernel module other than the target kernel module among the N kernel modules inserted in the virtual machine kernel space, and the KPGT, where the N is greater than 1.
  • the VMM copies the code parameters stored in the M-STACK for transferring the kernel code in the K-SPACE and the return address RIP for calling the kernel code in the K-SPACE;
  • the VMM converts a stack currently used by the virtual machine kernel space from an esp-old location to an esp-new location, where the esp-old location is a storage location of the RIP in the M-STACK, The esp-new location is the storage location of the RIP in the K-STACK.
  • the VMM first captures the page table interrupt event, and secondly, when the VMM determines that the target kernel module has permission to invoke the kernel code in the K-SPACE through the pre-stored page table interrupt processing function, the VMM is based on the target.
  • the kernel module calls the permission mapping of the kernel code in the K-SPACE, performs a page table switching operation and a stack switching operation to switch the stack of the virtual machine kernel space from the isolated space stack M-STACK to the kernel space stack K-STACK, so that The target kernel module invokes the kernel code in the K-SPACE based on the K-STACK after the handover.
  • the page table interrupt event is that after the CPU detects the call request of the target kernel module for the kernel code in the kernel space K-SPACE, and determines that the target kernel module is not created in the isolated space page table MPGT in the K-SPACE
  • the kernel code's call permission mapping is generated. It can be seen that the target kernel module has no permission to directly call the kernel code in K-SPACE, which can avoid the target kernel module inadvertently calling the kernel code in K-SPACE if the security is unknown. It is beneficial to improve the security of system kernel code calls.
  • the VMM first captures the page table interrupt event, and secondly, when the VMM determines that the target kernel module has permission to invoke the kernel code in the K-SPACE through the pre-stored page table interrupt processing function, the VMM is based on the target.
  • the kernel module calls the permission mapping of the kernel code in the K-SPACE, performs a page table switching operation and a stack switching operation to switch the stack of the virtual machine kernel space from the isolated space stack M-STACK to the kernel space stack K-STACK, so that The target kernel module invokes the kernel code in the K-SPACE based on the K-STACK after the handover.
  • the page table interrupt event is that after the CPU detects the call request of the target kernel module for the kernel code in the kernel space K-SPACE, and determines that the target kernel module is not created in the isolated space page table MPGT in the K-SPACE
  • the kernel code is generated by the call permission mapping. It can be seen that the target kernel module has no permission to directly call the kernel code, which can avoid the target kernel module inadvertently calling the kernel code in K-SPACE if the security is unknown, which is beneficial to the system. The security of the kernel code call.
  • the VMM with higher privilege level is isolated from the virtual machine in execution permission, and is not directly attacked by the virtual machine. .
  • VMM has client platform independence, it can isolate kernel modules of several different types of guest operating systems at the same time.
  • the following operations may also be performed to create an isolation mechanism for the target kernel module:
  • the VMM maps virtual address distribution information of the target kernel module to physical address distribution information according to a pre-stored space page table of the virtual machine kernel space, where the target kernel module is inserted from the virtual machine kernel space a kernel module selected from the N kernel modules to be isolated, wherein N is a positive integer greater than one;
  • the VMM separates the virtual machine kernel space into the M-SPACE and the K-SPACE based on the physical address distribution information
  • the VMM marks the space page table of the virtual machine kernel space as a kernel space page table KPGT, and creates the MPGT based on the physical address distribution information.
  • FIG. 7 is a schematic flowchart of a code invoking method according to an embodiment of the present invention. As shown in FIG. 7, the code calling method is described from one side of a VMM, and specifically includes the following steps:
  • the VMM maps virtual address distribution information of the target kernel module to physical address distribution information according to the pre-stored space page table of the virtual machine kernel space, where the target kernel module is from the virtual machine kernel space.
  • a kernel module selected to be isolated among the inserted N kernel modules, where N is a positive integer greater than one;
  • the VMM separates the virtual machine kernel space into the M-SPACE and the K-SPACE based on the physical address distribution information
  • the VMM marks the space page table of the virtual machine kernel space as a kernel space page table KPGT, and creates the MPGT based on the physical address distribution information;
  • a call permission mapping of the target kernel module to the kernel code in the M-SPACE is created in the MPGT, so that the target kernel module has permission to invoke the kernel in the M-SPACE. Code.
  • the virtual machine monitor VMM captures a page table interrupt event, and the page table interrupt event is determined by the central processing unit CPU after detecting the target kernel module calling request for the kernel code in the kernel space K-SPACE
  • the virtual page kernel space corresponding to the kernel code in the K-SPACE is not created in the space page table MPGT, wherein the virtual machine kernel space corresponding to the VMM includes the K-SPACE and Isolated space M-SPACE, said The M-SPACE includes the target kernel module and the MPGT, and the MPGT is configured to support operation of the target kernel module;
  • the VMM determines, by using a pre-stored page table interrupt processing function, whether the target kernel module has permission to invoke the kernel code in the K-SPACE.
  • the VMM determines, by using a pre-stored page table interrupt processing function, that the target kernel module has permission to invoke the kernel code in the K-SPACE, the VMM is configured according to the target kernel module to the K-SPACE. a call permission mapping of the kernel code in the table, performing a page table switching operation and a stack switching operation to switch the stack of the virtual machine kernel space from the isolated space stack M-STACK to the kernel space stack K-STACK, such that the target core
  • the module calls the kernel code in the K-SPACE based on the K-STACK after switching.
  • the specific implementation manner of the VMM performing the page table page table switching operation is:
  • the VMM switches the page table currently loaded by the VMM from the MPGT to a kernel space page table KPGT, wherein the KPGT is used to support operation of a kernel module in the K-SPACE, in the K-SPACE And including the basic kernel module in the virtual machine kernel space, a kernel module other than the target kernel module among the N kernel modules inserted in the virtual machine kernel space, and the KPGT, where the N is greater than 1.
  • KPGT is used to support operation of a kernel module in the K-SPACE, in the K-SPACE And including the basic kernel module in the virtual machine kernel space, a kernel module other than the target kernel module among the N kernel modules inserted in the virtual machine kernel space, and the KPGT, where the N is greater than 1.
  • the VMM copies the code parameters stored in the M-STACK for transferring the kernel code in the K-SPACE and the return address RIP for calling the kernel code in the K-SPACE;
  • the VMM converts a stack currently used by the virtual machine kernel space from an esp-old location to an esp-new location, where the esp-old location is a storage location of the RIP in the M-STACK, The esp-new location is the storage location of the RIP in the K-STACK.
  • the VMM first captures the page table interrupt event, and secondly, when the VMM determines that the target kernel module has permission to invoke the kernel code in the K-SPACE through the pre-stored page table interrupt processing function, the VMM is based on the target.
  • the kernel module calls the permission mapping of the kernel code in the K-SPACE, performs a page table switching operation and a stack switching operation to switch the stack of the virtual machine kernel space from the isolated space stack M-STACK to the kernel space stack K-STACK, so that The target kernel module is based on The switched K-STACK calls the kernel code in the K-SPACE.
  • the page table interrupt event is that after the CPU detects the call request of the target kernel module for the kernel code in the kernel space K-SPACE, and determines that the target kernel module is not created in the isolated space page table MPGT in the K-SPACE
  • the kernel code's call permission mapping is generated. It can be seen that the target kernel module has no permission to directly call the kernel code in K-SPACE, which can avoid the target kernel module inadvertently calling the kernel code in K-SPACE if the security is unknown. It is beneficial to improve the security of system kernel code calls.
  • the VMM with higher privilege level is isolated from the virtual machine in execution permission, and is not directly attacked by the virtual machine. .
  • VMM has client platform independence, it can isolate kernel modules of several different types of guest operating systems at the same time.
  • the target kernel module in step S706 calls the kernel code in the K-SPACE based on the stack switched to K-STACK
  • the code execution execution process needs to be from K.
  • -SPACE returns to the target kernel module, including the following process:
  • the kernel module CPU to which the kernel code in the above K-SPACE belongs executes the ret instruction, and the request is returned to the target kernel module;
  • the memory management module in the CPU detects the above ret instruction, and determines whether the KPGT creates a call permission mapping of the kernel module in the K-SPACE to the kernel code in the target kernel module;
  • the memory management module in the CPU determines that the KPGT does not create a call permission mapping of the kernel module in the K-SPACE to the kernel code in the target kernel module, and generates a page table interrupt event M3.
  • the VMM captures the above page table interrupt event M3, responds to the page table interrupt event M3, and determines whether the kernel module in the K-SPACE has permission to call the kernel code of the target kernel module through the pre-stored page table interrupt processing function, and if it is determined that there is permission
  • the VMM creates a call permission mapping of the kernel module in the K-SPACE to the kernel code of the target kernel module in the KPGT, switches the currently loaded page table from the KPGT to the MPGT, and performs a stack switching operation to virtualize
  • the stack loaded by the kernel space is switched back to the kernel space stack M-STACK by the isolated space stack K-STACK.
  • the execution flow returns to M-SPACE, and the kernel code can continue to be called in the target kernel space.
  • the VMM may further perform the following operations: the VMM deletes the kernel in the K-SPACE stored in the KPGT and the kernel in the M-SPACE The call permission mapping for the code.
  • the VMM deletes the call permission mapping of the kernel code in the M-SPACE of the kernel module in the K-SPACE stored in the KPGT
  • the kernel module requests to call the kernel code in the target kernel module.
  • the specific execution process is as follows:
  • the CPU detects the code call instruction issued by the kernel module in the K-SPACE for the kernel code in the target kernel module, and determines whether the KPGT creates a call permission mapping of the kernel module of the target kernel module in the K-SPACE kernel module. ;
  • the CPU determines that the KPGT does not create a call permission mapping of the kernel module of the K-SPACE to the kernel code of the target kernel module, and generates a page table interrupt event M1;
  • the VMM captures the above page table interrupt event M1, and determines whether the kernel module in the K-SPACE has permission to call the kernel code of the target kernel module through the pre-stored page table interrupt processing function. If it is determined that there is permission, the VMM is based on the VMM.
  • the kernel module in the K-SPACE maps the call permission of the kernel code of the target kernel module, switches the page table currently loaded by the VMM from the KPGT to the MPGT, and performs a stack switch operation to load the virtual machine kernel space
  • the stack is switched from the isolated space stack K-STACK to the kernel space stack M-STACK.
  • the system code execution flow is in M-SPACE, and the kernel code of the target kernel module is executed.
  • the virtual machine code calling execution process needs to be returned from the target kernel module to the K-SPACE, including The following steps:
  • the CPU detects the return ret command issued by the target kernel module, and determines whether the target permission of the target kernel module to the kernel code in the K-SPACE is created in the MPGT;
  • the CPU determines that the calling kernel mapping of the target kernel module to the kernel code in the K-SPACE is not created in the MPGT, and generates a page table interrupt event M2;
  • the VMM captures the above page table interrupt event M2, and determines whether the target kernel module has permission to invoke the kernel code in the kernel module in the K-SPACE through the pre-stored page table interrupt processing function. Determining that there is permission, the VMM switches the page table currently loaded by the VMM from the MPGT to the KPGT, and performs a stack switch according to the calling authority mapping of the target kernel module to the kernel code in the K-SPACE. The operation is to switch the stack loaded by the virtual machine kernel space from the isolated space stack M-STACK to the kernel space stack K-STACK. At this time, the code of the virtual machine calls the execution flow and returns to the K-SPACE.
  • FIG. 8 is a schematic structural diagram of a VMM according to an embodiment of the present invention, which is used to control access of kernel data in a K-SPACE by a target kernel module in an M-SPACE, as shown in FIG.
  • the event capture unit 801 is configured to capture a page table interrupt event, and the page table interrupt event is determined by the CPU after detecting an access request for kernel data in the kernel space K-SPACE sent by the target kernel module. And generating, in the isolated space page table MPGT, the access authority mapping of the target kernel module to the kernel data in the K-SPACE, wherein the virtual machine kernel space corresponding to the VMM includes the K-SPACE And an isolation space M-SPACE, the M-SPACE including the target kernel module and the MPGT, the MPGT being used to support operation of the target kernel module;
  • the access authority mapping of the target kernel module to the kernel data in the M-SPACE is created in the MPGT, so that the target kernel module has the right to access the kernel data in the M-SPACE. .
  • the authority determining unit 802 is configured to determine, by using a pre-stored page table interrupt processing function, whether the target kernel module has permission to access kernel data in the K-SPACE;
  • the permission creation unit 803 is configured to create in the MPGT when the permission determination unit determines that the target kernel module has permission to access kernel data in the K-SPACE through a pre-stored page table interrupt processing function.
  • the target kernel module maps access rights to the kernel data in the K-SPACE such that the target kernel module has permission to access kernel data in the K-SPACE.
  • the VMM first captures the page table interrupt event, and secondly, the VMM The pre-stored page table interrupt processing function determines whether the target kernel module has permission to access the kernel data in K-SPACE. Finally, when the VMM uses the pre-stored page table interrupt processing function to determine that the target kernel module has permission to access the kernel in K-SPACE. In the case of data, the VMM creates an access authority mapping of the target kernel module to the kernel data in the K-SPACE in the MPGT, so that the target kernel module has access to the kernel data in the K-SPACE.
  • the CPU detects the access request for the kernel data in the kernel space K-SPACE sent by the target kernel module, and determines that the target kernel module is not created in the isolated space page table MPGT, the K- In the case of the access rights mapping of kernel data in SPACE, it can be seen that the target kernel module has no permission to directly access the kernel data in the K-SPACE space, thereby avoiding the target kernel module from accessing K-SPACE without security.
  • the kernel data in the kernel helps to improve the security of system kernel data access.
  • the VMM with higher privilege level is isolated from the virtual machine in execution permission, and is not directly attacked by the virtual machine. .
  • VMM has client platform independence, it can isolate kernel modules of several different types of guest operating systems at the same time.
  • the foregoing authority determining unit 802 is specifically configured to:
  • the foregoing VMM further includes:
  • An address mapping unit configured to map virtual address distribution information of the target kernel module to physical address distribution information according to a pre-stored space page table of the virtual machine kernel space before the event capture unit captures a page table interrupt event
  • the target kernel module is a kernel module selected from N kernel modules inserted in the virtual machine kernel space, and the N is a positive integer;
  • a space separating unit configured to separate the virtual machine kernel space based on the physical address distribution information For the M-SPACE and the K-SPACE;
  • a page table creation unit configured to mark a space page table of the virtual machine kernel space as a kernel space page table KPGT, and create the MPGT based on the physical address distribution information, wherein the KPGT is used to support the K-
  • the kernel module in the SPACE includes a base kernel module in the virtual machine kernel space and a kernel module other than the target kernel module among the N kernel modules.
  • FIG. 9 is a schematic structural diagram of a VMM according to an embodiment of the present invention, for controlling a call of a target kernel module in an M-SPACE to a kernel code in a K-SPACE, as shown in FIG.
  • An event capture unit 901, a rights determination unit 902, and a switching unit 903, where
  • the event capture unit 901 is configured to capture a page table interrupt event, and the page table interrupt event is determined by the central processing unit CPU after detecting a call request of the target kernel module for the kernel code in the kernel space K-SPACE. And generating, in the isolated space page table MPGT, the target kernel module does not create a call permission mapping of the kernel code in the K-SPACE, wherein the virtual machine kernel space corresponding to the VMM includes the K- SPACE and an isolated space M-SPACE, the M-SPACE including the target kernel module and the MPGT, the MPGT being used to support operation of the target kernel module;
  • the call authority mapping of the target kernel module to the kernel code in the M-SPACE is created in the MPGT, so that the target kernel module has permission to invoke the kernel code in the M-SPACE. .
  • the authority determining unit 902 is configured to determine, by using a pre-stored page table interrupt processing function, whether the target kernel module has permission to invoke the kernel code in the K-SPACE;
  • the switching unit 903 is configured to: when the authority determining unit determines, by using a pre-stored page table interrupt processing function, that the target kernel module has permission to invoke the kernel code in the K-SPACE, according to the target kernel module pair The call permission mapping of the kernel code in the K-SPACE, performing a page table switching operation and a stack switching operation to switch the stack of the virtual machine kernel space from the isolation space stack M-STACK to the kernel space stack K-STACK, The target kernel module is caused to call the kernel code in the K-SPACE based on the K-STACK after the handover.
  • the VMM first captures the page table interrupt event, and secondly, when the VMM When the pre-stored page table interrupt processing function determines that the target kernel module has permission to call the kernel code in the K-SPACE, the VMM performs the page table switching operation and the stack according to the calling authority mapping of the target kernel module to the kernel code in the K-SPACE. Switching operation to switch the stack of virtual machine kernel space from the isolated space stack M-STACK to the kernel space stack K-STACK, such that the target kernel module invokes the K-SPACE based on the K-STACK after the handover Kernel code.
  • the page table interrupt event is that after the CPU detects the call request of the target kernel module for the kernel code in the kernel space K-SPACE, and determines that the target kernel module is not created in the isolated space page table MPGT in the K-SPACE
  • the kernel code's call permission mapping is generated. It can be seen that the target kernel module has no permission to directly call the kernel code in K-SPACE, which can avoid the target kernel module inadvertently calling the kernel code in K-SPACE if the security is unknown. It is beneficial to improve the security of system kernel code calls.
  • the VMM with higher privilege level is isolated from the virtual machine in execution permission, and is not directly attacked by the virtual machine. .
  • VMM has client platform independence, it can isolate kernel modules of several different types of guest operating systems at the same time.
  • the foregoing authority determining unit 902 is specifically configured to:
  • the foregoing switching unit 903 is specifically configured to:
  • KPGT Converting a page table currently loaded by the VMM from the MPGT to a kernel space page table KPGT, wherein the KPGT is configured to support operation of a kernel module in the K-SPACE, the K-SPACE including the The base kernel module in the virtual machine kernel space, the kernel module other than the target kernel module among the N kernel modules inserted in the virtual machine kernel space, and the KPGT, the N is a positive integer greater than 1.
  • the foregoing switching unit 903 is specifically configured to:
  • the foregoing VMM further includes:
  • An address mapping unit configured to: before the event capture unit captures the page table interrupt event, map the virtual address distribution information of the target kernel module to the physical address distribution information according to the pre-stored space page table of the virtual machine kernel space, where
  • the target kernel module is a kernel module selected from N kernel modules inserted in the virtual machine kernel space, and the N is a positive integer greater than 1.
  • a space separating unit configured to separate the virtual machine kernel space into the M-SPACE and the K-SPACE based on the physical address distribution information
  • a page table creation unit that marks a space page table of the virtual machine kernel space as a kernel space page table KPGT, and creates the MPGT based on the physical address distribution information.
  • FIG. 10 is a schematic structural diagram of a VMM according to an embodiment of the present invention.
  • the VMM may include: at least one processor 1001, such as a CPU, at least one memory 1002, and at least one communication bus 1003. .
  • the communication bus 1003 is used to implement connection communication between the processor 1001 and the memory 1002, wherein the memory 1002 may include a high speed RAM memory, and may also include a non-volatile memory such as at least one disk memory.
  • the memory 1002 stores the following elements (executable modules or data structures, or a subset of them, or their extended set):
  • An operating system 10021 including various system programs for implementing various basic services and processing hardware-based tasks;
  • the application 10022 includes various applications such as a device control service program and a device identification service program for implementing various application services.
  • the processor 1001 is configured to invoke a program stored in the memory 1002 to perform the following operations:
  • the processor 1001 captures a page table interrupt event, and the page table interrupt event is determined by the CPU after detecting the access request for the kernel data in the kernel space K-SPACE sent by the target kernel module, and determining the isolated space page table MPGT
  • the virtual machine kernel space corresponding to the VMM and the isolated space M- SPACE, the M-SPACE includes the target kernel module and the MPGT, and the MPGT is configured to support operation of the target kernel module;
  • the access authority mapping of the target kernel module to the kernel data in the M-SPACE is created in the MPGT, so that the target kernel module has the right to access the kernel data in the M-SPACE. .
  • the processor 1001 determines, by using a pre-stored page table interrupt processing function, whether the target kernel module has permission to access kernel data in the K-SPACE;
  • the processor 1001 when the pre-stored page table interrupt processing function determines that the target kernel module has permission to access the kernel data in the K-SPACE, creates the target kernel module in the MPGT to the K-
  • the access rights mapping of the kernel data in the SPACE is such that the target kernel module has access to the kernel data in the K-SPACE.
  • the VMM first captures the page table interrupt event, and secondly, the VMM determines whether the target kernel module has access to the kernel data in the K-SPACE through the pre-stored page table interrupt processing function, and finally, when the VMM passes
  • the VMM creates an access authority mapping of the target kernel module to the kernel data in the K-SPACE in the MPGT, so that the target kernel module Have access to kernel data in K-SPACE.
  • the CPU detects the access request for the kernel data in the kernel space K-SPACE sent by the target kernel module, and determines that the target kernel module is not created in the isolated space page table MPGT, the K- In the case of the access rights mapping of kernel data in SPACE, it can be seen that the target kernel module has no permission to directly access the kernel data in the K-SPACE space, thereby avoiding the target kernel module from accessing K-SPACE without security.
  • the kernel data in the kernel helps to improve the security of system kernel data access.
  • the VMM with higher privilege level is isolated from the virtual machine in execution permission, Will be directly attacked by the virtual machine.
  • VMM has client platform independence, it can isolate kernel modules of several different types of guest operating systems at the same time.
  • the processor 1001 determines, by using a pre-stored page table interrupt processing function, whether the target kernel module has the right to access the kernel data in the K-SPACE: the processor 1001 first Acquiring a preset permission judgment policy corresponding to the page table interrupt event by using a pre-stored page table interrupt function, and acquiring virtual address distribution information of the kernel data in the K-SPACE; secondly, the processor 1001 determines that the page table is interrupted The event type of the event; finally, the processor 1001 determines, according to the preset authority determination policy, the virtual address distribution information, and the event type, whether the target kernel module has permission to access kernel data in the K-SPACE.
  • the following operations may also be performed to create a kernel space isolation mechanism for the target kernel module:
  • the processor 1001 maps virtual address distribution information of the target kernel module to physical address distribution information according to a pre-stored space page table of the virtual machine kernel space, where the target kernel module is from the virtual machine kernel space.
  • the processor 1001 separates the virtual machine kernel space into the M-SPACE and the K-SPACE based on the physical address distribution information;
  • the processor 1001 marks a space page table of the virtual machine kernel space as a kernel space page table KPGT, and creates the MPGT based on the physical address distribution information, wherein the KPGT is used to support the K-SPACE.
  • the operation of the kernel module, the kernel module in the K-SPACE includes a base kernel module in the virtual machine kernel space and a kernel module other than the target kernel module among the N kernel modules.
  • FIG. 11 is a schematic structural diagram of a code invoking device according to an embodiment of the present invention.
  • the code invoking device may include: at least one processor 1001, such as a CPU, at least one memory 1002, at least A communication bus 1003.
  • the communication bus 1003 is used to implement connection communication between the processor 1001 and the memory 1002, wherein the memory 1002 may include a high speed RAM memory, and may also include a non-volatile memory, such as at least one magnetic Disk storage.
  • the memory 1002 stores the following elements (executable modules or data structures, or a subset of them, or their extended set):
  • An operating system 10021 including various system programs for implementing various basic services and processing hardware-based tasks;
  • the application 10022 includes various applications such as a device control service program and a device identification service program for implementing various application services.
  • the processor 1001 is configured to invoke a program stored in the memory 1002 to perform the following operations:
  • the processor 1001 captures a page table interrupt event, and the page table interrupt event is determined by the central processing unit CPU after detecting the target kernel module's call request for the kernel code in the kernel space K-SPACE, and determines the isolated space page table.
  • the virtual machine kernel space corresponding to the VMM corresponding to the kernel code in the K-SPACE is generated in the MPGT, and the K-SPACE and the isolation space M are included.
  • the M-SPACE includes the target kernel module and the MPGT, the MPGT is used to support operation of the target kernel module;
  • the call authority mapping of the target kernel module to the kernel code in the M-SPACE is created in the MPGT, so that the target kernel module has permission to invoke the kernel code in the M-SPACE. .
  • the processor 1001 determines, by using a pre-stored page table interrupt processing function, whether the target kernel module has permission to invoke the kernel code in the K-SPACE;
  • the processor 1001 when the VMM determines, by the pre-stored page table interrupt processing function, that the target kernel module has permission to invoke the kernel code in the K-SPACE, the VMM according to the target kernel module to the K a call permission mapping of kernel code in -SPACE, performing a page table switching operation and a stack switching operation to switch the stack of the virtual machine kernel space from the isolated space stack M-STACK to a kernel space stack K-STACK, such that The target kernel module calls the kernel code in the K-SPACE based on the K-STACK after the handover.
  • the VMM first captures the page table interrupt event, and secondly, when the VMM uses the pre-stored page table interrupt processing function to determine that the target kernel module has permission to invoke the K-SPACE.
  • the VMM performs a page table switching operation and a stack switching operation to switch the stack of the virtual machine kernel space from the isolated space stack M-STACK to the kernel space according to the target permission of the target kernel module to the kernel code in the K-SPACE.
  • the K-STACK is stacked such that the target kernel module invokes the kernel code in the K-SPACE based on the K-STACK after the handover.
  • the page table interrupt event is that after the CPU detects the call request of the target kernel module for the kernel code in the kernel space K-SPACE, and determines that the target kernel module is not created in the isolated space page table MPGT in the K-SPACE
  • the kernel code's call permission mapping is generated. It can be seen that the target kernel module has no permission to directly call the kernel code in K-SPACE, which can avoid the target kernel module inadvertently calling the kernel code in K-SPACE if the security is unknown. It is beneficial to improve the security of system kernel code calls.
  • the VMM with higher privilege level is isolated from the virtual machine in execution permission, and is not directly attacked by the virtual machine. .
  • VMM has client platform independence, it can isolate kernel modules of several different types of guest operating systems at the same time.
  • the following operations may also be performed to create an isolation mechanism for the target kernel module:
  • the processor 1001 maps virtual address distribution information of the target kernel module to physical address distribution information according to the pre-stored space page table of the virtual machine kernel space, where the target kernel module is inserted from the virtual machine kernel space.
  • a kernel module selected from the N kernel modules to be isolated, wherein N is a positive integer greater than one;
  • the processor 1001 separates the virtual machine kernel space into the M-SPACE and the K-SPACE based on the physical address distribution information;
  • the processor 1001 marks the space page table of the virtual machine kernel space as a kernel space page table KPGT, and creates the MPGT based on the physical address distribution information.
  • the processor 1001 determines, by using a pre-stored page table interrupt processing function, whether the target kernel module has permission to invoke the kernel code in the K-SPACE: 1001 obtains the page table interrupt event pair by using a pre-stored page table interrupt function Determining the policy by the preset authority, and obtaining the virtual address distribution information of the kernel code in the K-SPACE; determining whether the target kernel module has the content according to the obtained preset permission judgment policy and the virtual address distribution information Permission to access the kernel code in the K-SPACE.
  • the processor 1001 performs a page table page table switching operation, where the processor 1001 switches the page table currently loaded by the VMM from the MPGT to a kernel space page table.
  • KPGT wherein the KPGT is used to support operation of a kernel module in the K-SPACE
  • the K-SPACE includes a base kernel module in the virtual machine kernel space, and the virtual machine kernel space is inserted Among the N kernel modules, except for the kernel module other than the target kernel module and the KPGT, the N is a positive integer greater than one.
  • the processor 1001 performs a stack switching operation, where the processor 1001 copies the code parameters stored in the M-STACK for transmitting the kernel code in the K-SPACE. And a return address RIP for calling the kernel code in the K-SPACE; writing the code parameter and the RIP in the K-STACK; and using the stack currently used by the virtual machine kernel space by esp- The old position is changed to an esp-new position, wherein the esp-old position is a storage location of the RIP in the M-STACK, and the esp-new position is the RIP in the K-STACK storage location.
  • the program may be stored in a computer readable storage medium, and the storage medium may include: Flash disk, Read-Only Memory (ROM), Random Access Memory (RAM), disk or optical disk.

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Memory System Of A Hierarchy Structure (AREA)
  • Storage Device Security (AREA)

Abstract

A data access method, a code calling method, and a virtual machine monitor (VMM). The data access method comprises: a VMM captures a page table interrupt event (S201); the VMM determines via a prestored page table interrupt processing function whether or not a target kernel module has the permission to access kernel data in a K-SPACE (S202); when the VMM determines via the prestored page table interrupt processing function that the target kernel module has the permission to access the kernel data in the K-SPACE, the VMM creates in an MPGT a mapping of the permission of the target kernel module to access the kernel data in the K-SPACE, thus allowing the target kernel module to have the permission to access the kernel data in the K-SPACE (S203). The method facilitates increased security of system kernel data access and code calling.

Description

一种数据访问方法、代码调用方法及虚拟机监视器Data access method, code calling method and virtual machine monitor
本发明要求2015年9月6日递交的发明名称为“一种数据访问方法、代码调用方法及虚拟机监视器”的申请号201510559382.6的在先申请优先权,上述在先申请的内容以引入的方式并入本文本中。The present invention claims the priority of the prior application filed on September 6, 2015, entitled "A Data Access Method, Code Calling Method, and Virtual Machine Monitor", Application No. 201510559382.6, the contents of which are incorporated herein by reference. The way is incorporated into this text.
技术领域Technical field
本发明涉及计算机内存管理技术领域,具体涉及了一种数据访问方法、代码调用方法及虚拟机监视器VMM。The invention relates to the technical field of computer memory management, and particularly relates to a data access method, a code calling method and a virtual machine monitor VMM.
背景技术Background technique
现代操作系统几乎都支持模块的动态插入与卸载,这使得操作系统内核可以按需拓展功能。当目标内核模块插入操作系统内核后,其行为就不再受到监控与限制。被加载的目标内核模块与操作系统内核运行在相同特权级,目标内核模块可以任意调用操作系统内核提供的代码并修改操作系统内核数据,致使操作系统内核完整性面临安全威胁。Modern operating systems almost support dynamic insertion and unloading of modules, which allows the operating system kernel to extend functionality as needed. When the target kernel module is inserted into the operating system kernel, its behavior is no longer monitored and restricted. The loaded target kernel module runs at the same privilege level as the operating system kernel. The target kernel module can arbitrarily call the code provided by the operating system kernel and modify the operating system kernel data, thus causing the operating system kernel integrity to face security threats.
以在操作系统内核添加驱动程序模块为例,目前,开发人员一般通过在操作系统内核以及驱动程序模块之间添加一个驱动隔离层,从而达到隔离操作系统内核与驱动程序模块的目的,但是,由于该驱动隔离层位于操作系统内核空间中,与操作系统内核空间中的驱动程序模块位于同一特权级,因此,驱动程序模块可以修改该驱动程序模块的页表中的权限映射关系,修改后的权限映射关系能够使驱动隔离层的隔离功能失效,使得操作系统处于不安全状态,并且由于该驱动隔离层对每个内核设备的驱动程序模块均进行隔离,将严重影响系统性能。Taking the driver module in the operating system kernel as an example, at present, developers generally add a driver isolation layer between the operating system kernel and the driver module to achieve the purpose of isolating the operating system kernel and the driver module, but The driver isolation layer is located in the operating system kernel space and is at the same privilege level as the driver module in the operating system kernel space. Therefore, the driver module can modify the permission mapping relationship in the page table of the driver module, and the modified permission. The mapping relationship can disable the isolation function of the driver isolation layer, making the operating system in an unsafe state, and the driver isolation layer will isolate the driver modules of each core device, which will seriously affect the system performance.
发明内容Summary of the invention
本发明实施例提供一种数据访问方法、代码调用方法及VMM,以期提升系统内核数据访问和代码调用的安全性。The embodiment of the invention provides a data access method, a code calling method and a VMM, so as to improve the security of the system kernel data access and code calling.
本发明实施例第一方面公开了一种数据访问方法,包括:A first aspect of the embodiments of the present invention discloses a data access method, including:
虚拟机监视器VMM捕获页表中断事件,所述页表中断事件是由中央处理单元CPU在检测到目标内核模块发送的针对内核空间K-SPACE中的内核数据的访问请求之后、且判断出隔离空间页表MPGT中未创建所述目标内核模块对所述K-SPACE中的内核数据的访问权限映射的情况下产生的,其中,所述VMM对应的虚拟机内核空间包括所述K-SPACE和隔离空间M-SPACE,所述M-SPACE包括所述目标内核模块和所述MPGT,所述MPGT用于支持所述目标内核模块的运行;The virtual machine monitor VMM captures a page table interrupt event, which is determined by the central processing unit CPU after detecting the access request for the kernel data in the kernel space K-SPACE sent by the target kernel module. The virtual page kernel space corresponding to the kernel data in the K-SPACE is not created in the space page table MPGT, wherein the virtual machine kernel space corresponding to the VMM includes the K-SPACE and An isolation space M-SPACE, the M-SPACE including the target kernel module and the MPGT, the MPGT being used to support operation of the target kernel module;
所述VMM通过预存的页表中断处理函数判断所述目标内核模块是否有权限访问所述K-SPACE中的内核数据;The VMM determines, by using a pre-stored page table interrupt processing function, whether the target kernel module has permission to access kernel data in the K-SPACE;
当所述VMM通过预存的页表中断处理函数判断出所述目标内核模块有权限访问所述K-SPACE中的内核数据时,所述VMM在所述MPGT中创建所述目标内核模块对所述K-SPACE中的内核数据的访问权限映射,以使得所述目标内核模块有权限访问所述K-SPACE中的内核数据。When the VMM determines, by the pre-stored page table interrupt processing function, that the target kernel module has permission to access kernel data in the K-SPACE, the VMM creates the target kernel module in the MPGT to The access rights mapping of kernel data in K-SPACE is such that the target kernel module has access to the kernel data in the K-SPACE.
本发明实施例第一方面第一种可能的实现方式中,所述VMM通过预存的页表中断处理函数判断所述目标内核模块是否有权限访问所述K-SPACE中的内核数据,包括:In a first possible implementation manner of the first aspect of the present disclosure, the VMM determines, by using a pre-stored page table interrupt processing function, whether the target kernel module has the right to access the kernel data in the K-SPACE, including:
所述VMM通过预存的页表中断函数获取所述页表中断事件对应的预设权限判断策略,并获取所述K-SPACE中的内核数据的虚拟地址分布信息;The VMM obtains a preset permission judgment policy corresponding to the page table interrupt event by using a pre-stored page table interrupt function, and acquires virtual address distribution information of the kernel data in the K-SPACE;
所述VMM确定所述页表中断事件的事件类型;Determining, by the VMM, an event type of the page table interrupt event;
所述VMM根据所述预设权限判断策略、所述虚拟地址分布信息以及所述事件类型判断所述目标内核模块是否有权限访问所述K-SPACE中的内核数据。The VMM determines, according to the preset authority determination policy, the virtual address distribution information, and the event type, whether the target kernel module has permission to access kernel data in the K-SPACE.
结合本发明实施例第一方面或第一方面第一种可能的实现方式,在本发明实施例第一方面第二种可能的实现方式中,所述VMM捕获页表中断事件之前,所述方法还包括:With reference to the first aspect of the embodiments of the present invention or the first possible implementation manner of the first aspect, in a second possible implementation manner of the first aspect of the embodiments of the present disclosure, the method is configured before the VMM captures a page table interrupt event. Also includes:
所述VMM根据预存的所述虚拟机内核空间的空间页表将所述目标内核模 块的虚拟地址分布信息映射为物理地址分布信息,其中,所述目标内核模块为从所述虚拟机内核空间中插入的N个内核模块中选取的需要被隔离的内核模块,所述N为正整数;The VMM, according to the pre-stored space page table of the virtual machine kernel space, the target kernel module The virtual address distribution information of the block is mapped to physical address distribution information, wherein the target kernel module is a kernel module selected from N kernel modules inserted in the virtual machine kernel space and needs to be isolated, and the N is positive Integer
所述VMM基于所述物理地址分布信息分隔所述虚拟机内核空间为所述M-SPACE和所述K-SPACE;The VMM separates the virtual machine kernel space into the M-SPACE and the K-SPACE based on the physical address distribution information;
所述VMM标记所述虚拟机内核空间的空间页表为内核空间页表KPGT,并基于所述物理地址分布信息创建所述MPGT,其中,所述KPGT用于支持所述K-SPACE中的内核模块的运行,所述K-SPACE中的内核模块包括所述虚拟机内核空间中的基础内核模块和所述N个内核模块中除所述目标内核模块之外的内核模块The VMM marks a space page table of the virtual machine kernel space as a kernel space page table KPGT, and creates the MPGT based on the physical address distribution information, wherein the KPGT is used to support a kernel in the K-SPACE The operation of the module, the kernel module in the K-SPACE includes a base kernel module in the virtual machine kernel space and a kernel module other than the target kernel module among the N kernel modules
结合本发明实施例第一方面或第一方面第一种或第二种可能的实现方式,在本发明实施例第一方面第三种可能的实现方式中,所述MPGT中创建有所述目标内核模块对所述M-SPACE中的内核数据的访问权限映射,以使得所述目标内核模块有权限访问所述M-SPACE中的内核数据。With reference to the first aspect of the embodiment of the present invention or the first or second possible implementation manner of the first aspect, in a third possible implementation manner of the first aspect of the embodiment of the present invention, the target is created in the MPGT The kernel module maps access rights to the kernel data in the M-SPACE such that the target kernel module has access to the kernel data in the M-SPACE.
本发明实施例第二方面公开了一种VMM,包括:A second aspect of the embodiment of the present invention discloses a VMM, including:
事件捕获单元,用于捕获页表中断事件,所述页表中断事件是由CPU在检测到目标内核模块发送的针对内核空间K-SPACE中的内核数据的访问请求之后、且判断出隔离空间页表MPGT中未创建所述目标内核模块对所述K-SPACE中的内核数据的访问权限映射的情况下产生的,其中,所述VMM对应的虚拟机内核空间包括所述K-SPACE和隔离空间M-SPACE,所述M-SPACE包括所述目标内核模块和所述MPGT,所述MPGT用于支持所述目标内核模块的运行;An event capture unit, configured to capture a page table interrupt event, where the page table interrupt event is determined by the CPU after detecting an access request for kernel data in the kernel space K-SPACE sent by the target kernel module, and determining an isolated space page The file MPGT is generated without creating an access authority mapping of the target kernel module to the kernel data in the K-SPACE, wherein the virtual machine kernel space corresponding to the VMM includes the K-SPACE and the isolation space. M-SPACE, the M-SPACE includes the target kernel module and the MPGT, the MPGT is used to support operation of the target kernel module;
权限判断单元,用于通过预存的页表中断处理函数判断所述目标内核模块是否有权限访问所述K-SPACE中的内核数据;a permission determining unit, configured to determine, by using a pre-stored page table interrupt processing function, whether the target kernel module has permission to access kernel data in the K-SPACE;
权限创建单元,用于当所述权限判断单元通过预存的页表中断处理函数判断出所述目标内核模块有权限访问所述K-SPACE中的内核数据时,在所述MPGT中创建所述目标内核模块对所述K-SPACE中的内核数据的访问权限映射,以使得所述目标内核模块有权限访问所述K-SPACE中的内核数据。a permission creation unit, configured to create the target in the MPGT when the permission determination unit determines that the target kernel module has permission to access kernel data in the K-SPACE through a pre-stored page table interrupt processing function The kernel module maps access rights to the kernel data in the K-SPACE such that the target kernel module has access to the kernel data in the K-SPACE.
本发明实施例第二方面第一种可能的实现方式中,所述权限判断单元具体 用于:In the first possible implementation manner of the second aspect of the embodiment of the present invention, the authority determining unit is specific Used for:
通过预存的页表中断函数获取所述页表中断事件对应的预设权限判断策略,并获取所述K-SPACE中的内核数据的虚拟地址分布信息;Acquiring a preset permission judgment policy corresponding to the page table interrupt event by using a pre-stored page table interrupt function, and acquiring virtual address distribution information of the kernel data in the K-SPACE;
确定所述页表中断事件的事件类型;Determining the type of event of the page table interrupt event;
根据所述预设权限判断策略、所述虚拟地址分布信息以及所述事件类型判断所述目标内核模块是否有权限访问所述K-SPACE中的内核数据。Determining, according to the preset authority determination policy, the virtual address distribution information, and the event type, whether the target kernel module has permission to access kernel data in the K-SPACE.
结合本发明实施例第二方面或第二方面第一种可能的实现方式中,在本发明实施例第二方面第二种可能的实现方式中,所述VMM还包括:With reference to the second aspect of the embodiment of the present invention or the first possible implementation manner of the second aspect, in the second possible implementation manner of the second aspect of the embodiment, the VMM further includes:
地址映射单元,用于在所述事件捕获单元捕获页表中断事件之前之前,根据预存的所述虚拟机内核空间的空间页表将所述目标内核模块的虚拟地址分布信息映射为物理地址分布信息,其中,所述目标内核模块为从所述虚拟机内核空间中插入的N个内核模块中选取的需要被隔离的内核模块,所述N为正整数;An address mapping unit, configured to map virtual address distribution information of the target kernel module to physical address distribution information according to a pre-stored space page table of the virtual machine kernel space before the event capture unit captures a page table interrupt event The target kernel module is a kernel module selected from N kernel modules inserted in the virtual machine kernel space, and the N is a positive integer;
空间分隔单元,用于基于所述物理地址分布信息分隔所述虚拟机内核空间为所述M-SPACE和所述K-SPACE;a space separating unit, configured to separate the virtual machine kernel space into the M-SPACE and the K-SPACE based on the physical address distribution information;
页表创建单元,用于标记所述虚拟机内核空间的空间页表为内核空间页表KPGT,并基于所述物理地址分布信息创建所述MPGT,其中,所述KPGT用于支持所述K-SPACE中的内核模块的运行,所述K-SPACE中的内核模块包括所述虚拟机内核空间中的基础内核模块和所述N个内核模块中除所述目标内核模块之外的内核模块。a page table creation unit, configured to mark a space page table of the virtual machine kernel space as a kernel space page table KPGT, and create the MPGT based on the physical address distribution information, wherein the KPGT is used to support the K- The kernel module in the SPACE includes a base kernel module in the virtual machine kernel space and a kernel module other than the target kernel module among the N kernel modules.
结合本发明实施例第二方面或第二方面第一种或第二种可能的实现方式中,在本发明实施例第二方面第三种可能的实现方式中,所述MPGT中创建有所述目标内核模块对所述M-SPACE中的内核数据的访问权限映射,以使得所述目标内核模块有权限访问所述M-SPACE中的内核数据。With reference to the second aspect of the embodiment of the present invention or the first or second possible implementation manner of the second aspect, in a third possible implementation manner of the second aspect of the embodiment of the present invention, the MPGT is created in the MPGT. The target kernel module maps access rights to the kernel data in the M-SPACE such that the target kernel module has access to the kernel data in the M-SPACE.
本发明实施例中,VMM首先捕获页表中断事件,其次,VMM通过预存的页表中断处理函数判断目标内核模块是否有权限访问K-SPACE中的内核数据,最后,当VMM通过预存的页表中断处理函数判断出目标内核模块有权限访问K-SPACE中的内核数据时,VMM在MPGT中创建目标内核模块对K-SPACE中 的内核数据的访问权限映射,以使得目标内核模块有权限访问K-SPACE中的内核数据。由于上述页表中断事件是CPU在检测到目标内核模块发送的针对内核空间K-SPACE中的内核数据的访问请求之后、且判断出隔离空间页表MPGT中未创建目标内核模块对所述K-SPACE中的内核数据的访问权限映射的情况下产生的,可见,目标内核模块无权限直接访问K-SPACE空间中内核数据,从而能够避免目标内核模块在安全性未知的情况下肆意访问K-SPACE中的内核数据,有利于提升系统内核数据访问的安全性。In the embodiment of the present invention, the VMM first captures the page table interrupt event, and secondly, the VMM determines whether the target kernel module has access to the kernel data in the K-SPACE through the pre-stored page table interrupt processing function, and finally, when the VMM passes the pre-stored page table. When the interrupt handler determines that the target kernel module has access to the kernel data in K-SPACE, the VMM creates the target kernel module in the MPGT for K-SPACE. The access rights mapping of the kernel data is such that the target kernel module has access to the kernel data in the K-SPACE. Since the above page table interrupt event is that the CPU detects the access request for the kernel data in the kernel space K-SPACE sent by the target kernel module, and determines that the target kernel module is not created in the isolated space page table MPGT, the K- In the case of the access rights mapping of kernel data in SPACE, it can be seen that the target kernel module has no permission to directly access the kernel data in the K-SPACE space, thereby avoiding the target kernel module from accessing K-SPACE without security. The kernel data in the kernel helps to improve the security of system kernel data access.
同时,由于VMM相对于虚拟机操作系统拥有更高的运行权限,故而在虚拟化环境下,具备更高特权级VMM在执行权限上与虚拟机之间相互隔离,不会受到虚拟机的直接攻击。At the same time, because the VMM has higher running rights than the virtual machine operating system, in the virtualized environment, the VMM with higher privilege level is isolated from the virtual machine in execution permission, and is not directly attacked by the virtual machine. .
同时,由于VMM具有客户机平台无关性,可以同时对多个不同类型的客户操作系统的内核模块进行隔离。At the same time, because VMM has client platform independence, it can isolate kernel modules of several different types of guest operating systems at the same time.
本发明实施例第三方面公开了一种代码调用方法,包括:A third aspect of the embodiment of the present invention discloses a code calling method, including:
虚拟机监视器VMM捕获页表中断事件,所述页表中断事件是由中央处理单元CPU在检测到目标内核模块针对内核空间K-SPACE中的内核代码的调用请求之后、且判断出隔离空间页表MPGT中未创建所述目标内核模块对所述K-SPACE中的内核代码的调用权限映射的情况下生成的,其中,所述VMM对应的虚拟机内核空间包括所述K-SPACE和隔离空间M-SPACE,所述M-SPACE包括所述目标内核模块和所述MPGT,所述MPGT用于支持所述目标内核模块的运行;The virtual machine monitor VMM captures a page table interrupt event, which is determined by the central processing unit CPU after detecting the target kernel module's call request for the kernel code in the kernel space K-SPACE, and determines the isolated space page The table MPGT is generated without creating the call permission mapping of the target kernel module to the kernel code in the K-SPACE, wherein the virtual machine kernel space corresponding to the VMM includes the K-SPACE and the isolation space. M-SPACE, the M-SPACE includes the target kernel module and the MPGT, the MPGT is used to support operation of the target kernel module;
所述VMM通过预存的页表中断处理函数判断所述目标内核模块是否有权限调用所述K-SPACE中的内核代码;The VMM determines, by using a pre-stored page table interrupt processing function, whether the target kernel module has permission to invoke the kernel code in the K-SPACE;
当所述VMM通过预存的页表中断处理函数判断出所述目标内核模块有权限调用所述K-SPACE中的内核代码时,所述VMM根据所述目标内核模块对所述K-SPACE中的内核代码的调用权限映射,执行页表切换操作和堆栈切换操作以将所述虚拟机内核空间的堆栈由隔离空间堆栈M-STACK切换为内核空间堆栈K-STACK,以使得所述目标内核模块基于切换后的所述K-STACK调用所述K-SPACE中的内核代码。 When the VMM determines, by the pre-stored page table interrupt processing function, that the target kernel module has permission to invoke the kernel code in the K-SPACE, the VMM is configured according to the target kernel module in the K-SPACE a call permission mapping of kernel code, performing a page table switching operation and a stack switching operation to switch the stack of the virtual machine kernel space from the isolated space stack M-STACK to a kernel space stack K-STACK, such that the target kernel module is based on The switched K-STACK calls the kernel code in the K-SPACE.
本发明实施例第三方面第一种可能的实现方式中,所述VMM通过预存的页表中断处理函数判断所述目标内核模块是否有权限调用所述K-SPACE中的内核代码,包括:In a first possible implementation manner of the third aspect of the embodiment of the present invention, the VMM determines, by using a pre-stored page table interrupt processing function, whether the target kernel module has permission to invoke the kernel code in the K-SPACE, including:
所述VMM通过预存的页表中断函数获取所述页表中断事件对应的预设权限判断策略,并获取所述K-SPACE中的内核代码的虚拟地址分布信息;The VMM obtains a preset permission judgment policy corresponding to the page table interrupt event by using a pre-stored page table interrupt function, and acquires virtual address distribution information of the kernel code in the K-SPACE;
所述VMM根据获取的所述预设权限判断策略和所述虚拟地址分布信息判断所述目标内核模块是否有权限访问所述K-SPACE中的内核代码。The VMM determines, according to the obtained preset permission judgment policy and the virtual address distribution information, whether the target kernel module has permission to access the kernel code in the K-SPACE.
结合本发明实施例第三方面或第三方面第一种可能的实现方式,在本发明实施例第三方面第二种可能的实现方式中,所述VMM执行页表页表切换操作,包括:With reference to the third aspect of the embodiment of the present invention or the first possible implementation manner of the third aspect, in a second possible implementation manner of the third aspect of the embodiment, the VMM performs a page table page table switching operation, including:
所述VMM将所述VMM当前加载的页表由所述MPGT切换为内核空间页表KPGT,其中,所述KPGT用于支持所述K-SPACE中的内核模块的运行,所述K-SPACE中包括所述虚拟机内核空间中的基础内核模块、所述虚拟机内核空间中插入的N个内核模块中除所述目标内核模块之外的内核模块以及所述KPGT,所述N为大于1的正整数。The VMM switches the page table currently loaded by the VMM from the MPGT to a kernel space page table KPGT, wherein the KPGT is used to support operation of a kernel module in the K-SPACE, in the K-SPACE And including the basic kernel module in the virtual machine kernel space, a kernel module other than the target kernel module among the N kernel modules inserted in the virtual machine kernel space, and the KPGT, where the N is greater than 1. A positive integer.
结合本发明实施例第三方面或第三方面第一种或第二种可能的实现方式,在本发明实施例第三方面第三种可能的实现方式中,所述VMM执行堆栈切换操作,包括:With reference to the third aspect of the embodiment of the present invention or the first or second possible implementation manner of the third aspect, in a third possible implementation manner of the third aspect of the embodiment of the present invention, the VMM performs a stack switching operation, including :
所述VMM拷贝M-STACK中存储的用于传递所述K-SPACE中的内核代码的代码参数和用于调用所述K-SPACE中的内核代码的返回地址RIP;The VMM copies the code parameters stored in the M-STACK for transferring the kernel code in the K-SPACE and the return address RIP for calling the kernel code in the K-SPACE;
所述VMM在所述K-STACK中写入所述代码参数和所述RIP;Writing, by the VMM, the code parameter and the RIP in the K-STACK;
所述VMM将所述虚拟机内核空间当前使用的堆栈由esp-old位置转变为esp-new位置,其中,所述esp-old位置为所述RIP在所述M-STACK中的存储位置,所述esp-new位置为所述RIP在所述K-STACK中的存储位置。The VMM converts a stack currently used by the virtual machine kernel space from an esp-old location to an esp-new location, where the esp-old location is a storage location of the RIP in the M-STACK, The esp-new location is the storage location of the RIP in the K-STACK.
结合本发明实施例第三方面或第三方面第一种或第二种或第三种可能的实现方式,在本发明实施例第三方面第四种可能的实现方式中,所述VMM捕获页表中断事件之前,所述方法还包括:With reference to the third aspect of the embodiment of the present invention or the first or second or the third possible implementation manner of the third aspect, in the fourth possible implementation manner of the third aspect of the embodiment of the present invention, the VMM capture page Before the table interrupt event, the method further includes:
所述VMM根据预存的所述虚拟机内核空间的空间页表将目标内核模块的 虚拟地址分布信息映射为物理地址分布信息,其中,所述目标内核模块为从所述虚拟机内核空间中插入的N个内核模块中选取的需要被隔离的内核模块,所述N为大于1的正整数;The VMM sets the target kernel module according to the pre-stored space page table of the virtual machine kernel space. The virtual address distribution information is mapped to physical address distribution information, wherein the target kernel module is a kernel module selected from N kernel modules inserted in the virtual machine kernel space and needs to be isolated, and the N is greater than 1. Positive integer
所述VMM基于所述物理地址分布信息分隔所述虚拟机内核空间为所述M-SPACE和所述K-SPACE;The VMM separates the virtual machine kernel space into the M-SPACE and the K-SPACE based on the physical address distribution information;
所述VMM标记所述虚拟机内核空间的空间页表为内核空间页表KPGT,并基于所述物理地址分布信息创建所述MPGT。The VMM marks the space page table of the virtual machine kernel space as a kernel space page table KPGT, and creates the MPGT based on the physical address distribution information.
结合本发明实施例第三方面或第三方面第一种或第二种或第三种或第四种可能的实现方式,在本发明实施例第三方面第五种可能的实现方式中,所述MPGT中创建有所述目标内核模块对所述M-SPACE中的内核代码的调用权限映射,以使得所述目标内核模块有权限调用所述M-SPACE中的内核代码。With reference to the third aspect of the embodiment of the present invention or the first or second or the third or the fourth possible implementation manner of the third aspect, in the fifth possible implementation manner of the third aspect of the embodiment of the present invention, The calling privilege mapping of the target kernel module to the kernel code in the M-SPACE is created in the MPGT, so that the target kernel module has permission to invoke the kernel code in the M-SPACE.
本发明实施例第四方面公开了一种VMM,包括:A fourth aspect of the embodiment of the present invention discloses a VMM, including:
事件捕获单元,用于捕获页表中断事件,所述页表中断事件是由中央处理单元CPU在检测到目标内核模块针对内核空间K-SPACE中的内核代码的调用请求之后、且判断出隔离空间页表MPGT中未创建所述目标内核模块对所述K-SPACE中的内核代码的调用权限映射的情况下生成的,其中,所述VMM对应的虚拟机内核空间包括所述K-SPACE和隔离空间M-SPACE,所述M-SPACE包括所述目标内核模块和所述MPGT,所述MPGT用于支持所述目标内核模块的运行;An event capture unit, configured to capture a page table interrupt event, wherein the page table interrupt event is determined by the central processing unit CPU after detecting a call request of the target kernel module for kernel code in the kernel space K-SPACE The page table MPGT is generated without creating a call permission mapping of the target kernel module to the kernel code in the K-SPACE, wherein the virtual machine kernel space corresponding to the VMM includes the K-SPACE and isolation a space M-SPACE, the M-SPACE including the target kernel module and the MPGT, the MPGT being used to support operation of the target kernel module;
权限判断单元,用于通过预存的页表中断处理函数判断所述目标内核模块是否有权限调用所述K-SPACE中的内核代码;a permission determining unit, configured to determine, by using a pre-stored page table interrupt processing function, whether the target kernel module has permission to invoke the kernel code in the K-SPACE;
切换单元,用于当所述权限判断单元通过预存的页表中断处理函数判断出所述目标内核模块有权限调用所述K-SPACE中的内核代码时,根据所述目标内核模块对所述K-SPACE中的内核代码的调用权限映射,执行页表切换操作和堆栈切换操作以将所述虚拟机内核空间的堆栈由隔离空间堆栈M-STACK切换为内核空间堆栈K-STACK,以使得所述目标内核模块基于切换后的所述K-STACK调用所述K-SPACE中的内核代码。a switching unit, configured to: when the authority determining unit determines, by using a pre-stored page table interrupt processing function, that the target kernel module has permission to invoke the kernel code in the K-SPACE, according to the target kernel module, the K a call permission mapping of kernel code in -SPACE, performing a page table switching operation and a stack switching operation to switch the stack of the virtual machine kernel space from the isolated space stack M-STACK to a kernel space stack K-STACK, such that The target kernel module calls the kernel code in the K-SPACE based on the K-STACK after the handover.
本发明实施例第四方面第一种可能的实现方式中,所述权限判断单元具体 用于:In the first possible implementation manner of the fourth aspect of the embodiment of the present invention, the authority determining unit is specific Used for:
通过预存的页表中断函数获取所述页表中断事件对应的预设权限判断策略,并获取所述K-SPACE中的内核代码的虚拟地址分布信息;Acquiring a preset permission judgment policy corresponding to the page table interrupt event by using a pre-stored page table interrupt function, and acquiring virtual address distribution information of the kernel code in the K-SPACE;
根据获取的所述预设权限判断策略和所述虚拟地址分布信息判断所述目标内核模块是否有权限访问所述K-SPACE中的内核代码。Determining, according to the obtained preset permission judgment policy and the virtual address distribution information, whether the target kernel module has permission to access the kernel code in the K-SPACE.
结合本发明实施例第四方面或第四方面第一种可能的实现方式,在本发明实施例第四方面第二种可能的实现方式中,所述切换单元具体用于:With reference to the fourth aspect of the embodiments of the present invention or the first possible implementation manner of the fourth aspect, in the second possible implementation manner of the fourth aspect of the embodiments of the present disclosure, the switching unit is specifically configured to:
将所述VMM当前加载的页表由所述MPGT切换为内核空间页表KPGT,其中,所述KPGT用于支持所述K-SPACE中的内核模块的运行,所述K-SPACE中包括所述虚拟机内核空间中的基础内核模块、所述虚拟机内核空间中插入的N个内核模块中除所述目标内核模块之外的内核模块以及所述KPGT,所述N为大于1的正整数。Converting a page table currently loaded by the VMM from the MPGT to a kernel space page table KPGT, wherein the KPGT is configured to support operation of a kernel module in the K-SPACE, the K-SPACE including the The base kernel module in the virtual machine kernel space, the kernel module other than the target kernel module among the N kernel modules inserted in the virtual machine kernel space, and the KPGT, the N is a positive integer greater than 1.
结合本发明实施例第四方面或第四方面第一种或第二种可能的实现方式,在本发明实施例第四方面第三种可能的实现方式中,所述切换单元具体用于:With reference to the fourth aspect of the embodiment of the present invention or the first or second possible implementation manner of the fourth aspect, in a third possible implementation manner of the fourth aspect of the embodiment, the switching unit is specifically configured to:
拷贝M-STACK中存储的用于传递所述K-SPACE中的内核代码的代码参数和用于调用所述K-SPACE中的内核代码的返回地址RIP;Copying a code parameter stored in the M-STACK for transferring the kernel code in the K-SPACE and a return address RIP for calling the kernel code in the K-SPACE;
在所述K-STACK中写入所述代码参数和所述RIP;Writing the code parameter and the RIP in the K-STACK;
将所述虚拟机内核空间当前使用的堆栈由esp-old位置转变为esp-new位置,其中,所述esp-old位置为所述RIP在所述M-STACK中的存储位置,所述esp-new位置为所述RIP在所述K-STACK中的存储位置。Converting the stack currently used by the virtual machine kernel space from an esp-old location to an esp-new location, wherein the esp-old location is a storage location of the RIP in the M-STACK, the esp- The new location is the storage location of the RIP in the K-STACK.
结合本发明实施例第四方面或第四方面第一种或第二种或第三种可能的实现方式,在本发明实施例第四方面第四种可能的实现方式中,所述VMM还包括:With reference to the fourth aspect of the embodiment of the present invention or the first or second or the third possible implementation manner of the fourth aspect, in a fourth possible implementation manner of the fourth aspect of the embodiments of the present invention, the VMM further includes :
地址映射单元,用于在所述事件捕获单元捕获页表中断事件之前,根据预存的所述虚拟机内核空间的空间页表将目标内核模块的虚拟地址分布信息映射为物理地址分布信息,其中,所述目标内核模块为从所述虚拟机内核空间中插入的N个内核模块中选取的需要被隔离的内核模块,所述N为大于1的正整数; An address mapping unit, configured to: before the event capture unit captures the page table interrupt event, map the virtual address distribution information of the target kernel module to the physical address distribution information according to the pre-stored space page table of the virtual machine kernel space, where The target kernel module is a kernel module selected from N kernel modules inserted in the virtual machine kernel space, and the N is a positive integer greater than 1.
空间分隔单元,用于基于所述物理地址分布信息分隔所述虚拟机内核空间为所述M-SPACE和所述K-SPACE;a space separating unit, configured to separate the virtual machine kernel space into the M-SPACE and the K-SPACE based on the physical address distribution information;
页表创建单元,用于标记所述虚拟机内核空间的空间页表为内核空间页表KPGT,并基于所述物理地址分布信息创建所述MPGT。a page table creation unit that marks a space page table of the virtual machine kernel space as a kernel space page table KPGT, and creates the MPGT based on the physical address distribution information.
结合本发明实施例第四方面或第四方面第一种或第二种或第三种或第四种可能的实现方式,在本发明实施例第四方面第五种可能的实现方式中,所述MPGT中创建有所述目标内核模块对所述M-SPACE中的内核代码的调用权限映射,以使得所述目标内核模块有权限调用所述M-SPACE中的内核代码。With reference to the fourth aspect or the fourth or fourth or the third or the fourth possible implementation manner of the fourth embodiment, the fifth possible implementation manner of the fourth aspect of the embodiment of the present invention The calling privilege mapping of the target kernel module to the kernel code in the M-SPACE is created in the MPGT, so that the target kernel module has permission to invoke the kernel code in the M-SPACE.
本发明实施例中,VMM首先捕获页表中断事件,其次,当VMM通过预存的页表中断处理函数判断出目标内核模块有权限调用K-SPACE中的内核代码时,VMM根据目标内核模块对K-SPACE中的内核代码的调用权限映射,执行页表切换操作和堆栈切换操作以将虚拟机内核空间的堆栈由隔离空间堆栈M-STACK切换为内核空间堆栈K-STACK,以使得所述目标内核模块基于切换后的所述K-STACK调用所述K-SPACE中的内核代码。其中,上述页表中断事件是CPU在检测到目标内核模块针对内核空间K-SPACE中的内核代码的调用请求之后、且判断出隔离空间页表MPGT中未创建目标内核模块对K-SPACE中的内核代码的调用权限映射的情况下生成的,可见,目标内核模块无权限直接调用内核代码,能够避免目标内核模块在安全性未知的情况下肆意调用K-SPACE中的内核代码,有利于提升系统内核代码调用的安全性。In the embodiment of the present invention, the VMM first captures the page table interrupt event, and secondly, when the VMM determines that the target kernel module has permission to invoke the kernel code in the K-SPACE through the pre-stored page table interrupt processing function, the VMM is based on the target kernel module pair K. Calling permission mapping of kernel code in -SPACE, performing page table switching operation and stack switching operation to switch stack of virtual machine kernel space from isolation space stack M-STACK to kernel space stack K-STACK, so that the target kernel The module calls the kernel code in the K-SPACE based on the K-STACK after switching. The page table interrupt event is that after the CPU detects the call request of the target kernel module for the kernel code in the kernel space K-SPACE, and determines that the target kernel module is not created in the isolated space page table MPGT in the K-SPACE The kernel code is generated by the call permission mapping. It can be seen that the target kernel module has no permission to directly call the kernel code, which can avoid the target kernel module inadvertently calling the kernel code in K-SPACE if the security is unknown, which is beneficial to the system. The security of the kernel code call.
同时,由于VMM相对于虚拟机操作系统拥有更高的运行权限,故而在虚拟化环境下,具备更高特权级VMM在执行权限上与虚拟机之间相互隔离,不会受到虚拟机的直接攻击。At the same time, because the VMM has higher running rights than the virtual machine operating system, in the virtualized environment, the VMM with higher privilege level is isolated from the virtual machine in execution permission, and is not directly attacked by the virtual machine. .
同时,由于VMM具有客户机平台无关性,可以同时对多个不同类型的客户操作系统的内核模块进行隔离。At the same time, because VMM has client platform independence, it can isolate kernel modules of several different types of guest operating systems at the same time.
附图说明DRAWINGS
为了更清楚地说明本发明实施例中的技术方案,下面将对实施例描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本发明 的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他的附图。In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the drawings used in the description of the embodiments will be briefly described below. It is obvious that the drawings in the following description are merely the present invention. Some of the embodiments can be obtained by those of ordinary skill in the art in view of the drawings without any inventive effort.
图1.1是本发明实施例公开的一种典型裸机模式虚拟化平台部署架构图;FIG. 1.1 is a schematic structural diagram of a typical bare metal mode virtualization platform deployment according to an embodiment of the present invention;
图1.2是本发明实施例公开的一种典型宿主模式虚拟化平台部署架构图;FIG. 1.2 is a schematic structural diagram of a typical host mode virtualization platform deployed according to an embodiment of the present invention;
图2是本发明实施例公开的一种数据访问方法的流程示意图;2 is a schematic flowchart of a data access method according to an embodiment of the present invention;
图3是本发明实施例公开的另一种数据访问方法的流程示意图;3 is a schematic flowchart diagram of another data access method according to an embodiment of the present invention;
图4是本发明实施例公开的有一种数据访问方法的流程示意图;4 is a schematic flowchart of a data access method according to an embodiment of the present invention;
图5是本发明实施例公开的一种代码调用方法的流程示意图;FIG. 5 is a schematic flowchart diagram of a code calling method according to an embodiment of the present invention; FIG.
图6是本发明实施例公开的另一种代码调用方法的流程示意图;6 is a schematic flowchart diagram of another code calling method disclosed in an embodiment of the present invention;
图7是本发明实施例公开的又一种代码调用方法的流程示意图;FIG. 7 is a schematic flowchart diagram of still another code calling method according to an embodiment of the present invention; FIG.
图8是本发明实施例公开的一种用于控制M-SPACE中的目标内核模块对K-SPACE中的内核数据的访问的VMM的结构示意图;FIG. 8 is a schematic structural diagram of a VMM for controlling access to kernel data in a K-SPACE by a target kernel module in an M-SPACE according to an embodiment of the present invention; FIG.
图9是本发明实施例公开的一种用于控制M-SPACE中的目标内核模块对K-SPACE中的内核代码的调用VMM的结构示意图;9 is a schematic structural diagram of a VMM for controlling a kernel code in a K-SPACE by a target kernel module in an M-SPACE according to an embodiment of the present invention;
图10是本发明实施例公开的一种VMM的实体装置结构示意图;10 is a schematic structural diagram of a physical device of a VMM according to an embodiment of the present invention;
图11是本发明实施例公开的一种VMM的实体装置结构示意图。FIG. 11 is a schematic structural diagram of a physical device of a VMM according to an embodiment of the present invention.
具体实施方式detailed description
下面将结合本发明实施例中的附图,对本发明实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例仅仅是本发明一部分的实施例,而不是全部的实施例。基于本发明中的实施例,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其他实施例,都应当属于本发明保护的范围。The technical solutions in the embodiments of the present invention are clearly and completely described in the following with reference to the accompanying drawings in the embodiments of the present invention. It is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments obtained by those skilled in the art based on the embodiments of the present invention without creative efforts shall fall within the scope of the present invention.
本发明实施例提供一种数据访问方法、代码调用方法及虚拟机监视器(Virtual Machine Monitor,VMM),以期提升系统内核数据访问和代码调用的安全性。The embodiment of the invention provides a data access method, a code calling method and a virtual machine monitor (VMM), so as to improve the security of the system kernel data access and code call.
为了便于理解本发明实施例,下面先对本发明实施例的网络架构进行描述。请参阅图1.1和图1.2,图1.1是本发明实施例公开的一种典型裸机模式虚拟化平台部署架构图,图1.2是本发明实施例公开的一种典型宿主模式虚拟化平 台部署架构图。如图1.1和图1.2所示,两种模式中的虚拟机操作系统都运行在VMM之上,VMM拥有比虚拟机操作系统更高的执行权限,且两者之间相互隔离。虚拟机操作系统内核可以进一步划分为代码部分、数据部分、内核运行所需堆栈以及动态可加载的内核模块。附图1.1所示的典型的裸机虚拟化模式(比如Xen)中,VMM直接运行在物理机之上,操作物理硬件,向上对虚拟机提供服务。附图1.2所示的典型宿主模式(比如KVM)中,VMM运行在宿主机操作系统之上,其虚拟化功能需要借助于宿主机实现,宿主机直接控制下层硬件资源。In order to facilitate the understanding of the embodiments of the present invention, the network architecture of the embodiment of the present invention is described below. Referring to FIG. 1.1 and FIG. 1.2, FIG. 1.1 is a schematic diagram of a typical bare-machine mode virtualization platform deployment architecture disclosed in the embodiment of the present invention, and FIG. 1.2 is a typical host mode virtualization flat disclosed in the embodiment of the present invention. Platform deployment architecture diagram. As shown in Figure 1.1 and Figure 1.2, the virtual machine operating systems in both modes run on the VMM. The VMM has higher execution privileges than the virtual machine operating system, and the two are isolated from each other. The virtual machine operating system kernel can be further divided into code parts, data parts, stacks required for kernel operations, and dynamically loadable kernel modules. In the typical bare metal virtualization mode (such as Xen) shown in Figure 1.1, the VMM runs directly on the physical machine, operates on physical hardware, and provides services to the virtual machine upwards. In the typical host mode (such as KVM) shown in Figure 1.2, the VMM runs on the host operating system, and its virtualization function needs to be implemented by means of the host. The host directly controls the underlying hardware resources.
参阅图2,图2是本发明实施例公开的一种数据访问方法的流程示意图,如图2所示,该数据访问方法是从VMM单侧进行描述的,具体包括以下步骤:Referring to FIG. 2, FIG. 2 is a schematic flowchart of a data access method according to an embodiment of the present invention. As shown in FIG. 2, the data access method is described from one side of the VMM, and specifically includes the following steps:
S201,VMM捕获页表中断事件,所述页表中断事件是由CPU在检测到目标内核模块发送的针对内核空间K-SPACE中的内核数据的访问请求之后、且判断出隔离空间页表MPGT中未创建所述目标内核模块对所述K-SPACE中的内核数据的访问权限映射的情况下产生的,其中,所述VMM对应的虚拟机内核空间包括所述K-SPACE和隔离空间M-SPACE,所述M-SPACE包括所述目标内核模块和所述MPGT,所述MPGT用于支持所述目标内核模块的运行;S201, the VMM captures a page table interrupt event, where the page table interrupt event is determined by the CPU after detecting the access request for the kernel data in the kernel space K-SPACE sent by the target kernel module, and determining the isolation space page table MPGT The target kernel module is not created with the access authority mapping of the kernel data in the K-SPACE, wherein the virtual machine kernel space corresponding to the VMM includes the K-SPACE and the isolation space M-SPACE The M-SPACE includes the target kernel module and the MPGT, and the MPGT is configured to support operation of the target kernel module;
本发明实施例中,上述MPGT中创建有所述目标内核模块对所述M-SPACE中的内核数据的访问权限映射,以使得所述目标内核模块有权限访问所述M-SPACE中的内核数据。In the embodiment of the present invention, the access authority mapping of the target kernel module to the kernel data in the M-SPACE is created in the MPGT, so that the target kernel module has the right to access the kernel data in the M-SPACE. .
S202,所述VMM通过预存的页表中断处理函数判断所述目标内核模块是否有权限访问所述K-SPACE中的内核数据;S202. The VMM determines, by using a pre-stored page table interrupt processing function, whether the target kernel module has permission to access kernel data in the K-SPACE.
本发明实施例中,上述VMM通过预存的页表中断处理函数判断所述目标内核模块是否有权限访问所述K-SPACE中的内核数据的具体方式为:In the embodiment of the present invention, the specific manner in which the VMM determines whether the target kernel module has the right to access the kernel data in the K-SPACE through the pre-stored page table interrupt processing function is:
所述VMM首先通过预存的页表中断函数获取所述页表中断事件对应的预设权限判断策略,并获取所述K-SPACE中的内核数据的虚拟地址分布信息;其次,VMM确定所述页表中断事件的事件类型;最后,VMM根据所述预设权限判断策略、所述虚拟地址分布信息以及所述事件类型判断所述目标内核模块是否有权限访问所述K-SPACE中的内核数据。 The VMM first acquires a preset permission judgment policy corresponding to the page table interrupt event by using a pre-stored page table interrupt function, and acquires virtual address distribution information of the kernel data in the K-SPACE; secondly, the VMM determines the page. The event type of the table interrupt event; finally, the VMM determines, according to the preset authority judgment policy, the virtual address distribution information, and the event type, whether the target kernel module has permission to access kernel data in the K-SPACE.
S203,当所述VMM通过预存的页表中断处理函数判断出所述目标内核模块有权限访问所述K-SPACE中的内核数据时,所述VMM在所述MPGT中创建所述目标内核模块对所述K-SPACE中的内核数据的访问权限映射,以使得所述目标内核模块有权限访问所述K-SPACE中的内核数据。S203. When the VMM determines, by using a pre-stored page table interrupt processing function, that the target kernel module has permission to access kernel data in the K-SPACE, the VMM creates the target kernel module pair in the MPGT. The access rights mapping of the kernel data in the K-SPACE is such that the target kernel module has access to the kernel data in the K-SPACE.
可以看出,本发明实施例中,VMM首先捕获页表中断事件,其次,VMM通过预存的页表中断处理函数判断目标内核模块是否有权限访问K-SPACE中的内核数据,最后,当VMM通过预存的页表中断处理函数判断出目标内核模块有权限访问K-SPACE中的内核数据时,VMM在MPGT中创建目标内核模块对K-SPACE中的内核数据的访问权限映射,以使得目标内核模块有权限访问K-SPACE中的内核数据。由于上述页表中断事件是CPU在检测到目标内核模块发送的针对内核空间K-SPACE中的内核数据的访问请求之后、且判断出隔离空间页表MPGT中未创建目标内核模块对所述K-SPACE中的内核数据的访问权限映射的情况下产生的,可见,目标内核模块无权限直接访问K-SPACE空间中内核数据,从而能够避免目标内核模块在安全性未知的情况下肆意访问K-SPACE中的内核数据,有利于提升系统内核数据访问的安全性。It can be seen that, in the embodiment of the present invention, the VMM first captures the page table interrupt event, and secondly, the VMM determines whether the target kernel module has access to the kernel data in the K-SPACE through the pre-stored page table interrupt processing function, and finally, when the VMM passes When the pre-stored page table interrupt processing function determines that the target kernel module has permission to access the kernel data in the K-SPACE, the VMM creates an access authority mapping of the target kernel module to the kernel data in the K-SPACE in the MPGT, so that the target kernel module Have access to kernel data in K-SPACE. Since the above page table interrupt event is that the CPU detects the access request for the kernel data in the kernel space K-SPACE sent by the target kernel module, and determines that the target kernel module is not created in the isolated space page table MPGT, the K- In the case of the access rights mapping of kernel data in SPACE, it can be seen that the target kernel module has no permission to directly access the kernel data in the K-SPACE space, thereby avoiding the target kernel module from accessing K-SPACE without security. The kernel data in the kernel helps to improve the security of system kernel data access.
同时,由于VMM相对于虚拟机操作系统拥有更高的运行权限,故而在虚拟化环境下,具备更高特权级VMM在执行权限上与虚拟机之间相互隔离,不会受到虚拟机的直接攻击。At the same time, because the VMM has higher running rights than the virtual machine operating system, in the virtualized environment, the VMM with higher privilege level is isolated from the virtual machine in execution permission, and is not directly attacked by the virtual machine. .
同时,由于VMM具有客户机平台无关性,可以同时对多个不同类型的客户操作系统的内核模块进行隔离。At the same time, because VMM has client platform independence, it can isolate kernel modules of several different types of guest operating systems at the same time.
可选的,本发明实施例中,上述VMM捕获页表中断事件之前,还可以执行以下操作以针对目标内核模块创建内核空间隔离机制:Optionally, in the embodiment of the present invention, before the VMM captures the page table interrupt event, the following operations may also be performed to create a kernel space isolation mechanism for the target kernel module:
所述VMM根据预存的所述虚拟机内核空间的空间页表将所述目标内核模块的虚拟地址分布信息映射为物理地址分布信息,其中,所述目标内核模块为从所述虚拟机内核空间中插入的N个内核模块中选取的需要被隔离的内核模块,所述N为正整数;The VMM maps virtual address distribution information of the target kernel module to physical address distribution information according to a pre-stored space page table of the virtual machine kernel space, where the target kernel module is from the virtual machine kernel space a kernel module selected to be isolated among the inserted N kernel modules, where N is a positive integer;
所述VMM基于所述物理地址分布信息分隔所述虚拟机内核空间为所述M-SPACE和所述K-SPACE; The VMM separates the virtual machine kernel space into the M-SPACE and the K-SPACE based on the physical address distribution information;
所述VMM标记所述虚拟机内核空间的空间页表为内核空间页表KPGT,并基于所述物理地址分布信息创建所述MPGT,其中,所述KPGT用于支持所述K-SPACE中的内核模块的运行,所述K-SPACE中的内核模块包括所述虚拟机内核空间中的基础内核模块和所述N个内核模块中除所述目标内核模块之外的内核模块。The VMM marks a space page table of the virtual machine kernel space as a kernel space page table KPGT, and creates the MPGT based on the physical address distribution information, wherein the KPGT is used to support a kernel in the K-SPACE The operation of the module, the kernel module in the K-SPACE includes a base kernel module in the virtual machine kernel space and a kernel module other than the target kernel module among the N kernel modules.
参阅图3,图3是本发明实施例公开的一种数据访问方法的流程示意图,如图3所示,该数据访问方法是从VMM单侧进行描述的,具体包括以下步骤:Referring to FIG. 3, FIG. 3 is a schematic flowchart of a data access method according to an embodiment of the present invention. As shown in FIG. 3, the data access method is described from one side of the VMM, and specifically includes the following steps:
S301,虚拟机监视器VMM捕获页表中断事件,所述页表中断事件是由中央处理单元CPU在检测到目标内核模块发送的针对内核空间K-SPACE中的内核数据的访问请求之后、且判断出隔离空间页表MPGT中未创建所述目标内核模块对所述K-SPACE中的内核数据的访问权限映射的情况下产生的,其中,所述VMM对应的虚拟机内核空间包括所述K-SPACE和隔离空间M-SPACE,所述M-SPACE包括所述目标内核模块和所述MPGT,所述MPGT用于支持所述目标内核模块的运行;S301, the virtual machine monitor VMM captures a page table interrupt event, and the page table interrupt event is determined by the central processing unit CPU after detecting the access request for the kernel data in the kernel space K-SPACE sent by the target kernel module. And generating, in the isolated space page table MPGT, the access authority mapping of the target kernel module to the kernel data in the K-SPACE, wherein the virtual machine kernel space corresponding to the VMM includes the K- SPACE and an isolated space M-SPACE, the M-SPACE including the target kernel module and the MPGT, the MPGT being used to support operation of the target kernel module;
本发明实施例中,上述MPGT中创建有所述目标内核模块对所述M-SPACE中的内核数据的访问权限映射,以使得所述目标内核模块有权限访问所述M-SPACE中的内核数据。In the embodiment of the present invention, the access authority mapping of the target kernel module to the kernel data in the M-SPACE is created in the MPGT, so that the target kernel module has the right to access the kernel data in the M-SPACE. .
S302,所述VMM通过预存的页表中断函数获取所述页表中断事件对应的预设权限判断策略,并获取所述K-SPACE中的内核数据的虚拟地址分布信息;S302, the VMM acquires a preset permission judgment policy corresponding to the page table interrupt event by using a pre-stored page table interrupt function, and acquires virtual address distribution information of the kernel data in the K-SPACE;
S303,所述VMM确定所述页表中断事件的事件类型;S303. The VMM determines an event type of the page table interrupt event.
S304,所述VMM根据所述预设权限判断策略、所述虚拟地址分布信息以及所述事件类型判断所述目标内核模块是否有权限访问所述K-SPACE中的内核数据;S304. The VMM determines, according to the preset permission determination policy, the virtual address distribution information, and the event type, whether the target kernel module has permission to access kernel data in the K-SPACE.
S305,当所述VMM通过预存的页表中断处理函数判断出所述目标内核模块有权限访问所述K-SPACE中的内核数据时,所述VMM在所述MPGT中创建所述目标内核模块对所述K-SPACE中的内核数据的访问权限映射,以使得所述目标内核模块有权限访问所述K-SPACE中的内核数据。S305. When the VMM determines, by using a pre-stored page table interrupt processing function, that the target kernel module has permission to access kernel data in the K-SPACE, the VMM creates the target kernel module pair in the MPGT. The access rights mapping of the kernel data in the K-SPACE is such that the target kernel module has access to the kernel data in the K-SPACE.
可以看出,本发明实施例中,VMM首先捕获页表中断事件,其次,VMM 通过预存的页表中断处理函数判断目标内核模块是否有权限访问K-SPACE中的内核数据,最后,当VMM通过预存的页表中断处理函数判断出目标内核模块有权限访问K-SPACE中的内核数据时,VMM在MPGT中创建目标内核模块对K-SPACE中的内核数据的访问权限映射,以使得目标内核模块有权限访问K-SPACE中的内核数据。由于上述页表中断事件是CPU在检测到目标内核模块发送的针对内核空间K-SPACE中的内核数据的访问请求之后、且判断出隔离空间页表MPGT中未创建目标内核模块对所述K-SPACE中的内核数据的访问权限映射的情况下产生的,可见,目标内核模块无权限直接访问K-SPACE空间中内核数据,从而能够避免目标内核模块在安全性未知的情况下肆意访问K-SPACE中的内核数据,有利于提升系统内核数据访问的安全性。It can be seen that in the embodiment of the present invention, the VMM first captures the page table interrupt event, and secondly, the VMM The pre-stored page table interrupt processing function determines whether the target kernel module has permission to access the kernel data in K-SPACE. Finally, when the VMM uses the pre-stored page table interrupt processing function to determine that the target kernel module has permission to access the kernel in K-SPACE. In the case of data, the VMM creates an access authority mapping of the target kernel module to the kernel data in the K-SPACE in the MPGT, so that the target kernel module has access to the kernel data in the K-SPACE. Since the above page table interrupt event is that the CPU detects the access request for the kernel data in the kernel space K-SPACE sent by the target kernel module, and determines that the target kernel module is not created in the isolated space page table MPGT, the K- In the case of the access rights mapping of kernel data in SPACE, it can be seen that the target kernel module has no permission to directly access the kernel data in the K-SPACE space, thereby avoiding the target kernel module from accessing K-SPACE without security. The kernel data in the kernel helps to improve the security of system kernel data access.
同时,由于VMM相对于虚拟机操作系统拥有更高的运行权限,故而在虚拟化环境下,具备更高特权级VMM在执行权限上与虚拟机之间相互隔离,不会受到虚拟机的直接攻击。At the same time, because the VMM has higher running rights than the virtual machine operating system, in the virtualized environment, the VMM with higher privilege level is isolated from the virtual machine in execution permission, and is not directly attacked by the virtual machine. .
同时,由于VMM具有客户机平台无关性,可以同时对多个不同类型的客户操作系统的内核模块进行隔离。At the same time, because VMM has client platform independence, it can isolate kernel modules of several different types of guest operating systems at the same time.
可选的,本发明实施例中,上述VMM捕获页表中断事件之前,还可以执行以下操作以针对目标内核模块创建内核空间隔离机制:Optionally, in the embodiment of the present invention, before the VMM captures the page table interrupt event, the following operations may also be performed to create a kernel space isolation mechanism for the target kernel module:
所述VMM根据预存的所述虚拟机内核空间的空间页表将所述目标内核模块的虚拟地址分布信息映射为物理地址分布信息,其中,所述目标内核模块为从所述虚拟机内核空间中插入的N个内核模块中选取的需要被隔离的内核模块,所述N为正整数;The VMM maps virtual address distribution information of the target kernel module to physical address distribution information according to a pre-stored space page table of the virtual machine kernel space, where the target kernel module is from the virtual machine kernel space a kernel module selected to be isolated among the inserted N kernel modules, where N is a positive integer;
所述VMM基于所述物理地址分布信息分隔所述虚拟机内核空间为所述M-SPACE和所述K-SPACE;The VMM separates the virtual machine kernel space into the M-SPACE and the K-SPACE based on the physical address distribution information;
所述VMM标记所述虚拟机内核空间的空间页表为内核空间页表KPGT,并基于所述物理地址分布信息创建所述MPGT,其中,所述KPGT用于支持所述K-SPACE中的内核模块的运行,所述K-SPACE中的内核模块包括所述虚拟机内核空间中的基础内核模块和所述N个内核模块中除所述目标内核模块之外的内核模块。 The VMM marks a space page table of the virtual machine kernel space as a kernel space page table KPGT, and creates the MPGT based on the physical address distribution information, wherein the KPGT is used to support a kernel in the K-SPACE The operation of the module, the kernel module in the K-SPACE includes a base kernel module in the virtual machine kernel space and a kernel module other than the target kernel module among the N kernel modules.
可选的,本发明实施例中,上述VMM捕获页表中断事件之前,还可以执行以下操作以针对目标内核模块创建内核空间隔离机制:Optionally, in the embodiment of the present invention, before the VMM captures the page table interrupt event, the following operations may also be performed to create a kernel space isolation mechanism for the target kernel module:
所述VMM根据预存的所述虚拟机内核空间的空间页表将所述目标内核模块的虚拟地址分布信息映射为物理地址分布信息,其中,所述目标内核模块为从所述虚拟机内核空间中插入的N个内核模块中选取的需要被隔离的内核模块,所述N为正整数;The VMM maps virtual address distribution information of the target kernel module to physical address distribution information according to a pre-stored space page table of the virtual machine kernel space, where the target kernel module is from the virtual machine kernel space a kernel module selected to be isolated among the inserted N kernel modules, where N is a positive integer;
所述VMM基于所述物理地址分布信息分隔所述虚拟机内核空间为所述M-SPACE和所述K-SPACE;The VMM separates the virtual machine kernel space into the M-SPACE and the K-SPACE based on the physical address distribution information;
所述VMM标记所述虚拟机内核空间的空间页表为内核空间页表KPGT,并基于所述物理地址分布信息创建所述MPGT,其中,所述KPGT用于支持所述K-SPACE中的内核模块的运行,所述K-SPACE中的内核模块包括所述虚拟机内核空间中的基础内核模块和所述N个内核模块中除所述目标内核模块之外的内核模块。The VMM marks a space page table of the virtual machine kernel space as a kernel space page table KPGT, and creates the MPGT based on the physical address distribution information, wherein the KPGT is used to support a kernel in the K-SPACE The operation of the module, the kernel module in the K-SPACE includes a base kernel module in the virtual machine kernel space and a kernel module other than the target kernel module among the N kernel modules.
参阅图4,图4是本发明实施例公开的一种数据访问方法的流程示意图,如图4所示,该数据访问方法是从VMM单侧进行描述的,具体包括以下步骤:Referring to FIG. 4, FIG. 4 is a schematic flowchart of a data access method according to an embodiment of the present invention. As shown in FIG. 4, the data access method is described from one side of the VMM, and specifically includes the following steps:
S401,VMM根据预存的所述虚拟机内核空间的空间页表将所述目标内核模块的虚拟地址分布信息映射为物理地址分布信息,其中,所述目标内核模块为从所述虚拟机内核空间中插入的N个内核模块中选取的需要被隔离的内核模块,所述N为正整数;S401. The VMM maps virtual address distribution information of the target kernel module to physical address distribution information according to a pre-stored space page table of the virtual machine kernel space, where the target kernel module is from the virtual machine kernel space. a kernel module selected to be isolated among the inserted N kernel modules, where N is a positive integer;
S402,所述VMM基于所述物理地址分布信息分隔所述虚拟机内核空间为所述M-SPACE和所述K-SPACE;S402, the VMM separates the virtual machine kernel space into the M-SPACE and the K-SPACE based on the physical address distribution information;
S403,所述VMM标记所述虚拟机内核空间的空间页表为内核空间页表KPGT,并基于所述物理地址分布信息创建所述MPGT,其中,所述KPGT用于支持所述K-SPACE中的内核模块的运行,所述K-SPACE中的内核模块包括所述虚拟机内核空间中的基础内核模块和所述N个内核模块中除所述目标内核模块之外的内核模块;S403. The VMM marks a space page table of the virtual machine kernel space as a kernel space page table KPGT, and creates the MPGT based on the physical address distribution information, where the KPGT is used to support the K-SPACE. The kernel module in the K-SPACE includes a base kernel module in the virtual machine kernel space and a kernel module other than the target kernel module among the N kernel modules;
本发明实施例中,上述MPGT中创建有所述目标内核模块对所述M-SPACE中的内核数据的访问权限映射,以使得所述目标内核模块有权限访问所述 M-SPACE中的内核数据。In the embodiment of the present invention, an access authority mapping of the target kernel module to the kernel data in the M-SPACE is created in the MPGT, so that the target kernel module has the right to access the Kernel data in M-SPACE.
S404,VMM捕获页表中断事件,所述页表中断事件是由CPU在检测到目标内核模块发送的针对内核空间K-SPACE中的内核数据的访问请求之后、且判断出隔离空间页表MPGT中未创建所述目标内核模块对所述K-SPACE中的内核数据的访问权限映射的情况下产生的,其中,所述VMM对应的虚拟机内核空间包括所述K-SPACE和隔离空间M-SPACE,所述M-SPACE包括所述目标内核模块和所述MPGT,所述MPGT用于支持所述目标内核模块的运行;S404, the VMM captures a page table interrupt event, where the page table interrupt event is determined by the CPU after detecting the access request for the kernel data in the kernel space K-SPACE sent by the target kernel module, and determining the isolation space page table MPGT The target kernel module is not created with the access authority mapping of the kernel data in the K-SPACE, wherein the virtual machine kernel space corresponding to the VMM includes the K-SPACE and the isolation space M-SPACE The M-SPACE includes the target kernel module and the MPGT, and the MPGT is configured to support operation of the target kernel module;
S405,所述VMM通过预存的页表中断函数获取所述页表中断事件对应的预设权限判断策略,并获取所述K-SPACE中的内核数据的虚拟地址分布信息;S405, the VMM acquires a preset permission judgment policy corresponding to the page table interrupt event by using a pre-stored page table interrupt function, and acquires virtual address distribution information of the kernel data in the K-SPACE;
S406,所述VMM确定所述页表中断事件的事件类型;S406. The VMM determines an event type of the page table interrupt event.
S407,所述VMM根据所述预设权限判断策略、所述虚拟地址分布信息以及所述事件类型判断所述目标内核模块是否有权限访问所述K-SPACE中的内核数据;S407. The VMM determines, according to the preset permission determination policy, the virtual address distribution information, and the event type, whether the target kernel module has permission to access kernel data in the K-SPACE.
本发明实施例中,上述权限判断策略可以由用户预先设置并存储在内存空间中,上述页表中断事件对应的事件类型包括数据读取类型和数据写入类型。In the embodiment of the present invention, the foregoing authority judgment policy may be preset and stored in the memory space by the user, and the event type corresponding to the page table interrupt event includes a data read type and a data write type.
举例来说,假设目标内核模块对K-SPACE中的内核数据的数据读取类型对应的权限判断策略中包括以下子策略:若目标内核模块向CPU的内存管理单元请求数据读取的内核数据为K-SPACE中的中断向量表,则内存管理单元拒绝目标内核模块本次的数据读取请求。For example, suppose that the target kernel module has the following sub-policy in the authority judging policy corresponding to the data read type of the kernel data in the K-SPACE: if the target kernel module requests the core data of the data read from the memory management unit of the CPU as In the interrupt vector table in K-SPACE, the memory management unit rejects the current data read request of the target kernel module.
S408,当所述VMM通过预存的页表中断处理函数判断出所述目标内核模块有权限访问所述K-SPACE中的内核数据时,所述VMM在所述MPGT中创建所述目标内核模块对所述K-SPACE中的内核数据的访问权限映射,以使得所述目标内核模块有权限访问所述K-SPACE中的内核数据。S408, when the VMM determines, by using a pre-stored page table interrupt processing function, that the target kernel module has permission to access kernel data in the K-SPACE, the VMM creates the target kernel module pair in the MPGT. The access rights mapping of the kernel data in the K-SPACE is such that the target kernel module has access to the kernel data in the K-SPACE.
可以看出,本发明实施例中,VMM首先捕获页表中断事件,其次,VMM通过预存的页表中断处理函数判断目标内核模块是否有权限访问K-SPACE中的内核数据,最后,当VMM通过预存的页表中断处理函数判断出目标内核模块有权限访问K-SPACE中的内核数据时,VMM在MPGT中创建目标内核模块对K-SPACE中的内核数据的访问权限映射,以使得目标内核模块有权限访问 K-SPACE中的内核数据。由于上述页表中断事件是CPU在检测到目标内核模块发送的针对内核空间K-SPACE中的内核数据的访问请求之后、且判断出隔离空间页表MPGT中未创建目标内核模块对所述K-SPACE中的内核数据的访问权限映射的情况下产生的,可见,目标内核模块无权限直接访问K-SPACE空间中内核数据,从而能够避免目标内核模块在安全性未知的情况下肆意访问K-SPACE中的内核数据,有利于提升系统内核数据访问的安全性。It can be seen that, in the embodiment of the present invention, the VMM first captures the page table interrupt event, and secondly, the VMM determines whether the target kernel module has access to the kernel data in the K-SPACE through the pre-stored page table interrupt processing function, and finally, when the VMM passes When the pre-stored page table interrupt processing function determines that the target kernel module has permission to access the kernel data in the K-SPACE, the VMM creates an access authority mapping of the target kernel module to the kernel data in the K-SPACE in the MPGT, so that the target kernel module Have access to Kernel data in K-SPACE. Since the above page table interrupt event is that the CPU detects the access request for the kernel data in the kernel space K-SPACE sent by the target kernel module, and determines that the target kernel module is not created in the isolated space page table MPGT, the K- In the case of the access rights mapping of kernel data in SPACE, it can be seen that the target kernel module has no permission to directly access the kernel data in the K-SPACE space, thereby avoiding the target kernel module from accessing K-SPACE without security. The kernel data in the kernel helps to improve the security of system kernel data access.
同时,由于VMM相对于虚拟机操作系统拥有更高的运行权限,故而在虚拟化环境下,具备更高特权级VMM在执行权限上与虚拟机之间相互隔离,不会受到虚拟机的直接攻击。At the same time, because the VMM has higher running rights than the virtual machine operating system, in the virtualized environment, the VMM with higher privilege level is isolated from the virtual machine in execution permission, and is not directly attacked by the virtual machine. .
同时,由于VMM具有客户机平台无关性,可以同时对多个不同类型的客户操作系统的内核模块进行隔离。At the same time, because VMM has client platform independence, it can isolate kernel modules of several different types of guest operating systems at the same time.
进一步可选的,本发明实施例中,上述VMM根据预存的虚拟机内核空间的空间页表将目标内核模块的虚拟地址分布信息映射为物理地址分布信息之前,VMM还可以执行以下操作:Further, in the embodiment of the present invention, before the VMM maps the virtual address distribution information of the target kernel module to the physical address distribution information according to the spatial page table of the pre-stored virtual machine kernel space, the VMM may also perform the following operations:
VMM获取所述虚拟机内核空间中的客户代理模块发送的目标内核模块在虚拟机内核空间中的虚拟地址分布信息。The VMM obtains virtual address distribution information of the target kernel module sent by the client proxy module in the virtual machine kernel space in the virtual machine kernel space.
其中,该客户代理模块设置于K-SAPCE中,用于获取需要目标内核模块在虚拟机内核空间中的虚拟地址分布信息,并向VMM发送获取的上述虚拟地址分布信息,以便于VMM基于上述虚拟地址分布信息建立上述目标内核模块的隔离地址空间。其中,上述客户代理获取虚拟地址分布信息的具体实现方式包括以下两种:The client agent module is configured in the K-SAPCE, and is configured to obtain virtual address distribution information of the target kernel module in the virtual machine kernel space, and send the obtained virtual address distribution information to the VMM, so that the VMM is based on the virtual The address distribution information establishes an isolated address space of the above target kernel module. The specific implementation manners for obtaining the virtual address distribution information by the foregoing client agent include the following two types:
当检测到上述目标内核模块在虚拟机中尚未开始运行时,上述客户代理模块拦截该目标内核模块插入时所调用的相关的系统调用,当检测到目标内核模块插入时所调用的相关的系统调用时,客户代理模块获取目标内核模块在加载进入虚拟机内核空间后的虚拟地址分布信息{virt1,virt2}。例如,Windows虚拟机可以通过注册回调函数的方式来获取虚拟机中的内存映像插入事件,根据映像名称判断是否是目标内核模块被加载到虚拟机内核空间中。When it is detected that the target kernel module has not started running in the virtual machine, the client agent module intercepts the related system call invoked when the target kernel module is inserted, and the related system call invoked when the target kernel module is inserted is detected. When the client agent module obtains the virtual address distribution information {virt1, virt2} of the target kernel module after loading into the virtual machine kernel space. For example, the Windows virtual machine can obtain a memory image insertion event in the virtual machine by registering a callback function, and determine whether the target kernel module is loaded into the virtual machine kernel space according to the image name.
当检测到上述目标内核模块在虚拟机中已经开始运行时,上述客户代理模 块需要遍历虚拟机内核空间中的内核模块链表,获取目标内核模块在虚拟机内核空间中的虚拟地址分布信息{virt1,virt2}。The above client proxy module is detected when it is detected that the target kernel module has started running in the virtual machine. The block needs to traverse the kernel module linked list in the virtual machine kernel space to obtain the virtual address distribution information {virt1, virt2} of the target kernel module in the virtual machine kernel space.
可以看出,本发明实施例中,上述客户代理模块位于K-SPACE中,与M-SPACE中的目标内核模块运行于不同内核空间,因而不会受到来自目标内核模块的攻击,有利于进一步提升系统内核的安全性。It can be seen that, in the embodiment of the present invention, the client agent module is located in the K-SPACE, and the target kernel module in the M-SPACE runs in a different kernel space, and thus is not attacked by the target kernel module, which is beneficial to further improve. The security of the system kernel.
进一步可选的,本发明实施例中,上述VMM基于所述物理地址分布信息创建隔离空间页表MPGT之后,上述VMM还可以执行以下操作:Further, in the embodiment of the present invention, after the VMM creates the isolated space page table MPGT based on the physical address distribution information, the VMM may further perform the following operations:
所述VMM删除所述KPGT中存储的所述K-SPACE中的内核模块所述M-SPACE中的内核数据的访问权限映射,以使得所述K-SPACE中的内核模块无法直接访问M-SPACE中的内核数据,进一步增强系统内核数据访问的安全性。The VMM deletes an access authority mapping of kernel data in the M-SPACE of the kernel module in the K-SPACE stored in the KPGT, so that the kernel module in the K-SPACE cannot directly access the M-SPACE The kernel data in the library further enhances the security of the system kernel data access.
请参阅图5,图5是本发明实施例公开的一种代码调用方法的流程示意图,如图5所示,该代码调用方法是从VMM单侧进行描述的,具体包括以下步骤:Referring to FIG. 5, FIG. 5 is a schematic flowchart of a code invoking method according to an embodiment of the present invention. As shown in FIG. 5, the code calling method is described from one side of the VMM, and specifically includes the following steps:
S501,虚拟机监视器VMM捕获页表中断事件,所述页表中断事件是由中央处理单元CPU在检测到目标内核模块针对内核空间K-SPACE中的内核代码的调用请求之后、且判断出隔离空间页表MPGT中未创建所述目标内核模块对所述K-SPACE中的内核代码的调用权限映射的情况下生成的,其中,所述VMM对应的虚拟机内核空间包括所述K-SPACE和隔离空间M-SPACE,所述M-SPACE包括所述目标内核模块和所述MPGT,所述MPGT用于支持所述目标内核模块的运行;S501, the virtual machine monitor VMM captures a page table interrupt event, and the page table interrupt event is determined by the central processing unit CPU after detecting the target kernel module calling request for the kernel code in the kernel space K-SPACE The virtual page kernel space corresponding to the kernel code in the K-SPACE is not created in the space page table MPGT, wherein the virtual machine kernel space corresponding to the VMM includes the K-SPACE and An isolation space M-SPACE, the M-SPACE including the target kernel module and the MPGT, the MPGT being used to support operation of the target kernel module;
本发明实施例中,所述MPGT中创建有所述目标内核模块对所述M-SPACE中的内核代码的调用权限映射,以使得所述目标内核模块有权限调用所述M-SPACE中的内核代码。In the embodiment of the present invention, a call permission mapping of the target kernel module to the kernel code in the M-SPACE is created in the MPGT, so that the target kernel module has permission to invoke the kernel in the M-SPACE. Code.
S502,所述VMM通过预存的页表中断处理函数判断所述目标内核模块是否有权限调用所述K-SPACE中的内核代码;S502. The VMM determines, by using a pre-stored page table interrupt processing function, whether the target kernel module has permission to invoke the kernel code in the K-SPACE.
本发明实施例中,上述VMM通过预存的页表中断处理函数判断所述目标内核模块是否有权限调用所述K-SPACE中的内核代码的具体实施方式为:In the embodiment of the present invention, the VMM determines, by using a pre-stored page table interrupt processing function, whether the target kernel module has permission to invoke the kernel code in the K-SPACE:
所述VMM通过预存的页表中断函数获取所述页表中断事件对应的预设权 限判断策略,并获取所述K-SPACE中的内核代码的虚拟地址分布信息;The VMM acquires a preset right corresponding to the page table interrupt event by using a pre-stored page table interrupt function Limiting the judgment strategy, and obtaining virtual address distribution information of the kernel code in the K-SPACE;
所述VMM根据获取的所述预设权限判断策略和所述虚拟地址分布信息判断所述目标内核模块是否有权限访问所述K-SPACE中的内核代码。The VMM determines, according to the obtained preset permission judgment policy and the virtual address distribution information, whether the target kernel module has permission to access the kernel code in the K-SPACE.
S503,当所述VMM通过预存的页表中断处理函数判断出所述目标内核模块有权限调用所述K-SPACE中的内核代码时,所述VMM根据所述目标内核模块对所述K-SPACE中的内核代码的调用权限映射,执行页表切换操作和堆栈切换操作以将所述虚拟机内核空间的堆栈由隔离空间堆栈M-STACK切换为内核空间堆栈K-STACK,以使得所述目标内核模块基于切换后的所述K-STACK调用所述K-SPACE中的内核代码。S503, when the VMM determines, by using a pre-stored page table interrupt processing function, that the target kernel module has permission to invoke the kernel code in the K-SPACE, the VMM according to the target kernel module to the K-SPACE a call permission mapping of the kernel code in the table, performing a page table switching operation and a stack switching operation to switch the stack of the virtual machine kernel space from the isolated space stack M-STACK to the kernel space stack K-STACK, such that the target core The module calls the kernel code in the K-SPACE based on the K-STACK after switching.
本发明实施例中,上述VMM执行页表页表切换操作的具体实施方式为:In the embodiment of the present invention, the specific implementation manner of the VMM performing the page table page table switching operation is:
所述VMM将所述VMM当前加载的页表由所述MPGT切换为内核空间页表KPGT,其中,所述KPGT用于支持所述K-SPACE中的内核模块的运行,所述K-SPACE中包括所述虚拟机内核空间中的基础内核模块、所述虚拟机内核空间中插入的N个内核模块中除所述目标内核模块之外的内核模块以及所述KPGT,所述N为大于1的正整数。The VMM switches the page table currently loaded by the VMM from the MPGT to a kernel space page table KPGT, wherein the KPGT is used to support operation of a kernel module in the K-SPACE, in the K-SPACE And including the basic kernel module in the virtual machine kernel space, a kernel module other than the target kernel module among the N kernel modules inserted in the virtual machine kernel space, and the KPGT, where the N is greater than 1. A positive integer.
上述VMM执行堆栈切换操作的具体实施方式为:The specific implementation manner of the above VMM performing a stack switching operation is:
所述VMM拷贝M-STACK中存储的用于传递所述K-SPACE中的内核代码的代码参数和用于调用所述K-SPACE中的内核代码的返回地址RIP;The VMM copies the code parameters stored in the M-STACK for transferring the kernel code in the K-SPACE and the return address RIP for calling the kernel code in the K-SPACE;
所述VMM在所述K-STACK中写入所述代码参数和所述RIP;Writing, by the VMM, the code parameter and the RIP in the K-STACK;
所述VMM将所述虚拟机内核空间当前使用的堆栈由esp-old位置转变为esp-new位置,其中,所述esp-old位置为所述RIP在所述M-STACK中的存储位置,所述esp-new位置为所述RIP在所述K-STACK中的存储位置。The VMM converts a stack currently used by the virtual machine kernel space from an esp-old location to an esp-new location, where the esp-old location is a storage location of the RIP in the M-STACK, The esp-new location is the storage location of the RIP in the K-STACK.
可以看出,本发明实施例中,VMM首先捕获页表中断事件,其次,当VMM通过预存的页表中断处理函数判断出目标内核模块有权限调用K-SPACE中的内核代码时,VMM根据目标内核模块对K-SPACE中的内核代码的调用权限映射,执行页表切换操作和堆栈切换操作以将虚拟机内核空间的堆栈由隔离空间堆栈M-STACK切换为内核空间堆栈K-STACK,以使得所述目标内核模块基于切换后的所述K-STACK调用所述K-SPACE中的内核代码。其中,上述页表中 断事件是CPU在检测到目标内核模块针对内核空间K-SPACE中的内核代码的调用请求之后、且判断出隔离空间页表MPGT中未创建目标内核模块对K-SPACE中的内核代码的调用权限映射的情况下生成的,可见,目标内核模块无权限直接调用K-SPACE中的内核代码,能够避免目标内核模块在安全性未知的情况下肆意调用K-SPACE中的内核代码,有利于提升系统内核代码调用的安全性。It can be seen that, in the embodiment of the present invention, the VMM first captures the page table interrupt event, and secondly, when the VMM determines that the target kernel module has permission to invoke the kernel code in the K-SPACE through the pre-stored page table interrupt processing function, the VMM is based on the target. The kernel module calls the permission mapping of the kernel code in the K-SPACE, performs a page table switching operation and a stack switching operation to switch the stack of the virtual machine kernel space from the isolated space stack M-STACK to the kernel space stack K-STACK, so that The target kernel module invokes the kernel code in the K-SPACE based on the K-STACK after the handover. Among them, in the above page table The interrupt event is that the CPU detects the call request of the target kernel module for the kernel code in the kernel space K-SPACE, and determines that the target kernel module does not create the call permission of the kernel code in the K-SPACE in the isolated space page table MPGT. In the case of mapping, it can be seen that the target kernel module has no permission to directly call the kernel code in K-SPACE, which can avoid the target kernel module inadvertently calling the kernel code in K-SPACE if the security is unknown, which is beneficial to the system. The security of the kernel code call.
同时,由于VMM相对于虚拟机操作系统拥有更高的运行权限,故而在虚拟化环境下,具备更高特权级VMM在执行权限上与虚拟机之间相互隔离,不会受到虚拟机的直接攻击。At the same time, because the VMM has higher running rights than the virtual machine operating system, in the virtualized environment, the VMM with higher privilege level is isolated from the virtual machine in execution permission, and is not directly attacked by the virtual machine. .
同时,由于VMM具有客户机平台无关性,可以同时对多个不同类型的客户操作系统的内核模块进行隔离。At the same time, because VMM has client platform independence, it can isolate kernel modules of several different types of guest operating systems at the same time.
可选的,本发明实施例中,上述VMM捕获页表中断事件之前,还可以执行以下操作以创建针对目标内核模块的隔离机制:Optionally, in the embodiment of the present invention, before the VMM captures the page table interrupt event, the following operations may also be performed to create an isolation mechanism for the target kernel module:
所述VMM根据预存的所述虚拟机内核空间的空间页表将目标内核模块的虚拟地址分布信息映射为物理地址分布信息,其中,所述目标内核模块为从所述虚拟机内核空间中插入的N个内核模块中选取的需要被隔离的内核模块,所述N为大于1的正整数;The VMM maps virtual address distribution information of the target kernel module to physical address distribution information according to a pre-stored space page table of the virtual machine kernel space, where the target kernel module is inserted from the virtual machine kernel space a kernel module selected from the N kernel modules to be isolated, wherein N is a positive integer greater than one;
所述VMM基于所述物理地址分布信息分隔所述虚拟机内核空间为所述M-SPACE和所述K-SPACE;The VMM separates the virtual machine kernel space into the M-SPACE and the K-SPACE based on the physical address distribution information;
所述VMM标记所述虚拟机内核空间的空间页表为内核空间页表KPGT,并基于所述物理地址分布信息创建所述MPGT。The VMM marks the space page table of the virtual machine kernel space as a kernel space page table KPGT, and creates the MPGT based on the physical address distribution information.
请参阅图6,图6是本发明实施例公开的一种代码调用方法的流程示意图,如图6所示,该代码调用方法是从VMM单侧进行描述的,具体包括以下步骤:Referring to FIG. 6 , FIG. 6 is a schematic flowchart of a code invoking method according to an embodiment of the present invention. As shown in FIG. 6 , the code calling method is described from one side of the VMM, and specifically includes the following steps:
S601,虚拟机监视器VMM捕获页表中断事件,所述页表中断事件是由中央处理单元CPU在检测到目标内核模块针对内核空间K-SPACE中的内核代码的调用请求之后、且判断出隔离空间页表MPGT中未创建所述目标内核模块对所述K-SPACE中的内核代码的调用权限映射的情况下生成的,其中,所述VMM对应的虚拟机内核空间包括所述K-SPACE和隔离空间M-SPACE,所述 M-SPACE包括所述目标内核模块和所述MPGT,所述MPGT用于支持所述目标内核模块的运行;S601, the virtual machine monitor VMM captures a page table interrupt event, and the page table interrupt event is determined by the central processing unit CPU after detecting the target kernel module calling request for the kernel code in the kernel space K-SPACE The virtual page kernel space corresponding to the kernel code in the K-SPACE is not created in the space page table MPGT, wherein the virtual machine kernel space corresponding to the VMM includes the K-SPACE and Isolated space M-SPACE, said The M-SPACE includes the target kernel module and the MPGT, and the MPGT is configured to support operation of the target kernel module;
本发明实施例中,所述MPGT中创建有所述目标内核模块对所述M-SPACE中的内核代码的调用权限映射,以使得所述目标内核模块有权限调用所述M-SPACE中的内核代码。In the embodiment of the present invention, a call permission mapping of the target kernel module to the kernel code in the M-SPACE is created in the MPGT, so that the target kernel module has permission to invoke the kernel in the M-SPACE. Code.
S602,所述VMM通过预存的页表中断函数获取所述页表中断事件对应的预设权限判断策略,并获取所述K-SPACE中的内核代码的虚拟地址分布信息;S602, the VMM acquires a preset permission judgment policy corresponding to the page table interrupt event by using a pre-stored page table interrupt function, and acquires virtual address distribution information of the kernel code in the K-SPACE;
S603,所述VMM根据获取的所述预设权限判断策略和所述虚拟地址分布信息判断所述目标内核模块是否有权限访问所述K-SPACE中的内核代码;S603, the VMM determines, according to the obtained preset permission judgment policy and the virtual address distribution information, whether the target kernel module has permission to access the kernel code in the K-SPACE;
S604,当所述VMM通过预存的页表中断处理函数判断出所述目标内核模块有权限调用所述K-SPACE中的内核代码时,所述VMM根据所述目标内核模块对所述K-SPACE中的内核代码的调用权限映射,执行页表切换操作和堆栈切换操作以将所述虚拟机内核空间的堆栈由隔离空间堆栈M-STACK切换为内核空间堆栈K-STACK,以使得所述目标内核模块基于切换后的所述K-STACK调用所述K-SPACE中的内核代码。S604, when the VMM determines, by using a pre-stored page table interrupt processing function, that the target kernel module has permission to invoke the kernel code in the K-SPACE, the VMM is configured according to the target kernel module to the K-SPACE. a call permission mapping of the kernel code in the table, performing a page table switching operation and a stack switching operation to switch the stack of the virtual machine kernel space from the isolated space stack M-STACK to the kernel space stack K-STACK, such that the target core The module calls the kernel code in the K-SPACE based on the K-STACK after switching.
本发明实施例中,上述VMM执行页表页表切换操作的具体实施方式为:In the embodiment of the present invention, the specific implementation manner of the VMM performing the page table page table switching operation is:
所述VMM将所述VMM当前加载的页表由所述MPGT切换为内核空间页表KPGT,其中,所述KPGT用于支持所述K-SPACE中的内核模块的运行,所述K-SPACE中包括所述虚拟机内核空间中的基础内核模块、所述虚拟机内核空间中插入的N个内核模块中除所述目标内核模块之外的内核模块以及所述KPGT,所述N为大于1的正整数。The VMM switches the page table currently loaded by the VMM from the MPGT to a kernel space page table KPGT, wherein the KPGT is used to support operation of a kernel module in the K-SPACE, in the K-SPACE And including the basic kernel module in the virtual machine kernel space, a kernel module other than the target kernel module among the N kernel modules inserted in the virtual machine kernel space, and the KPGT, where the N is greater than 1. A positive integer.
上述VMM执行堆栈切换操作的具体实施方式为:The specific implementation manner of the above VMM performing a stack switching operation is:
所述VMM拷贝M-STACK中存储的用于传递所述K-SPACE中的内核代码的代码参数和用于调用所述K-SPACE中的内核代码的返回地址RIP;The VMM copies the code parameters stored in the M-STACK for transferring the kernel code in the K-SPACE and the return address RIP for calling the kernel code in the K-SPACE;
所述VMM在所述K-STACK中写入所述代码参数和所述RIP;Writing, by the VMM, the code parameter and the RIP in the K-STACK;
所述VMM将所述虚拟机内核空间当前使用的堆栈由esp-old位置转变为esp-new位置,其中,所述esp-old位置为所述RIP在所述M-STACK中的存储位置,所述esp-new位置为所述RIP在所述K-STACK中的存储位置。 The VMM converts a stack currently used by the virtual machine kernel space from an esp-old location to an esp-new location, where the esp-old location is a storage location of the RIP in the M-STACK, The esp-new location is the storage location of the RIP in the K-STACK.
可以看出,本发明实施例中,VMM首先捕获页表中断事件,其次,当VMM通过预存的页表中断处理函数判断出目标内核模块有权限调用K-SPACE中的内核代码时,VMM根据目标内核模块对K-SPACE中的内核代码的调用权限映射,执行页表切换操作和堆栈切换操作以将虚拟机内核空间的堆栈由隔离空间堆栈M-STACK切换为内核空间堆栈K-STACK,以使得所述目标内核模块基于切换后的所述K-STACK调用所述K-SPACE中的内核代码。其中,上述页表中断事件是CPU在检测到目标内核模块针对内核空间K-SPACE中的内核代码的调用请求之后、且判断出隔离空间页表MPGT中未创建目标内核模块对K-SPACE中的内核代码的调用权限映射的情况下生成的,可见,目标内核模块无权限直接调用K-SPACE中的内核代码,能够避免目标内核模块在安全性未知的情况下肆意调用K-SPACE中的内核代码,有利于提升系统内核代码调用的安全性。It can be seen that, in the embodiment of the present invention, the VMM first captures the page table interrupt event, and secondly, when the VMM determines that the target kernel module has permission to invoke the kernel code in the K-SPACE through the pre-stored page table interrupt processing function, the VMM is based on the target. The kernel module calls the permission mapping of the kernel code in the K-SPACE, performs a page table switching operation and a stack switching operation to switch the stack of the virtual machine kernel space from the isolated space stack M-STACK to the kernel space stack K-STACK, so that The target kernel module invokes the kernel code in the K-SPACE based on the K-STACK after the handover. The page table interrupt event is that after the CPU detects the call request of the target kernel module for the kernel code in the kernel space K-SPACE, and determines that the target kernel module is not created in the isolated space page table MPGT in the K-SPACE The kernel code's call permission mapping is generated. It can be seen that the target kernel module has no permission to directly call the kernel code in K-SPACE, which can avoid the target kernel module inadvertently calling the kernel code in K-SPACE if the security is unknown. It is beneficial to improve the security of system kernel code calls.
可以看出,本发明实施例中,VMM首先捕获页表中断事件,其次,当VMM通过预存的页表中断处理函数判断出目标内核模块有权限调用K-SPACE中的内核代码时,VMM根据目标内核模块对K-SPACE中的内核代码的调用权限映射,执行页表切换操作和堆栈切换操作以将虚拟机内核空间的堆栈由隔离空间堆栈M-STACK切换为内核空间堆栈K-STACK,以使得所述目标内核模块基于切换后的所述K-STACK调用所述K-SPACE中的内核代码。其中,上述页表中断事件是CPU在检测到目标内核模块针对内核空间K-SPACE中的内核代码的调用请求之后、且判断出隔离空间页表MPGT中未创建目标内核模块对K-SPACE中的内核代码的调用权限映射的情况下生成的,可见,目标内核模块无权限直接调用内核代码,能够避免目标内核模块在安全性未知的情况下肆意调用K-SPACE中的内核代码,有利于提升系统内核代码调用的安全性。It can be seen that, in the embodiment of the present invention, the VMM first captures the page table interrupt event, and secondly, when the VMM determines that the target kernel module has permission to invoke the kernel code in the K-SPACE through the pre-stored page table interrupt processing function, the VMM is based on the target. The kernel module calls the permission mapping of the kernel code in the K-SPACE, performs a page table switching operation and a stack switching operation to switch the stack of the virtual machine kernel space from the isolated space stack M-STACK to the kernel space stack K-STACK, so that The target kernel module invokes the kernel code in the K-SPACE based on the K-STACK after the handover. The page table interrupt event is that after the CPU detects the call request of the target kernel module for the kernel code in the kernel space K-SPACE, and determines that the target kernel module is not created in the isolated space page table MPGT in the K-SPACE The kernel code is generated by the call permission mapping. It can be seen that the target kernel module has no permission to directly call the kernel code, which can avoid the target kernel module inadvertently calling the kernel code in K-SPACE if the security is unknown, which is beneficial to the system. The security of the kernel code call.
同时,由于VMM相对于虚拟机操作系统拥有更高的运行权限,故而在虚拟化环境下,具备更高特权级VMM在执行权限上与虚拟机之间相互隔离,不会受到虚拟机的直接攻击。At the same time, because the VMM has higher running rights than the virtual machine operating system, in the virtualized environment, the VMM with higher privilege level is isolated from the virtual machine in execution permission, and is not directly attacked by the virtual machine. .
同时,由于VMM具有客户机平台无关性,可以同时对多个不同类型的客户操作系统的内核模块进行隔离。 At the same time, because VMM has client platform independence, it can isolate kernel modules of several different types of guest operating systems at the same time.
可选的,本发明实施例中,上述VMM捕获页表中断事件之前,还可以执行以下操作以创建针对目标内核模块的隔离机制:Optionally, in the embodiment of the present invention, before the VMM captures the page table interrupt event, the following operations may also be performed to create an isolation mechanism for the target kernel module:
所述VMM根据预存的所述虚拟机内核空间的空间页表将目标内核模块的虚拟地址分布信息映射为物理地址分布信息,其中,所述目标内核模块为从所述虚拟机内核空间中插入的N个内核模块中选取的需要被隔离的内核模块,所述N为大于1的正整数;The VMM maps virtual address distribution information of the target kernel module to physical address distribution information according to a pre-stored space page table of the virtual machine kernel space, where the target kernel module is inserted from the virtual machine kernel space a kernel module selected from the N kernel modules to be isolated, wherein N is a positive integer greater than one;
所述VMM基于所述物理地址分布信息分隔所述虚拟机内核空间为所述M-SPACE和所述K-SPACE;The VMM separates the virtual machine kernel space into the M-SPACE and the K-SPACE based on the physical address distribution information;
所述VMM标记所述虚拟机内核空间的空间页表为内核空间页表KPGT,并基于所述物理地址分布信息创建所述MPGT。The VMM marks the space page table of the virtual machine kernel space as a kernel space page table KPGT, and creates the MPGT based on the physical address distribution information.
参阅图7,图7是本发明实施例公开的一种代码调用方法的流程示意图,如图7所示,该代码调用方法是从VMM单侧进行描述的,具体包括以下步骤:Referring to FIG. 7, FIG. 7 is a schematic flowchart of a code invoking method according to an embodiment of the present invention. As shown in FIG. 7, the code calling method is described from one side of a VMM, and specifically includes the following steps:
S701,所述VMM根据预存的所述虚拟机内核空间的空间页表将目标内核模块的虚拟地址分布信息映射为物理地址分布信息,其中,所述目标内核模块为从所述虚拟机内核空间中插入的N个内核模块中选取的需要被隔离的内核模块,所述N为大于1的正整数;S701. The VMM maps virtual address distribution information of the target kernel module to physical address distribution information according to the pre-stored space page table of the virtual machine kernel space, where the target kernel module is from the virtual machine kernel space. a kernel module selected to be isolated among the inserted N kernel modules, where N is a positive integer greater than one;
S702,所述VMM基于所述物理地址分布信息分隔所述虚拟机内核空间为所述M-SPACE和所述K-SPACE;S702, the VMM separates the virtual machine kernel space into the M-SPACE and the K-SPACE based on the physical address distribution information;
S703,所述VMM标记所述虚拟机内核空间的空间页表为内核空间页表KPGT,并基于所述物理地址分布信息创建所述MPGT;S703, the VMM marks the space page table of the virtual machine kernel space as a kernel space page table KPGT, and creates the MPGT based on the physical address distribution information;
本发明实施例中,所述MPGT中创建有所述目标内核模块对所述M-SPACE中的内核代码的调用权限映射,以使得所述目标内核模块有权限调用所述M-SPACE中的内核代码。In the embodiment of the present invention, a call permission mapping of the target kernel module to the kernel code in the M-SPACE is created in the MPGT, so that the target kernel module has permission to invoke the kernel in the M-SPACE. Code.
S704,虚拟机监视器VMM捕获页表中断事件,所述页表中断事件是由中央处理单元CPU在检测到目标内核模块针对内核空间K-SPACE中的内核代码的调用请求之后、且判断出隔离空间页表MPGT中未创建所述目标内核模块对所述K-SPACE中的内核代码的调用权限映射的情况下生成的,其中,所述VMM对应的虚拟机内核空间包括所述K-SPACE和隔离空间M-SPACE,所述 M-SPACE包括所述目标内核模块和所述MPGT,所述MPGT用于支持所述目标内核模块的运行;S704, the virtual machine monitor VMM captures a page table interrupt event, and the page table interrupt event is determined by the central processing unit CPU after detecting the target kernel module calling request for the kernel code in the kernel space K-SPACE The virtual page kernel space corresponding to the kernel code in the K-SPACE is not created in the space page table MPGT, wherein the virtual machine kernel space corresponding to the VMM includes the K-SPACE and Isolated space M-SPACE, said The M-SPACE includes the target kernel module and the MPGT, and the MPGT is configured to support operation of the target kernel module;
S705,所述VMM通过预存的页表中断处理函数判断所述目标内核模块是否有权限调用所述K-SPACE中的内核代码;S705. The VMM determines, by using a pre-stored page table interrupt processing function, whether the target kernel module has permission to invoke the kernel code in the K-SPACE.
S706,当所述VMM通过预存的页表中断处理函数判断出所述目标内核模块有权限调用所述K-SPACE中的内核代码时,所述VMM根据所述目标内核模块对所述K-SPACE中的内核代码的调用权限映射,执行页表切换操作和堆栈切换操作以将所述虚拟机内核空间的堆栈由隔离空间堆栈M-STACK切换为内核空间堆栈K-STACK,以使得所述目标内核模块基于切换后的所述K-STACK调用所述K-SPACE中的内核代码。S706. When the VMM determines, by using a pre-stored page table interrupt processing function, that the target kernel module has permission to invoke the kernel code in the K-SPACE, the VMM is configured according to the target kernel module to the K-SPACE. a call permission mapping of the kernel code in the table, performing a page table switching operation and a stack switching operation to switch the stack of the virtual machine kernel space from the isolated space stack M-STACK to the kernel space stack K-STACK, such that the target core The module calls the kernel code in the K-SPACE based on the K-STACK after switching.
本发明实施例中,上述VMM执行页表页表切换操作的具体实施方式为:In the embodiment of the present invention, the specific implementation manner of the VMM performing the page table page table switching operation is:
所述VMM将所述VMM当前加载的页表由所述MPGT切换为内核空间页表KPGT,其中,所述KPGT用于支持所述K-SPACE中的内核模块的运行,所述K-SPACE中包括所述虚拟机内核空间中的基础内核模块、所述虚拟机内核空间中插入的N个内核模块中除所述目标内核模块之外的内核模块以及所述KPGT,所述N为大于1的正整数。The VMM switches the page table currently loaded by the VMM from the MPGT to a kernel space page table KPGT, wherein the KPGT is used to support operation of a kernel module in the K-SPACE, in the K-SPACE And including the basic kernel module in the virtual machine kernel space, a kernel module other than the target kernel module among the N kernel modules inserted in the virtual machine kernel space, and the KPGT, where the N is greater than 1. A positive integer.
上述VMM执行堆栈切换操作的具体实施方式为:The specific implementation manner of the above VMM performing a stack switching operation is:
所述VMM拷贝M-STACK中存储的用于传递所述K-SPACE中的内核代码的代码参数和用于调用所述K-SPACE中的内核代码的返回地址RIP;The VMM copies the code parameters stored in the M-STACK for transferring the kernel code in the K-SPACE and the return address RIP for calling the kernel code in the K-SPACE;
所述VMM在所述K-STACK中写入所述代码参数和所述RIP;Writing, by the VMM, the code parameter and the RIP in the K-STACK;
所述VMM将所述虚拟机内核空间当前使用的堆栈由esp-old位置转变为esp-new位置,其中,所述esp-old位置为所述RIP在所述M-STACK中的存储位置,所述esp-new位置为所述RIP在所述K-STACK中的存储位置。The VMM converts a stack currently used by the virtual machine kernel space from an esp-old location to an esp-new location, where the esp-old location is a storage location of the RIP in the M-STACK, The esp-new location is the storage location of the RIP in the K-STACK.
可以看出,本发明实施例中,VMM首先捕获页表中断事件,其次,当VMM通过预存的页表中断处理函数判断出目标内核模块有权限调用K-SPACE中的内核代码时,VMM根据目标内核模块对K-SPACE中的内核代码的调用权限映射,执行页表切换操作和堆栈切换操作以将虚拟机内核空间的堆栈由隔离空间堆栈M-STACK切换为内核空间堆栈K-STACK,以使得所述目标内核模块基于 切换后的所述K-STACK调用所述K-SPACE中的内核代码。其中,上述页表中断事件是CPU在检测到目标内核模块针对内核空间K-SPACE中的内核代码的调用请求之后、且判断出隔离空间页表MPGT中未创建目标内核模块对K-SPACE中的内核代码的调用权限映射的情况下生成的,可见,目标内核模块无权限直接调用K-SPACE中的内核代码,能够避免目标内核模块在安全性未知的情况下肆意调用K-SPACE中的内核代码,有利于提升系统内核代码调用的安全性。It can be seen that, in the embodiment of the present invention, the VMM first captures the page table interrupt event, and secondly, when the VMM determines that the target kernel module has permission to invoke the kernel code in the K-SPACE through the pre-stored page table interrupt processing function, the VMM is based on the target. The kernel module calls the permission mapping of the kernel code in the K-SPACE, performs a page table switching operation and a stack switching operation to switch the stack of the virtual machine kernel space from the isolated space stack M-STACK to the kernel space stack K-STACK, so that The target kernel module is based on The switched K-STACK calls the kernel code in the K-SPACE. The page table interrupt event is that after the CPU detects the call request of the target kernel module for the kernel code in the kernel space K-SPACE, and determines that the target kernel module is not created in the isolated space page table MPGT in the K-SPACE The kernel code's call permission mapping is generated. It can be seen that the target kernel module has no permission to directly call the kernel code in K-SPACE, which can avoid the target kernel module inadvertently calling the kernel code in K-SPACE if the security is unknown. It is beneficial to improve the security of system kernel code calls.
同时,由于VMM相对于虚拟机操作系统拥有更高的运行权限,故而在虚拟化环境下,具备更高特权级VMM在执行权限上与虚拟机之间相互隔离,不会受到虚拟机的直接攻击。At the same time, because the VMM has higher running rights than the virtual machine operating system, in the virtualized environment, the VMM with higher privilege level is isolated from the virtual machine in execution permission, and is not directly attacked by the virtual machine. .
同时,由于VMM具有客户机平台无关性,可以同时对多个不同类型的客户操作系统的内核模块进行隔离。At the same time, because VMM has client platform independence, it can isolate kernel modules of several different types of guest operating systems at the same time.
进一步可选的,本发明实施例中,上述步骤S706中所述目标内核模块基于切换为K-STACK的所述堆栈调用所述K-SPACE中的内核代码之后,上述代码调用执行流程需要从K-SPACE返回到目标内核模块中,具体包括如下过程:Further, in the embodiment of the present invention, after the target kernel module in step S706 calls the kernel code in the K-SPACE based on the stack switched to K-STACK, the code execution execution process needs to be from K. -SPACE returns to the target kernel module, including the following process:
上述K-SPACE中的内核代码所属的内核模块CPU执行ret指令,请求返回到目标内核模块中;The kernel module CPU to which the kernel code in the above K-SPACE belongs executes the ret instruction, and the request is returned to the target kernel module;
CPU中的内存管理模块检测到上述ret指令,判断KPGT中是否创建有K-SPACE中的内核模块对目标内核模块中的内核代码的调用权限映射;The memory management module in the CPU detects the above ret instruction, and determines whether the KPGT creates a call permission mapping of the kernel module in the K-SPACE to the kernel code in the target kernel module;
CPU中的内存管理模块判断出KPGT中未创建有K-SPACE中的内核模块对目标内核模块中的内核代码的调用权限映射,产生页表中断事件M3,The memory management module in the CPU determines that the KPGT does not create a call permission mapping of the kernel module in the K-SPACE to the kernel code in the target kernel module, and generates a page table interrupt event M3.
VMM捕捉到上述页表中断事件M3,响应该页表中断事件M3,通过预存的页表中断处理函数判断K-SPACE中的内核模块是否有权限调用目标内核模块的内核代码,若判断出有权限,则所述VMM在KPGT中创建K-SPACE中的内核模块对目标内核模块的内核代码的调用权限映射,将当前加载的页表由所述KPGT切换为MPGT,以及执行堆栈切换操作以将虚拟机内核空间加载的堆栈由隔离空间堆栈K-STACK切换回内核空间堆栈M-STACK,此时执行流程返回到M-SPACE,可以继续在目标内核空间调用内核代码。 The VMM captures the above page table interrupt event M3, responds to the page table interrupt event M3, and determines whether the kernel module in the K-SPACE has permission to call the kernel code of the target kernel module through the pre-stored page table interrupt processing function, and if it is determined that there is permission The VMM creates a call permission mapping of the kernel module in the K-SPACE to the kernel code of the target kernel module in the KPGT, switches the currently loaded page table from the KPGT to the MPGT, and performs a stack switching operation to virtualize The stack loaded by the kernel space is switched back to the kernel space stack M-STACK by the isolated space stack K-STACK. At this point, the execution flow returns to M-SPACE, and the kernel code can continue to be called in the target kernel space.
进一步可选的,本发明实施例中,上述VMM执行堆栈切换操作之后,还可以执行以下操作:VMM删除所述KPGT中存储的所述K-SPACE中的内核模块所述M-SPACE中的内核代码的调用权限映射。Further, in the embodiment of the present invention, after performing the stack switching operation, the VMM may further perform the following operations: the VMM deletes the kernel in the K-SPACE stored in the KPGT and the kernel in the M-SPACE The call permission mapping for the code.
进一步可选的,本发明实施例中,上述VMM在删除所述KPGT中存储的所述K-SPACE中的内核模块所述M-SPACE中的内核代码的调用权限映射之后,K-SPACE中的内核模块请求调用目标内核模块中的内核代码,具体执行过程如下:Further, in the embodiment of the present invention, after the VMM deletes the call permission mapping of the kernel code in the M-SPACE of the kernel module in the K-SPACE stored in the KPGT, in the K-SPACE The kernel module requests to call the kernel code in the target kernel module. The specific execution process is as follows:
CPU检测到K-SPACE中的内核模块发出的针对目标内核模块中的内核代码的代码调用指令,则判断KPGT中是否创建有K-SPACE中的内核模块对目标内核模块的内核代码的调用权限映射;The CPU detects the code call instruction issued by the kernel module in the K-SPACE for the kernel code in the target kernel module, and determines whether the KPGT creates a call permission mapping of the kernel module of the target kernel module in the K-SPACE kernel module. ;
CPU判断出KPGT中未创建有K-SPACE中的内核模块对目标内核模块的内核代码的调用权限映射,则产生页表中断事件M1;The CPU determines that the KPGT does not create a call permission mapping of the kernel module of the K-SPACE to the kernel code of the target kernel module, and generates a page table interrupt event M1;
VMM捕捉到上述页表中断事件M1,通过预存的页表中断处理函数判断所述K-SPACE中的内核模块是否有权限调用目标内核模块的内核代码,若判断出有权限,则所述VMM根据所述K-SPACE中的内核模块对目标内核模块的内核代码的调用权限映射,将所述VMM当前加载的页表由所述KPGT切换为MPGT,以及执行堆栈切换操作以将虚拟机内核空间加载的堆栈由隔离空间堆栈K-STACK切换为内核空间堆栈M-STACK,此时,系统的代码调用执行流程处于M-SPACE,执行目标内核模块的内核代码。The VMM captures the above page table interrupt event M1, and determines whether the kernel module in the K-SPACE has permission to call the kernel code of the target kernel module through the pre-stored page table interrupt processing function. If it is determined that there is permission, the VMM is based on the VMM. The kernel module in the K-SPACE maps the call permission of the kernel code of the target kernel module, switches the page table currently loaded by the VMM from the KPGT to the MPGT, and performs a stack switch operation to load the virtual machine kernel space The stack is switched from the isolated space stack K-STACK to the kernel space stack M-STACK. At this time, the system code execution flow is in M-SPACE, and the kernel code of the target kernel module is executed.
进一步可选的,上述M-SPACE中的目标内核模块执行完K-SPACE中的内核模块所调用的内核代码之后,虚拟机代码调用执行流程需要从目标内核模块返回到K-SPACE中,具体包括以下步骤:Further optionally, after the target kernel module in the above M-SPACE executes the kernel code invoked by the kernel module in the K-SPACE, the virtual machine code calling execution process needs to be returned from the target kernel module to the K-SPACE, including The following steps:
CPU检测到目标内核模块发出的返回ret指令,判断MPGT中是否创建有目标内核模块对K-SPACE中的内核代码的调用权限映射;The CPU detects the return ret command issued by the target kernel module, and determines whether the target permission of the target kernel module to the kernel code in the K-SPACE is created in the MPGT;
CPU判断出MPGT中未创建目标内核模块对K-SPACE中的内核代码的调用权限映射,产生页表中断事件M2;The CPU determines that the calling kernel mapping of the target kernel module to the kernel code in the K-SPACE is not created in the MPGT, and generates a page table interrupt event M2;
VMM捕捉到上述页表中断事件M2,通过预存的页表中断处理函数判断所述目标内核模块是否有权限调用上述K-SPACE中的内核模块中的内核代码,若 判断出有权限,则上述VMM根据所述目标内核模块对K-SPACE中的内核代码的调用权限映射,将所述VMM当前加载的页表由所述MPGT切换为所述KPGT,以及执行堆栈切换操作以将虚拟机内核空间加载的堆栈由隔离空间堆栈M-STACK切换为内核空间堆栈K-STACK,此时,虚拟机的代码调用执行流程返回到K-SPACE中。The VMM captures the above page table interrupt event M2, and determines whether the target kernel module has permission to invoke the kernel code in the kernel module in the K-SPACE through the pre-stored page table interrupt processing function. Determining that there is permission, the VMM switches the page table currently loaded by the VMM from the MPGT to the KPGT, and performs a stack switch according to the calling authority mapping of the target kernel module to the kernel code in the K-SPACE. The operation is to switch the stack loaded by the virtual machine kernel space from the isolated space stack M-STACK to the kernel space stack K-STACK. At this time, the code of the virtual machine calls the execution flow and returns to the K-SPACE.
参阅图8,图8是本发明实施例公开的一种VMM的结构示意图,用于控制M-SPACE中的目标内核模块对K-SPACE中的内核数据的访问,如图8所示,该VMM包括事件捕获单元801、权限判断单元802、权限创建单元803,其中,Referring to FIG. 8, FIG. 8 is a schematic structural diagram of a VMM according to an embodiment of the present invention, which is used to control access of kernel data in a K-SPACE by a target kernel module in an M-SPACE, as shown in FIG. An event capture unit 801, a rights determination unit 802, and a rights creation unit 803, where
所述事件捕获单元801,用于捕获页表中断事件,所述页表中断事件是由CPU在检测到目标内核模块发送的针对内核空间K-SPACE中的内核数据的访问请求之后、且判断出隔离空间页表MPGT中未创建所述目标内核模块对所述K-SPACE中的内核数据的访问权限映射的情况下产生的,其中,所述VMM对应的虚拟机内核空间包括所述K-SPACE和隔离空间M-SPACE,所述M-SPACE包括所述目标内核模块和所述MPGT,所述MPGT用于支持所述目标内核模块的运行;The event capture unit 801 is configured to capture a page table interrupt event, and the page table interrupt event is determined by the CPU after detecting an access request for kernel data in the kernel space K-SPACE sent by the target kernel module. And generating, in the isolated space page table MPGT, the access authority mapping of the target kernel module to the kernel data in the K-SPACE, wherein the virtual machine kernel space corresponding to the VMM includes the K-SPACE And an isolation space M-SPACE, the M-SPACE including the target kernel module and the MPGT, the MPGT being used to support operation of the target kernel module;
本发明实施例中,上述MPGT中创建有所述目标内核模块对所述M-SPACE中的内核数据的访问权限映射,以使得所述目标内核模块有权限访问所述M-SPACE中的内核数据。In the embodiment of the present invention, the access authority mapping of the target kernel module to the kernel data in the M-SPACE is created in the MPGT, so that the target kernel module has the right to access the kernel data in the M-SPACE. .
所述权限判断单元802,用于通过预存的页表中断处理函数判断所述目标内核模块是否有权限访问所述K-SPACE中的内核数据;The authority determining unit 802 is configured to determine, by using a pre-stored page table interrupt processing function, whether the target kernel module has permission to access kernel data in the K-SPACE;
所述权限创建单元803,用于当所述权限判断单元通过预存的页表中断处理函数判断出所述目标内核模块有权限访问所述K-SPACE中的内核数据时,在所述MPGT中创建所述目标内核模块对所述K-SPACE中的内核数据的访问权限映射,以使得所述目标内核模块有权限访问所述K-SPACE中的内核数据。The permission creation unit 803 is configured to create in the MPGT when the permission determination unit determines that the target kernel module has permission to access kernel data in the K-SPACE through a pre-stored page table interrupt processing function. The target kernel module maps access rights to the kernel data in the K-SPACE such that the target kernel module has permission to access kernel data in the K-SPACE.
可以理解的是,本发明实施例的VMM的各功能模块的功能可根据上述方法实施例中的方法具体实现,其具体实现过程可以参照上述方法实施例的相关描述,此处不再赘述。It is to be understood that the functions of the functional modules of the VMM in the embodiments of the present invention may be specifically implemented according to the method in the foregoing method embodiments. For the specific implementation process, refer to the related description of the foregoing method embodiments, and details are not described herein again.
可以看出,本发明实施例中,VMM首先捕获页表中断事件,其次,VMM 通过预存的页表中断处理函数判断目标内核模块是否有权限访问K-SPACE中的内核数据,最后,当VMM通过预存的页表中断处理函数判断出目标内核模块有权限访问K-SPACE中的内核数据时,VMM在MPGT中创建目标内核模块对K-SPACE中的内核数据的访问权限映射,以使得目标内核模块有权限访问K-SPACE中的内核数据。由于上述页表中断事件是CPU在检测到目标内核模块发送的针对内核空间K-SPACE中的内核数据的访问请求之后、且判断出隔离空间页表MPGT中未创建目标内核模块对所述K-SPACE中的内核数据的访问权限映射的情况下产生的,可见,目标内核模块无权限直接访问K-SPACE空间中内核数据,从而能够避免目标内核模块在安全性未知的情况下肆意访问K-SPACE中的内核数据,有利于提升系统内核数据访问的安全性。It can be seen that in the embodiment of the present invention, the VMM first captures the page table interrupt event, and secondly, the VMM The pre-stored page table interrupt processing function determines whether the target kernel module has permission to access the kernel data in K-SPACE. Finally, when the VMM uses the pre-stored page table interrupt processing function to determine that the target kernel module has permission to access the kernel in K-SPACE. In the case of data, the VMM creates an access authority mapping of the target kernel module to the kernel data in the K-SPACE in the MPGT, so that the target kernel module has access to the kernel data in the K-SPACE. Since the above page table interrupt event is that the CPU detects the access request for the kernel data in the kernel space K-SPACE sent by the target kernel module, and determines that the target kernel module is not created in the isolated space page table MPGT, the K- In the case of the access rights mapping of kernel data in SPACE, it can be seen that the target kernel module has no permission to directly access the kernel data in the K-SPACE space, thereby avoiding the target kernel module from accessing K-SPACE without security. The kernel data in the kernel helps to improve the security of system kernel data access.
同时,由于VMM相对于虚拟机操作系统拥有更高的运行权限,故而在虚拟化环境下,具备更高特权级VMM在执行权限上与虚拟机之间相互隔离,不会受到虚拟机的直接攻击。At the same time, because the VMM has higher running rights than the virtual machine operating system, in the virtualized environment, the VMM with higher privilege level is isolated from the virtual machine in execution permission, and is not directly attacked by the virtual machine. .
同时,由于VMM具有客户机平台无关性,可以同时对多个不同类型的客户操作系统的内核模块进行隔离。At the same time, because VMM has client platform independence, it can isolate kernel modules of several different types of guest operating systems at the same time.
可选的,本发明实施例中,上述权限判断单元802具体用于:Optionally, in the embodiment of the present invention, the foregoing authority determining unit 802 is specifically configured to:
通过预存的页表中断函数获取所述页表中断事件对应的预设权限判断策略,并获取所述K-SPACE中的内核数据的虚拟地址分布信息;Acquiring a preset permission judgment policy corresponding to the page table interrupt event by using a pre-stored page table interrupt function, and acquiring virtual address distribution information of the kernel data in the K-SPACE;
确定所述页表中断事件的事件类型;Determining the type of event of the page table interrupt event;
根据所述预设权限判断策略、所述虚拟地址分布信息以及所述事件类型判断所述目标内核模块是否有权限访问所述K-SPACE中的内核数据。Determining, according to the preset authority determination policy, the virtual address distribution information, and the event type, whether the target kernel module has permission to access kernel data in the K-SPACE.
可选的,本发明实施例中,上述VMM还包括:Optionally, in the embodiment of the present invention, the foregoing VMM further includes:
地址映射单元,用于在所述事件捕获单元捕获页表中断事件之前之前,根据预存的所述虚拟机内核空间的空间页表将所述目标内核模块的虚拟地址分布信息映射为物理地址分布信息,其中,所述目标内核模块为从所述虚拟机内核空间中插入的N个内核模块中选取的需要被隔离的内核模块,所述N为正整数;An address mapping unit, configured to map virtual address distribution information of the target kernel module to physical address distribution information according to a pre-stored space page table of the virtual machine kernel space before the event capture unit captures a page table interrupt event The target kernel module is a kernel module selected from N kernel modules inserted in the virtual machine kernel space, and the N is a positive integer;
空间分隔单元,用于基于所述物理地址分布信息分隔所述虚拟机内核空间 为所述M-SPACE和所述K-SPACE;a space separating unit, configured to separate the virtual machine kernel space based on the physical address distribution information For the M-SPACE and the K-SPACE;
页表创建单元,用于标记所述虚拟机内核空间的空间页表为内核空间页表KPGT,并基于所述物理地址分布信息创建所述MPGT,其中,所述KPGT用于支持所述K-SPACE中的内核模块的运行,所述K-SPACE中的内核模块包括所述虚拟机内核空间中的基础内核模块和所述N个内核模块中除所述目标内核模块之外的内核模块。a page table creation unit, configured to mark a space page table of the virtual machine kernel space as a kernel space page table KPGT, and create the MPGT based on the physical address distribution information, wherein the KPGT is used to support the K- The kernel module in the SPACE includes a base kernel module in the virtual machine kernel space and a kernel module other than the target kernel module among the N kernel modules.
参阅图9,图9是本发明实施例公开的一种VMM的结构示意图,用于控制M-SPACE中的目标内核模块对K-SPACE中的内核代码的调用,如图9所示,该VMM包括事件捕获单元901、权限判断单元902、切换单元903,其中,Referring to FIG. 9, FIG. 9 is a schematic structural diagram of a VMM according to an embodiment of the present invention, for controlling a call of a target kernel module in an M-SPACE to a kernel code in a K-SPACE, as shown in FIG. An event capture unit 901, a rights determination unit 902, and a switching unit 903, where
所述事件捕获单元901,用于捕获页表中断事件,所述页表中断事件是由中央处理单元CPU在检测到目标内核模块针对内核空间K-SPACE中的内核代码的调用请求之后、且判断出隔离空间页表MPGT中未创建所述目标内核模块对所述K-SPACE中的内核代码的调用权限映射的情况下生成的,其中,所述VMM对应的虚拟机内核空间包括所述K-SPACE和隔离空间M-SPACE,所述M-SPACE包括所述目标内核模块和所述MPGT,所述MPGT用于支持所述目标内核模块的运行;The event capture unit 901 is configured to capture a page table interrupt event, and the page table interrupt event is determined by the central processing unit CPU after detecting a call request of the target kernel module for the kernel code in the kernel space K-SPACE. And generating, in the isolated space page table MPGT, the target kernel module does not create a call permission mapping of the kernel code in the K-SPACE, wherein the virtual machine kernel space corresponding to the VMM includes the K- SPACE and an isolated space M-SPACE, the M-SPACE including the target kernel module and the MPGT, the MPGT being used to support operation of the target kernel module;
本发明实施例中,上述MPGT中创建有所述目标内核模块对所述M-SPACE中的内核代码的调用权限映射,以使得所述目标内核模块有权限调用所述M-SPACE中的内核代码。In the embodiment of the present invention, the call authority mapping of the target kernel module to the kernel code in the M-SPACE is created in the MPGT, so that the target kernel module has permission to invoke the kernel code in the M-SPACE. .
所述权限判断单元902,用于通过预存的页表中断处理函数判断所述目标内核模块是否有权限调用所述K-SPACE中的内核代码;The authority determining unit 902 is configured to determine, by using a pre-stored page table interrupt processing function, whether the target kernel module has permission to invoke the kernel code in the K-SPACE;
所述切换单元903,用于当所述权限判断单元通过预存的页表中断处理函数判断出所述目标内核模块有权限调用所述K-SPACE中的内核代码时,根据所述目标内核模块对所述K-SPACE中的内核代码的调用权限映射,执行页表切换操作和堆栈切换操作以将所述虚拟机内核空间的堆栈由隔离空间堆栈M-STACK切换为内核空间堆栈K-STACK,以使得所述目标内核模块基于切换后的所述K-STACK调用所述K-SPACE中的内核代码。The switching unit 903 is configured to: when the authority determining unit determines, by using a pre-stored page table interrupt processing function, that the target kernel module has permission to invoke the kernel code in the K-SPACE, according to the target kernel module pair The call permission mapping of the kernel code in the K-SPACE, performing a page table switching operation and a stack switching operation to switch the stack of the virtual machine kernel space from the isolation space stack M-STACK to the kernel space stack K-STACK, The target kernel module is caused to call the kernel code in the K-SPACE based on the K-STACK after the handover.
可以看出,本发明实施例中,VMM首先捕获页表中断事件,其次,当VMM 通过预存的页表中断处理函数判断出目标内核模块有权限调用K-SPACE中的内核代码时,VMM根据目标内核模块对K-SPACE中的内核代码的调用权限映射,执行页表切换操作和堆栈切换操作以将虚拟机内核空间的堆栈由隔离空间堆栈M-STACK切换为内核空间堆栈K-STACK,以使得所述目标内核模块基于切换后的所述K-STACK调用所述K-SPACE中的内核代码。其中,上述页表中断事件是CPU在检测到目标内核模块针对内核空间K-SPACE中的内核代码的调用请求之后、且判断出隔离空间页表MPGT中未创建目标内核模块对K-SPACE中的内核代码的调用权限映射的情况下生成的,可见,目标内核模块无权限直接调用K-SPACE中的内核代码,能够避免目标内核模块在安全性未知的情况下肆意调用K-SPACE中的内核代码,有利于提升系统内核代码调用的安全性。It can be seen that in the embodiment of the present invention, the VMM first captures the page table interrupt event, and secondly, when the VMM When the pre-stored page table interrupt processing function determines that the target kernel module has permission to call the kernel code in the K-SPACE, the VMM performs the page table switching operation and the stack according to the calling authority mapping of the target kernel module to the kernel code in the K-SPACE. Switching operation to switch the stack of virtual machine kernel space from the isolated space stack M-STACK to the kernel space stack K-STACK, such that the target kernel module invokes the K-SPACE based on the K-STACK after the handover Kernel code. The page table interrupt event is that after the CPU detects the call request of the target kernel module for the kernel code in the kernel space K-SPACE, and determines that the target kernel module is not created in the isolated space page table MPGT in the K-SPACE The kernel code's call permission mapping is generated. It can be seen that the target kernel module has no permission to directly call the kernel code in K-SPACE, which can avoid the target kernel module inadvertently calling the kernel code in K-SPACE if the security is unknown. It is beneficial to improve the security of system kernel code calls.
同时,由于VMM相对于虚拟机操作系统拥有更高的运行权限,故而在虚拟化环境下,具备更高特权级VMM在执行权限上与虚拟机之间相互隔离,不会受到虚拟机的直接攻击。At the same time, because the VMM has higher running rights than the virtual machine operating system, in the virtualized environment, the VMM with higher privilege level is isolated from the virtual machine in execution permission, and is not directly attacked by the virtual machine. .
同时,由于VMM具有客户机平台无关性,可以同时对多个不同类型的客户操作系统的内核模块进行隔离。At the same time, because VMM has client platform independence, it can isolate kernel modules of several different types of guest operating systems at the same time.
可选的,本发明实施例中,上述权限判断单元902具体用于:Optionally, in the embodiment of the present invention, the foregoing authority determining unit 902 is specifically configured to:
通过预存的页表中断函数获取所述页表中断事件对应的预设权限判断策略,并获取所述K-SPACE中的内核代码的虚拟地址分布信息;Acquiring a preset permission judgment policy corresponding to the page table interrupt event by using a pre-stored page table interrupt function, and acquiring virtual address distribution information of the kernel code in the K-SPACE;
根据获取的所述预设权限判断策略和所述虚拟地址分布信息判断所述目标内核模块是否有权限访问所述K-SPACE中的内核代码。Determining, according to the obtained preset permission judgment policy and the virtual address distribution information, whether the target kernel module has permission to access the kernel code in the K-SPACE.
可选的,本发明实施例中,上述切换单元903具体用于:Optionally, in the embodiment of the present invention, the foregoing switching unit 903 is specifically configured to:
将所述VMM当前加载的页表由所述MPGT切换为内核空间页表KPGT,其中,所述KPGT用于支持所述K-SPACE中的内核模块的运行,所述K-SPACE中包括所述虚拟机内核空间中的基础内核模块、所述虚拟机内核空间中插入的N个内核模块中除所述目标内核模块之外的内核模块以及所述KPGT,所述N为大于1的正整数。Converting a page table currently loaded by the VMM from the MPGT to a kernel space page table KPGT, wherein the KPGT is configured to support operation of a kernel module in the K-SPACE, the K-SPACE including the The base kernel module in the virtual machine kernel space, the kernel module other than the target kernel module among the N kernel modules inserted in the virtual machine kernel space, and the KPGT, the N is a positive integer greater than 1.
可选的,本发明实施例中,上述切换单元903具体用于: Optionally, in the embodiment of the present invention, the foregoing switching unit 903 is specifically configured to:
拷贝M-STACK中存储的用于传递所述K-SPACE中的内核代码的代码参数和用于调用所述K-SPACE中的内核代码的返回地址RIP;Copying a code parameter stored in the M-STACK for transferring the kernel code in the K-SPACE and a return address RIP for calling the kernel code in the K-SPACE;
在所述K-STACK中写入所述代码参数和所述RIP;Writing the code parameter and the RIP in the K-STACK;
将所述虚拟机内核空间当前使用的堆栈由esp-old位置转变为esp-new位置,其中,所述esp-old位置为所述RIP在所述M-STACK中的存储位置,所述esp-new位置为所述RIP在所述K-STACK中的存储位置。Converting the stack currently used by the virtual machine kernel space from an esp-old location to an esp-new location, wherein the esp-old location is a storage location of the RIP in the M-STACK, the esp- The new location is the storage location of the RIP in the K-STACK.
可选的,本发明实施例中,上述VMM还包括:Optionally, in the embodiment of the present invention, the foregoing VMM further includes:
地址映射单元,用于在所述事件捕获单元捕获页表中断事件之前,根据预存的所述虚拟机内核空间的空间页表将目标内核模块的虚拟地址分布信息映射为物理地址分布信息,其中,所述目标内核模块为从所述虚拟机内核空间中插入的N个内核模块中选取的需要被隔离的内核模块,所述N为大于1的正整数;An address mapping unit, configured to: before the event capture unit captures the page table interrupt event, map the virtual address distribution information of the target kernel module to the physical address distribution information according to the pre-stored space page table of the virtual machine kernel space, where The target kernel module is a kernel module selected from N kernel modules inserted in the virtual machine kernel space, and the N is a positive integer greater than 1.
空间分隔单元,用于基于所述物理地址分布信息分隔所述虚拟机内核空间为所述M-SPACE和所述K-SPACE;a space separating unit, configured to separate the virtual machine kernel space into the M-SPACE and the K-SPACE based on the physical address distribution information;
页表创建单元,用于标记所述虚拟机内核空间的空间页表为内核空间页表KPGT,并基于所述物理地址分布信息创建所述MPGT。a page table creation unit that marks a space page table of the virtual machine kernel space as a kernel space page table KPGT, and creates the MPGT based on the physical address distribution information.
参阅图10,图10是本发明实施例公开的一种VMM的结构示意图,如图10所示,该VMM可以包括:至少一个处理器1001,例如CPU,至少一个存储器1002,至少一个通信总线1003。通信总线1003用于实现处理器1001和存储器1002之间的连接通信,其中,存储器1002可能包含高速RAM存储器,也可能还包括非易失性存储器(non-volatile memory),例如至少一个磁盘存储器。Referring to FIG. 10, FIG. 10 is a schematic structural diagram of a VMM according to an embodiment of the present invention. As shown in FIG. 10, the VMM may include: at least one processor 1001, such as a CPU, at least one memory 1002, and at least one communication bus 1003. . The communication bus 1003 is used to implement connection communication between the processor 1001 and the memory 1002, wherein the memory 1002 may include a high speed RAM memory, and may also include a non-volatile memory such as at least one disk memory.
在一些实施方式中,存储器1002存储了如下的元素(可执行模块或者数据结构,或者他们的子集,或者他们的扩展集):In some implementations, the memory 1002 stores the following elements (executable modules or data structures, or a subset of them, or their extended set):
操作系统10021,包含各种系统程序,用于实现各种基础业务以及处理基于硬件的任务;An operating system 10021, including various system programs for implementing various basic services and processing hardware-based tasks;
应用程序10022,包含设备控制服务程序、设备识别服务程序等各种应用程序,用于实现各种应用业务。The application 10022 includes various applications such as a device control service program and a device identification service program for implementing various application services.
具体地,处理器1001用于调用存储器1002中存储的程序,执行以下操作: Specifically, the processor 1001 is configured to invoke a program stored in the memory 1002 to perform the following operations:
上述处理器1001捕获页表中断事件,所述页表中断事件是由CPU在检测到目标内核模块发送的针对内核空间K-SPACE中的内核数据的访问请求之后、且判断出隔离空间页表MPGT中未创建所述目标内核模块对所述K-SPACE中的内核数据的访问权限映射的情况下产生的,其中,所述VMM对应的虚拟机内核空间包括所述K-SPACE和隔离空间M-SPACE,所述M-SPACE包括所述目标内核模块和所述MPGT,所述MPGT用于支持所述目标内核模块的运行;The processor 1001 captures a page table interrupt event, and the page table interrupt event is determined by the CPU after detecting the access request for the kernel data in the kernel space K-SPACE sent by the target kernel module, and determining the isolated space page table MPGT The virtual machine kernel space corresponding to the VMM and the isolated space M- SPACE, the M-SPACE includes the target kernel module and the MPGT, and the MPGT is configured to support operation of the target kernel module;
本发明实施例中,上述MPGT中创建有所述目标内核模块对所述M-SPACE中的内核数据的访问权限映射,以使得所述目标内核模块有权限访问所述M-SPACE中的内核数据。In the embodiment of the present invention, the access authority mapping of the target kernel module to the kernel data in the M-SPACE is created in the MPGT, so that the target kernel module has the right to access the kernel data in the M-SPACE. .
上述处理器1001通过预存的页表中断处理函数判断所述目标内核模块是否有权限访问所述K-SPACE中的内核数据;The processor 1001 determines, by using a pre-stored page table interrupt processing function, whether the target kernel module has permission to access kernel data in the K-SPACE;
上述处理器1001当通过预存的页表中断处理函数判断出所述目标内核模块有权限访问所述K-SPACE中的内核数据时,在所述MPGT中创建所述目标内核模块对所述K-SPACE中的内核数据的访问权限映射,以使得所述目标内核模块有权限访问所述K-SPACE中的内核数据。The processor 1001, when the pre-stored page table interrupt processing function determines that the target kernel module has permission to access the kernel data in the K-SPACE, creates the target kernel module in the MPGT to the K- The access rights mapping of the kernel data in the SPACE is such that the target kernel module has access to the kernel data in the K-SPACE.
可以看出,本发明实施例中,VMM首先捕获页表中断事件,其次,VMM通过预存的页表中断处理函数判断目标内核模块是否有权限访问K-SPACE中的内核数据,最后,当VMM通过预存的页表中断处理函数判断出目标内核模块有权限访问K-SPACE中的内核数据时,VMM在MPGT中创建目标内核模块对K-SPACE中的内核数据的访问权限映射,以使得目标内核模块有权限访问K-SPACE中的内核数据。由于上述页表中断事件是CPU在检测到目标内核模块发送的针对内核空间K-SPACE中的内核数据的访问请求之后、且判断出隔离空间页表MPGT中未创建目标内核模块对所述K-SPACE中的内核数据的访问权限映射的情况下产生的,可见,目标内核模块无权限直接访问K-SPACE空间中内核数据,从而能够避免目标内核模块在安全性未知的情况下肆意访问K-SPACE中的内核数据,有利于提升系统内核数据访问的安全性。It can be seen that, in the embodiment of the present invention, the VMM first captures the page table interrupt event, and secondly, the VMM determines whether the target kernel module has access to the kernel data in the K-SPACE through the pre-stored page table interrupt processing function, and finally, when the VMM passes When the pre-stored page table interrupt processing function determines that the target kernel module has permission to access the kernel data in the K-SPACE, the VMM creates an access authority mapping of the target kernel module to the kernel data in the K-SPACE in the MPGT, so that the target kernel module Have access to kernel data in K-SPACE. Since the above page table interrupt event is that the CPU detects the access request for the kernel data in the kernel space K-SPACE sent by the target kernel module, and determines that the target kernel module is not created in the isolated space page table MPGT, the K- In the case of the access rights mapping of kernel data in SPACE, it can be seen that the target kernel module has no permission to directly access the kernel data in the K-SPACE space, thereby avoiding the target kernel module from accessing K-SPACE without security. The kernel data in the kernel helps to improve the security of system kernel data access.
同时,由于VMM相对于虚拟机操作系统拥有更高的运行权限,故而在虚拟化环境下,具备更高特权级VMM在执行权限上与虚拟机之间相互隔离,不 会受到虚拟机的直接攻击。At the same time, because the VMM has higher running rights than the virtual machine operating system, in the virtualized environment, the VMM with higher privilege level is isolated from the virtual machine in execution permission, Will be directly attacked by the virtual machine.
同时,由于VMM具有客户机平台无关性,可以同时对多个不同类型的客户操作系统的内核模块进行隔离。At the same time, because VMM has client platform independence, it can isolate kernel modules of several different types of guest operating systems at the same time.
可选的,本发明实施例中,上述处理器1001通过预存的页表中断处理函数判断所述目标内核模块是否有权限访问所述K-SPACE中的内核数据的具体方式为:处理器1001首先通过预存的页表中断函数获取所述页表中断事件对应的预设权限判断策略,并获取所述K-SPACE中的内核数据的虚拟地址分布信息;其次,处理器1001确定所述页表中断事件的事件类型;最后,处理器1001根据所述预设权限判断策略、所述虚拟地址分布信息以及所述事件类型判断所述目标内核模块是否有权限访问所述K-SPACE中的内核数据。Optionally, in the embodiment of the present invention, the processor 1001 determines, by using a pre-stored page table interrupt processing function, whether the target kernel module has the right to access the kernel data in the K-SPACE: the processor 1001 first Acquiring a preset permission judgment policy corresponding to the page table interrupt event by using a pre-stored page table interrupt function, and acquiring virtual address distribution information of the kernel data in the K-SPACE; secondly, the processor 1001 determines that the page table is interrupted The event type of the event; finally, the processor 1001 determines, according to the preset authority determination policy, the virtual address distribution information, and the event type, whether the target kernel module has permission to access kernel data in the K-SPACE.
可选的,本发明实施例中,上述处理器1001捕获页表中断事件之前,还可以执行以下操作以针对目标内核模块创建内核空间隔离机制:Optionally, in the embodiment of the present invention, before the processor 1001 captures the page table interrupt event, the following operations may also be performed to create a kernel space isolation mechanism for the target kernel module:
上述处理器1001根据预存的所述虚拟机内核空间的空间页表将所述目标内核模块的虚拟地址分布信息映射为物理地址分布信息,其中,所述目标内核模块为从所述虚拟机内核空间中插入的N个内核模块中选取的需要被隔离的内核模块,所述N为正整数;The processor 1001 maps virtual address distribution information of the target kernel module to physical address distribution information according to a pre-stored space page table of the virtual machine kernel space, where the target kernel module is from the virtual machine kernel space. a kernel module selected to be isolated among the N kernel modules inserted, and the N is a positive integer;
上述处理器1001基于所述物理地址分布信息分隔所述虚拟机内核空间为所述M-SPACE和所述K-SPACE;The processor 1001 separates the virtual machine kernel space into the M-SPACE and the K-SPACE based on the physical address distribution information;
上述处理器1001标记所述虚拟机内核空间的空间页表为内核空间页表KPGT,并基于所述物理地址分布信息创建所述MPGT,其中,所述KPGT用于支持所述K-SPACE中的内核模块的运行,所述K-SPACE中的内核模块包括所述虚拟机内核空间中的基础内核模块和所述N个内核模块中除所述目标内核模块之外的内核模块。The processor 1001 marks a space page table of the virtual machine kernel space as a kernel space page table KPGT, and creates the MPGT based on the physical address distribution information, wherein the KPGT is used to support the K-SPACE. The operation of the kernel module, the kernel module in the K-SPACE includes a base kernel module in the virtual machine kernel space and a kernel module other than the target kernel module among the N kernel modules.
参阅图11,图11是本发明实施例公开的一种代码调用装置的结构示意图,如图11所示,该代码调用装置可以包括:至少一个处理器1001,例如CPU,至少一个存储器1002,至少一个通信总线1003。通信总线1003用于实现处理器1001和存储器1002之间的连接通信,其中,存储器1002可能包含高速RAM存储器,也可能还包括非易失性存储器(non-volatile memory),例如至少一个磁 盘存储器。Referring to FIG. 11, FIG. 11 is a schematic structural diagram of a code invoking device according to an embodiment of the present invention. As shown in FIG. 11, the code invoking device may include: at least one processor 1001, such as a CPU, at least one memory 1002, at least A communication bus 1003. The communication bus 1003 is used to implement connection communication between the processor 1001 and the memory 1002, wherein the memory 1002 may include a high speed RAM memory, and may also include a non-volatile memory, such as at least one magnetic Disk storage.
在一些实施方式中,存储器1002存储了如下的元素(可执行模块或者数据结构,或者他们的子集,或者他们的扩展集):In some implementations, the memory 1002 stores the following elements (executable modules or data structures, or a subset of them, or their extended set):
操作系统10021,包含各种系统程序,用于实现各种基础业务以及处理基于硬件的任务;An operating system 10021, including various system programs for implementing various basic services and processing hardware-based tasks;
应用程序10022,包含设备控制服务程序、设备识别服务程序等各种应用程序,用于实现各种应用业务。The application 10022 includes various applications such as a device control service program and a device identification service program for implementing various application services.
具体地,处理器1001用于调用存储器1002中存储的程序,执行以下操作:Specifically, the processor 1001 is configured to invoke a program stored in the memory 1002 to perform the following operations:
上述处理器1001捕获页表中断事件,所述页表中断事件是由中央处理单元CPU在检测到目标内核模块针对内核空间K-SPACE中的内核代码的调用请求之后、且判断出隔离空间页表MPGT中未创建所述目标内核模块对所述K-SPACE中的内核代码的调用权限映射的情况下生成的,其中,所述VMM对应的虚拟机内核空间包括所述K-SPACE和隔离空间M-SPACE,所述M-SPACE包括所述目标内核模块和所述MPGT,所述MPGT用于支持所述目标内核模块的运行;The processor 1001 captures a page table interrupt event, and the page table interrupt event is determined by the central processing unit CPU after detecting the target kernel module's call request for the kernel code in the kernel space K-SPACE, and determines the isolated space page table. The virtual machine kernel space corresponding to the VMM corresponding to the kernel code in the K-SPACE is generated in the MPGT, and the K-SPACE and the isolation space M are included. - SPACE, the M-SPACE includes the target kernel module and the MPGT, the MPGT is used to support operation of the target kernel module;
本发明实施例中,上述MPGT中创建有所述目标内核模块对所述M-SPACE中的内核代码的调用权限映射,以使得所述目标内核模块有权限调用所述M-SPACE中的内核代码。In the embodiment of the present invention, the call authority mapping of the target kernel module to the kernel code in the M-SPACE is created in the MPGT, so that the target kernel module has permission to invoke the kernel code in the M-SPACE. .
上述处理器1001通过预存的页表中断处理函数判断所述目标内核模块是否有权限调用所述K-SPACE中的内核代码;The processor 1001 determines, by using a pre-stored page table interrupt processing function, whether the target kernel module has permission to invoke the kernel code in the K-SPACE;
上述处理器1001当所述VMM通过预存的页表中断处理函数判断出所述目标内核模块有权限调用所述K-SPACE中的内核代码时,所述VMM根据所述目标内核模块对所述K-SPACE中的内核代码的调用权限映射,执行页表切换操作和堆栈切换操作以将所述虚拟机内核空间的堆栈由隔离空间堆栈M-STACK切换为内核空间堆栈K-STACK,以使得所述目标内核模块基于切换后的所述K-STACK调用所述K-SPACE中的内核代码。The processor 1001, when the VMM determines, by the pre-stored page table interrupt processing function, that the target kernel module has permission to invoke the kernel code in the K-SPACE, the VMM according to the target kernel module to the K a call permission mapping of kernel code in -SPACE, performing a page table switching operation and a stack switching operation to switch the stack of the virtual machine kernel space from the isolated space stack M-STACK to a kernel space stack K-STACK, such that The target kernel module calls the kernel code in the K-SPACE based on the K-STACK after the handover.
可选的,本发明实施例中,VMM首先捕获页表中断事件,其次,当VMM通过预存的页表中断处理函数判断出目标内核模块有权限调用K-SPACE中的 内核代码时,VMM根据目标内核模块对K-SPACE中的内核代码的调用权限映射,执行页表切换操作和堆栈切换操作以将虚拟机内核空间的堆栈由隔离空间堆栈M-STACK切换为内核空间堆栈K-STACK,以使得所述目标内核模块基于切换后的所述K-STACK调用所述K-SPACE中的内核代码。其中,上述页表中断事件是CPU在检测到目标内核模块针对内核空间K-SPACE中的内核代码的调用请求之后、且判断出隔离空间页表MPGT中未创建目标内核模块对K-SPACE中的内核代码的调用权限映射的情况下生成的,可见,目标内核模块无权限直接调用K-SPACE中的内核代码,能够避免目标内核模块在安全性未知的情况下肆意调用K-SPACE中的内核代码,有利于提升系统内核代码调用的安全性。Optionally, in the embodiment of the present invention, the VMM first captures the page table interrupt event, and secondly, when the VMM uses the pre-stored page table interrupt processing function to determine that the target kernel module has permission to invoke the K-SPACE. In the kernel code, the VMM performs a page table switching operation and a stack switching operation to switch the stack of the virtual machine kernel space from the isolated space stack M-STACK to the kernel space according to the target permission of the target kernel module to the kernel code in the K-SPACE. The K-STACK is stacked such that the target kernel module invokes the kernel code in the K-SPACE based on the K-STACK after the handover. The page table interrupt event is that after the CPU detects the call request of the target kernel module for the kernel code in the kernel space K-SPACE, and determines that the target kernel module is not created in the isolated space page table MPGT in the K-SPACE The kernel code's call permission mapping is generated. It can be seen that the target kernel module has no permission to directly call the kernel code in K-SPACE, which can avoid the target kernel module inadvertently calling the kernel code in K-SPACE if the security is unknown. It is beneficial to improve the security of system kernel code calls.
同时,由于VMM相对于虚拟机操作系统拥有更高的运行权限,故而在虚拟化环境下,具备更高特权级VMM在执行权限上与虚拟机之间相互隔离,不会受到虚拟机的直接攻击。At the same time, because the VMM has higher running rights than the virtual machine operating system, in the virtualized environment, the VMM with higher privilege level is isolated from the virtual machine in execution permission, and is not directly attacked by the virtual machine. .
同时,由于VMM具有客户机平台无关性,可以同时对多个不同类型的客户操作系统的内核模块进行隔离。At the same time, because VMM has client platform independence, it can isolate kernel modules of several different types of guest operating systems at the same time.
可选的,本发明实施例中,上述处理器1001VMM捕获页表中断事件之前,还可以执行以下操作以创建针对目标内核模块的隔离机制:Optionally, in the embodiment of the present invention, before the processor 1001VMM captures the page table interrupt event, the following operations may also be performed to create an isolation mechanism for the target kernel module:
上述处理器1001根据预存的所述虚拟机内核空间的空间页表将目标内核模块的虚拟地址分布信息映射为物理地址分布信息,其中,所述目标内核模块为从所述虚拟机内核空间中插入的N个内核模块中选取的需要被隔离的内核模块,所述N为大于1的正整数;The processor 1001 maps virtual address distribution information of the target kernel module to physical address distribution information according to the pre-stored space page table of the virtual machine kernel space, where the target kernel module is inserted from the virtual machine kernel space. a kernel module selected from the N kernel modules to be isolated, wherein N is a positive integer greater than one;
上述处理器1001基于所述物理地址分布信息分隔所述虚拟机内核空间为所述M-SPACE和所述K-SPACE;The processor 1001 separates the virtual machine kernel space into the M-SPACE and the K-SPACE based on the physical address distribution information;
上述处理器1001标记所述虚拟机内核空间的空间页表为内核空间页表KPGT,并基于所述物理地址分布信息创建所述MPGT。The processor 1001 marks the space page table of the virtual machine kernel space as a kernel space page table KPGT, and creates the MPGT based on the physical address distribution information.
可选的,本发明实施例中,上述处理器1001通过预存的页表中断处理函数判断所述目标内核模块是否有权限调用所述K-SPACE中的内核代码的具体实施方式为:上述处理器1001通过预存的页表中断函数获取所述页表中断事件对 应的预设权限判断策略,并获取所述K-SPACE中的内核代码的虚拟地址分布信息;根据获取的所述预设权限判断策略和所述虚拟地址分布信息判断所述目标内核模块是否有权限访问所述K-SPACE中的内核代码。Optionally, in the embodiment of the present invention, the processor 1001 determines, by using a pre-stored page table interrupt processing function, whether the target kernel module has permission to invoke the kernel code in the K-SPACE: 1001 obtains the page table interrupt event pair by using a pre-stored page table interrupt function Determining the policy by the preset authority, and obtaining the virtual address distribution information of the kernel code in the K-SPACE; determining whether the target kernel module has the content according to the obtained preset permission judgment policy and the virtual address distribution information Permission to access the kernel code in the K-SPACE.
可选的,本发明实施例中,上述处理器1001执行页表页表切换操作的具体实施方式为:上述处理器1001将所述VMM当前加载的页表由所述MPGT切换为内核空间页表KPGT,其中,所述KPGT用于支持所述K-SPACE中的内核模块的运行,所述K-SPACE中包括所述虚拟机内核空间中的基础内核模块、所述虚拟机内核空间中插入的N个内核模块中除所述目标内核模块之外的内核模块以及所述KPGT,所述N为大于1的正整数。Optionally, in the embodiment of the present invention, the processor 1001 performs a page table page table switching operation, where the processor 1001 switches the page table currently loaded by the VMM from the MPGT to a kernel space page table. KPGT, wherein the KPGT is used to support operation of a kernel module in the K-SPACE, the K-SPACE includes a base kernel module in the virtual machine kernel space, and the virtual machine kernel space is inserted Among the N kernel modules, except for the kernel module other than the target kernel module and the KPGT, the N is a positive integer greater than one.
可选的,本发明实施例中,上述处理器1001执行堆栈切换操作的具体实施方式为:上述处理器1001拷贝M-STACK中存储的用于传递所述K-SPACE中的内核代码的代码参数和用于调用所述K-SPACE中的内核代码的返回地址RIP;在所述K-STACK中写入所述代码参数和所述RIP;将所述虚拟机内核空间当前使用的堆栈由esp-old位置转变为esp-new位置,其中,所述esp-old位置为所述RIP在所述M-STACK中的存储位置,所述esp-new位置为所述RIP在所述K-STACK中的存储位置。Optionally, in the embodiment of the present invention, the processor 1001 performs a stack switching operation, where the processor 1001 copies the code parameters stored in the M-STACK for transmitting the kernel code in the K-SPACE. And a return address RIP for calling the kernel code in the K-SPACE; writing the code parameter and the RIP in the K-STACK; and using the stack currently used by the virtual machine kernel space by esp- The old position is changed to an esp-new position, wherein the esp-old position is a storage location of the RIP in the M-STACK, and the esp-new position is the RIP in the K-STACK storage location.
本领域普通技术人员可以理解上述实施例的各种方法中的全部或部分步骤是可以通过程序来指令相关的硬件来完成,该程序可以存储于一计算机可读存储介质中,存储介质可以包括:闪存盘、只读存储器(Read-Only Memory,ROM)、随机存取器(Random Access Memory,RAM)、磁盘或光盘等。A person skilled in the art may understand that all or part of the various steps of the foregoing embodiments may be performed by a program to instruct related hardware. The program may be stored in a computer readable storage medium, and the storage medium may include: Flash disk, Read-Only Memory (ROM), Random Access Memory (RAM), disk or optical disk.
以上对本发明实施例公开的一种模块隔离、数据访问、代码调用方法、相关装置及系统进行了详细介绍,本文中应用了具体个例对本发明的原理及实施方式进行了阐述,以上实施例的说明只是用于帮助理解本发明的方法及其核心思想;同时,对于本领域的一般技术人员,依据本发明的思想,在具体实施方式及应用范围上均会有改变之处,综上所述,本说明书内容不应理解为对本发明的限制。 The module isolation, data access, code calling method, related device and system disclosed in the embodiments of the present invention are described in detail. The principles and implementation manners of the present invention are described in the following examples. The description is only for helping to understand the method of the present invention and its core idea; at the same time, for those skilled in the art, according to the idea of the present invention, there will be changes in specific embodiments and application scopes. The contents of this specification are not to be construed as limiting the invention.

Claims (20)

  1. 一种数据访问方法,其特征在于,包括:A data access method, comprising:
    虚拟机监视器VMM捕获页表中断事件,所述页表中断事件是由中央处理单元CPU在检测到目标内核模块发送的针对内核空间K-SPACE中的内核数据的访问请求之后、且判断出隔离空间页表MPGT中未创建所述目标内核模块对所述K-SPACE中的内核数据的访问权限映射的情况下产生的,其中,所述VMM对应的虚拟机内核空间包括所述K-SPACE和隔离空间M-SPACE,所述M-SPACE包括所述目标内核模块和所述MPGT,所述MPGT用于支持所述目标内核模块的运行;The virtual machine monitor VMM captures a page table interrupt event, which is determined by the central processing unit CPU after detecting the access request for the kernel data in the kernel space K-SPACE sent by the target kernel module. The virtual page kernel space corresponding to the kernel data in the K-SPACE is not created in the space page table MPGT, wherein the virtual machine kernel space corresponding to the VMM includes the K-SPACE and An isolation space M-SPACE, the M-SPACE including the target kernel module and the MPGT, the MPGT being used to support operation of the target kernel module;
    所述VMM通过预存的页表中断处理函数判断所述目标内核模块是否有权限访问所述K-SPACE中的内核数据;The VMM determines, by using a pre-stored page table interrupt processing function, whether the target kernel module has permission to access kernel data in the K-SPACE;
    当所述VMM通过预存的页表中断处理函数判断出所述目标内核模块有权限访问所述K-SPACE中的内核数据时,所述VMM在所述MPGT中创建所述目标内核模块对所述K-SPACE中的内核数据的访问权限映射,以使得所述目标内核模块有权限访问所述K-SPACE中的内核数据。When the VMM determines, by the pre-stored page table interrupt processing function, that the target kernel module has permission to access kernel data in the K-SPACE, the VMM creates the target kernel module in the MPGT to The access rights mapping of kernel data in K-SPACE is such that the target kernel module has access to the kernel data in the K-SPACE.
  2. 根据权利要求1所述的数据访问方法,其特征在于,所述VMM通过预存的页表中断处理函数判断所述目标内核模块是否有权限访问所述K-SPACE中的内核数据,包括:The data access method according to claim 1, wherein the VMM determines, by the pre-stored page table interrupt processing function, whether the target kernel module has permission to access kernel data in the K-SPACE, including:
    所述VMM通过预存的页表中断函数获取所述页表中断事件对应的预设权限判断策略,并获取所述K-SPACE中的内核数据的虚拟地址分布信息;The VMM obtains a preset permission judgment policy corresponding to the page table interrupt event by using a pre-stored page table interrupt function, and acquires virtual address distribution information of the kernel data in the K-SPACE;
    所述VMM确定所述页表中断事件的事件类型;Determining, by the VMM, an event type of the page table interrupt event;
    所述VMM根据所述预设权限判断策略、所述虚拟地址分布信息以及所述事件类型判断所述目标内核模块是否有权限访问所述K-SPACE中的内核数据。The VMM determines, according to the preset authority determination policy, the virtual address distribution information, and the event type, whether the target kernel module has permission to access kernel data in the K-SPACE.
  3. 根据权利要求1或2任一项所述的数据访问方法,其特征在于,所述VMM捕获页表中断事件之前,所述方法还包括:The data access method according to any one of claims 1 to 2, wherein before the VMM captures a page table interrupt event, the method further includes:
    所述VMM根据预存的所述虚拟机内核空间的空间页表将所述目标内核模块的虚拟地址分布信息映射为物理地址分布信息,其中,所述目标内核模块为从所述虚拟机内核空间中插入的N个内核模块中选取的需要被隔离的内核模 块,所述N为正整数;The VMM maps virtual address distribution information of the target kernel module to physical address distribution information according to a pre-stored space page table of the virtual machine kernel space, where the target kernel module is from the virtual machine kernel space The kernel module selected from the inserted N kernel modules to be isolated Block, the N is a positive integer;
    所述VMM基于所述物理地址分布信息分隔所述虚拟机内核空间为所述M-SPACE和所述K-SPACE;The VMM separates the virtual machine kernel space into the M-SPACE and the K-SPACE based on the physical address distribution information;
    所述VMM标记所述虚拟机内核空间的空间页表为内核空间页表KPGT,并基于所述物理地址分布信息创建所述MPGT,其中,所述KPGT用于支持所述K-SPACE中的内核模块的运行,所述K-SPACE中的内核模块包括所述虚拟机内核空间中的基础内核模块和所述N个内核模块中除所述目标内核模块之外的内核模块。The VMM marks a space page table of the virtual machine kernel space as a kernel space page table KPGT, and creates the MPGT based on the physical address distribution information, wherein the KPGT is used to support a kernel in the K-SPACE The operation of the module, the kernel module in the K-SPACE includes a base kernel module in the virtual machine kernel space and a kernel module other than the target kernel module among the N kernel modules.
  4. 根据权利要求1-3任一项所述的数据访问方法,其特征在于,所述MPGT中创建有所述目标内核模块对所述M-SPACE中的内核数据的访问权限映射,以使得所述目标内核模块有权限访问所述M-SPACE中的内核数据。The data access method according to any one of claims 1 to 3, wherein an access authority mapping of the target kernel module to kernel data in the M-SPACE is created in the MPGT, so that the The target kernel module has access to the kernel data in the M-SPACE.
  5. 一种虚拟机监视器VMM,其特征在于,包括:A virtual machine monitor VMM, comprising:
    事件捕获单元,用于捕获页表中断事件,所述页表中断事件是由CPU在检测到目标内核模块发送的针对内核空间K-SPACE中的内核数据的访问请求之后、且判断出隔离空间页表MPGT中未创建所述目标内核模块对所述K-SPACE中的内核数据的访问权限映射的情况下产生的,其中,所述VMM对应的虚拟机内核空间包括所述K-SPACE和隔离空间M-SPACE,所述M-SPACE包括所述目标内核模块和所述MPGT,所述MPGT用于支持所述目标内核模块的运行;An event capture unit, configured to capture a page table interrupt event, where the page table interrupt event is determined by the CPU after detecting an access request for kernel data in the kernel space K-SPACE sent by the target kernel module, and determining an isolated space page The file MPGT is generated without creating an access authority mapping of the target kernel module to the kernel data in the K-SPACE, wherein the virtual machine kernel space corresponding to the VMM includes the K-SPACE and the isolation space. M-SPACE, the M-SPACE includes the target kernel module and the MPGT, the MPGT is used to support operation of the target kernel module;
    权限判断单元,用于通过预存的页表中断处理函数判断所述目标内核模块是否有权限访问所述K-SPACE中的内核数据;a permission determining unit, configured to determine, by using a pre-stored page table interrupt processing function, whether the target kernel module has permission to access kernel data in the K-SPACE;
    权限创建单元,用于当所述权限判断单元通过预存的页表中断处理函数判断出所述目标内核模块有权限访问所述K-SPACE中的内核数据时,在所述MPGT中创建所述目标内核模块对所述K-SPACE中的内核数据的访问权限映射,以使得所述目标内核模块有权限访问所述K-SPACE中的内核数据。a permission creation unit, configured to create the target in the MPGT when the permission determination unit determines that the target kernel module has permission to access kernel data in the K-SPACE through a pre-stored page table interrupt processing function The kernel module maps access rights to the kernel data in the K-SPACE such that the target kernel module has access to the kernel data in the K-SPACE.
  6. 根据权利要求5所述的VMM,其特征在于,所述权限判断单元具体用于:The VMM according to claim 5, wherein the authority determining unit is specifically configured to:
    通过预存的页表中断函数获取所述页表中断事件对应的预设权限判断策略,并获取所述K-SPACE中的内核数据的虚拟地址分布信息; Acquiring a preset permission judgment policy corresponding to the page table interrupt event by using a pre-stored page table interrupt function, and acquiring virtual address distribution information of the kernel data in the K-SPACE;
    确定所述页表中断事件的事件类型;Determining the type of event of the page table interrupt event;
    根据所述预设权限判断策略、所述虚拟地址分布信息以及所述事件类型判断所述目标内核模块是否有权限访问所述K-SPACE中的内核数据。Determining, according to the preset authority determination policy, the virtual address distribution information, and the event type, whether the target kernel module has permission to access kernel data in the K-SPACE.
  7. 根据权利要求5或6所述的VMM,其特征在于,所述VMM还包括:The VMM according to claim 5 or 6, wherein the VMM further comprises:
    地址映射单元,用于在所述事件捕获单元捕获页表中断事件之前之前,根据预存的所述虚拟机内核空间的空间页表将所述目标内核模块的虚拟地址分布信息映射为物理地址分布信息,其中,所述目标内核模块为从所述虚拟机内核空间中插入的N个内核模块中选取的需要被隔离的内核模块,所述N为正整数;An address mapping unit, configured to map virtual address distribution information of the target kernel module to physical address distribution information according to a pre-stored space page table of the virtual machine kernel space before the event capture unit captures a page table interrupt event The target kernel module is a kernel module selected from N kernel modules inserted in the virtual machine kernel space, and the N is a positive integer;
    空间分隔单元,用于基于所述物理地址分布信息分隔所述虚拟机内核空间为所述M-SPACE和所述K-SPACE;a space separating unit, configured to separate the virtual machine kernel space into the M-SPACE and the K-SPACE based on the physical address distribution information;
    页表创建单元,用于标记所述虚拟机内核空间的空间页表为内核空间页表KPGT,并基于所述物理地址分布信息创建所述MPGT,其中,所述KPGT用于支持所述K-SPACE中的内核模块的运行,所述K-SPACE中的内核模块包括所述虚拟机内核空间中的基础内核模块和所述N个内核模块中除所述目标内核模块之外的内核模块。a page table creation unit, configured to mark a space page table of the virtual machine kernel space as a kernel space page table KPGT, and create the MPGT based on the physical address distribution information, wherein the KPGT is used to support the K- The kernel module in the SPACE includes a base kernel module in the virtual machine kernel space and a kernel module other than the target kernel module among the N kernel modules.
  8. 根据权利要求5-7任一项所述的VMM,其特征在于,所述MPGT中创建有所述目标内核模块对所述M-SPACE中的内核数据的访问权限映射,以使得所述目标内核模块有权限访问所述M-SPACE中的内核数据。The VMM according to any one of claims 5-7, wherein an access authority mapping of the target kernel module to kernel data in the M-SPACE is created in the MPGT to cause the target kernel The module has access to the kernel data in the M-SPACE.
  9. 一种代码调用方法,其特征在于,包括:A code calling method, comprising:
    虚拟机监视器VMM捕获页表中断事件,所述页表中断事件是由中央处理单元CPU在检测到目标内核模块针对内核空间K-SPACE中的内核代码的调用请求之后、且判断出隔离空间页表MPGT中未创建所述目标内核模块对所述K-SPACE中的内核代码的调用权限映射的情况下生成的,其中,所述VMM对应的虚拟机内核空间包括所述K-SPACE和隔离空间M-SPACE,所述M-SPACE包括所述目标内核模块和所述MPGT,所述MPGT用于支持所述目标内核模块的运行;The virtual machine monitor VMM captures a page table interrupt event, which is determined by the central processing unit CPU after detecting the target kernel module's call request for the kernel code in the kernel space K-SPACE, and determines the isolated space page The table MPGT is generated without creating the call permission mapping of the target kernel module to the kernel code in the K-SPACE, wherein the virtual machine kernel space corresponding to the VMM includes the K-SPACE and the isolation space. M-SPACE, the M-SPACE includes the target kernel module and the MPGT, the MPGT is used to support operation of the target kernel module;
    所述VMM通过预存的页表中断处理函数判断所述目标内核模块是否有权 限调用所述K-SPACE中的内核代码;Determining, by the pre-stored page table interrupt processing function, whether the target kernel module has the right Limit the kernel code in the K-SPACE;
    当所述VMM通过预存的页表中断处理函数判断出所述目标内核模块有权限调用所述K-SPACE中的内核代码时,所述VMM根据所述目标内核模块对所述K-SPACE中的内核代码的调用权限映射,执行页表切换操作和堆栈切换操作以将所述虚拟机内核空间的堆栈由隔离空间堆栈M-STACK切换为内核空间堆栈K-STACK,以使得所述目标内核模块基于切换后的所述K-STACK调用所述K-SPACE中的内核代码。When the VMM determines, by the pre-stored page table interrupt processing function, that the target kernel module has permission to invoke the kernel code in the K-SPACE, the VMM is configured according to the target kernel module in the K-SPACE a call permission mapping of kernel code, performing a page table switching operation and a stack switching operation to switch the stack of the virtual machine kernel space from the isolated space stack M-STACK to a kernel space stack K-STACK, such that the target kernel module is based on The switched K-STACK calls the kernel code in the K-SPACE.
  10. 根据权利要求9所述的代码调用方法,其特征在于,所述VMM通过预存的页表中断处理函数判断所述目标内核模块是否有权限调用所述K-SPACE中的内核代码,包括:The code calling method according to claim 9, wherein the VMM determines, by the pre-stored page table interrupt processing function, whether the target kernel module has permission to invoke the kernel code in the K-SPACE, including:
    所述VMM通过预存的页表中断函数获取所述页表中断事件对应的预设权限判断策略,并获取所述K-SPACE中的内核代码的虚拟地址分布信息;The VMM obtains a preset permission judgment policy corresponding to the page table interrupt event by using a pre-stored page table interrupt function, and acquires virtual address distribution information of the kernel code in the K-SPACE;
    所述VMM根据获取的所述预设权限判断策略和所述虚拟地址分布信息判断所述目标内核模块是否有权限访问所述K-SPACE中的内核代码。The VMM determines, according to the obtained preset permission judgment policy and the virtual address distribution information, whether the target kernel module has permission to access the kernel code in the K-SPACE.
  11. 根据权利要求9或10任一项所述的代码调用方法,其特征在于,所述VMM执行页表页表切换操作,包括:The code calling method according to any one of claims 9 to 10, wherein the VMM performs a page table page table switching operation, including:
    所述VMM将所述VMM当前加载的页表由所述MPGT切换为内核空间页表KPGT,其中,所述KPGT用于支持所述K-SPACE中的内核模块的运行,所述K-SPACE中包括所述虚拟机内核空间中的基础内核模块、所述虚拟机内核空间中插入的N个内核模块中除所述目标内核模块之外的内核模块以及所述KPGT,所述N为大于1的正整数。The VMM switches the page table currently loaded by the VMM from the MPGT to a kernel space page table KPGT, wherein the KPGT is used to support operation of a kernel module in the K-SPACE, in the K-SPACE And including the basic kernel module in the virtual machine kernel space, a kernel module other than the target kernel module among the N kernel modules inserted in the virtual machine kernel space, and the KPGT, where the N is greater than 1. A positive integer.
  12. 根据权利要求9-11任一项所述的代码调用方法,其特征在于,所述VMM执行堆栈切换操作,包括:The code calling method according to any one of claims 9 to 11, wherein the VMM performs a stack switching operation, including:
    所述VMM拷贝M-STACK中存储的用于传递所述K-SPACE中的内核代码的代码参数和用于调用所述K-SPACE中的内核代码的返回地址RIP;The VMM copies the code parameters stored in the M-STACK for transferring the kernel code in the K-SPACE and the return address RIP for calling the kernel code in the K-SPACE;
    所述VMM在所述K-STACK中写入所述代码参数和所述RIP;Writing, by the VMM, the code parameter and the RIP in the K-STACK;
    所述VMM将所述虚拟机内核空间当前使用的堆栈由esp-old位置转变为esp-new位置,其中,所述esp-old位置为所述RIP在所述M-STACK中的存储位 置,所述esp-new位置为所述RIP在所述K-STACK中的存储位置。The VMM converts a stack currently used by the virtual machine kernel space from an esp-old location to an esp-new location, wherein the esp-old location is a storage location of the RIP in the M-STACK The esp-new location is a storage location of the RIP in the K-STACK.
  13. 根据权利要求9-12任一项所述的代码调用方法,其特征在于,所述VMM捕获页表中断事件之前,所述方法还包括:The code calling method according to any one of claims 9 to 12, wherein before the VMM captures a page table interrupt event, the method further includes:
    所述VMM根据预存的所述虚拟机内核空间的空间页表将目标内核模块的虚拟地址分布信息映射为物理地址分布信息,其中,所述目标内核模块为从所述虚拟机内核空间中插入的N个内核模块中选取的需要被隔离的内核模块,所述N为大于1的正整数;The VMM maps virtual address distribution information of the target kernel module to physical address distribution information according to a pre-stored space page table of the virtual machine kernel space, where the target kernel module is inserted from the virtual machine kernel space a kernel module selected from the N kernel modules to be isolated, wherein N is a positive integer greater than one;
    所述VMM基于所述物理地址分布信息分隔所述虚拟机内核空间为所述M-SPACE和所述K-SPACE;The VMM separates the virtual machine kernel space into the M-SPACE and the K-SPACE based on the physical address distribution information;
    所述VMM标记所述虚拟机内核空间的空间页表为内核空间页表KPGT,并基于所述物理地址分布信息创建所述MPGT。The VMM marks the space page table of the virtual machine kernel space as a kernel space page table KPGT, and creates the MPGT based on the physical address distribution information.
  14. 根据权利要求9-13任一项所述的代码调用方法,其特征在于,所述MPGT中创建有所述目标内核模块对所述M-SPACE中的内核代码的调用权限映射,以使得所述目标内核模块有权限调用所述M-SPACE中的内核代码。The code calling method according to any one of claims 9 to 13, wherein a call permission mapping of the target kernel module to the kernel code in the M-SPACE is created in the MPGT, so that the The target kernel module has permission to call the kernel code in the M-SPACE.
  15. 一种虚拟机监视器VMM,其特征在于,包括:A virtual machine monitor VMM, comprising:
    事件捕获单元,用于捕获页表中断事件,所述页表中断事件是由中央处理单元CPU在检测到目标内核模块针对内核空间K-SPACE中的内核代码的调用请求之后、且判断出隔离空间页表MPGT中未创建所述目标内核模块对所述K-SPACE中的内核代码的调用权限映射的情况下生成的,其中,所述VMM对应的虚拟机内核空间包括所述K-SPACE和隔离空间M-SPACE,所述M-SPACE包括所述目标内核模块和所述MPGT,所述MPGT用于支持所述目标内核模块的运行;An event capture unit, configured to capture a page table interrupt event, wherein the page table interrupt event is determined by the central processing unit CPU after detecting a call request of the target kernel module for kernel code in the kernel space K-SPACE The page table MPGT is generated without creating a call permission mapping of the target kernel module to the kernel code in the K-SPACE, wherein the virtual machine kernel space corresponding to the VMM includes the K-SPACE and isolation a space M-SPACE, the M-SPACE including the target kernel module and the MPGT, the MPGT being used to support operation of the target kernel module;
    权限判断单元,用于通过预存的页表中断处理函数判断所述目标内核模块是否有权限调用所述K-SPACE中的内核代码;a permission determining unit, configured to determine, by using a pre-stored page table interrupt processing function, whether the target kernel module has permission to invoke the kernel code in the K-SPACE;
    切换单元,用于当所述权限判断单元通过预存的页表中断处理函数判断出所述目标内核模块有权限调用所述K-SPACE中的内核代码时,根据所述目标内核模块对所述K-SPACE中的内核代码的调用权限映射,执行页表切换操作和堆栈切换操作以将所述虚拟机内核空间的堆栈由隔离空间堆栈M-STACK切换为 内核空间堆栈K-STACK,以使得所述目标内核模块基于切换后的所述K-STACK调用所述K-SPACE中的内核代码。a switching unit, configured to: when the authority determining unit determines, by using a pre-stored page table interrupt processing function, that the target kernel module has permission to invoke the kernel code in the K-SPACE, according to the target kernel module, the K Calling permission mapping of kernel code in -SPACE, performing page table switching operations and stack switching operations to switch the stack of the virtual machine kernel space from the isolated space stack M-STACK to The kernel space stack K-STACK is such that the target kernel module invokes the kernel code in the K-SPACE based on the K-STACK after the handover.
  16. 根据权利要求15所述的VMM,其特征在于,所述权限判断单元具体用于:The VMM according to claim 15, wherein the authority determining unit is specifically configured to:
    通过预存的页表中断函数获取所述页表中断事件对应的预设权限判断策略,并获取所述K-SPACE中的内核代码的虚拟地址分布信息;Acquiring a preset permission judgment policy corresponding to the page table interrupt event by using a pre-stored page table interrupt function, and acquiring virtual address distribution information of the kernel code in the K-SPACE;
    根据获取的所述预设权限判断策略和所述虚拟地址分布信息判断所述目标内核模块是否有权限访问所述K-SPACE中的内核代码。Determining, according to the obtained preset permission judgment policy and the virtual address distribution information, whether the target kernel module has permission to access the kernel code in the K-SPACE.
  17. 根据权利要求15或16任一项所述的VMM,其特征在于,所述切换单元具体用于:The VMM according to any one of claims 15 or 16, wherein the switching unit is specifically configured to:
    将所述VMM当前加载的页表由所述MPGT切换为内核空间页表KPGT,其中,所述KPGT用于支持所述K-SPACE中的内核模块的运行,所述K-SPACE中包括所述虚拟机内核空间中的基础内核模块、所述虚拟机内核空间中插入的N个内核模块中除所述目标内核模块之外的内核模块以及所述KPGT,所述N为大于1的正整数。Converting a page table currently loaded by the VMM from the MPGT to a kernel space page table KPGT, wherein the KPGT is configured to support operation of a kernel module in the K-SPACE, the K-SPACE including the The base kernel module in the virtual machine kernel space, the kernel module other than the target kernel module among the N kernel modules inserted in the virtual machine kernel space, and the KPGT, the N is a positive integer greater than 1.
  18. 根据权利要求15或17任一项所述的VMM,其特征在于,所述切换单元具体用于:The VMM according to any one of claims 15 or 17, wherein the switching unit is specifically configured to:
    拷贝M-STACK中存储的用于传递所述K-SPACE中的内核代码的代码参数和用于调用所述K-SPACE中的内核代码的返回地址RIP;Copying a code parameter stored in the M-STACK for transferring the kernel code in the K-SPACE and a return address RIP for calling the kernel code in the K-SPACE;
    在所述K-STACK中写入所述代码参数和所述RIP;Writing the code parameter and the RIP in the K-STACK;
    将所述虚拟机内核空间当前使用的堆栈由esp-old位置转变为esp-new位置,其中,所述esp-old位置为所述RIP在所述M-STACK中的存储位置,所述esp-new位置为所述RIP在所述K-STACK中的存储位置。Converting the stack currently used by the virtual machine kernel space from an esp-old location to an esp-new location, wherein the esp-old location is a storage location of the RIP in the M-STACK, the esp- The new location is the storage location of the RIP in the K-STACK.
  19. 根据权利要求15或18任一项所述的VMM,其特征在于,所述VMM还包括:The VMM according to any one of claims 15 or 18, wherein the VMM further comprises:
    地址映射单元,用于在所述事件捕获单元捕获页表中断事件之前,根据预存的所述虚拟机内核空间的空间页表将目标内核模块的虚拟地址分布信息映射为物理地址分布信息,其中,所述目标内核模块为从所述虚拟机内核空间中 插入的N个内核模块中选取的需要被隔离的内核模块,所述N为大于1的正整数;An address mapping unit, configured to: before the event capture unit captures the page table interrupt event, map the virtual address distribution information of the target kernel module to the physical address distribution information according to the pre-stored space page table of the virtual machine kernel space, where The target kernel module is from the virtual machine kernel space a kernel module selected to be isolated among the inserted N kernel modules, where N is a positive integer greater than one;
    空间分隔单元,用于基于所述物理地址分布信息分隔所述虚拟机内核空间为所述M-SPACE和所述K-SPACE;a space separating unit, configured to separate the virtual machine kernel space into the M-SPACE and the K-SPACE based on the physical address distribution information;
    页表创建单元,用于标记所述虚拟机内核空间的空间页表为内核空间页表KPGT,并基于所述物理地址分布信息创建所述MPGT。a page table creation unit that marks a space page table of the virtual machine kernel space as a kernel space page table KPGT, and creates the MPGT based on the physical address distribution information.
  20. 根据权利要求15-19任一项所述的VMM,其特征在于,所述MPGT中创建有所述目标内核模块对所述M-SPACE中的内核代码的调用权限映射,以使得所述目标内核模块有权限调用所述M-SPACE中的内核代码。 The VMM according to any one of claims 15 to 19, wherein a call permission mapping of the target kernel module to the kernel code in the M-SPACE is created in the MPGT to cause the target kernel The module has permission to call the kernel code in the M-SPACE.
PCT/CN2016/097246 2015-09-06 2016-08-29 Data access method, code calling method, and virtual machine monitor WO2017036376A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201510559382.6A CN106502759B (en) 2015-09-06 2015-09-06 A kind of data access method, code call method and virtual machine monitor
CN201510559382.6 2015-09-06

Publications (1)

Publication Number Publication Date
WO2017036376A1 true WO2017036376A1 (en) 2017-03-09

Family

ID=58186729

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2016/097246 WO2017036376A1 (en) 2015-09-06 2016-08-29 Data access method, code calling method, and virtual machine monitor

Country Status (2)

Country Link
CN (1) CN106502759B (en)
WO (1) WO2017036376A1 (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2022166553A1 (en) * 2021-02-05 2022-08-11 华为技术有限公司 Method and apparatus for implementing batch system calls
WO2023160398A1 (en) * 2022-02-25 2023-08-31 阿里巴巴(中国)有限公司 Data processing method and system

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112084490A (en) * 2020-09-09 2020-12-15 南京烽火星空通信发展有限公司 Method and system for realizing protection of software source code based on Linux kernel calling
CN113448690B (en) * 2021-08-27 2022-02-01 阿里云计算有限公司 Monitoring method and device

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20080244206A1 (en) * 2007-03-30 2008-10-02 Samsung Electronics Co., Ltd. Method of controlling memory access
CN102938035A (en) * 2012-11-08 2013-02-20 西安交通大学 Driving separation system inside virtual machine and method
CN103778368A (en) * 2014-01-23 2014-05-07 重庆邮电大学 Safe progress isolating method based on system virtualization technology
CN104036185A (en) * 2014-06-23 2014-09-10 常熟理工学院 Virtualization based power and function isolating method for loading module of monolithic kernel operation system
US20150046924A1 (en) * 2007-10-30 2015-02-12 Vmware, Inc. Transparent memory-mapped emulation of i/o calls
CN104573553A (en) * 2014-12-30 2015-04-29 中国航天科工集团第二研究院七O六所 Xen-oriented memory sharing security isolation method for virtual machines

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20080244206A1 (en) * 2007-03-30 2008-10-02 Samsung Electronics Co., Ltd. Method of controlling memory access
US20150046924A1 (en) * 2007-10-30 2015-02-12 Vmware, Inc. Transparent memory-mapped emulation of i/o calls
CN102938035A (en) * 2012-11-08 2013-02-20 西安交通大学 Driving separation system inside virtual machine and method
CN103778368A (en) * 2014-01-23 2014-05-07 重庆邮电大学 Safe progress isolating method based on system virtualization technology
CN104036185A (en) * 2014-06-23 2014-09-10 常熟理工学院 Virtualization based power and function isolating method for loading module of monolithic kernel operation system
CN104573553A (en) * 2014-12-30 2015-04-29 中国航天科工集团第二研究院七O六所 Xen-oriented memory sharing security isolation method for virtual machines

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2022166553A1 (en) * 2021-02-05 2022-08-11 华为技术有限公司 Method and apparatus for implementing batch system calls
WO2023160398A1 (en) * 2022-02-25 2023-08-31 阿里巴巴(中国)有限公司 Data processing method and system

Also Published As

Publication number Publication date
CN106502759A (en) 2017-03-15
CN106502759B (en) 2019-11-15

Similar Documents

Publication Publication Date Title
US11132440B2 (en) Hybrid trust execution environment based android security framework, android device equipped with the same and method of executing trust service in android device
US20180276229A1 (en) Trusted File Indirection
EP3047419B1 (en) Virtual secure mode for virtual machines
EP2443553B1 (en) Annotating virtual application processes
KR101602519B1 (en) Virtualized storage assignment method
US10176007B2 (en) Guest code emulation by virtual machine function
US10592434B2 (en) Hypervisor-enforced self encrypting memory in computing fabric
KR100938521B1 (en) Method, apparatus and system for enabling a secure location-aware platform
US10255088B2 (en) Modification of write-protected memory using code patching
WO2017036376A1 (en) Data access method, code calling method, and virtual machine monitor
US10083129B2 (en) Code loading hardening by hypervisor page table switching
CN112003877B (en) Network isolation method and device, electronic equipment and storage medium
US11256534B2 (en) System and method for trapping system calls for remote execution
JP2016518672A (en) Interrupt processing method and apparatus
CN112035272A (en) Method and device for interprocess communication and computer equipment
CN108073423B (en) Accelerator loading method and system and accelerator loading device
CN113391881B (en) Interrupt management method and device, electronic equipment and computer storage medium
US9558364B2 (en) Computing machine, access management method, and access management program
US11513825B2 (en) System and method for implementing trusted execution environment on PCI device
US11301282B2 (en) Information protection method and apparatus
US20200401492A1 (en) Container-level monitoring
JP2023064327A (en) Virtual machine container apparatus, control method of virtual machine container, program, and recording medium

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: 16840805

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 16840805

Country of ref document: EP

Kind code of ref document: A1