Bitdefender Hypervisor Memory Introspection
|
Go to the source code of this file.
Functions | |
INTSTATUS | IntHandleEptViolation (void *GuestHandle, QWORD PhysicalAddress, DWORD Length, QWORD LinearAddress, DWORD CpuNumber, INTRO_ACTION *Action, IG_EPT_ACCESS AccessType) |
Handle an EPT violation. More... | |
INTSTATUS | IntHandleMsrViolation (void *GuestHandle, DWORD Msr, IG_MSR_HOOK_TYPE Flags, INTRO_ACTION *Action, QWORD OriginalValue, QWORD *NewValue, DWORD CpuNumber) |
Handle a model specific register violation. More... | |
INTSTATUS | IntHandleCrWrite (void *GuestHandle, DWORD Cr, DWORD CpuNumber, QWORD OldValue, QWORD NewValue, INTRO_ACTION *Action) |
Handle a control register violation. More... | |
INTSTATUS | IntHandleDtrViolation (void *GuestHandle, DWORD Flags, DWORD CpuNumber, INTRO_ACTION *Action) |
Handle GDTR, IDTR, LDTR, TR accesses. More... | |
INTSTATUS | IntHandleIntroCall (void *GuestHandle, QWORD Rip, DWORD CpuNumber) |
Handle a VMCALL issued inside the guest. More... | |
INTSTATUS | IntHandleTimer (void *GuestHandle) |
Periodically called by the integrator, once every second. More... | |
INTSTATUS | IntHandleXcrWrite (void *GuestHandle, DWORD CpuNumber, INTRO_ACTION *Action) |
Handle extended control registers writes. More... | |
INTSTATUS | IntHandleBreakpoint (void *GuestHandle, QWORD GuestPhysicalAddress, DWORD CpuNumber) |
Handle guest breakpoints. More... | |
INTSTATUS | IntCallbacksInit (void) |
Initialize the callbacks. More... | |
INTSTATUS | IntCallbacksUnInit (void) |
Uninit all the Introcore callbacks. More... | |
static INTSTATUS | IntEnableEptNotifications (void) |
static INTSTATUS | IntDisableEptNotifications (void) |
static INTSTATUS | IntEnableDtrNotifications (void) |
static INTSTATUS | IntDisableDtrNotifications (void) |
static INTSTATUS | IntEnableMsrNotifications (void) |
static INTSTATUS | IntDisableMsrNotifications (void) |
static INTSTATUS | IntEnableCrNotifications (void) |
static INTSTATUS | IntDisableCrNotifications (void) |
static INTSTATUS | IntEnableXcrNotifications (void) |
static INTSTATUS | IntDisableXcrNotifications (void) |
static INTSTATUS | IntEnableBreakpointNotifications (void) |
static INTSTATUS | IntDisableBreakpointNotifications (void) |
INTSTATUS IntCallbacksInit | ( | void | ) |
Initialize the callbacks.
Most of the callbacks are initialized here. As soon as a callback is registered for a certain type of event, Introcore can start processing them. NOTE: Some callbacks, such as the breakpoint handler or the EPT violation handler are registered on the init flow, so as to avoid having to handle many irrelevant events while we initialize.
INT_STATUS_SUCCESS | On success. |
Definition at line 3527 of file callbacks.c.
Referenced by IntGuestHandleCr3Write().
INTSTATUS IntCallbacksUnInit | ( | void | ) |
Uninit all the Introcore callbacks.
INT_STATUS_SUCCESS | On success. |
Definition at line 3576 of file callbacks.c.
Referenced by IntGuestUninit().
|
inlinestatic |
Definition at line 278 of file callbacks.h.
Referenced by IntLixAgentExit(), and IntLixAgentThreadExit().
|
inlinestatic |
Definition at line 210 of file callbacks.h.
Referenced by IntHookCrDeleteHook().
|
inlinestatic |
Definition at line 142 of file callbacks.h.
Referenced by IntHookDtrDeleteHook().
|
inlinestatic |
Definition at line 108 of file callbacks.h.
Referenced by IntHookGpaDeleteHookInternal().
|
inlinestatic |
Definition at line 176 of file callbacks.h.
Referenced by IntHookMsrDeleteHook().
|
inlinestatic |
Definition at line 244 of file callbacks.h.
Referenced by IntHookXcrDeleteHook().
|
inlinestatic |
Definition at line 261 of file callbacks.h.
Referenced by IntLixAgentActivatePendingAgent().
|
inlinestatic |
Definition at line 193 of file callbacks.h.
Referenced by IntHookCrSetHook().
|
inlinestatic |
Definition at line 125 of file callbacks.h.
Referenced by IntHookDtrSetHook().
|
inlinestatic |
Definition at line 91 of file callbacks.h.
Referenced by IntHookGpaSetHook().
|
inlinestatic |
Definition at line 159 of file callbacks.h.
Referenced by IntHookMsrSetHook().
|
inlinestatic |
Definition at line 227 of file callbacks.h.
Referenced by IntHookXcrSetHook().
Handle guest breakpoints.
This handler is called by the integrator whenever a breakpoint (INT3) takes place inside the guest. This function will just dispatch the event to an appropriate Introcore handler, in this order:
[in] | GuestHandle | The guest handle. |
[in] | GuestPhysicalAddress | Unused. |
[in] | CpuNumber | The VCPU number. |
INT_STATUS_SUCCESS | On success. |
INT_STATUS_INVALID_PARAMETER | If an invalid parameter is supplied. |
INT_STATUS_NOT_INITIALIZED_HINT | If the guest is not initialized. |
INT_STATUS_NOT_FOUND | If Introcore did not handle the VMCALL. |
INT_STATUS_FATAL_ERROR | If a fatal error occurred and the integrator should unload Introcore. |
INT_STATUS_UNINIT_BUGCHECK | If a bug-check occurred inside the guest and Introcore should be unloaded. |
Definition at line 2734 of file callbacks.c.
Referenced by IntEnableBreakpointNotifications(), and IntWinGuestInit().
INTSTATUS IntHandleCrWrite | ( | void * | GuestHandle, |
DWORD | Cr, | ||
DWORD | CpuNumber, | ||
QWORD | OldValue, | ||
QWORD | NewValue, | ||
INTRO_ACTION * | Action | ||
) |
Handle a control register violation.
This function is called by the integrator/HV on each CR violation. The handler will simply iterate the list of registered callbacks for this particular CR, and call each one of them. Introcore only places write hooks on the control registers; read hooks may trigger a very high performance impact.
[in] | GuestHandle | The guest handle. |
[in] | Cr | The accessed CR. |
[in] | CpuNumber | The VCPU number. |
[in] | OldValue | Old CR value. |
[in] | NewValue | New CR value. |
[in] | Action | The desired action. |
INT_STATUS_SUCCESS | On success. |
INT_STATUS_NOT_INITIALIZED_HINT | If the guest is not initialized yet. |
INT_STATUS_INVALID_PARAMETER | If an invalid parameter is supplied. |
INT_STATUS_NOT_FOUND | If no callback is found for this MSR. |
INT_STATUS_FATAL_ERROR | A fatal error occurred, and the integrator should unload Introcore. |
Definition at line 1692 of file callbacks.c.
Referenced by IntEnableCrNotifications().
INTSTATUS IntHandleDtrViolation | ( | void * | GuestHandle, |
DWORD | Flags, | ||
DWORD | CpuNumber, | ||
INTRO_ACTION * | Action | ||
) |
Handle GDTR, IDTR, LDTR, TR accesses.
This function is called on descriptor table registers accesses. This function will iterate registered callbacks and it will call all of them. Special handling is done, however, for these instructions, as they generate a descriptor table access VM exit before doing any kind of memory checks; therefore, emulating such an instruction may lead to an EPT protection bypass (since the HV may not check EPT access rights when emulating instructions). As a result, we do some serious checks when handling these instructions:
[in] | GuestHandle | The guest handle. |
[in] | Flags | Descriptor table accessed & accessed type. Check out IG_DESC_ACCESS. |
[in] | CpuNumber | The VCPU number. |
[out] | Action | Desired action. |
INT_STATUS_SUCCESS | On success. |
INT_STATUS_INVALID_PARAMETER | If an invalid parameter is supplied. |
INT_STATUS_NOT_INITIALIZED_HINT | If the guest is not initialized. |
INT_STATUS_FATAL_ERROR | If a fatal error occurred and Introcore should be unloaded. |
(for example, GDTR READ, IDTR WRITE, etc.).
Definition at line 3116 of file callbacks.c.
Referenced by IntEnableDtrNotifications().
INTSTATUS IntHandleEptViolation | ( | void * | GuestHandle, |
QWORD | PhysicalAddress, | ||
DWORD | Length, | ||
QWORD | LinearAddress, | ||
DWORD | CpuNumber, | ||
INTRO_ACTION * | Action, | ||
IG_EPT_ACCESS | AccessType | ||
) |
Handle an EPT violation.
This callback is called by the HV/integrator whenever an EPT violation takes place. Introcore will handle the event by calling registered callbacks for the accessed memory area. Note that Introcore will also call the callbacks for other linear addresses that may be accessed by the instruction. Upon return, it has to return an action to the integrator. The main steps taken by this function are:
[in] | GuestHandle | A handle to the guest that generated the EPT violation. |
[in] | PhysicalAddress | Accessed guest physical address. |
[in] | Length | Access size. Note that this parameter is reserved for future use, as the HV does not decode (and the CPU does not provide) the access size. |
[in] | LinearAddress | The accessed guest linear address. |
[in] | CpuNumber | VCPU number. |
[out] | Action | Will contain, upon successful return, the action to be taken fro the access. |
[in] | AccessType | Access type: IG_EPT_HOOK_READ, IG_EPT_HOOK_WRITE & IG_EPT_HOOK_EXECUTE. |
INT_STATUS_SUCCESS | On success. |
INT_STATUS_INVALID_PARAMETER | If an invalid parameter is supplied. |
INT_STATUS_FORCE_ACTION_ON_BETA | Force the introGuestNotAllowed, even in beta mode. This ensures that our hooks don't get overwritten. |
INT_STATUS_FATAL_ERROR | A fatal error occurred, and the integrator should unload Introcore. |
NOTE: The instruction may be modified after the fault is triggered. Therefore, we may process the GLA/GPA the fault took place at, but the instruction may encode a different address.
Definition at line 825 of file callbacks.c.
Referenced by IntEnableEptNotifications().
Handle a VMCALL issued inside the guest.
This function will be called by the hypervisor whenever a VMCALL is executed inside the guest with a magic value in EAX register. For the Xen hypervisor, this magic value involves several registers: On x64: RAX = 0x22, RDI = 0x18, RSI = 0 On x86: EAX = 0x22, EBX = 0x18, ECX = 0 The EAX register will be overwritten by the HV on guest re-entry, so don't use it to pass the result of the VMCALL. This function will dispatch the VMCALL to the following handlers, in this order:
[in] | GuestHandle | The guest handle. |
[in] | Rip | RIP where the VMCALL originates. |
[in] | CpuNumber | The VCPU number. |
INT_STATUS_SUCCESS | On success. |
INT_STATUS_INVALID_PARAMETER | If an invalid parameter is supplied. |
INT_STATUS_NOT_INITIALIZED_HINT | If the guest is not initialized. |
INT_STATUS_NOT_FOUND | If Introcore did not handle the VMCALL. |
INT_STATUS_FATAL_ERROR | If a fatal error occurred and the integrator should unload Introcore. |
INT_STATUS_UNINIT_BUGCHECK | If a bug-check occurred inside the guest and Introcore should be unloaded. |
Definition at line 2140 of file callbacks.c.
Referenced by IntCallbacksInit().
INTSTATUS IntHandleMsrViolation | ( | void * | GuestHandle, |
DWORD | Msr, | ||
IG_MSR_HOOK_TYPE | Flags, | ||
INTRO_ACTION * | Action, | ||
QWORD | OriginalValue, | ||
QWORD * | NewValue, | ||
DWORD | CpuNumber | ||
) |
Handle a model specific register violation.
This callback is called on MSR violations. This handle will iterate the list of registered callbacks for that particular MSR, and will call each one of them. NOTE: Although read hooks can also be established on MSRs, Introcore does not make use of that, only write hooks are set.
[in] | GuestHandle | The guest handle. |
[in] | Msr | The accessed MSR. |
[in] | Flags | MSR violation type (read or write). |
[out] | Action | Desired action. |
[in] | OriginalValue | Original MSR value. |
[out] | NewValue | New MSR value. Can be modified, but whether the HV will take this into consideration or not is implementation dependent, so it is advisable to not modify this value. |
[in] | CpuNumber | The VCPU number. |
INT_STATUS_SUCCESS | On success. |
INT_STATUS_NOT_INITIALIZED_HINT | If the guest is not initialized yet. |
INT_STATUS_INVALID_PARAMETER | If an invalid parameter is supplied. |
INT_STATUS_NOT_FOUND | If no callback is found for this MSR. |
INT_STATUS_FATAL_ERROR | A fatal error occurred, and the integrator should unload Introcore. |
Definition at line 1536 of file callbacks.c.
Referenced by IntEnableMsrNotifications().
INTSTATUS IntHandleTimer | ( | void * | GuestHandle | ) |
Periodically called by the integrator, once every second.
This function is called every second. Tasks such as integrity checks can be done here. The main tasks this handle carries are:
[in] | GuestHandle | The guest handle. |
INT_STATUS_SUCCESS | On success. |
INT_STATUS_INVALID_PARAMETER | If an invalid parameter is supplied. |
INT_STATUS_NOT_INITIALIZED_HINT | If the guest is not initialized. |
It would be nice to pause the guest while we do the checks; However, since we're doing read-only operations and the protected areas should not be modified during the normal usage, we can safely let all other processors run code.
Definition at line 2359 of file callbacks.c.
Referenced by IntCallbacksInit().
INTSTATUS IntHandleXcrWrite | ( | void * | GuestHandle, |
DWORD | CpuNumber, | ||
INTRO_ACTION * | Action | ||
) |
Handle extended control registers writes.
This function handles the XSETBV instruction, which modifies XCRs. Currently, only XCR0 can be intercepted. Even this is intercepted in order to aid into activating protection, and it is not protected against attacks. This function will iterate the list of XCR callbacks, and it will call each one.
[in] | GuestHandle | The guest handle. |
[in] | CpuNumber | The VCPU number. |
[out] | Action | The desired action. |
INT_STATUS_SUCCESS | On success. |
INT_STATUS_INVALID_PARAMETER | If an invalid parameter is supplied. |
INT_STATUS_NOT_INITIALIZED_HINT | If the guest is not initialized. |
INT_STATUS_NOT_FOUND | If Introcore did not handle the VMCALL. |
INT_STATUS_FATAL_ERROR | If a fatal error occurred and the integrator should unload Introcore. |
Definition at line 2580 of file callbacks.c.
Referenced by IntEnableXcrNotifications().