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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
flg_bachelors
TS
2024
hypervisor rootkit
Commits
c7ae8fcd
Commit
c7ae8fcd
authored
7 months ago
by
iliya.saroukha
Browse files
Options
Downloads
Patches
Plain Diff
todo: need to understand thoroughly the code added
parent
9cea4db9
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
proto/hypervisor.c
+47
-0
47 additions, 0 deletions
proto/hypervisor.c
with
47 additions
and
0 deletions
proto/hypervisor.c
+
47
−
0
View file @
c7ae8fcd
...
...
@@ -2,12 +2,54 @@
#include
<linux/init.h>
/* Needed for the macros */
#include
<linux/module.h>
/* Needed by all modules */
#define FEATURE_CONTROL_VMXON_ENABLED_OUTSIDE_SMX (1 << 2)
#define FEATURE_CONTROL_LOCKED (1 << 0)
#define MSR_IA32_FEATURE_CONTROL 0x0000003a
/*asm ( assembler template*/
/* : output operands (optional)*/
/* : input operands (optional)*/
/* : clobbered registers list (optional)*/
/* );*/
static
bool
getVmxOperation
(
void
)
{
/*
* Configure IA32_FEATURE_CONTROL MSR to allow VMXON:
* Bit 0: Lock bit. If clear, VMXON causes a #GP.
* Bit 2: Enables VMXON outside of SMX operation. If clear, VMXON
* outside of SMX causes a #GP.
*/
unsigned
long
cr0
,
cr4
;
unsigned
long
long
required
,
feature_control
;
unsigned
long
low1
=
0
;
required
=
FEATURE_CONTROL_VMXON_ENABLED_OUTSIDE_SMX
;
required
|=
FEATURE_CONTROL_LOCKED
;
feature_control
=
__rdmsr
(
MSR_IA32_FEATURE_CONTROL
);
printk
(
KERN_INFO
"RDMS output is %ld
\n
"
,
(
long
)
feature_control
);
if
((
feature_control
&
required
)
!=
required
)
{
wrmsr
(
MSR_IA32_FEATURE_CONTROL
,
feature_control
|
required
,
low1
);
}
/*
* Ensure bits in CR0 and CR4 are valid in VMX operation:
* - Bit X is 1 in _FIXED0: bit X is fixed to 1 in CRx.
* - Bit X is 0 in _FIXED1: bit X is fixed to 0 in CRx.
*/
__asm__
volatile
(
"mov %%cr0, %0"
:
"=r"
(
cr0
)
:
:
"memory"
);
cr0
&=
__rdmsr
(
MSR_IA32_VMX_CR0_FIXED1
);
cr0
|=
__rdmsr
(
MSR_IA32_VMX_CR0_FIXED0
);
__asm__
volatile
(
"mov %0, %%cr0"
:
:
"r"
(
cr0
)
:
"memory"
);
__asm__
volatile
(
"mov %%cr4, %0"
:
"=r"
(
cr4
)
:
:
"memory"
);
cr4
&=
__rdmsr
(
MSR_IA32_VMX_CR4_FIXED1
);
cr4
|=
__rdmsr
(
MSR_IA32_VMX_CR4_FIXED0
);
__asm__
volatile
(
"mov %0, %%cr4"
:
:
"r"
(
cr4
)
:
"memory"
);
return
true
;
}
static
void
enable_vmx
(
void
)
{
unsigned
long
cr4
;
...
...
@@ -38,6 +80,11 @@ static int my_init(void) {
printk
(
KERN_INFO
"VMX has been successfully enabled!
\n
"
);
if
(
!
getVmxOperation
())
{
printk
(
KERN_INFO
"VMX operation couldn't correctly setup
\n
"
);
return
-
1
;
}
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