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
6f3597ac
Commit
6f3597ac
authored
3 months ago
by
iliya.saroukha
Browse files
Options
Downloads
Patches
Plain Diff
feat: switching to specific cpus using the set_cpus_allowed_ptr func
parent
64d02a09
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
proto/hypervisor.c
+13
-9
13 additions, 9 deletions
proto/hypervisor.c
proto/vmm/vmm.c
+19
-31
19 additions, 31 deletions
proto/vmm/vmm.c
with
32 additions
and
40 deletions
proto/hypervisor.c
+
13
−
9
View file @
6f3597ac
...
...
@@ -17,9 +17,7 @@
#include
"vmm/vmm.h"
#include
"vmx/vmx.h"
#define NULL ((void *)0)
#define NB_VCPUS 1
#define NB_VCPUS 4
/*asm ( assembler template*/
/* : output operands (optional)*/
...
...
@@ -45,7 +43,7 @@ static int my_init(void) {
int
ret_err
;
if
((
ret_err
=
init_vmm
(
&
ctx
,
1
))
!=
0
)
{
if
((
ret_err
=
init_vmm
(
&
ctx
,
NB_VCPUS
))
!=
0
)
{
pr_err
(
"VMM initialization has failed
\n
"
);
return
ret_err
;
}
...
...
@@ -72,6 +70,8 @@ static int my_init(void) {
}
for
(
unsigned
long
i
=
0
;
i
<
ctx
.
vcpu_count
;
i
++
)
{
set_cpus_allowed_ptr
(
current
,
cpumask_of
(
i
));
DEBUG_FMT
(
"CURRENT CPU = %d
\n
"
,
smp_processor_id
());
if
((
ret_err
=
kvm_cpu_vmxon
(
__pa
(
&
ctx
.
vcpu_table
[
i
])))
!=
0
)
{
pr_err
(
"Failed to execute `vmxon` on vCPU[%lu]
\n
"
,
i
);
destroy_vmm
(
&
ctx
);
...
...
@@ -85,13 +85,17 @@ static int my_init(void) {
}
static
void
my_exit
(
void
)
{
pr_info
(
"Executing VMXOFF
\n
"
);
/*__asm__ volatile("vmxoff");*/
int
vmxoff
;
if
((
vmxoff
=
kvm_cpu_vmxoff
())
!=
0
)
{
pr_err
(
"Failed to execute VMXOFF
\n
"
);
return
;
for
(
unsigned
long
i
=
0
;
i
<
ctx
.
vcpu_count
;
i
++
)
{
set_cpus_allowed_ptr
(
current
,
cpumask_of
(
i
));
DEBUG_FMT
(
"CURRENT CPU = %d
\n
"
,
smp_processor_id
());
pr_info
(
"[-] Executing VMXOFF on vCPU[%lu]
\n
"
,
i
);
if
((
vmxoff
=
kvm_cpu_vmxoff
())
!=
0
)
{
pr_err
(
"Failed to execute VMXOFF
\n
"
);
return
;
}
}
pr_info
(
"[*] Freeing VMM ctx
\n
"
);
...
...
This diff is collapsed.
Click to expand it.
proto/vmm/vmm.c
+
19
−
31
View file @
6f3597ac
#include
"vmm.h"
#include
"../debug/debug.h"
#include
"linux/cpumask.h"
#include
"linux/gfp_types.h"
#include
"linux/sched.h"
#include
"linux/slab.h"
#include
"linux/smp.h"
int
init_vmm
(
struct
vmm_t
*
ctx
,
unsigned
long
vcpu_count
)
{
if
(
!
ctx
)
{
...
...
@@ -19,40 +20,27 @@ int init_vmm(struct vmm_t *ctx, unsigned long vcpu_count) {
ctx
->
vcpu_count
=
vcpu_count
;
int
proc_id
=
smp_processor_id
();
int
ret
=
init_vcpu
(
&
ctx
->
vcpu_table
[
proc_id
],
proc_id
);
for
(
unsigned
long
i
=
0
;
i
<
ctx
->
vcpu_count
;
i
++
)
{
/*NOTE: need to study the function below*/
set_cpus_allowed_ptr
(
current
,
cpumask_of
(
i
));
DEBUG_FMT
(
"CURRENT CPU = %d
\n
"
,
smp_processor_id
());
if
(
ret
!=
0
)
{
destroy_vmm
(
ctx
);
DEBUG_FMT
(
"vCPU[%d] initialization has failed
\n
"
,
proc_id
);
return
ret
;
}
int
ret
=
init_vcpu
(
&
ctx
->
vcpu_table
[
i
],
i
);
DEBUG_FMT
(
"VA of vCPU[%d]'s VMXON region: 0x%px
\n
"
,
proc_id
,
ctx
->
vcpu_table
[
proc_id
].
vmxon
);
DEBUG_FMT
(
"PA of vCPU[%d]'s VMXON region: 0x%lx
\n
"
,
proc_id
,
__pa
(
ctx
->
vcpu_table
[
proc_id
].
vmxon
));
if
(
ret
!=
0
)
{
destroy_vmm
(
ctx
);
DEBUG_FMT
(
"vCPU[%lu] initialization has failed
\n
"
,
i
);
return
ret
;
}
DEBUG_FMT
(
"vCPU[%d]'s VMCS rev id: 0x%x
\n
"
,
proc_id
,
ctx
->
vcpu_table
[
proc_id
].
vmxon
->
vmcs_rev_id
);
DEBUG_FMT
(
"VA of vCPU[%lu]'s VMXON region: 0x%px
\n
"
,
i
,
ctx
->
vcpu_table
[
i
].
vmxon
);
DEBUG_FMT
(
"PA of vCPU[%lu]'s VMXON region: 0x%lx
\n
"
,
i
,
__pa
(
ctx
->
vcpu_table
[
i
].
vmxon
));
/*for (unsigned long i = 0; i < ctx->vcpu_count; i++) {*/
/* int ret = init_vcpu(&ctx->vcpu_table[i], );*/
/**/
/* if (ret != 0) {*/
/* destroy_vmm(ctx);*/
/* DEBUG_FMT("vCPU[%lu] initialization has failed\n", i);*/
/* return ret;*/
/* }*/
/**/
/* DEBUG_FMT("VA of vCPU[%lu]'s VMXON region: 0x%px\n", i,*/
/* ctx->vcpu_table[i].vmxon);*/
/* DEBUG_FMT("PA of vCPU[%lu]'s VMXON region: 0x%lx\n", i,*/
/* __pa(ctx->vcpu_table[i].vmxon));*/
/**/
/* DEBUG_FMT("vCPU[%lu]'s VMCS rev id: 0x%x\n", i,*/
/* ctx->vcpu_table[i].vmxon->vmcs_rev_id);*/
/*}*/
DEBUG_FMT
(
"vCPU[%lu]'s VMCS rev id: 0x%x
\n
"
,
i
,
ctx
->
vcpu_table
[
i
].
vmxon
->
vmcs_rev_id
);
}
return
0
;
}
...
...
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