Coder Social home page Coder Social logo

kvm-kernel-example's People

Contributors

david942j avatar jserv avatar wanghaemq 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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

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

kvm-kernel-example's Issues

Incorrect RSP value?

Many thanks for making this code available. I have one doubt on the working of the code.

In the function setup_regs in hypervisor.c, shouldn't the value of RSP be set to MAX_KERNEL_SIZE + 0x5000 + KERNEL_STACK_SIZE instead of MAX_KERNEL_SIZE +KERNEL_STACK_SIZE? My understanding of the memory layout of the guest is that you place the kernel, then the page table, and then the kernel stack. With the current setting of RSP, the stack is writing to the same page that is used for the page tables. Of course, the code works correctly even now, because the page table and the kernel stack are both not using the full page. But, if they did, it would cause issues.

Please let me know if my understanding is correct.

interrupt and exception handling

I tried to add exception/interruput handler based on this but fail. The VM exit with "shutdown" reason.

I realize there is not gdt setup in the orignal code. But even after I add it, it still doesn't work.

Could you please let me know what I need to do beside setup gdt and idt?

Security vulnerability in `hp_handle_write` and `hp_handle_read`

The functions that do the hypercall for read and write does check whether if the beginning of the buffer is valid memory, but the buffer could extend into memory that is not valid.

If the user is able to gain control of the kernel, they can at the very least leak memory that is mmap'd right before the the guest memory segment. If, however, the mmap'd segment is also writable, the user can also write to that memory segment, and compromise the hypervisor, by passing data as stdin, and invoking a hp read call.

Trying to run "make", receives this error.

Any idea? :3

alon @ ~/kvm-test/kvm-kernel-example - [master] $ sudo make
make -C hypervisor
make[1]: Entering directory '/home/alon/kvm-test/kvm-kernel-example/hypervisor'
make[1]: Nothing to be done for 'all'.
make[1]: Leaving directory '/home/alon/kvm-test/kvm-kernel-example/hypervisor'
make -C kernel
make[1]: Entering directory '/home/alon/kvm-test/kvm-kernel-example/kernel'
make -C syscalls/ syscalls.a
make[2]: Entering directory '/home/alon/kvm-test/kvm-kernel-example/kernel/syscalls'
make[2]: 'syscalls.a' is up to date.
make[2]: Leaving directory '/home/alon/kvm-test/kvm-kernel-example/kernel/syscalls'
make -C hypercalls/ hypercalls.a
make[2]: Entering directory '/home/alon/kvm-test/kvm-kernel-example/kernel/hypercalls'
make[2]: 'hypercalls.a' is up to date.
make[2]: Leaving directory '/home/alon/kvm-test/kvm-kernel-example/kernel/hypercalls'
make -C mm/ mm.a
make[2]: Entering directory '/home/alon/kvm-test/kvm-kernel-example/kernel/mm'
make[2]: 'mm.a' is up to date.
make[2]: Leaving directory '/home/alon/kvm-test/kvm-kernel-example/kernel/mm'
make -C elf/ elf.a
make[2]: Entering directory '/home/alon/kvm-test/kvm-kernel-example/kernel/elf'
make[2]: 'elf.a' is up to date.
make[2]: Leaving directory '/home/alon/kvm-test/kvm-kernel-example/kernel/elf'
make -C utils/ utils.a
make[2]: Entering directory '/home/alon/kvm-test/kvm-kernel-example/kernel/utils'
cc -nostdlib -Os -Wall -Werror -fPIE -pie -masm=intel -I.. -c -MMD -MP string.c
string.c: In function ‘strlen’:
string.c:6:10: error: ‘strnlen’ specified bound 18446744073709551615 exceeds maximum object size 9223372036854775807 [-Werror=stringop-overflow=]
6 | return strnlen(s, ~0ll);
| ^~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors
make[2]: *** [../template.mk:16: string.o] Error 1
make[2]: Leaving directory '/home/alon/kvm-test/kvm-kernel-example/kernel/utils'
make[1]: *** [Makefile:24: utils/utils.a] Error 2
make[1]: Leaving directory '/home/alon/kvm-test/kvm-kernel-example/kernel'
make: *** [Makefile:6: kernel] Error 2

Error: ambiguous operand size for `sysret'

I was seeing the following errors when compiling on Ubuntu 22.04:

as syscall_entry.s -o syscall_entry.o
syscall_entry.s: Assembler messages:
syscall_entry.s:36: Error: ambiguous operand size for `sysret'
cc -nostdlib -Os -Wall -Werror -fPIE -pie -masm=intel -I.. -c -MMD -MP sys_execve.c
syscall_entry.s: Assembler messages:
syscall_entry.s:36: Error: ambiguous operand size for `sysret'
make[2]: *** [../template.mk:19: syscall_entry.o] Error 1
make[2]: *** Waiting for unfinished jobs....
sys_execve.c: Assembler messages:
sys_execve.c:123: Error: ambiguous operand size for `sysret'

I changed sysret to sysretq in both files and it worked.

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.