From patchwork Wed Oct 30 14:49:59 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Bulekov X-Patchwork-Id: 1186799 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=bu.edu Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=bushare.onmicrosoft.com header.i=@bushare.onmicrosoft.com header.b="yE9Ny86W"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 473Bbp4PkYz9sP3 for ; Thu, 31 Oct 2019 02:05:58 +1100 (AEDT) Received: from localhost ([::1]:41348 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iPpXn-0000RY-R9 for incoming@patchwork.ozlabs.org; Wed, 30 Oct 2019 11:05:55 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35365) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iPpIR-00053j-JP for qemu-devel@nongnu.org; Wed, 30 Oct 2019 10:50:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iPpIQ-0007KN-CB for qemu-devel@nongnu.org; Wed, 30 Oct 2019 10:50:03 -0400 Received: from mail-eopbgr690115.outbound.protection.outlook.com ([40.107.69.115]:23033 helo=NAM04-CO1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iPpIQ-0007Ax-4Q for qemu-devel@nongnu.org; Wed, 30 Oct 2019 10:50:02 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ob/O8ADCS1WReBZ6hk3CNr5k21el4oQUy2NFEpLdVDyLUMF1PceElcwsI9kCOVOt+lLj+Rbwe1Y/0MXh/z7ZWEITDIm67eKI5iAkX43Hb1BUKOhfqKZ8MA6coHOsy4MKWxyick1bkhAQJRmBfr50khWgPq4bpWAdnNfJInFWfVnVkVjBJyP50ipqd5RN1qVIxg/WJ070idupoIVezrYm++qF30ioqpp/dqG1BqTHllOXxt7ELGqCRT/uVT2exqih/pfMDhynzevVuV/5sfhgo4YWPyx47qWVcCOmJjaA3XAQgu2vTpoKWKuIzQl3bOifmaEC3o9Q0pfECpIdq7fGOQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=5A2jXiUgW+IZC2QLmA+Q4LR+o2sg3npX/gkaI/Li8WI=; b=GTRBDNDjDMK4gg/gQdOGtDiQM6YzcxrMjwGSeNeC2aySteVOku+G1G3xT9wTJ6hJN/64op4J+dedPabGdRGu2vdfj19jKQoBv4jxjXlJKVe1tS7AMdmld8Q0LuM91IhaZEyRMULnwJ/aL5ESiiyzTcJMDPSogqBas1K2eKyL5WFW8BmMbeWb8Ue9qtwQIE2dfqs6zO1rwdWK8GhDYMPREKxY0+sUGSFrRrgFPsVlbfNBdsT8iu3H+V84N6cR21qjCiE06Imi8lEdAcMxswHwZ+4yKks73FteZRJwWX51BxFKqCcfsQ9Ov1zzqZfrBTt5Sm+kNjdBfnL+pyDDO5dUgw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=bu.edu; dmarc=pass action=none header.from=bu.edu; dkim=pass header.d=bu.edu; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bushare.onmicrosoft.com; s=selector2-bushare-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=5A2jXiUgW+IZC2QLmA+Q4LR+o2sg3npX/gkaI/Li8WI=; b=yE9Ny86WoBg4KQ4tgKwQCXDmYE8OKvANE2UiFi+WZYep6528BSTtIbsMfukMwtLCWbeBYIRb85Jx/A5pa7pfJ50wG+bcGL/erGniDeuD0daJrYdopGLIeqmrQVpKcBHmkd9f20AMGY7bM4Zb3lhg1X/s8+Zk0/Zd9D8s/oq4uxs= Received: from MN2PR03MB4800.namprd03.prod.outlook.com (20.179.82.78) by MN2PR03MB4959.namprd03.prod.outlook.com (52.132.168.18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2387.22; Wed, 30 Oct 2019 14:49:59 +0000 Received: from MN2PR03MB4800.namprd03.prod.outlook.com ([fe80::344f:b88:26f0:9f66]) by MN2PR03MB4800.namprd03.prod.outlook.com ([fe80::344f:b88:26f0:9f66%7]) with mapi id 15.20.2387.028; Wed, 30 Oct 2019 14:49:59 +0000 From: "Oleinik, Alexander" To: "qemu-devel@nongnu.org" Subject: [PATCH v4 13/20] fuzz: add configure flag --enable-fuzzing Thread-Topic: [PATCH v4 13/20] fuzz: add configure flag --enable-fuzzing Thread-Index: AQHVjzFNJM1RkEcEfUWq2jVZP3MbOA== Date: Wed, 30 Oct 2019 14:49:59 +0000 Message-ID: <20191030144926.11873-14-alxndr@bu.edu> References: <20191030144926.11873-1-alxndr@bu.edu> In-Reply-To: <20191030144926.11873-1-alxndr@bu.edu> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-mailer: git-send-email 2.23.0 x-originating-ip: [128.197.127.33] x-clientproxiedby: DM5PR08CA0048.namprd08.prod.outlook.com (2603:10b6:4:60::37) To MN2PR03MB4800.namprd03.prod.outlook.com (2603:10b6:208:101::14) authentication-results: spf=none (sender IP is ) smtp.mailfrom=alxndr@bu.edu; x-ms-exchange-messagesentrepresentingtype: 1 x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 41e83748-740c-4189-fbd7-08d75d486fc8 x-ms-traffictypediagnostic: MN2PR03MB4959: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:962; x-forefront-prvs: 02065A9E77 x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(396003)(366004)(39860400002)(376002)(346002)(136003)(199004)(189003)(102836004)(386003)(6506007)(66946007)(66446008)(64756008)(66476007)(2616005)(186003)(2351001)(446003)(26005)(36756003)(66556008)(3846002)(6116002)(2501003)(14454004)(11346002)(66066001)(256004)(4326008)(6916009)(305945005)(1076003)(6486002)(486006)(5660300002)(71190400001)(50226002)(71200400001)(476003)(86362001)(88552002)(7736002)(52116002)(76176011)(2906002)(478600001)(99286004)(786003)(316002)(8676002)(81166006)(5640700003)(81156014)(25786009)(6436002)(75432002)(8936002)(6512007); DIR:OUT; SFP:1102; SCL:1; SRVR:MN2PR03MB4959; H:MN2PR03MB4800.namprd03.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; received-spf: None (protection.outlook.com: bu.edu does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: Yw9hg+ho3XUeN1xXcvCfU+Xi88MEUV1+7loj2vTmXhIftp0tEKDApT+uSIMUYz2hxU4Mnn/IGDNGa44Iz2lfvDHEqpmqx6VLfKwyxJPobi4/1X63KgayM1o1Z/Y9Q+N4Ae/S5HOMEqby0iqwBRvrbVaRCBOyBs8GpMbQblEY093K2z1bhdo5xB246Kf2J8AKd0oW6C1bArSuPQklUrN+0pQtnw8JNa8vW/5yft/AtD2kT5KKODj909vEZ0hHh/jPgs9FLFVFVRPaCnb1adB0gDXmVaAar/6X6taI1e3ocift+zo51Xq8zoM4SclouOs8sDEdjELyNhBxrGKIgjxi6XkPdEFsIGeU1t1xnN0RusHg115IHgvS95BswpTRYa4iKyUIU98kmyfrqSs1MXNHSRogNMaqcLsBBR2FDUWQbuuvV5+dih68tUsiSAmxYjv7 MIME-Version: 1.0 X-OriginatorOrg: bu.edu X-MS-Exchange-CrossTenant-Network-Message-Id: 41e83748-740c-4189-fbd7-08d75d486fc8 X-MS-Exchange-CrossTenant-originalarrivaltime: 30 Oct 2019 14:49:59.2694 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: d57d32cc-c121-488f-b07b-dfe705680c71 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: kltoLeTetWkMHfB/yULXqN7mkg883N2P+QiIa6lDVDTUJHlM8RB6V31qcI8CyROB X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR03MB4959 X-detected-operating-system: by eggs.gnu.org: Windows 7 or 8 [fuzzy] X-Received-From: 40.107.69.115 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: "Oleinik, Alexander" Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Alexander Oleinik Signed-off-by: Alexander Oleinik Reviewed-by: Stefan Hajnoczi --- configure | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/configure b/configure index 3be9e92a24..aeca632dd9 100755 --- a/configure +++ b/configure @@ -501,6 +501,7 @@ libxml2="" debug_mutex="no" libpmem="" default_devices="yes" +fuzzing="no" supported_cpu="no" supported_os="no" @@ -630,6 +631,15 @@ int main(void) { return 0; } EOF } +write_c_fuzzer_skeleton() { + cat > $TMPC < +#include +int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size); +int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) { return 0; } +EOF +} + if check_define __linux__ ; then targetos="Linux" elif check_define _WIN32 ; then @@ -1532,6 +1542,10 @@ for opt do ;; --disable-xkbcommon) xkbcommon=no ;; + --enable-fuzzing) fuzzing=yes + ;; + --disable-fuzzing) fuzzing=no + ;; *) echo "ERROR: unknown option $opt" echo "Try '$0 --help' for more information" @@ -5911,6 +5925,15 @@ EOF fi fi +########################################## +# checks for fuzzer +if test "$fuzzing" = "yes" ; then + write_c_fuzzer_skeleton + if compile_prog "$CPU_CFLAGS -Werror -fsanitize=address,fuzzer" ""; then + have_fuzzer=yes + fi +fi + ########################################## # check for libpmem @@ -6491,6 +6514,7 @@ echo "capstone $capstone" echo "libpmem support $libpmem" echo "libudev $libudev" echo "default devices $default_devices" +echo "fuzzing support $fuzzing" if test "$supported_cpu" = "no"; then echo @@ -7327,6 +7351,16 @@ fi if test "$sheepdog" = "yes" ; then echo "CONFIG_SHEEPDOG=y" >> $config_host_mak fi +if test "$fuzzing" = "yes" ; then + if test "$have_fuzzer" = "yes"; then + FUZZ_LDFLAGS=" -fsanitize=address,fuzzer" + FUZZ_CFLAGS=" -fsanitize=address,fuzzer" + CFLAGS=" -fsanitize=address" + else + error_exit "Your compiler doesn't support -fsanitize=address,fuzzer" + exit 1 + fi +fi if test "$tcg_interpreter" = "yes"; then QEMU_INCLUDES="-iquote \$(SRC_PATH)/tcg/tci $QEMU_INCLUDES" @@ -7409,6 +7443,11 @@ if test "$libudev" != "no"; then echo "CONFIG_LIBUDEV=y" >> $config_host_mak echo "LIBUDEV_LIBS=$libudev_libs" >> $config_host_mak fi +if test "$fuzzing" != "no"; then + echo "CONFIG_FUZZ=y" >> $config_host_mak + echo "FUZZ_CFLAGS=$FUZZ_CFLAGS" >> $config_host_mak + echo "FUZZ_LDFLAGS=$FUZZ_LDFLAGS" >> $config_host_mak +fi # use included Linux headers if test "$linux" = "yes" ; then