public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* x86 instruction emulator fuzzing
@ 2019-05-21 15:39 Sam Caccavale
  2019-05-21 15:39 ` [PATCH 1/3] Build target for emulate.o as a userspace binary Sam Caccavale
                   ` (3 more replies)
  0 siblings, 4 replies; 11+ messages in thread
From: Sam Caccavale @ 2019-05-21 15:39 UTC (permalink / raw)
  Cc: samcacc, samcaccavale, nmanthey, wipawel, dwmw, mpohlack, graf,
	karahmed, andrew.cooper3, JBeulich, pbonzini, rkrcmar, tglx,
	mingo, bp, hpa, paullangton4, anirudhkaushik, x86, kvm,
	linux-kernel

Dear all,

This series aims to provide an entrypoint for, and fuzz KVM's x86 instruction
emulator from userspace.  It mirrors Xen's application of the AFL fuzzer to
it's instruction emulator in the hopes of discovering vulnerabilities.
Since this entrypoint also allows arbitrary execution of the emulators code
from userspace, it may also be useful for testing.

The current 3 patches build the emulator and 2 harnesses: simple-harness is
an example of unit testing; afl-harness is a frontend for the AFL fuzzer.
They are early POC and include some issues outlined under "Issues."

Patches
=======

- 01: Builds and links afl-harness with the required kernel objects.
- 02: Introduces the minimal set of emulator operations and supporting code
to emulate simple instructions.
- 03: Demonstrates simple-harness as a unit test.

Issues
=======

1. Currently, building requires manually running the `make_deps` script
since I was unable to make the kernel objects a dependency of the tool.
2. The code will segfault if `CONFIG_STACKPROTECTOR=y` in config.
3. The code requires stderr to be buffered or it otherwise segfaults.

The latter two issues seem related and all of them are likely fixable by
someone more familiar with the linux than me.

Concerns
=======

I was able to carve the `arch/x86/kvm/emulate.c` code, but the emulator is
constructed in such a way that a lot of the code which enforces expected
behavior lives in the x86_emulate_ops supplied in `arch/x86/kvm/x86.c`.
Testing the emulator is still valuable, but a reproducible way to use the kvm
ops would be useful.

Any comments/suggestions are greatly appreciated.

Best,
Sam Caccavale





Amazon Development Center Germany GmbH
Krausenstr. 38
10117 Berlin
Geschaeftsfuehrer: Christian Schlaeger, Ralf Herbrich
Ust-ID: DE 289 237 879
Eingetragen am Amtsgericht Charlottenburg HRB 149173 B



^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2019-06-21 13:28 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-05-21 15:39 x86 instruction emulator fuzzing Sam Caccavale
2019-05-21 15:39 ` [PATCH 1/3] Build target for emulate.o as a userspace binary Sam Caccavale
2019-05-31  8:02   ` Alexander Graf
2019-06-12 15:19     ` samcacc
2019-05-21 15:39 ` [PATCH 2/3] Emulate simple x86 instructions in userspace Sam Caccavale
2019-05-31  8:38   ` Alexander Graf
2019-06-12 15:19     ` samcacc
2019-06-21 13:28       ` Alexander Graf
2019-05-21 15:39 ` [PATCH 3/3] Demonstrating unit testing via simple-harness Sam Caccavale
2019-05-31  8:39 ` x86 instruction emulator fuzzing Alexander Graf
2019-06-12 15:19   ` samcacc

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox