qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: Max Moroz <mmoroz@google.com>
Cc: Stefan Hajnoczi <stefanha@gmail.com>,
	Dmitry Vyukov <dvyukov@google.com>,
	Oliver Chang <ochang@google.com>,
	Jonathan Metzman <metzman@google.com>,
	Bandan Das <bsd@redhat.com>, qemu-devel <qemu-devel@nongnu.org>,
	Andrey Konovalov <andreyknvl@google.com>,
	Kostya Serebryany <kcc@google.com>
Subject: Re: [Qemu-devel] Internship idea: virtio-blk oss-fuzz support
Date: Fri, 11 Jan 2019 17:16:40 +0100	[thread overview]
Message-ID: <0387b8e9-2b4f-ce1a-05df-b508851b84f0@redhat.com> (raw)
In-Reply-To: <CABiizERPJa06YNEyUxEAgDaSgjJny4bTa4qpTDCwKzKMn5Ji=Q@mail.gmail.com>

On 11/01/19 16:41, Max Moroz wrote:
> 
> 
> On Fri, Jan 11, 2019 at 7:34 AM Paolo Bonzini <pbonzini@redhat.com
> <mailto:pbonzini@redhat.com>> wrote:
> 
>     On 11/01/19 16:04, Max Moroz wrote:
>     > We usually have a single fuzzing process, it starts with a fuzzing
>     > engine's main function and is calling LLVMFuzzerTestOneInput with
>     > various inputs and keep mutating them based on the coverage feedback.
>     > Running a second process which you don't care too much about might be
>     > fine, but the fuzzing process should be "replacing" or should I say
>     > "imitating" the process whose coverage you're interested in.
> 
>     What do you mean by replacing or imitating?
> 
> To give you an example, when we fuzz ffmpeg, we do not run ffmpeg's main
> function. We write LLVMFuzzerTestOneInput that would do the necessary
> initialization, reset the state, etc, and then would pass (data, size)
> provided by a fuzzing engine to the API(s) we're trying to fuzz. So, in
> your case, there should not be a regular QEMU process, and instead the
> fuzz target (i.e. LLVMFuzzerTestOneInput) should be doing certain
> initialization (which is usually done by the QEMU process) and then call
> the API you want to fuzz.

The main issue is that we are not really testing an API and QEMU has a
lot of global state.  Of course there are C functions to do the
elementary I/O operations, but there are two problems.  The first and
smaller is that one input would correspond to a sequence of invocations
of the functions, not just one function invocation; the larger, is that
the knowledge of the guest (memory map, placement of devices, etc.) is
not easy to consume from within QEMU.  We do have a library that
includes that knowledge, and it would be easy to use it from a mutator
or input postprocessor, but I'm afraid that it would be very very
intrusive to embed that library into QEMU, replacing all of main() etc.

The simplest way would be to test the input by fork()-ing QEMU, followed
by waitpid() in the parent and invoking the original main() in the
child.  But that wouldn't buy much and would probably even be slower
than an efficient deferred fork server.

Paolo

>  
> 
> 
>     Avoiding fork would probably be hard.  I'm mostly afraid that some state
>     guest state is not resetted properly across runs, and this would result
>     in non-reproducible crashes.
> 
>     It seems to me that the task can be approached with AFL and a test case
>     postprocessor to generate the qtest input; however, my knowledge of
>     libFuzzer is very very limited.
> 
>     Paolo
> 

  reply	other threads:[~2019-01-11 16:16 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-09 17:34 [Qemu-devel] Internship idea: virtio-blk oss-fuzz support Stefan Hajnoczi
2019-01-10 10:46 ` Dmitry Vyukov
2019-01-10 13:40 ` Bandan Das
2019-01-10 14:01   ` Dmitry Vyukov
2019-01-10 16:07     ` Max Moroz
2019-01-10 23:25       ` Paolo Bonzini
2019-01-11  6:49         ` Stefan Hajnoczi
2019-01-11 15:04           ` Max Moroz
2019-01-11 15:33             ` Paolo Bonzini
2019-01-11 15:41               ` Max Moroz
2019-01-11 16:16                 ` Paolo Bonzini [this message]
2019-01-11 19:09                   ` Jonathan Metzman
2019-01-11 20:27                     ` Paolo Bonzini
2019-01-11 22:56                       ` Jonathan Metzman
2019-01-14  9:24                   ` Stefan Hajnoczi
2019-01-18  7:51                     ` Bandan Das

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=0387b8e9-2b4f-ce1a-05df-b508851b84f0@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=andreyknvl@google.com \
    --cc=bsd@redhat.com \
    --cc=dvyukov@google.com \
    --cc=kcc@google.com \
    --cc=metzman@google.com \
    --cc=mmoroz@google.com \
    --cc=ochang@google.com \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@gmail.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;
as well as URLs for NNTP newsgroup(s).