public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: Avi Kivity <avi@redhat.com>
To: Marcelo Tosatti <mtosatti@redhat.com>, lmr@redhat.com
Cc: kvm@vger.kernel.org
Subject: [PATCH 0/3] Emulator fuzz tester
Date: Mon, 22 Aug 2011 16:41:06 +0300	[thread overview]
Message-ID: <1314020469-30882-1-git-send-email-avi@redhat.com> (raw)

As it is exposed directly to guest code, the x86 emulator is an interesting
target for exploiters: a vulnerability may lead to compromise of the entire
host.

In an attempt to catch vulnerabilities before they make it into production
code, this patchset adds a fuzz tester for the emulator.  Instructions
are synthesized and fed into the emulator; a vulnerability will usually
result in an access violation.

I tried to make the emulator test build an run in userspace; this proved too
difficult, so the test is built as part of the kernel.  It can still be run
in userspace, via KVM:

  qemu -enable-kvm -smp 4 -serial stdio -kernel bzImage \
      -append 'console=ttyS0 test_emulator.iterations=1000000000'

  ...
  starting emulator test
  emulator fuzz test results
    instructions:     1000000000
    decoded:            94330032
    emulated:           92529152
    nofault:                 117
    failures:                  0
  emulator test: PASS
  ...

One billion random instructions failed to find a vulnerability, so either
the emulator is really good, or the test is really bad, or we need a lot more
runtime.

Lucas, how would we go about integrating this into kvm-autotest?

Avi Kivity (3):
  KVM: x86 emulator: make prototype of ->write_std() the same as
    ->write_emulated
  KVM: x86 emulator: export main interface
  KVM: x86 emulator: fuzz tester

 arch/x86/Kbuild                    |    1 +
 arch/x86/include/asm/kvm_emulate.h |    3 +-
 arch/x86/kvm/Kconfig               |   11 +
 arch/x86/kvm/Makefile              |    1 +
 arch/x86/kvm/emulate.c             |    2 +
 arch/x86/kvm/test-emulator.c       |  533 ++++++++++++++++++++++++++++++++++++
 arch/x86/kvm/x86.c                 |    4 +-
 arch/x86/kvm/x86.h                 |    2 +-
 8 files changed, 553 insertions(+), 4 deletions(-)
 create mode 100644 arch/x86/kvm/test-emulator.c

-- 
1.7.5.3


             reply	other threads:[~2011-08-22 13:41 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-08-22 13:41 Avi Kivity [this message]
2011-08-22 13:41 ` [PATCH 1/3] KVM: x86 emulator: make prototype of ->write_std() the same as ->write_emulated Avi Kivity
2011-08-22 13:41 ` [PATCH 2/3] KVM: x86 emulator: export main interface Avi Kivity
2011-08-22 13:41 ` [PATCH 3/3] KVM: x86 emulator: fuzz tester Avi Kivity
2011-08-25 16:27   ` Marcelo Tosatti
2011-08-25 19:04     ` Avi Kivity
2011-08-29 12:42       ` Avi Kivity
2011-08-25 22:17   ` Lucas Meneghel Rodrigues
2011-08-29 12:01     ` Avi Kivity
2011-08-25 19:07 ` [PATCH 0/3] Emulator " Lucas Meneghel Rodrigues
2011-08-26  0:11 ` Lucas Meneghel Rodrigues
2011-08-29 12:05   ` Avi Kivity

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1314020469-30882-1-git-send-email-avi@redhat.com \
    --to=avi@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=lmr@redhat.com \
    --cc=mtosatti@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox