Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
H
hypervisor rootkit
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
flg_bachelors
TS
2024
hypervisor rootkit
Commits
c60ae0a8
Commit
c60ae0a8
authored
3 months ago
by
iliya.saroukha
Browse files
Options
Downloads
Patches
Plain Diff
wip: associating a vmxon region to its corresponding vcpu
parent
d8060b52
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
proto/hypervisor.c
+22
-16
22 additions, 16 deletions
proto/hypervisor.c
with
22 additions
and
16 deletions
proto/hypervisor.c
+
22
−
16
View file @
c60ae0a8
...
...
@@ -16,8 +16,10 @@
#include
"asm/special_insns.h"
#include
"asm/tlbflush.h"
#include
"debug/debug.h"
#include
"linux/threads.h"
#include
"msr/msr.h"
#include
"region/vxmon_reg.h"
#include
"region/vxmon.h"
#include
"vcpu/vcpu.h"
#define NULL ((void *)0)
...
...
@@ -27,7 +29,7 @@
/* : clobbered registers list (optional)*/
/* );*/
static
struct
v
mxon_region_t
vmxon_region
;
static
struct
v
cpu_t
vcpus
[
1
]
;
static
int
cr4_enable_vmx
(
void
)
{
unsigned
long
cr4
;
...
...
@@ -177,18 +179,22 @@ static int my_init(void) {
DEBUG_FMT
(
"IA32_VMX_BASIC_MSR = 0x%llx
\n
"
,
__rdmsr
(
IA32_VMX_BASIC
));
pr_info
(
"Initializing VMXON region
\n
"
);
int
ret_init_vmxon
;
if
((
ret_init_vmxon
=
init_vmxon_reg
(
&
vmxon_region
))
!=
0
)
{
pr_err
(
"Failed to initialized the VMXON region
\n
"
);
return
-
ret_init_vmxon
;
pr_info
(
"Allocating VMXON region
\n
"
);
struct
vmxon_t
*
vmxon_reg
=
alloc_vmxon
();
if
(
!
vmxon_reg
)
{
pr_err
(
"VMXON region allocation failed
\n
"
);
return
-
ENOMEM
;
}
pr_info
(
"VA of the allocated region = 0x%px
\n
"
,
vmxon_region
.
va
);
pr_info
(
"PA of the allocated region = 0x%llx
\n
"
,
vmxon_region
.
pa
);
vmxon_regions
[
0
]
=
vmxon_reg
;
pr_info
(
"VA of the allocated region = 0x%px
\n
"
,
vmxon_reg
);
pr_info
(
"PA of the allocated region = 0x%lx
\n
"
,
__pa
(
vmxon_reg
));
pr_info
(
"Reading VMXON region for VMCS ID: 0x%
l
x
\n
"
,
(
*
(
unsigned
long
*
)
vmxon_region
.
va
)
);
pr_info
(
"Reading VMXON region for VMCS ID: 0x%x
\n
"
,
vmxon_reg
->
header
.
vmcs_rev_id
);
pr_info
(
"Patching CR0 and CR4 depending on the value of their respective "
"MSRs
\n
"
);
...
...
@@ -209,18 +215,18 @@ static int my_init(void) {
return
-
EPERM
;
}
pr_info
(
"Executing VMXON with address = 0x%
l
lx as its operand
\n
"
,
vmxon_reg
ion
.
pa
);
pr_info
(
"Executing VMXON with address = 0x%lx as its operand
\n
"
,
__pa
(
vmxon_reg
)
);
unsigned
char
vmxon_ret
=
0
;
/*if ((vmxon_ret = vmxon(vmxon_region.pa) != 0)) {*/
if
((
vmxon_ret
=
kvm_cpu_vmxon
(
vmxon_reg
ion
.
pa
)
!=
0
))
{
if
((
vmxon_ret
=
kvm_cpu_vmxon
(
__pa
(
vmxon_reg
)
)
!=
0
))
{
/*unsigned long vm_err = __rdmsr(0x4400);*/
/*pr_err("VM_ERR val = 0x%lx\n", vm_err);*/
cr4_clear_bits
(
13
);
kfree
(
vmxon_reg
ion
.
va
);
kfree
(
vmxon_reg
);
/*__asm__ volatile("vmxoff");*/
pr_err
(
"`vmxon` failed with return code %d
\n
"
,
vmxon_ret
);
return
-
1
;
...
...
@@ -242,7 +248,7 @@ static void my_exit(void) {
}
pr_info
(
"Freeing memory of the VMXON region
\n
"
);
kfree
(
vmxon_region
.
va
);
kfree
(
vmxon_region
s
[
0
]
);
pr_info
(
"vmbr.ko has exited
\n
"
);
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment