From nobody Fri Sep 5 22:22:05 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1603707556; cv=none; d=zohomail.com; s=zohoarc; b=H2cH3B1Jv5OROyeuJzqCN1dcvCjf0RCP1IWLVY3G8xujabNqz9A+MMLoIGl6RDLlVcsdj7qyYicNIHxfpglmK6xwWfCTeT1QDi5Yuy+72zR8esgqwoAP0AJTneO8Pyb9hc1M+n36wITLP3dKR+wcI1XKyUbkiLudEUMZc5+xZ3U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1603707556; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=rPj1DFhuZ+EQW7IN7zl+uQqA9OVlS+YiYiVtbtyvbdg=; b=NkT7e+kG0gsRUycnlgo+PbP2tbyAUJyXV5cbJOvqWLT2fa25MWErTqZXzfOniJebuEqwp6x6mFRUhFzWJ9LA5AzS6yZBwCuDr8A3nno1rAD/HzG6r6O0oSv/Jy5jhU615g1dzwVQx5uq5yu1/7DJKsETmezRoC5/lV52PxmJCt4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1603707556390174.5419120646966; Mon, 26 Oct 2020 03:19:16 -0700 (PDT) Received: from localhost ([::1]:38030 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kWzat-0001U0-6o for importer@patchew.org; Mon, 26 Oct 2020 06:19:15 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38972) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kWzPI-0002o0-4A for qemu-devel@nongnu.org; Mon, 26 Oct 2020 06:07:16 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:26364) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kWzPD-0006kD-3Z for qemu-devel@nongnu.org; Mon, 26 Oct 2020 06:07:15 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-99-qwwkHxQtPmOndVfO_KXOKw-1; Mon, 26 Oct 2020 06:07:07 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 9C30F10E2185; Mon, 26 Oct 2020 10:07:06 +0000 (UTC) Received: from thuth.com (ovpn-112-104.ams2.redhat.com [10.36.112.104]) by smtp.corp.redhat.com (Postfix) with ESMTP id 922E88B842; Mon, 26 Oct 2020 10:07:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1603706829; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:content-type:content-type:in-reply-to:in-reply-to: references:references; bh=rPj1DFhuZ+EQW7IN7zl+uQqA9OVlS+YiYiVtbtyvbdg=; b=ijNmUxBBbgZ0H2T/tMGegC3Si7L9/IW0yoUCrayqrTZJO3xMWM9e1uUUNett3W+I1e5xFD 6xdYih4W78iWthTqzwhzS8YhnAqxMBvwnXN5MTrk4tu8m+NI7YSExFt8eQeX3hFVDlN/AT 9MLabP3/ZSrwJUtflcyYrtDtG4eM6tQ= X-MC-Unique: qwwkHxQtPmOndVfO_KXOKw-1 From: Thomas Huth To: qemu-devel@nongnu.org, Peter Maydell Subject: [PULL 20/31] fuzz: Add instructions for using generic-fuzz Date: Mon, 26 Oct 2020 11:06:21 +0100 Message-Id: <20201026100632.212530-21-thuth@redhat.com> In-Reply-To: <20201026100632.212530-1-thuth@redhat.com> References: <20201026100632.212530-1-thuth@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=thuth@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=thuth@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/26 02:39:09 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Alexander Bulekov Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Alexander Bulekov Reviewed-by: Darren Kenny Signed-off-by: Alexander Bulekov Message-Id: <20201023150746.107063-13-alxndr@bu.edu> Signed-off-by: Thomas Huth --- docs/devel/fuzzing.txt | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/docs/devel/fuzzing.txt b/docs/devel/fuzzing.txt index 96d71c94d7..03585c1a9b 100644 --- a/docs/devel/fuzzing.txt +++ b/docs/devel/fuzzing.txt @@ -125,6 +125,45 @@ provided by libfuzzer. Libfuzzer passes a byte array a= nd length. Commonly the fuzzer loops over the byte-array interpreting it as a list of qtest comman= ds, addresses, or values. =20 +=3D=3D The Generic Fuzzer =3D=3D +Writing a fuzz target can be a lot of effort (especially if a device drive= r has +not be built-out within libqos). Many devices can be fuzzed to some degree, +without any device-specific code, using the generic-fuzz target. + +The generic-fuzz target is capable of fuzzing devices over their PIO, MMIO, +and DMA input-spaces. To apply the generic-fuzz to a device, we need to de= fine +two env-variables, at minimum: + +QEMU_FUZZ_ARGS=3D is the set of QEMU arguments used to configure a machine= , with +the device attached. For example, if we want to fuzz the virtio-net device +attached to a pc-i440fx machine, we can specify: +QEMU_FUZZ_ARGS=3D"-M pc -nodefaults -netdev user,id=3Duser0 \ + -device virtio-net,netdev=3Duser0" + +QEMU_FUZZ_OBJECTS=3D is a set of space-delimited strings used to identify = the +MemoryRegions that will be fuzzed. These strings are compared against +MemoryRegion names and MemoryRegion owner names, to decide whether each +MemoryRegion should be fuzzed. These strings support globbing. For the +virtio-net example, we could use QEMU_FUZZ_OBJECTS=3D + * 'virtio-net' + * 'virtio*' + * 'virtio* pcspk' (Fuzz the virtio devices and the PC speaker...) + * '*' (Fuzz the whole machine) + +The "info mtree" and "info qom-tree" monitor commands can be especially us= eful +for identifying the MemoryRegion and Object names used for matching. + +As a generic rule-of-thumb, the more MemoryRegions/Devices we match, the g= reater +the input-space, and the smaller the probability of finding crashing input= s for +individual devices. As such, it is usually a good idea to limit the fuzzer= to +only a few MemoryRegions. + +To ensure that these env variables have been configured correctly, we can = use: + +./qemu-fuzz-i386 --fuzz-target=3Dgeneric-fuzz -runs=3D0 + +The output should contain a complete list of matched MemoryRegions. + =3D Implementation Details =3D =20 =3D=3D The Fuzzer's Lifecycle =3D=3D --=20 2.18.2