Giter Site home page Giter Site logo

vbh's Introduction

DISCONTINUATION OF PROJECT

This project will no longer be maintained by Intel.
Intel has ceased development and contributions including, but not limited to, maintenance, bug fixes, new releases, or updates, to this project.
Intel no longer accepts patches to this project.
If you have an ongoing need to use this project, are interested in independently developing it, or would like to maintain patches for the open source software community, please create your own fork of this project.

Virtualization Based Hardening

(POC only - can NOT and should NOT be used in production)

Description

Virtualization Base Hardening (VBH) utilizes Intel Virtualization Technology to provide an infrastructure for other parties to build security policies (such as introspection engine) on top of it in order to protect hardware (Intel platform only), kernel and native container/user space apps. It is implemented as an out-of tree Linux module and supports Linux version 4.4 or above. It has 2 components:

  1. A slim hypervisor, when installed, turns the host into guest
  2. APIs to query and control the hypervisor. The APIs supports the following functionalities:
    • Query and update general guest info
    • vCPU management
    • Event related: to register event callbacks and to report event
    • Memory/EPT related
    • CR and MSR virtualization related
    • Emulation/Single Step related

For a full list of supported functions, please refer to hypervisor_introspection.h.

File Structure

vbh
+-- README.md
+-- sources
|   +-- cpu_switch_debug.c              /* Debug only */
|   +-- cpu_switch_debug.h              /* Header file for debug */
|   +-- guest_info.c                    /* Query and update guest info */
|   +-- hypervisor_introspection.c      /* API functions implementation */
|   +-- hypervisor_introspection.h      /* API function definition */
|   +-- kernelhardending.c              /* MSR and CR virtualization */
|   +-- Makefile                        /* Make file */
|   +-- offsets.h                       /* Register offset */
|   +-- ptable.c                        /* EPT related */
|   +-- vbh_events.c                    /* Event handling */
|   +-- vbh_rt.c                        /* slim hypervisor runtime: mostly for vmexit and vmentry */
|   +-- vbh_setup.c                     /* slim hypervisor initialization */
|   +-- vmexit.S                        /* Assembly for vmexit */
|   +-- vmx_common.h                    /* Shared header file */
+-- tests
|   +-- kernel_hardening_tests          /* tests related to CR and MSR virtualization */
    |   +-- kernel_hardening_test_module_main.c
    |   +-- Makefile
|   +-- query_guest_info_tests          /* tests related to query guest inof */
    |   +-- query_guest_info_tests_module.c
    |   +-- Makefile
|   +-- set_guest_info_tests            /* tests related to set guest info */
    |   +-- set_guest_info_test_module.c
    |   +-- Makefile
|   +-- shared                          /* Shared files to support test infrastructure */
    |   +-- vbh_test_shared.h
    |   +-- vmcall.S

Use Cases

We developed the following use cases so far and we are looking for adding more use cases.

  1. Help prevent hardware from being damaged by unsafe modification of CR and MSR registers. See kernelhardening.c.
  2. Help Prevent privilege escalation attack against Linux kernel. (source code not published)
  3. Help protect Linux's kernel code against tampering (source code not published)

How to Use

- To get source code
    >> git clone https://github.com/intel/vbh.git

- To compile
    >> cd vbh/sources
    >> make

- To clean
    >> make clean

- To install
    >> sudo insmod vmx-switch.ko switch_vmx_on_load=1

- To uninstall
    >> sudo rmmod vmx_switch

- To use APIs
Please refer to the files under test directory for sample usage of every api function.

How to Contribute

New Use Cases

If you use this project to help your own research or develop your own use cases, we would love to hear your feedback. Or if you have ideas of new use cases and need help, we can help you develop them. Please contact maintainers of the project.

Bugs or New Features

Feel free to contact project's maintaniers to learn next new features to be developed. We also welcome pull request with bug fixes or new feature implementations. Please provide detailed documentation describing proposed changes when sending pull request.

Any Questions or Suggestions

Feel free to contact project's maintainers.

Maintainers

vbh's People

Contributors

bbosinta avatar crisanandreiliviu avatar rliu88 avatar sainath14 avatar sfblackl-intel avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

vbh's Issues

Another build issue

Hi,

I tried to build vbh with an older version of the Linux kernel (which has the definitions for ASM_VMX_VMREAD_RDX_RAX and similar),, but I get a new error:
[...]
CC [M] /home/luca/Src/Virt/vbh/sources/vbh_setup.o
AS [M] /home/luca/Src/Virt/vbh/sources/vmcall.o
CC [M] /home/luca/Src/Virt/vbh/sources/vcpu.o
LD [M] /home/luca/Src/Virt/vbh/sources/vmx-switch.o
Building modules, stage 2.
MODPOST 1 modules
WARNING: "__stack_chk_fail" [/home/luca/Src/Virt/vbh/sources/vmx-switch.ko] undefined!
[...]
and of course the module cannot be inserted in the kernel, because it tries to link the __stack_chk_fail symbol that does not exist...

It seems to me that the problem is due to the fact that you unconditionally add "-fstack-protector-strong" to the compiler options...
(as a side note, why are you adding all those cflags and ldflags? Doesn't kbuild use the correct flags by default?)

Thanks,
Luca

Failed to compile the project

Hi
I'm interested in this project and doing a quick try, but failed to compile. Did you have idea ?
My code base is v4.4 as recommended in Readme.

root@:/vbh/sources# make -C /home/works/linux/
make: Entering directory '/home/works/linux'
  CHK     include/config/kernel.release
  CHK     include/generated/uapi/linux/version.h
  CHK     include/generated/utsrelease.h
  CHK     include/generated/bounds.h
  CHK     include/generated/timeconst.h
  CHK     include/generated/asm-offsets.h
  CALL    scripts/checksyscalls.sh
  CHK     include/generated/compile.h
  HOSTCC  arch/x86/entry/vdso/vdso2c
In file included from arch/x86/entry/vdso/vdso2c.c:161:
arch/x86/entry/vdso/vdso2c.h: In function ‘go64’:
arch/x86/entry/vdso/vdso2c.h:55:24: warning: unused variable ‘tag’ [-Wunused-variable]
   55 |   typeof(dyn[i].d_tag) tag = GET_LE(&dyn[i].d_tag);
      |                        ^~~
arch/x86/entry/vdso/vdso2c.h:7:22: error: invalid storage class for function ‘go32’
    7 | static void BITSFUNC(go)(void *raw_addr, size_t raw_len,
      |                      ^~
arch/x86/entry/vdso/vdso2c.c:150:39: note: in definition of macro ‘BITSFUNC3’
  150 | #define BITSFUNC3(name, bits, suffix) name##bits##suffix
      |                                       ^~~~
arch/x86/entry/vdso/vdso2c.c:152:24: note: in expansion of macro ‘BITSFUNC2’
  152 | #define BITSFUNC(name) BITSFUNC2(name, ELF_BITS, )
      |                        ^~~~~~~~~
arch/x86/entry/vdso/vdso2c.h:7:13: note: in expansion of macro ‘BITSFUNC’
    7 | static void BITSFUNC(go)(void *raw_addr, size_t raw_len,
      |             ^~~~~~~~
In file included from arch/x86/entry/vdso/vdso2c.c:165:
arch/x86/entry/vdso/vdso2c.h: In function ‘go32’:
arch/x86/entry/vdso/vdso2c.h:55:24: warning: unused variable ‘tag’ [-Wunused-variable]
   55 |   typeof(dyn[i].d_tag) tag = GET_LE(&dyn[i].d_tag);
      |                        ^~~
arch/x86/entry/vdso/vdso2c.c:168:13: error: invalid storage class for function ‘go’
  168 | static void go(void *raw_addr, size_t raw_len,
      |             ^~
arch/x86/entry/vdso/vdso2c.c:185:13: error: invalid storage class for function ‘map_input’
  185 | static void map_input(const char *name, void **addr, size_t *len, int prot)
      |             ^~~~~~~~~
arch/x86/entry/vdso/vdso2c.c:205:5: warning: ‘main’ is normally a non-static function [-Wmain]
  205 | int main(int argc, char **argv)
      |     ^~~~
arch/x86/entry/vdso/vdso2c.c:253:1: error: expected declaration or statement at end of input
  253 | }
      | ^
arch/x86/entry/vdso/vdso2c.c: In function ‘go64’:
arch/x86/entry/vdso/vdso2c.c:253:1: error: expected declaration or statement at end of input
At top level:
arch/x86/entry/vdso/vdso2c.c:205:5: warning: ‘main’ defined but not used [-Wunused-function]
  205 | int main(int argc, char **argv)
      |     ^~~~
make[3]: *** [scripts/Makefile.host:91: arch/x86/entry/vdso/vdso2c] Error 1
make[2]: *** [scripts/Makefile.build:403: arch/x86/entry/vdso] Error 2
make[1]: *** [scripts/Makefile.build:403: arch/x86/entry] Error 2
make: *** [Makefile:943: arch/x86] Error 2
make: Leaving directory '/home/works/linux'

Build error

Hello,

I get a build error when compiling on Ubuntu 20.04:

luca@luca64:/data/Test/Virt/vbh/sources$ make
make -C /lib/modules/5.4.0-40-lowlatency/build M=/data/Test/Virt/vbh/sources
make[1]: Entering directory '/usr/src/linux-headers-5.4.0-40-lowlatency'
AR /data/Test/Virt/vbh/sources/built-in.a
CC [M] /data/Test/Virt/vbh/sources/kernelhardening.o
In file included from /data/Test/Virt/vbh/sources/kernelhardening.c:6:
/data/Test/Virt/vbh/sources/vmx_common.h: In function ‘__vmcs_readl’:
/data/Test/Virt/vbh/sources/vmx_common.h:322:15: error: expected string literal before ‘ASM_VMX_VMREAD_RDX_RAX’
322 | asm volatile(ASM_VMX_VMREAD_RDX_RAX
| ^~~~~~~~~~~~~~~~~~~~~~
/data/Test/Virt/vbh/sources/vmx_common.h: In function ‘__vmcs_writel’:
/data/Test/Virt/vbh/sources/vmx_common.h:364:20: error: expected string literal before ‘ASM_VMX_VMWRITE_RAX_RDX’
364 | asm volatile(__ex(ASM_VMX_VMWRITE_RAX_RDX) "; setna %0"
| ^~~~~~~~~~~~~~~~~~~~~~~
/data/Test/Virt/vbh/sources/vmx_common.h:263:17: note: in definition of macro ‘__ex’
263 | #define __ex(x) x
| ^

It looks like the source expect to find ASM_VMX_VMREAD_RDX_RAX and similar defined in the kernel sources... However, that define has been removed some time ago (and the kernel now uses the vmread and vmwrite assembly instructions directly).

I think there are 2 possible solutions:

  1. switch to using vmread and vmwrite directly, as current kernels do
  2. define ASM_VMX_VMREAD_RDX_RAX and similar in vbh/sources/vmx_common.h

Which solution do you think is more appropriate?

As a side note, what is the purpose of the "__ex()" macro?

Thanks,
Luca

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.