From patchwork Wed Oct 21 01:07:37 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Bulekov X-Patchwork-Id: 302433 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.3 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, HK_RANDOM_FROM, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E5CEFC4363D for ; Wed, 21 Oct 2020 01:10:12 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 408D120797 for ; Wed, 21 Oct 2020 01:10:12 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=bushare.onmicrosoft.com header.i=@bushare.onmicrosoft.com header.b="3OFgpacv" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 408D120797 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=bu.edu Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:43086 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kV2dn-0002Ut-31 for qemu-devel@archiver.kernel.org; Tue, 20 Oct 2020 21:10:11 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44324) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kV2bx-0000rj-En for qemu-devel@nongnu.org; Tue, 20 Oct 2020 21:08:17 -0400 Received: from mail-co1nam11on2130.outbound.protection.outlook.com ([40.107.220.130]:28640 helo=NAM11-CO1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kV2bv-0004s9-J7 for qemu-devel@nongnu.org; Tue, 20 Oct 2020 21:08:17 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=NZVjnlfLBW0xhrgw3/jAQoj7ePx2Ad8ME4CnHrOyd5fugeoJ75ZI6HQ4Fdlig8vpP5S2/DidsYg+rT9lBKnGn45pV+N5Y/U4+x7/Mv42dLAbS4K0pJgAi8LEMCujhplMyZTq1KsUI97yUYylQ/xRQUDyx0evTpS3u1cDtizpMDLHzFgZz1dBE8fXsuWUDCDWq7cQgxIBtmwIrAhfp6BaCcTib15710NdIrMeOhs6+zZSGGZX5mdWT3N7FCcsau98M/5ebYOf5jae9uFXq3Khg8+zXksgBeILo8SziuZ1qNqv2sCSMnYPdzAhCYv5wegooVPXRuofm+OvaUvPW1hiWw== 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=MX056Rf6DSUltnR4J91NJYCtam/Fo4tFlIXd4RkYse8=; b=MV1/mFcJrEAozNY4unx/AW7GM51qmhb+nbR01dnpXHZcRe6yL+600UflGAF3wrBJqwRAkz4HoY77mQrmvr6VcTlVhsj/qG/bjNQku3shY+LMttAZFM1UTCDSOaidB0MHZWN0u3SCjnYDAJYPx4IZTAjVqJXAANa9VTbLria1MxddQF/JmvDTMq6nmv1l7BfGaVUPadJ1b+LQ6r+9R97zuxFDRvJygproDLPWNEImXDKPlhLu2ndFXEvg2hcQZ+soNQCR4MB3aKUDMWrei8mIpzsxBeenF+797+EWRBHKZNX1BPtX9M/3SQWqp4/dEU6gcjvsv+pQAKFrMYYOnlzQHw== 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=MX056Rf6DSUltnR4J91NJYCtam/Fo4tFlIXd4RkYse8=; b=3OFgpacvxwSY8y80Fk73pXilrItDrgKzdvOwV9w78Ci983yy5+CyOs+c/ZXVfuqFz/1pDFp2L5Foqfvto5EsvpGaFX90vPHFRHNOUlNl6NddMlbb4bXDjqMOZf62cLY+kHJDb8ATm8a5fwcNg9Tu5zk/PxEFDC/nhvD4d5i8wEc= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none; nongnu.org; dmarc=none action=none header.from=bu.edu; Received: from SN6PR03MB3871.namprd03.prod.outlook.com (2603:10b6:805:6d::32) by SN2PR03MB2333.namprd03.prod.outlook.com (2603:10b6:804:c::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3477.22; Wed, 21 Oct 2020 01:08:05 +0000 Received: from SN6PR03MB3871.namprd03.prod.outlook.com ([fe80::d520:4c19:8ce6:7db2]) by SN6PR03MB3871.namprd03.prod.outlook.com ([fe80::d520:4c19:8ce6:7db2%2]) with mapi id 15.20.3477.028; Wed, 21 Oct 2020 01:08:05 +0000 From: Alexander Bulekov To: qemu-devel@nongnu.org Subject: [PATCH v5 01/16] memory: Add FlatView foreach function Date: Tue, 20 Oct 2020 21:07:37 -0400 Message-Id: <20201021010752.973230-2-alxndr@bu.edu> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201021010752.973230-1-alxndr@bu.edu> References: <20201021010752.973230-1-alxndr@bu.edu> X-Originating-IP: [72.93.72.163] X-ClientProxiedBy: BL1PR13CA0119.namprd13.prod.outlook.com (2603:10b6:208:2b9::34) To SN6PR03MB3871.namprd03.prod.outlook.com (2603:10b6:805:6d::32) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from stormtrooper.vrmnet (72.93.72.163) by BL1PR13CA0119.namprd13.prod.outlook.com (2603:10b6:208:2b9::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3499.8 via Frontend Transport; Wed, 21 Oct 2020 01:08:04 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 141ea922-58b6-4f5c-8f9d-08d8755dc3ae X-MS-TrafficTypeDiagnostic: SN2PR03MB2333: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:2657; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: eV3WSTWgSS80brsJ6KMD/BH56I1+sbioNbjz4W9MhReCAy2Xac7JKRs4WA/32lfu4ZHntlbWDh5mLKysAtd2OqigYX1ijBW8i+kS7B7pT0FpEsdPf/gRXM7IhRVxREo2leJOU6Jbcm+GB3uCoWHC41kp1s9G39rvGwC17BGZ0eNPR/q7SIfAQ3S08XoUCt8+P3CXLb3intGj6iRgVJ+jdzU9mwuDigMJv6Cc6AeZgHp2SNC2PlukyHNg+RJA1gvVX7HlGQ7p66HqwOt80FkKtKVg7Tb4YoGqjAhqSeUAMNlsbZ96vC0J6JzX+WeddbjQGqoeQdaQai1r+Ria49bLzQ== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:SN6PR03MB3871.namprd03.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(39860400002)(396003)(376002)(346002)(366004)(136003)(52116002)(2616005)(8676002)(6512007)(6916009)(6506007)(36756003)(786003)(316002)(956004)(478600001)(1076003)(4326008)(6486002)(75432002)(8936002)(86362001)(5660300002)(26005)(16526019)(186003)(6666004)(66946007)(2906002)(66476007)(66556008); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: uH13vaCY/NH3IqL8Ni8AYGUGVhodrovVfX+qRaPVLnNfHLnxE8r+xJvz7yDx55jpXfdgQwfejtZpYFL7MlUyUfDSuGY50DGShy1oE6wPP16cV7tjIKB4H2ZVDRlN6Rx0wJI3TuYPs5U4arBWlMVJzQvlTxKLa0wPA9FC9/8OcL3cUQJ9tCC3lspTJyw+y3Ui/udvghnJBb6dDNxr85zYHfHFI+xx2KTwXqcKq7X2v3D0a1dCfU7x0Ql/EBEm7nJ3QkrfASFpmuXmhwIkYE38W6x1cXVUFbg6zAjFbGln4NIJzeuBEaelFjZqV8Q/vUw++lYxFWqzf4yIRX3XgxdJDv2p1bHayMb6wklS5zKqxnYOF8j2v+QZkZzJYe4NtBJnefnKqEFPvk6aWeQW/4zn8F/y+punnMr9E1GWpgdqLwTEHQTOZ3ipNr3i6yxNZ0yQAquTSIYyGqSjJaRlHHy53zu2zIW45FnbnstnuQCba8yhe84XS4nt7LFiGDiaJlibEygeJQNXg4F2XEjMPlqvgDeISMFSbbcgvImdfdCMewo04bn8FF7DPfC5aC/GWdHDJ5qSxOmNjJVwvteIEGKs4uVtMtjvCAy71/x6ggoL2ySuXrfpO/5+VOhgycsnB+Esf+i+jDbQt3CDnK9S9RA97A== X-OriginatorOrg: bu.edu X-MS-Exchange-CrossTenant-Network-Message-Id: 141ea922-58b6-4f5c-8f9d-08d8755dc3ae X-MS-Exchange-CrossTenant-AuthSource: SN6PR03MB3871.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Oct 2020 01:08:04.9989 (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: 4KVxQJnE5rWQNmVNYtS8MomCOsLrTgI4A2Ie6BlsCo7wTwgtsAsRzsz5Ke3uUopg X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN2PR03MB2333 Received-SPF: pass client-ip=40.107.220.130; envelope-from=alxndr@bu.edu; helo=NAM11-CO1-obe.outbound.protection.outlook.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/20 21:08:14 X-ACL-Warn: Detected OS = Windows NT kernel [generic] [fuzzy] X-Spam_score_int: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, HK_RANDOM_ENVFROM=0.001, HK_RANDOM_FROM=0.441, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no 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 , f4bug@amsat.org, darren.kenny@oracle.com, bsd@redhat.com, stefanha@redhat.com, pbonzini@redhat.com, dimastep@yandex-team.ru Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Acked-by: Paolo Bonzini Signed-off-by: Alexander Bulekov --- include/exec/memory.h | 5 +++++ softmmu/memory.c | 9 +++++++++ 2 files changed, 14 insertions(+) diff --git a/include/exec/memory.h b/include/exec/memory.h index 622207bde1..233655b29a 100644 --- a/include/exec/memory.h +++ b/include/exec/memory.h @@ -719,6 +719,11 @@ static inline FlatView *address_space_to_flatview(AddressSpace *as) return qatomic_rcu_read(&as->current_map); } +typedef int (*flatview_cb)(ram_addr_t start, + ram_addr_t len, + const MemoryRegion*, void*); + +void flatview_for_each_range(FlatView *fv, flatview_cb cb , void *opaque); /** * struct MemoryRegionSection: describes a fragment of a #MemoryRegion diff --git a/softmmu/memory.c b/softmmu/memory.c index 403ff3abc9..c46b0c6d65 100644 --- a/softmmu/memory.c +++ b/softmmu/memory.c @@ -656,6 +656,15 @@ static void render_memory_region(FlatView *view, } } +void flatview_for_each_range(FlatView *fv, flatview_cb cb , void *opaque) +{ + FlatRange *fr; + FOR_EACH_FLAT_RANGE(fr, fv) { + if (cb(fr->addr.start, fr->addr.size, fr->mr, opaque)) + break; + } +} + static MemoryRegion *memory_region_get_flatview_root(MemoryRegion *mr) { while (mr->enabled) { From patchwork Wed Oct 21 01:07:38 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Bulekov X-Patchwork-Id: 302432 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.3 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, HK_RANDOM_FROM, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id CCD22C388F2 for ; Wed, 21 Oct 2020 01:10:20 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id F0B3320797 for ; Wed, 21 Oct 2020 01:10:19 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=bushare.onmicrosoft.com header.i=@bushare.onmicrosoft.com header.b="zU/SDRBT" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org F0B3320797 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=bu.edu Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:43272 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kV2du-0002ZH-7L for qemu-devel@archiver.kernel.org; Tue, 20 Oct 2020 21:10:18 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44342) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kV2c0-0000sI-Ad for qemu-devel@nongnu.org; Tue, 20 Oct 2020 21:08:20 -0400 Received: from mail-co1nam11on2130.outbound.protection.outlook.com ([40.107.220.130]:28640 helo=NAM11-CO1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kV2bx-0004s9-RH for qemu-devel@nongnu.org; Tue, 20 Oct 2020 21:08:20 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=i0BgG6csKkzDKuFWWsS7X3TPGOoFEYRYPT5K52/kz3i0R3Mf1SgSI8MPd5qoVmmS86zYhvVyPzP7U0e19JrUBo8zldzWmgNc70ga2+j3OBPpkG4xSuJHdommp0NY+gOM/ivR8K+VV/a6rQBYEZDxlbLQ/dSTDrLJN/Ne21/y6Tfue3beyGzIwiCErKWzD6zQ2PiSnmMo9osODHCD9RMqg9+1LKRE7im+PeGBjNUpXak9UxTv2q+jevC8TLhjgfS9MwYIqPIc1+k1k44CSPr9EZOCGfqJ7VQcJPR9+s+9WvWQ0xO227OjxL+y2OKisPsKmNeurWVHpD+mP2mS4v7q3A== 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=hgnVKq3rlfr0QQt5ibv5kfWmASm2Jl1ktUSPPZc2bNc=; b=WeXhceMlHuxy1pVVMSfp0UmjpU0J3cjcUYiAhdVTtINGMjDJkoFn9iTwG0BfE3QhCatriAYs7DlOPM5XGLg6V/fVwihiSoqIrHp214w4RjrQsuKM2OQ9to8stcZQznlFfnYDXDk+4LslSX1hEVOVq6QAfvCdl+bR72L2uPvhdZ/m9qPhyx0SBldLeG7Lv7HpeVs43UcTL8h/FBGuxyHqGQ00Evyl4+czs+j8CxiEgHSWs9t+6OrD2OV7w/Q8DFQMYCuLwW+bc7cqTXjGEaBjSjiV3SL7bWSJeDSBi05KMi2p4Y7RCXlVWjUWN83okDXaoLdTr2v/K35ps3Xt7rjDmA== 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=hgnVKq3rlfr0QQt5ibv5kfWmASm2Jl1ktUSPPZc2bNc=; b=zU/SDRBT3X4wuZ6Ht5gkrffaSL0mfsge53JBW/tAqdeKVwF1aku9JR4QMPwgehXxgYb0qcd+c0mEAFvlo7oQymgfnMrq+9dZ7ywpgW2QJxcEBVZdUDAw6EinD0CQowKJ3qrBZ28GCZXL+rCbK5E13KBYcuuuVIj6R1uum8YoW5E= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none; nongnu.org; dmarc=none action=none header.from=bu.edu; Received: from SN6PR03MB3871.namprd03.prod.outlook.com (2603:10b6:805:6d::32) by SN2PR03MB2333.namprd03.prod.outlook.com (2603:10b6:804:c::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3477.22; Wed, 21 Oct 2020 01:08:06 +0000 Received: from SN6PR03MB3871.namprd03.prod.outlook.com ([fe80::d520:4c19:8ce6:7db2]) by SN6PR03MB3871.namprd03.prod.outlook.com ([fe80::d520:4c19:8ce6:7db2%2]) with mapi id 15.20.3477.028; Wed, 21 Oct 2020 01:08:06 +0000 From: Alexander Bulekov To: qemu-devel@nongnu.org Subject: [PATCH v5 02/16] fuzz: Add general virtual-device fuzzer Date: Tue, 20 Oct 2020 21:07:38 -0400 Message-Id: <20201021010752.973230-3-alxndr@bu.edu> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201021010752.973230-1-alxndr@bu.edu> References: <20201021010752.973230-1-alxndr@bu.edu> X-Originating-IP: [72.93.72.163] X-ClientProxiedBy: BL1PR13CA0119.namprd13.prod.outlook.com (2603:10b6:208:2b9::34) To SN6PR03MB3871.namprd03.prod.outlook.com (2603:10b6:805:6d::32) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from stormtrooper.vrmnet (72.93.72.163) by BL1PR13CA0119.namprd13.prod.outlook.com (2603:10b6:208:2b9::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3499.8 via Frontend Transport; Wed, 21 Oct 2020 01:08:05 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 66038689-6c82-4cad-e871-08d8755dc44f X-MS-TrafficTypeDiagnostic: SN2PR03MB2333: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:849; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 663v5MuerIek3A48lJ7qZ+N2V3Z3AyJ8v3siT9cbuOpJcccUGuN4f6eIuLvcHe9IIw3wgcI0zz93yKaES74sA3V7KKeNwzSpNHiPylSYv56+/9kYGVq5cayhBcSmB/LKuzRhU6np+c/lMHh+uCOBuvfSlottOeqqwQ8KUptrsdE+vCzi+XwkjxnCXVVvF7I0HKVCI6rdbWMSRsCxy8yjR09w8E5gYP3qIgjqQE70y5yX9IPK2ik1uDUXBU7RK06Vvd1WlfMCKBCrUlkIEQYw9rDcD9VO5u2b8DOPSTRF98Vn1WbtE+YXhTMy7bhS4NjKF4yCPlvBohnR3hYhNpr+MQ== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:SN6PR03MB3871.namprd03.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(39860400002)(396003)(376002)(346002)(366004)(136003)(52116002)(2616005)(8676002)(6512007)(6916009)(6506007)(36756003)(786003)(316002)(956004)(83380400001)(478600001)(1076003)(4326008)(6486002)(75432002)(8936002)(54906003)(30864003)(86362001)(5660300002)(26005)(16526019)(186003)(6666004)(66946007)(2906002)(66476007)(66556008); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: BabJejb6J6EmGc2DGvqiLxy5iZyu4CN9trYM3BtCq9JDFz3k6L3iLc0dFzjPp4mJSVVvHUVGvLzEC5+iuq0ilkzt5LkFLBUs3ZffDbKuEfJYI7mcB0TVx/kDhUDwJKpJTlv++TYurlarYlXaeSfmzIsL5ifA9gRXKyaI8wAhmFOvgLg7tG2poPrcN55IvstKj1QxJt5bxcNF0a08Op/7SFcsAzMJuCDWtMCuzBJSt5q4hbCkcgi6mPZ7sLxZ2sMRMtgz3JfRGgQAXKHPG4EkCIJUhAMTih1aY0MpWPwBZxdlQVr/DmE5sIJwoQJrsapMYzHqu8jiZsKzFOkJ4eAW5NzPwDsEqtmb/NUJKpZxopSVjcbASlB7OVvkTY1kseoBnQKBiWu2OGqFDxeoZs5klsZyBsYb909LHGCJXowbstSRpcabSgvaPiC2NtVvnWXybbMKPhVKs3OrU1JbBaOI/voJX0+I9F+jIjSMg5atcUp9XwX6l6zgIxPbYTpiMxTsTFxxvuZIrStAqeH8nPTWGOVRER+aU0AJpDi6KoYjz3v4FPM0/1WUEjarpiawdMkan+XqlEW74iy0TBaNS9czZkcT3dVc9w8qg3mWQvJa1eCakTRC/njGEktz4B/8S5ZtwE4mm18iQvKA6qnpRk3TTA== X-OriginatorOrg: bu.edu X-MS-Exchange-CrossTenant-Network-Message-Id: 66038689-6c82-4cad-e871-08d8755dc44f X-MS-Exchange-CrossTenant-AuthSource: SN6PR03MB3871.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Oct 2020 01:08:06.2122 (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: RQ9zMurBBNt3fsjURCz1if5SVSi8UkjMoFeu8wGshHb4FFqKwItSHDTVnMLrmrVc X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN2PR03MB2333 Received-SPF: pass client-ip=40.107.220.130; envelope-from=alxndr@bu.edu; helo=NAM11-CO1-obe.outbound.protection.outlook.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/20 21:08:14 X-ACL-Warn: Detected OS = Windows NT kernel [generic] [fuzzy] X-Spam_score_int: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, HK_RANDOM_ENVFROM=0.001, HK_RANDOM_FROM=0.441, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no 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: Laurent Vivier , Thomas Huth , Alexander Bulekov , f4bug@amsat.org, darren.kenny@oracle.com, bsd@redhat.com, stefanha@redhat.com, pbonzini@redhat.com, dimastep@yandex-team.ru Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" This is a generic fuzzer designed to fuzz a virtual device's MemoryRegions, as long as they exist within the Memory or Port IO (if it exists) AddressSpaces. The fuzzer's input is interpreted into a sequence of qtest commands (outb, readw, etc). The interpreted commands are separated by a magic seaparator, which should be easy for the fuzzer to guess. Without ASan, the separator can be specified as a "dictionary value" using the -dict argument (see libFuzzer documentation). Signed-off-by: Alexander Bulekov --- tests/qtest/fuzz/generic_fuzz.c | 511 ++++++++++++++++++++++++++++++++ tests/qtest/fuzz/meson.build | 1 + 2 files changed, 512 insertions(+) create mode 100644 tests/qtest/fuzz/generic_fuzz.c diff --git a/tests/qtest/fuzz/generic_fuzz.c b/tests/qtest/fuzz/generic_fuzz.c new file mode 100644 index 0000000000..50e5022d4a --- /dev/null +++ b/tests/qtest/fuzz/generic_fuzz.c @@ -0,0 +1,511 @@ +/* + * Generic Virtual-Device Fuzzing Target + * + * Copyright Red Hat Inc., 2020 + * + * Authors: + * Alexander Bulekov + * + * This work is licensed under the terms of the GNU GPL, version 2 or later. + * See the COPYING file in the top-level directory. + */ + +#include "qemu/osdep.h" + +#include + +#include "hw/core/cpu.h" +#include "tests/qtest/libqos/libqtest.h" +#include "fuzz.h" +#include "fork_fuzz.h" +#include "exec/address-spaces.h" +#include "string.h" +#include "exec/memory.h" +#include "exec/ramblock.h" +#include "exec/address-spaces.h" +#include "hw/qdev-core.h" + +/* + * SEPARATOR is used to separate "operations" in the fuzz input + */ +#define SEPARATOR "FUZZ" + +enum cmds { + OP_IN, + OP_OUT, + OP_READ, + OP_WRITE, + OP_CLOCK_STEP, +}; + +#define DEFAULT_TIMEOUT_US 100000 +#define USEC_IN_SEC 1000000000 + +typedef struct { + ram_addr_t addr; + ram_addr_t size; /* The number of bytes until the end of the I/O region */ +} address_range; + +static useconds_t timeout = DEFAULT_TIMEOUT_US; + +static bool qtest_log_enabled; + +/* + * List of memory regions that are children of QOM objects specified by the + * user for fuzzing. + */ +static GHashTable *fuzzable_memoryregions; + +struct get_io_cb_info { + int index; + int found; + address_range result; +}; + +static int get_io_address_cb(ram_addr_t start, ram_addr_t size, + const MemoryRegion *mr, void *opaque) { + struct get_io_cb_info *info = opaque; + if (g_hash_table_lookup(fuzzable_memoryregions, mr)) { + if (info->index == 0) { + info->result.addr = start; + info->result.size = size; + info->found = 1; + return 1; + } + info->index--; + } + return 0; +} + +/* + * Here we want to convert a fuzzer-provided [io-region-index, offset] to + * a physical address. To do this, we iterate over all of the matched + * MemoryRegions. Check whether each region exists within the particular io + * space. Return the absolute address of the offset within the index'th region + * that is a subregion of the io_space and the distance until the end of the + * memory region. + */ +static bool get_io_address(address_range *result, AddressSpace *as, + uint8_t index, + uint32_t offset) { + FlatView *view; + view = as->current_map; + g_assert(view); + struct get_io_cb_info cb_info = {}; + + cb_info.index = index; + + /* + * Loop around the FlatView until we match "index" number of + * fuzzable_memoryregions, or until we know that there are no matching + * memory_regions. + */ + do { + flatview_for_each_range(view, get_io_address_cb , &cb_info); + } while (cb_info.index != index && !cb_info.found); + + *result = cb_info.result; + return cb_info.found; +} +static bool get_pio_address(address_range *result, + uint8_t index, uint16_t offset) +{ + /* + * PIO BARs can be set past the maximum port address (0xFFFF). Thus, result + * can contain an addr that extends past the PIO space. When we pass this + * address to qtest_in/qtest_out, it is cast to a uint16_t, so we might end + * up fuzzing a completely different MemoryRegion/Device. Therefore, check + * that the address here is within the PIO space limits. + */ + bool found = get_io_address(result, &address_space_io, index, offset); + return result->addr <= 0xFFFF ? found : false; +} +static bool get_mmio_address(address_range *result, + uint8_t index, uint32_t offset) +{ + return get_io_address(result, &address_space_memory, index, offset); +} + +static void op_in(QTestState *s, const unsigned char * data, size_t len) +{ + enum Sizes {Byte, Word, Long, end_sizes}; + struct { + uint8_t size; + uint8_t base; + uint16_t offset; + } a; + address_range abs; + + if (len < sizeof(a)) { + return; + } + memcpy(&a, data, sizeof(a)); + if (get_pio_address(&abs, a.base, a.offset) == 0) { + return; + } + + switch (a.size %= end_sizes) { + case Byte: + qtest_inb(s, abs.addr); + break; + case Word: + if (abs.size >= 2) { + qtest_inw(s, abs.addr); + } + break; + case Long: + if (abs.size >= 4) { + qtest_inl(s, abs.addr); + } + break; + } +} + +static void op_out(QTestState *s, const unsigned char * data, size_t len) +{ + enum Sizes {Byte, Word, Long, end_sizes}; + struct { + uint8_t size; + uint8_t base; + uint16_t offset; + uint32_t value; + } a; + address_range abs; + + if (len < sizeof(a)) { + return; + } + memcpy(&a, data, sizeof(a)); + + if (get_pio_address(&abs, a.base, a.offset) == 0) { + return; + } + + switch (a.size %= end_sizes) { + case Byte: + qtest_outb(s, abs.addr, a.value & 0xFF); + break; + case Word: + if (abs.size >= 2) { + qtest_outw(s, abs.addr, a.value & 0xFFFF); + } + break; + case Long: + if (abs.size >= 4) { + qtest_outl(s, abs.addr, a.value); + } + break; + } +} + +static void op_read(QTestState *s, const unsigned char * data, size_t len) +{ + enum Sizes {Byte, Word, Long, Quad, end_sizes}; + struct { + uint8_t size; + uint8_t base; + uint32_t offset; + } a; + address_range abs; + + if (len < sizeof(a)) { + return; + } + memcpy(&a, data, sizeof(a)); + + if (get_mmio_address(&abs, a.base, a.offset) == 0) { + return; + } + + switch (a.size %= end_sizes) { + case Byte: + qtest_readb(s, abs.addr); + break; + case Word: + if (abs.size >= 2) { + qtest_readw(s, abs.addr); + } + break; + case Long: + if (abs.size >= 4) { + qtest_readl(s, abs.addr); + } + break; + case Quad: + if (abs.size >= 8) { + qtest_readq(s, abs.addr); + } + break; + } +} + +static void op_write(QTestState *s, const unsigned char * data, size_t len) +{ + enum Sizes {Byte, Word, Long, Quad, end_sizes}; + struct { + uint8_t size; + uint8_t base; + uint32_t offset; + uint64_t value; + } a; + address_range abs; + + if (len < sizeof(a)) { + return; + } + memcpy(&a, data, sizeof(a)); + + if (get_mmio_address(&abs, a.base, a.offset) == 0) { + return; + } + + switch (a.size %= end_sizes) { + case Byte: + qtest_writeb(s, abs.addr, a.value & 0xFF); + break; + case Word: + if (abs.size >= 2) { + qtest_writew(s, abs.addr, a.value & 0xFFFF); + } + break; + case Long: + if (abs.size >= 4) { + qtest_writel(s, abs.addr, a.value & 0xFFFFFFFF); + } + break; + case Quad: + if (abs.size >= 8) { + qtest_writeq(s, abs.addr, a.value); + } + break; + } +} +static void op_clock_step(QTestState *s, const unsigned char *data, size_t len) +{ + qtest_clock_step_next(s); +} + +static void handle_timeout(int sig) +{ + if (qtest_log_enabled) { + fprintf(stderr, "[Timeout]\n"); + fflush(stderr); + } + _Exit(0); +} + +/* + * Here, we interpret random bytes from the fuzzer, as a sequence of commands. + * Some commands can be variable-width, so we use a separator, SEPARATOR, to + * specify the boundaries between commands. SEPARATOR is used to separate + * "operations" in the fuzz input. Why use a separator, instead of just using + * the operations' length to identify operation boundaries? + * 1. This is a simple way to support variable-length operations + * 2. This adds "stability" to the input. + * For example take the input "AbBcgDefg", where there is no separator and + * Opcodes are capitalized. + * Simply, by removing the first byte, we end up with a very different + * sequence: + * BbcGdefg... + * By adding a separator, we avoid this problem: + * Ab SEP Bcg SEP Defg -> B SEP Bcg SEP Defg + * Since B uses two additional bytes as operands, the first "B" will be + * ignored. The fuzzer actively tries to reduce inputs, so such unused + * bytes are likely to be pruned, eventually. + * + * SEPARATOR is trivial for the fuzzer to discover when using ASan. Optionally, + * SEPARATOR can be manually specified as a dictionary value (see libfuzzer's + * -dict), though this should not be necessary. + * + * As a result, the stream of bytes is converted into a sequence of commands. + * In a simplified example where SEPARATOR is 0xFF: + * 00 01 02 FF 03 04 05 06 FF 01 FF ... + * becomes this sequence of commands: + * 00 01 02 -> op00 (0102) -> in (0102, 2) + * 03 04 05 06 -> op03 (040506) -> write (040506, 3) + * 01 -> op01 (-,0) -> out (-,0) + * ... + * + * Note here that it is the job of the individual opcode functions to check + * that enough data was provided. I.e. in the last command out (,0), out needs + * to check that there is not enough data provided to select an address/value + * for the operation. + */ +static void generic_fuzz(QTestState *s, const unsigned char *Data, size_t Size) +{ + void (*ops[]) (QTestState *s, const unsigned char* , size_t) = { + [OP_IN] = op_in, + [OP_OUT] = op_out, + [OP_READ] = op_read, + [OP_WRITE] = op_write, + [OP_CLOCK_STEP] = op_clock_step, + }; + const unsigned char *cmd = Data; + const unsigned char *nextcmd; + size_t cmd_len; + uint8_t op; + + if (fork() == 0) { + /* + * Sometimes the fuzzer will find inputs that take quite a long time to + * process. Often times, these inputs do not result in new coverage. + * Even if these inputs might be interesting, they can slow down the + * fuzzer, overall. Set a timeout to avoid hurting performance, too much + */ + if (timeout) { + struct sigaction sact; + struct itimerval timer; + + sigemptyset(&sact.sa_mask); + sact.sa_flags = SA_NODEFER; + sact.sa_handler = handle_timeout; + sigaction(SIGALRM, &sact, NULL); + + memset(&timer, 0, sizeof(timer)); + timer.it_value.tv_sec = timeout / USEC_IN_SEC; + timer.it_value.tv_usec = timeout % USEC_IN_SEC; + setitimer(ITIMER_VIRTUAL, &timer, NULL); + } + + while (cmd && Size) { + /* Get the length until the next command or end of input */ + nextcmd = memmem(cmd, Size, SEPARATOR, strlen(SEPARATOR)); + cmd_len = nextcmd ? nextcmd - cmd : Size; + + if (cmd_len > 0) { + /* Interpret the first byte of the command as an opcode */ + op = *cmd % (sizeof(ops) / sizeof((ops)[0])); + ops[op](s, cmd + 1, cmd_len - 1); + + /* Run the main loop */ + flush_events(s); + } + /* Advance to the next command */ + cmd = nextcmd ? nextcmd + sizeof(SEPARATOR) - 1 : nextcmd; + Size = Size - (cmd_len + sizeof(SEPARATOR) - 1); + } + _Exit(0); + } else { + flush_events(s); + wait(0); + } +} + +static void usage(void) +{ + printf("Please specify the following environment variables:\n"); + printf("QEMU_FUZZ_ARGS= the command line arguments passed to qemu\n"); + printf("QEMU_FUZZ_OBJECTS= " + "a space separated list of QOM type names for objects to fuzz\n"); + printf("Optionally: QEMU_FUZZ_TIMEOUT= Specify a custom timeout (us). " + "0 to disable. %d by default\n", timeout); + exit(0); +} + +static int locate_fuzz_memory_regions(Object *child, void *opaque) +{ + const char *name; + MemoryRegion *mr; + if (object_dynamic_cast(child, TYPE_MEMORY_REGION)) { + mr = MEMORY_REGION(child); + if ((memory_region_is_ram(mr) || + memory_region_is_ram_device(mr) || + memory_region_is_rom(mr)) == false) { + name = object_get_canonical_path_component(child); + /* + * We don't want duplicate pointers to the same MemoryRegion, so + * try to remove copies of the pointer, before adding it. + */ + g_hash_table_insert(fuzzable_memoryregions, mr, (gpointer)true); + } + } + return 0; +} +static int locate_fuzz_objects(Object *child, void *opaque) +{ + char *pattern = opaque; + if (g_pattern_match_simple(pattern, object_get_typename(child))) { + /* Find and save ptrs to any child MemoryRegions */ + object_child_foreach_recursive(child, locate_fuzz_memory_regions, NULL); + + } else if (object_dynamic_cast(OBJECT(child), TYPE_MEMORY_REGION)) { + if (g_pattern_match_simple(pattern, + object_get_canonical_path_component(child))) { + MemoryRegion *mr; + mr = MEMORY_REGION(child); + if ((memory_region_is_ram(mr) || + memory_region_is_ram_device(mr) || + memory_region_is_rom(mr)) == false) { + g_hash_table_insert(fuzzable_memoryregions, mr, (gpointer)true); + } + } + } + return 0; +} + +static void generic_pre_fuzz(QTestState *s) +{ + GHashTableIter iter; + MemoryRegion *mr; + char **result; + + if (!getenv("QEMU_FUZZ_OBJECTS")) { + usage(); + } + if (getenv("QTEST_LOG")) { + qtest_log_enabled = 1; + } + if (getenv("QEMU_FUZZ_TIMEOUT")) { + timeout = g_ascii_strtoll(getenv("QEMU_FUZZ_TIMEOUT"), NULL, 0); + } + + fuzzable_memoryregions = g_hash_table_new(NULL, NULL); + + result = g_strsplit(getenv("QEMU_FUZZ_OBJECTS"), " ", -1); + for (int i = 0; result[i] != NULL; i++) { + printf("Matching objects by name %s\n", result[i]); + object_child_foreach_recursive(qdev_get_machine(), + locate_fuzz_objects, + result[i]); + } + g_strfreev(result); + printf("This process will try to fuzz the following MemoryRegions:\n"); + + g_hash_table_iter_init(&iter, fuzzable_memoryregions); + while (g_hash_table_iter_next(&iter, (gpointer)&mr, NULL)) { + printf(" * %s (size %lx)\n", + object_get_canonical_path_component(&(mr->parent_obj)), + (uint64_t)mr->size); + } + + if (!g_hash_table_size(fuzzable_memoryregions)) { + printf("No fuzzable memory regions found...\n"); + exit(1); + } + + counter_shm_init(); +} + +static GString *generic_fuzz_cmdline(FuzzTarget *t) +{ + GString *cmd_line = g_string_new(TARGET_NAME); + if (!getenv("QEMU_FUZZ_ARGS")) { + usage(); + } + g_string_append_printf(cmd_line, " -display none \ + -machine accel=qtest, \ + -m 512M %s ", getenv("QEMU_FUZZ_ARGS")); + return cmd_line; +} + +static void register_generic_fuzz_targets(void) +{ + fuzz_add_target(&(FuzzTarget){ + .name = "generic-fuzz", + .description = "Fuzz based on any qemu command-line args. ", + .get_init_cmdline = general_fuzz_cmdline, + .pre_fuzz = general_pre_fuzz, + .fuzz = general_fuzz}); +} + +fuzz_target_init(register_generic_fuzz_targets); diff --git a/tests/qtest/fuzz/meson.build b/tests/qtest/fuzz/meson.build index b31ace7d5a..5162321f30 100644 --- a/tests/qtest/fuzz/meson.build +++ b/tests/qtest/fuzz/meson.build @@ -5,6 +5,7 @@ specific_fuzz_ss.add(files('fuzz.c', 'fork_fuzz.c', 'qos_fuzz.c', specific_fuzz_ss.add(when: 'CONFIG_I440FX', if_true: files('i440fx_fuzz.c')) specific_fuzz_ss.add(when: 'CONFIG_VIRTIO_NET', if_true: files('virtio_net_fuzz.c')) specific_fuzz_ss.add(when: 'CONFIG_VIRTIO_SCSI', if_true: files('virtio_scsi_fuzz.c')) +specific_fuzz_ss.add(files('generic_fuzz.c')) fork_fuzz = declare_dependency( link_args: config_host['FUZZ_EXE_LDFLAGS'].split() + From patchwork Wed Oct 21 01:07:39 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Bulekov X-Patchwork-Id: 270826 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.3 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, HK_RANDOM_FROM, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9B770C4363D for ; Wed, 21 Oct 2020 01:10:18 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 055D320797 for ; Wed, 21 Oct 2020 01:10:17 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=bushare.onmicrosoft.com header.i=@bushare.onmicrosoft.com header.b="sfjaWuaa" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 055D320797 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=bu.edu Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:43296 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kV2ds-0002Zz-SB for qemu-devel@archiver.kernel.org; Tue, 20 Oct 2020 21:10:16 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44364) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kV2c2-0000tT-Cf for qemu-devel@nongnu.org; Tue, 20 Oct 2020 21:08:22 -0400 Received: from mail-co1nam11on2130.outbound.protection.outlook.com ([40.107.220.130]:28640 helo=NAM11-CO1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kV2c0-0004s9-Ps for qemu-devel@nongnu.org; Tue, 20 Oct 2020 21:08:22 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=UA8oNqAOPoAEvwL6PNkK03zKyPbvCMBUBCypRbX8W+SvGIZmnLYEkK68x0fvzyL7tpd3tXd33xjSM7Pzqcwz97miPhc7/ecObRfs+iwKM2Oy6QzGzBzBuLJ4BcohtfJmcZRRkCSpt12N13bN/ZSKJusIL2oS2ugpSkgH8BrpJD0HQvlpWDZ+H+1pl/PsonXDBYAE5C0jdCNzXqjhKKt2IXTndOaPQVEyYKYD1NfIkt5XeXRtaVFVtZxekS9r+EZ8HQPVu2dsHAqArnoszg6VmosI2Z8VLfi/7Hx5SXKyvrLK+cXG+sPr6H1MV4+fBrkW5d+CmY2wAe0d/hG9mY0aMA== 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=D0oLyi3kpXguVgquDNXEHfgQwNaQJLCT6XK0weT4Oy0=; b=TBpBNJmulM9h1al2RiC6uv08cvo41L+k9agCaunpGU97bw7knaHRmJRaxwy4EUjtC/5NYiMgtP5OAeVIFUHsoew28hdSUfWiXZTf41l2HO/Qtl4ELG+f26IBoAMCeH5AW7vraz9EvesU0E2h9JGLapsNoVohaortnWDKNOXTkSEGSae/ZP5g5ykL0Ov9wWvWhm8cUznXLORNgbfYI+D6BVrVtgKDq0K2OKhn/6yv9OYfsZ0M8O3JhaRKfW6zArUrHKbvJBUtSTrGpnpLe3duP9HAKSDcfMSAUdBbRrpBryd0ZNGnKI4S4iPp5YHRyBNOSmcbt6N7hDufa2ZJzwahCg== 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=D0oLyi3kpXguVgquDNXEHfgQwNaQJLCT6XK0weT4Oy0=; b=sfjaWuaaJ/hxq7klHiEVs6A6JWy+IfEbTQSIEUW/LKmvDA7J2LEyVF3fgFRBoPsAoSDrGmEzCxMaXDbUwvZ8Cqq2V2X960MwMlREu2Ia6LtsrbIwwxIPym7+AU0dZ43R+8OQns/iPfqs7m/Uv+KAN1Ry6KjqVLMhZmsTrz6caIc= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none; nongnu.org; dmarc=none action=none header.from=bu.edu; Received: from SN6PR03MB3871.namprd03.prod.outlook.com (2603:10b6:805:6d::32) by SN2PR03MB2333.namprd03.prod.outlook.com (2603:10b6:804:c::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3477.22; Wed, 21 Oct 2020 01:08:08 +0000 Received: from SN6PR03MB3871.namprd03.prod.outlook.com ([fe80::d520:4c19:8ce6:7db2]) by SN6PR03MB3871.namprd03.prod.outlook.com ([fe80::d520:4c19:8ce6:7db2%2]) with mapi id 15.20.3477.028; Wed, 21 Oct 2020 01:08:08 +0000 From: Alexander Bulekov To: qemu-devel@nongnu.org Subject: [PATCH v5 03/16] fuzz: Add PCI features to the general fuzzer Date: Tue, 20 Oct 2020 21:07:39 -0400 Message-Id: <20201021010752.973230-4-alxndr@bu.edu> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201021010752.973230-1-alxndr@bu.edu> References: <20201021010752.973230-1-alxndr@bu.edu> X-Originating-IP: [72.93.72.163] X-ClientProxiedBy: BL1PR13CA0119.namprd13.prod.outlook.com (2603:10b6:208:2b9::34) To SN6PR03MB3871.namprd03.prod.outlook.com (2603:10b6:805:6d::32) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from stormtrooper.vrmnet (72.93.72.163) by BL1PR13CA0119.namprd13.prod.outlook.com (2603:10b6:208:2b9::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3499.8 via Frontend Transport; Wed, 21 Oct 2020 01:08:07 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 7ba5e3c2-82de-4ce7-1c70-08d8755dc550 X-MS-TrafficTypeDiagnostic: SN2PR03MB2333: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:268; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 6SqEuf2LPhozvg5dKDmizn7zNFatojUuCSsp82Q8K1yzteYT2gdupWHrIoyVHLMn6sBlpiAqf51ZuY5KaAuaD1Ecn6A4k01ue/mPQWiQQrpfAfaUDNPGWfK23rzb5WRhnf1oEGbsG0iMuuHB9kx6fRkYw0SuZHmRAu46ScxH9HntfPsv4xrUg88Esm7M/9TM/ia08TVsfSB/TziN5mI7XIUaftWy2mq344fBeAufWINvSejUsIjlZZjQNxpIJMW1iWvkFcRBnhdzQR0ud4qZzhU9rlJ2GDBkjScda8G22QR4NvXOJAFSjjRbxesP7M/h8dNEzUQoYE9PXQyTIVZtwg== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:SN6PR03MB3871.namprd03.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(39860400002)(396003)(376002)(346002)(366004)(136003)(52116002)(2616005)(8676002)(6512007)(6916009)(6506007)(36756003)(786003)(316002)(956004)(83380400001)(478600001)(1076003)(4326008)(6486002)(75432002)(8936002)(54906003)(86362001)(5660300002)(26005)(16526019)(186003)(6666004)(66946007)(2906002)(66476007)(66556008); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: yeMEfbM04uBm4p8IBGLGINL9n9618EE+S9dy5jHL40t94cWe5SK3vZfUaFSEd20a3+MrDjICFPbsuY7K7/PCJAhfx5gvzONZfwqUKyXPrvvAyMPAb198z6vzZda8tOWHAiktPtFQahSEKgJO1HZFhCh3LxVtGUrrxtJ1mH6YZJFHq1NLc2JrNmrVw/LMCPd2XqXsd16DD9SKKAoJuQyIpilqwgp+B3JIsBnH6VV4HUwajN+Zcj+zq2+BPlaqrhKzYZ8K41x/vRE552DIDsHpUuc3c0Vtq8uK9AS/YKTk2bpI8Ebh+9wTPWDqJRvgIscmDzCtEMA4iqZke0rHw9n4MxLIoz/hvRqcuk9x18JosYuSa1dWJXg3ZPLAin/C3ekBzyquZJkl/Hw5SgP+A+KhgBu9xOWtYqLGpe+IEHj1yQZEwCskTbYFfLD7jqynqVasK3XsdFAj7ZqAHEKIj1QHhi8QAarEg949BtRWsgdPtk4h5LtFUlgLFz2QmDu02vlx8wGE7P/palXfuM5zxn79mhx6y0VQZk8+UyPebA0LurID1QFbegIQhsVQtU+MBIvD0XWAvBBjSx5o3Q39ASkV9e6mgmyAJOdKGODlCbNduibZ+JsOsy42YwZyFkvDM3JwU39uCGanMkVHX0rAG1H1wQ== X-OriginatorOrg: bu.edu X-MS-Exchange-CrossTenant-Network-Message-Id: 7ba5e3c2-82de-4ce7-1c70-08d8755dc550 X-MS-Exchange-CrossTenant-AuthSource: SN6PR03MB3871.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Oct 2020 01:08:08.0182 (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: q0ZW41NQeJPRwSBzVNMkWibRKbDKB49kgPoTg3dgtFo9n/tMVKMQqqcRTRebeQf8 X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN2PR03MB2333 Received-SPF: pass client-ip=40.107.220.130; envelope-from=alxndr@bu.edu; helo=NAM11-CO1-obe.outbound.protection.outlook.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/20 21:08:14 X-ACL-Warn: Detected OS = Windows NT kernel [generic] [fuzzy] X-Spam_score_int: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, HK_RANDOM_ENVFROM=0.001, HK_RANDOM_FROM=0.441, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no 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: Laurent Vivier , Thomas Huth , Alexander Bulekov , f4bug@amsat.org, darren.kenny@oracle.com, bsd@redhat.com, stefanha@redhat.com, pbonzini@redhat.com, dimastep@yandex-team.ru Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" This patch compares TYPE_PCI_DEVICE objects against the user-provided matching pattern. If there is a match, we use some hacks and leverage QOS to map each possible BAR for that device. Now fuzzed inputs might be converted to pci_read/write commands which target specific. This means that we can fuzz a particular device's PCI configuration space, Signed-off-by: Alexander Bulekov Reviewed-by: Darren Kenny --- tests/qtest/fuzz/generic_fuzz.c | 81 +++++++++++++++++++++++++++++++++ 1 file changed, 81 insertions(+) diff --git a/tests/qtest/fuzz/generic_fuzz.c b/tests/qtest/fuzz/generic_fuzz.c index 50e5022d4a..2ba975aaae 100644 --- a/tests/qtest/fuzz/generic_fuzz.c +++ b/tests/qtest/fuzz/generic_fuzz.c @@ -24,6 +24,7 @@ #include "exec/ramblock.h" #include "exec/address-spaces.h" #include "hw/qdev-core.h" +#include "hw/pci/pci.h" /* * SEPARATOR is used to separate "operations" in the fuzz input @@ -35,12 +36,17 @@ enum cmds { OP_OUT, OP_READ, OP_WRITE, + OP_PCI_READ, + OP_PCI_WRITE, OP_CLOCK_STEP, }; #define DEFAULT_TIMEOUT_US 100000 #define USEC_IN_SEC 1000000000 +#define PCI_HOST_BRIDGE_CFG 0xcf8 +#define PCI_HOST_BRIDGE_DATA 0xcfc + typedef struct { ram_addr_t addr; ram_addr_t size; /* The number of bytes until the end of the I/O region */ @@ -55,6 +61,7 @@ static bool qtest_log_enabled; * user for fuzzing. */ static GHashTable *fuzzable_memoryregions; +static GPtrArray *fuzzable_pci_devices; struct get_io_cb_info { int index; @@ -280,6 +287,65 @@ static void op_write(QTestState *s, const unsigned char * data, size_t len) break; } } +static void op_pci_read(QTestState *s, const unsigned char * data, size_t len) +{ + enum Sizes {Byte, Word, Long, end_sizes}; + struct { + uint8_t size; + uint8_t base; + uint8_t offset; + } a; + if (len < sizeof(a) || fuzzable_pci_devices->len == 0) { + return; + } + memcpy(&a, data, sizeof(a)); + PCIDevice *dev = g_ptr_array_index(fuzzable_pci_devices, + a.base % fuzzable_pci_devices->len); + int devfn = dev->devfn; + qtest_outl(s, PCI_HOST_BRIDGE_CFG, (1U << 31) | (devfn << 8) | a.offset); + switch (a.size %= end_sizes) { + case Byte: + qtest_inb(s, PCI_HOST_BRIDGE_DATA); + break; + case Word: + qtest_inw(s, PCI_HOST_BRIDGE_DATA); + break; + case Long: + qtest_inl(s, PCI_HOST_BRIDGE_DATA); + break; + } +} + +static void op_pci_write(QTestState *s, const unsigned char * data, size_t len) +{ + enum Sizes {Byte, Word, Long, end_sizes}; + struct { + uint8_t size; + uint8_t base; + uint8_t offset; + uint32_t value; + } a; + if (len < sizeof(a) || fuzzable_pci_devices->len == 0) { + return; + } + memcpy(&a, data, sizeof(a)); + PCIDevice *dev = g_ptr_array_index(fuzzable_pci_devices, + a.base % fuzzable_pci_devices->len); + int devfn = dev->devfn; + qtest_outl(s, PCI_HOST_BRIDGE_CFG, (1U << 31) | (devfn << 8) | a.offset); + switch (a.size %= end_sizes) { + case Byte: + qtest_outb(s, PCI_HOST_BRIDGE_DATA, a.value & 0xFF); + break; + case Word: + qtest_outw(s, PCI_HOST_BRIDGE_DATA, a.value & 0xFFFF); + break; + case Long: + qtest_outl(s, PCI_HOST_BRIDGE_DATA, a.value & 0xFFFFFFFF); + break; + } +} + static void op_clock_step(QTestState *s, const unsigned char *data, size_t len) { qtest_clock_step_next(s); @@ -338,6 +404,8 @@ static void generic_fuzz(QTestState *s, const unsigned char *Data, size_t Size) [OP_OUT] = op_out, [OP_READ] = op_read, [OP_WRITE] = op_write, + [OP_PCI_READ] = op_pci_read, + [OP_PCI_WRITE] = op_pci_write, [OP_CLOCK_STEP] = op_clock_step, }; const unsigned char *cmd = Data; @@ -428,6 +496,18 @@ static int locate_fuzz_objects(Object *child, void *opaque) /* Find and save ptrs to any child MemoryRegions */ object_child_foreach_recursive(child, locate_fuzz_memory_regions, NULL); + /* + * We matched an object. If its a PCI device, store a pointer to it so + * we can map BARs and fuzz its config space. + */ + if (object_dynamic_cast(OBJECT(child), TYPE_PCI_DEVICE)) { + /* + * Don't want duplicate pointers to the same PCIDevice, so remove + * copies of the pointer, before adding it. + */ + g_ptr_array_remove_fast(fuzzable_pci_devices, PCI_DEVICE(child)); + g_ptr_array_add(fuzzable_pci_devices, PCI_DEVICE(child)); + } } else if (object_dynamic_cast(OBJECT(child), TYPE_MEMORY_REGION)) { if (g_pattern_match_simple(pattern, object_get_canonical_path_component(child))) { @@ -460,6 +540,7 @@ static void generic_pre_fuzz(QTestState *s) } fuzzable_memoryregions = g_hash_table_new(NULL, NULL); + fuzzable_pci_devices = g_ptr_array_new(); result = g_strsplit(getenv("QEMU_FUZZ_OBJECTS"), " ", -1); for (int i = 0; result[i] != NULL; i++) { From patchwork Wed Oct 21 01:07:40 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Bulekov X-Patchwork-Id: 270825 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.3 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, HK_RANDOM_FROM, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7C336C4363D for ; Wed, 21 Oct 2020 01:11:24 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 9704020797 for ; Wed, 21 Oct 2020 01:11:23 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=bushare.onmicrosoft.com header.i=@bushare.onmicrosoft.com header.b="EyBUqopj" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9704020797 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=bu.edu Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:46236 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kV2ew-0003sJ-DG for qemu-devel@archiver.kernel.org; Tue, 20 Oct 2020 21:11:22 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44376) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kV2c4-0000v9-VB for qemu-devel@nongnu.org; Tue, 20 Oct 2020 21:08:25 -0400 Received: from mail-co1nam11on2130.outbound.protection.outlook.com ([40.107.220.130]:28640 helo=NAM11-CO1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kV2c2-0004s9-SH for qemu-devel@nongnu.org; Tue, 20 Oct 2020 21:08:24 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=HITChfXyIlY7+beuRnkvwW9sCBX+140DhpEI7OIKBUMZEol2yIR6xCL7mGajtoeFmoEOSv2TyKYMJ+h0yD7qRAVKJwgf9sSbYfZ+YfsZEKgY24lGq2fMxJ9i5G1t5+qJTge+Do/ziwNDRoGK/LoXYdg4uveUHA7nk/+BkFreN/kC3r6OMEkci96C/Xm4IelJlW8EycJfR7BlyH9mCApWSZ9eJ3Y3/hXE9TV4p8X/cC/56EJHuQpIkWcRFKqOeQpKNf3XJfteEmgATKsi9GqdJAOkWT+H6LNljZ4F+3QKDB/E2mRb5WNpf+XuIIFy0X5GuL/hJbVcLCHfWImt2ZYgUQ== 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=KGrjvwJOI37RU+5qtwX8OWxNIpldct9l3CehaP007G0=; b=Prt6gcSDVkMnUSGKYS31ftIo4CtUe3Z5E//3oUuilKX4Rz6E1PnTrE1yvUwVJ5p8g3rZlLtoPVX0S9+X+ZPWlnO4pExI4meyQv0K+VCtOVdrznZygVWuRaTXy12A804WuUelhi+bFb5GQQV8axr8+/5fEkk13sLQEPUCkHI5Gy7zphEtwAHH0lFGNlFWGo41U4/50YPcBRnUg+OrutvrmmHAUdB5kafbE7hxNIx+h6zUONB+TGVwoTDZ8bMXrIcTXZ/TlQSwo0WQIoq/RkItGEAO2tlkknYrNbzYrvAPaACCC1ekY62h6cwoHseGPlmmJOYzmmu2XIVowkfFP/uRrQ== 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=KGrjvwJOI37RU+5qtwX8OWxNIpldct9l3CehaP007G0=; b=EyBUqopjWQAzPGy7SKK/9i0EvBIU2Fj1m0IJpCXOpYGxdIP9kS4osPOR7gQjfYbOzXVq5dZNt04KQtTXgRwBlOcGEAodYZUV8k/w6Ogct7nXKED7sEfTKxKmyQakequrE3ag5huEw0y+xqYTtdCNZJoMLlAOUb26K63VwYZAD0Y= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none; nongnu.org; dmarc=none action=none header.from=bu.edu; Received: from SN6PR03MB3871.namprd03.prod.outlook.com (2603:10b6:805:6d::32) by SN2PR03MB2333.namprd03.prod.outlook.com (2603:10b6:804:c::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3477.22; Wed, 21 Oct 2020 01:08:09 +0000 Received: from SN6PR03MB3871.namprd03.prod.outlook.com ([fe80::d520:4c19:8ce6:7db2]) by SN6PR03MB3871.namprd03.prod.outlook.com ([fe80::d520:4c19:8ce6:7db2%2]) with mapi id 15.20.3477.028; Wed, 21 Oct 2020 01:08:09 +0000 From: Alexander Bulekov To: qemu-devel@nongnu.org Subject: [PATCH v5 04/16] fuzz: Add DMA support to the generic-fuzzer Date: Tue, 20 Oct 2020 21:07:40 -0400 Message-Id: <20201021010752.973230-5-alxndr@bu.edu> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201021010752.973230-1-alxndr@bu.edu> References: <20201021010752.973230-1-alxndr@bu.edu> X-Originating-IP: [72.93.72.163] X-ClientProxiedBy: BL1PR13CA0119.namprd13.prod.outlook.com (2603:10b6:208:2b9::34) To SN6PR03MB3871.namprd03.prod.outlook.com (2603:10b6:805:6d::32) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from stormtrooper.vrmnet (72.93.72.163) by BL1PR13CA0119.namprd13.prod.outlook.com (2603:10b6:208:2b9::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3499.8 via Frontend Transport; Wed, 21 Oct 2020 01:08:08 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 504756c0-ab87-4fbf-f584-08d8755dc64c X-MS-TrafficTypeDiagnostic: SN2PR03MB2333: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:34; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: nwvOIabua3krjmfNfOFgzpLd7RyOjgaC8JsyYI4y9818K7ohllSpe55IUBtzj4UIg/l4CvI/BaVZ+fSEvZ8Ztc3ZMdS9MW5/PI3h/qwsiflZzjy2iH/YYo77spyteZmK92C2tgaJi7QsflakpcDfsr0QyTD9+FrpCvc+v9Ka6cJ1crECf4FZHEfcwBLMkeQHOTj1RADwGd6ljKMRChMhTlL2OFUROP1ShocNTGWINQv/TxRJ2ezx1HhedaN+IhDwIVW18NIBhwjgXy6QjL2sFes5jyueyI82rukxECKzbwEMxUZ+OsdstY5VPPThMUE1YcE4Npxiiv9DTUji4VT1bI7jpUqkIgpcgVRgyACiY4nXpAfGRvJFUdMT1z7JE7CP X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:SN6PR03MB3871.namprd03.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(39860400002)(396003)(376002)(346002)(366004)(136003)(52116002)(2616005)(8676002)(6512007)(6916009)(6506007)(36756003)(786003)(316002)(956004)(83380400001)(478600001)(1076003)(4326008)(6486002)(75432002)(8936002)(54906003)(30864003)(86362001)(5660300002)(26005)(16526019)(186003)(6666004)(66946007)(2906002)(66476007)(66556008)(41533002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: h6UByzmJnMuwp22M+ngxlLAZCIcbPj2rd2nqy97z7/4Rjzx3q5Ph+XIX/6vGiwCXGwGgXDauL+UoS4vKdqG2ctkE13bQcm7djn773TBfO0gxJEsYPM0i+0HR1r+JzFi+hSZXKssVZbC1zC6IWkJA1oKyJBuk/5rTrBez0CL6kMysGz1bBuaK6rMo5h+toOuQtbiD20KbOOIVqkWupzSQxbcAs6ZWHm4IYzMNcmxQ+Ban3sdSn5LRwbY4VXz/SO+vdmM9g8Ot95EeN/lL+BkakFmY6gKcG8e59nax16NJx8ELFXKMoFUbmsFwIkcTgJjdX3RE7MzgDtft3ZHe4N/KimCFpxrs/fTzju0HvfAnOfpehwyGAcyC1pVsLSo5okiQ7se2HAF8W4PI5j7nGe+w0+OPIoz93wHl8V/3UL8FdgIKLrI8eNboxQNfzBgH2Lk6xJ9W9uGXgqfDh+8197ftlyUDiG/nN3AcgJYDbT7aeJmVZ3AXXE813mEWz6fHAuxCeildNQnrHTQXC/jbdr22zwBvua7Cd9Uspsrxd6QIZuyxfPr0CSSxBUpAKlGBKD8e2hP/ZEVKns/ohXnDu832s5eE1INcTe38taRMM3kr60NggCgyJwokZwNwmpyoezuOVR1twSze+8kA0EActDdpBA== X-OriginatorOrg: bu.edu X-MS-Exchange-CrossTenant-Network-Message-Id: 504756c0-ab87-4fbf-f584-08d8755dc64c X-MS-Exchange-CrossTenant-AuthSource: SN6PR03MB3871.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Oct 2020 01:08:09.7822 (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: u2ZB5I/wxr37cFVFZfxdPPauTQIW3VTaKd7YN5sp0Hd65vo8P/7plka9KNCk20ui X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN2PR03MB2333 Received-SPF: pass client-ip=40.107.220.130; envelope-from=alxndr@bu.edu; helo=NAM11-CO1-obe.outbound.protection.outlook.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/20 21:08:14 X-ACL-Warn: Detected OS = Windows NT kernel [generic] [fuzzy] X-Spam_score_int: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, HK_RANDOM_ENVFROM=0.001, HK_RANDOM_FROM=0.441, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no 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: Laurent Vivier , Thomas Huth , Alexander Bulekov , f4bug@amsat.org, darren.kenny@oracle.com, bsd@redhat.com, stefanha@redhat.com, pbonzini@redhat.com, dimastep@yandex-team.ru Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" When a virtual-device tries to access some buffer in memory over DMA, we add call-backs into the fuzzer(next commit). The fuzzer checks verifies that the DMA request maps to a physical RAM address and fills the memory with fuzzer-provided data. The patterns that we use to fill this memory are specified using add_dma_pattern and clear_dma_patterns operations. Signed-off-by: Alexander Bulekov Reviewed-by: Darren Kenny --- include/exec/memory.h | 7 + tests/qtest/fuzz/generic_fuzz.c | 228 ++++++++++++++++++++++++++++++++ 2 files changed, 235 insertions(+) diff --git a/include/exec/memory.h b/include/exec/memory.h index 233655b29a..61c2aac943 100644 --- a/include/exec/memory.h +++ b/include/exec/memory.h @@ -42,6 +42,13 @@ typedef struct IOMMUMemoryRegionClass IOMMUMemoryRegionClass; DECLARE_OBJ_CHECKERS(IOMMUMemoryRegion, IOMMUMemoryRegionClass, IOMMU_MEMORY_REGION, TYPE_IOMMU_MEMORY_REGION) +#ifdef CONFIG_FUZZ +void fuzz_dma_read_cb(size_t addr, + size_t len, + MemoryRegion *mr, + bool is_write); +#endif + extern bool global_dirty_log; typedef struct MemoryRegionOps MemoryRegionOps; diff --git a/tests/qtest/fuzz/generic_fuzz.c b/tests/qtest/fuzz/generic_fuzz.c index 2ba975aaae..a12dc634b3 100644 --- a/tests/qtest/fuzz/generic_fuzz.c +++ b/tests/qtest/fuzz/generic_fuzz.c @@ -25,6 +25,7 @@ #include "exec/address-spaces.h" #include "hw/qdev-core.h" #include "hw/pci/pci.h" +#include "hw/boards.h" /* * SEPARATOR is used to separate "operations" in the fuzz input @@ -38,12 +39,16 @@ enum cmds { OP_WRITE, OP_PCI_READ, OP_PCI_WRITE, + OP_ADD_DMA_PATTERN, + OP_CLEAR_DMA_PATTERNS, OP_CLOCK_STEP, }; #define DEFAULT_TIMEOUT_US 100000 #define USEC_IN_SEC 1000000000 +#define MAX_DMA_FILL_SIZE 0x10000 + #define PCI_HOST_BRIDGE_CFG 0xcf8 #define PCI_HOST_BRIDGE_DATA 0xcfc @@ -56,6 +61,24 @@ static useconds_t timeout = DEFAULT_TIMEOUT_US; static bool qtest_log_enabled; +/* + * A pattern used to populate a DMA region or perform a memwrite. This is + * useful for e.g. populating tables of unique addresses. + * Example {.index = 1; .stride = 2; .len = 3; .data = "\x00\x01\x02"} + * Renders as: 00 01 02 00 03 02 00 05 02 00 07 02 ... + */ +typedef struct { + uint8_t index; /* Index of a byte to increment by stride */ + uint8_t stride; /* Increment each index'th byte by this amount */ + size_t len; + const uint8_t *data; +} pattern; + +/* Avoid filling the same DMA region between MMIO/PIO commands ? */ +static bool avoid_double_fetches; + +static QTestState *qts_global; /* Need a global for the DMA callback */ + /* * List of memory regions that are children of QOM objects specified by the * user for fuzzing. @@ -84,6 +107,167 @@ static int get_io_address_cb(ram_addr_t start, ram_addr_t size, return 0; } +/* + * List of dma regions populated since the last fuzzing command. Used to ensure + * that we only write to each DMA address once, to avoid race conditions when + * building reproducers. + */ +static GArray *dma_regions; + +static GArray *dma_patterns; +static int dma_pattern_index; + +/* + * Allocate a block of memory and populate it with a pattern. + */ +static void *pattern_alloc(pattern p, size_t len) +{ + int i; + uint8_t *buf = g_malloc(len); + uint8_t sum = 0; + + for (i = 0; i < len; ++i) { + buf[i] = p.data[i % p.len]; + if ((i % p.len) == p.index) { + buf[i] += sum; + sum += p.stride; + } + } + return buf; +} + +static int memory_access_size(MemoryRegion *mr, unsigned l, hwaddr addr) +{ + unsigned access_size_max = mr->ops->valid.max_access_size; + + /* Regions are assumed to support 1-4 byte accesses unless + otherwise specified. */ + if (access_size_max == 0) { + access_size_max = 4; + } + + /* Bound the maximum access by the alignment of the address. */ + if (!mr->ops->impl.unaligned) { + unsigned align_size_max = addr & -addr; + if (align_size_max != 0 && align_size_max < access_size_max) { + access_size_max = align_size_max; + } + } + + /* Don't attempt accesses larger than the maximum. */ + if (l > access_size_max) { + l = access_size_max; + } + l = pow2floor(l); + + return l; +} + +/* + * Call-back for functions that perform DMA reads from guest memory. Confirm + * that the region has not already been populated since the last loop in + * generic_fuzz(), avoiding potential race-conditions, which we don't have + * a good way for reproducing right now. + */ +void fuzz_dma_read_cb(size_t addr, size_t len, MemoryRegion *mr, bool is_write) +{ + /* Are we in the generic-fuzzer or are we using another fuzz-target? */ + if (!qts_global) { + return; + } + + /* + * Return immediately if: + * - We have no DMA patterns defined + * - The length of the DMA read request is zero + * - The DMA read is hitting an MR other than the machine's main RAM + * - The DMA request is not a read (what happens for a address_space_map + * with is_write=True? Can the device use the same pointer to do reads?) + * - The DMA request hits past the bounds of our RAM + */ + if (dma_patterns->len == 0 + || len == 0 + /* || mr != MACHINE(qdev_get_machine())->ram */ + || is_write + || addr > current_machine->ram_size) { + return; + } + + /* + * If we overlap with any existing dma_regions, split the range and only + * populate the non-overlapping parts. + */ + address_range region; + bool double_fetch = false; + for (int i = 0; + i < dma_regions->len && (avoid_double_fetches || qtest_log_enabled); + ++i) { + region = g_array_index(dma_regions, address_range, i); + if (addr < region.addr + region.size && addr + len > region.addr) { + double_fetch = true; + if (addr < region.addr + && avoid_double_fetches) { + fuzz_dma_read_cb(addr, region.addr - addr, mr, is_write); + } + if (addr + len > region.addr + region.size + && avoid_double_fetches) { + fuzz_dma_read_cb(region.addr + region.size, + addr + len - (region.addr + region.size), mr, is_write); + } + return; + } + } + + /* Cap the length of the DMA access to something reasonable */ + len = MIN(len, MAX_DMA_FILL_SIZE); + + address_range ar = {addr, len}; + g_array_append_val(dma_regions, ar); + pattern p = g_array_index(dma_patterns, pattern, dma_pattern_index); + void *buf = pattern_alloc(p, ar.size); + hwaddr l, addr1; + MemoryRegion *mr1; + uint8_t *ram_ptr; + while (len > 0) { + l = len; + mr1 = address_space_translate(first_cpu->as, + addr, &addr1, &l, true, + MEMTXATTRS_UNSPECIFIED); + + if (!(memory_region_is_ram(mr1) || + memory_region_is_romd(mr1))) { + l = memory_access_size(mr1, l, addr1); + } else { + /* ROM/RAM case */ + ram_ptr = qemu_map_ram_ptr(mr1->ram_block, addr1); + memcpy(ram_ptr, buf, l); + break; + } + len -= l; + buf += l; + addr += l; + + } + if (qtest_log_enabled) { + /* + * With QTEST_LOG, use a normal, slow QTest memwrite. Prefix the log + * that will be written by qtest.c with a DMA tag, so we can reorder + * the resulting QTest trace so the DMA fills precede the last PIO/MMIO + * command. + */ + fprintf(stderr, "[DMA] "); + if (double_fetch) { + fprintf(stderr, "[DOUBLE-FETCH] "); + } + fflush(stderr); + } + qtest_memwrite(qts_global, ar.addr, buf, ar.size); + g_free(buf); + + /* Increment the index of the pattern for the next DMA access */ + dma_pattern_index = (dma_pattern_index + 1) % dma_patterns->len; +} + /* * Here we want to convert a fuzzer-provided [io-region-index, offset] to * a physical address. To do this, we iterate over all of the matched @@ -346,6 +530,35 @@ static void op_pci_write(QTestState *s, const unsigned char * data, size_t len) } } +static void op_add_dma_pattern(QTestState *s, + const unsigned char *data, size_t len) +{ + struct { + /* + * index and stride can be used to increment the index-th byte of the + * pattern by the value stride, for each loop of the pattern. + */ + uint8_t index; + uint8_t stride; + } a; + + if (len < sizeof(a) + 1) { + return; + } + memcpy(&a, data, sizeof(a)); + pattern p = {a.index, a.stride, len - sizeof(a), data + sizeof(a)}; + p.index = a.index % p.len; + g_array_append_val(dma_patterns, p); + return; +} + +static void op_clear_dma_patterns(QTestState *s, + const unsigned char *data, size_t len) +{ + g_array_set_size(dma_patterns, 0); + dma_pattern_index = 0; +} + static void op_clock_step(QTestState *s, const unsigned char *data, size_t len) { qtest_clock_step_next(s); @@ -406,6 +619,8 @@ static void generic_fuzz(QTestState *s, const unsigned char *Data, size_t Size) [OP_WRITE] = op_write, [OP_PCI_READ] = op_pci_read, [OP_PCI_WRITE] = op_pci_write, + [OP_ADD_DMA_PATTERN] = op_add_dma_pattern, + [OP_CLEAR_DMA_PATTERNS] = op_clear_dma_patterns, [OP_CLOCK_STEP] = op_clock_step, }; const unsigned char *cmd = Data; @@ -435,6 +650,8 @@ static void generic_fuzz(QTestState *s, const unsigned char *Data, size_t Size) setitimer(ITIMER_VIRTUAL, &timer, NULL); } + op_clear_dma_patterns(s, NULL, 0); + while (cmd && Size) { /* Get the length until the next command or end of input */ nextcmd = memmem(cmd, Size, SEPARATOR, strlen(SEPARATOR)); @@ -451,6 +668,7 @@ static void generic_fuzz(QTestState *s, const unsigned char *Data, size_t Size) /* Advance to the next command */ cmd = nextcmd ? nextcmd + sizeof(SEPARATOR) - 1 : nextcmd; Size = Size - (cmd_len + sizeof(SEPARATOR) - 1); + g_array_set_size(dma_regions, 0); } _Exit(0); } else { @@ -465,6 +683,9 @@ static void usage(void) printf("QEMU_FUZZ_ARGS= the command line arguments passed to qemu\n"); printf("QEMU_FUZZ_OBJECTS= " "a space separated list of QOM type names for objects to fuzz\n"); + printf("Optionally: QEMU_AVOID_DOUBLE_FETCH= " + "Try to avoid racy DMA double fetch bugs? %d by default\n", + avoid_double_fetches); printf("Optionally: QEMU_FUZZ_TIMEOUT= Specify a custom timeout (us). " "0 to disable. %d by default\n", timeout); exit(0); @@ -535,9 +756,16 @@ static void generic_pre_fuzz(QTestState *s) if (getenv("QTEST_LOG")) { qtest_log_enabled = 1; } + if (getenv("QEMU_AVOID_DOUBLE_FETCH")) { + avoid_double_fetches = 1; + } if (getenv("QEMU_FUZZ_TIMEOUT")) { timeout = g_ascii_strtoll(getenv("QEMU_FUZZ_TIMEOUT"), NULL, 0); } + qts_global = s; + + dma_regions = g_array_new(false, false, sizeof(address_range)); + dma_patterns = g_array_new(false, false, sizeof(pattern)); fuzzable_memoryregions = g_hash_table_new(NULL, NULL); fuzzable_pci_devices = g_ptr_array_new(); From patchwork Wed Oct 21 01:07:41 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Bulekov X-Patchwork-Id: 270824 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.3 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, HK_RANDOM_FROM, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7DA78C4363D for ; Wed, 21 Oct 2020 01:13:45 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id B80B720797 for ; Wed, 21 Oct 2020 01:13:44 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=bushare.onmicrosoft.com header.i=@bushare.onmicrosoft.com header.b="v0tYHMfc" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B80B720797 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=bu.edu Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:51584 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kV2hD-00063u-PC for qemu-devel@archiver.kernel.org; Tue, 20 Oct 2020 21:13:43 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44388) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kV2c7-0000xM-Ar for qemu-devel@nongnu.org; Tue, 20 Oct 2020 21:08:27 -0400 Received: from mail-co1nam11on2130.outbound.protection.outlook.com ([40.107.220.130]:28640 helo=NAM11-CO1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kV2c5-0004s9-Td for qemu-devel@nongnu.org; Tue, 20 Oct 2020 21:08:27 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Auz5SfwJN5rtL88b8Xz2eNv7OGrqipLe8/FtC6E6jtWFxct3cgsylHisVJdOUe67yf1LbIuzDLOL0uWjfptCLrO4K/vQ7n2w+iVOsrSfqPEybh5lEvh+Mn+3NRIKP6HQaBh41X2vNoZeGAsnUFfEDnuRLQC4tRsJlNF5p3VgeHzHT7SRCGXInm9ogmQUgo2FJ19DsuQrp9jJNvBPHbSG3y8h9zf/TVj/fEkDgcugDNAnZ/q7/otEwmSh6mnMsFoLLMyxtvutnybgI394pHUT08p6NIbVOHRREwjyEvb9VEqQuLkTgiy/8EK2a5dacG3YzFG3LA8OG7ioJhKeHLWnzQ== 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=RzBnGDRyU66W2x50rl7hIybaGOx/maD6IfktlgFZWW8=; b=jccuX/HMqL6HWRjaM5PTLww8l1FHzUGQxvylFrkqoe8kRDnI1it/Qr2H0GrvHbv3MluLK3IdLinFVkyVlTUP5JKtVa8iKNzgMO0O0W0NE/sOvCOYp1DVpzoUGZIRzOut/wo8keUczv2hLqizzxzrDDJMOAlxjQXqpup9ySCu+9st2Yic5yqS5jXwm2UJsUXOWw33xMRYDUrU455NvmWDSOfHoFTdevNm0hjN9R09u1AHoHQxVtRESzDDGAYuwtPya/pc7j6OBqQSfB2cyz8HeGzQXKAow6yFoLFuu8osN2Xe0QcqCihEmRxzalUOMJOTRzYr8jg6dl30/MHKYzUPxQ== 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=RzBnGDRyU66W2x50rl7hIybaGOx/maD6IfktlgFZWW8=; b=v0tYHMfcVD+Nah2mlzsK5ZlEQgTqMn9W5u7x9V6/Sxn7JMV9ekoIc0yahftzuE3p/970Be+jYhyAetRLyIv/XTRtzZ7waydYROZ3UGzogd1kwSYTVVXf0NZi7MfO5xilpiLbtilKwYRGfB2VrnuiIAbQD3p0tTJCRa54J2Aetmw= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none; nongnu.org; dmarc=none action=none header.from=bu.edu; Received: from SN6PR03MB3871.namprd03.prod.outlook.com (2603:10b6:805:6d::32) by SN2PR03MB2333.namprd03.prod.outlook.com (2603:10b6:804:c::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3477.22; Wed, 21 Oct 2020 01:08:11 +0000 Received: from SN6PR03MB3871.namprd03.prod.outlook.com ([fe80::d520:4c19:8ce6:7db2]) by SN6PR03MB3871.namprd03.prod.outlook.com ([fe80::d520:4c19:8ce6:7db2%2]) with mapi id 15.20.3477.028; Wed, 21 Oct 2020 01:08:11 +0000 From: Alexander Bulekov To: qemu-devel@nongnu.org Subject: [PATCH v5 05/16] fuzz: Declare DMA Read callback function Date: Tue, 20 Oct 2020 21:07:41 -0400 Message-Id: <20201021010752.973230-6-alxndr@bu.edu> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201021010752.973230-1-alxndr@bu.edu> References: <20201021010752.973230-1-alxndr@bu.edu> X-Originating-IP: [72.93.72.163] X-ClientProxiedBy: BL1PR13CA0119.namprd13.prod.outlook.com (2603:10b6:208:2b9::34) To SN6PR03MB3871.namprd03.prod.outlook.com (2603:10b6:805:6d::32) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from stormtrooper.vrmnet (72.93.72.163) by BL1PR13CA0119.namprd13.prod.outlook.com (2603:10b6:208:2b9::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3499.8 via Frontend Transport; Wed, 21 Oct 2020 01:08:10 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: a90b7bfa-bef2-4517-a453-08d8755dc739 X-MS-TrafficTypeDiagnostic: SN2PR03MB2333: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:2512; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: uvV1R51ZtfYpBGiJmm4+PsSkWfJIqIPhn+3gPXDcYMOtM9ZRPHvi+QRLfNS+ARxmwczcybTYon8klR51IKYca0II6s8SMF5iUKOq3zePdm+kBr2yBFfsJqX9YvH8TfYbHd0SaSbpTbZ8a7vUfDnNCnw2VWt+u3ic8x+omysoN5u412qy9b5lEUF99tAPxK9H7ST4IfWQwN8gq+NLGai8nGI3lvamMtZUJg5D0+X6W4khus9j4ugM6CKA8BtsoVT2IY0WyWuK42q9Zr7t9x5UOHhUDlAfCIoUBUG4tvmWAvLLo0YPUwRpRVknxWxubgvDe40bC+caq8bbkVlYXG8gYw== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:SN6PR03MB3871.namprd03.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(39860400002)(396003)(376002)(346002)(366004)(136003)(52116002)(2616005)(8676002)(6512007)(6916009)(6506007)(36756003)(786003)(316002)(956004)(478600001)(1076003)(4326008)(6486002)(75432002)(8936002)(86362001)(5660300002)(26005)(16526019)(186003)(6666004)(66946007)(2906002)(66476007)(66556008); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: QsF0RNWQn0fIrPOw/pqwaumUSB4z/pss4lG401Ygmuh8yv9s3uBkBPc/Cp4eqWILIFKoe7797WQc5H00DPTro0z6jobjHLtWPYD7h9qBXJTzNtfpLO+az2pTpiG+yZ13UgRq4JyDYKGwF8RlXfwj6dTpmuQS3WvYziTSEwJUAxWDSzzU9HC0Eq9ks3x4Fr2DkbxG/MALv59CitZdjnFd0IhcY7+ydkFQ0BVeESCHuswGC+vsgUDw1P6r2xUZU61GIVYeARn5R+FjtiBZAaW3o7eUCDxQpwFC54r9NXxUWJsw0yGExaR2a2FPYPVaEFWJz9CgtOgsCkpoFZesGulgOVFq/w7XIPXT8VAYkYpn9OMfufd7VcO2IACVYkOPTDkdsNPRy5mJRTVlmMyqXJ01q/qZFMFljFQs9edwC5E5b17CyVLttjfOahb7tgS0Ld0woWUFgV6yDvy/cTjWpxiEZUyJNw58fRcxfW84nMO0cq8t7fTgrjZPjP0z8QSQjSw96UqXL82ctnQa/bGYrwxHLg0JwYX9hWtxel5mJ8vv8ecr6qSkfgDl6crPatB/EmD4ksbRRdZqnbgNQuUZD092uK1e8QD2fR8LxDlXtdsWOV5uKNbV3IY10/CoZplhpV6i+Va+Ii7iRMrkE3c7LTIalg== X-OriginatorOrg: bu.edu X-MS-Exchange-CrossTenant-Network-Message-Id: a90b7bfa-bef2-4517-a453-08d8755dc739 X-MS-Exchange-CrossTenant-AuthSource: SN6PR03MB3871.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Oct 2020 01:08:11.1375 (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: GSNXfo1Wuae5O3r+MOna6+LG82r8i3cJ+aGNXDsCWwz+F/qY1gA98qKZEHCUHyRy X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN2PR03MB2333 Received-SPF: pass client-ip=40.107.220.130; envelope-from=alxndr@bu.edu; helo=NAM11-CO1-obe.outbound.protection.outlook.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/20 21:08:14 X-ACL-Warn: Detected OS = Windows NT kernel [generic] [fuzzy] X-Spam_score_int: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, HK_RANDOM_ENVFROM=0.001, HK_RANDOM_FROM=0.441, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no 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 , f4bug@amsat.org, darren.kenny@oracle.com, bsd@redhat.com, stefanha@redhat.com, pbonzini@redhat.com, dimastep@yandex-team.ru Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" This patch declares the fuzz_dma_read_cb function and uses the preprocessor and linker(weak symbols) to handle these cases: When we build softmmu/all with --enable-fuzzing, there should be no strong symbol defined for fuzz_dma_read_cb, and we link against a weak stub function. When we build softmmu/fuzz with --enable-fuzzing, we link against the strong symbol in general_fuzz.c When we build softmmu/all without --enable-fuzzing, fuzz_dma_read_cb is an empty, inlined function. As long as we don't call any other functions when building the arguments, there should be no overhead. Signed-off-by: Alexander Bulekov Reviewed-by: Darren Kenny --- include/exec/memory.h | 8 ++++++++ softmmu/memory.c | 13 +++++++++++++ 2 files changed, 21 insertions(+) diff --git a/include/exec/memory.h b/include/exec/memory.h index 61c2aac943..854480859d 100644 --- a/include/exec/memory.h +++ b/include/exec/memory.h @@ -47,6 +47,14 @@ void fuzz_dma_read_cb(size_t addr, size_t len, MemoryRegion *mr, bool is_write); +#else +static inline void fuzz_dma_read_cb(size_t addr, + size_t len, + MemoryRegion *mr, + bool is_write) +{ + /* Do Nothing */ +} #endif extern bool global_dirty_log; diff --git a/softmmu/memory.c b/softmmu/memory.c index c46b0c6d65..d3cdb46459 100644 --- a/softmmu/memory.c +++ b/softmmu/memory.c @@ -3242,6 +3242,19 @@ void memory_region_init_rom_device(MemoryRegion *mr, vmstate_register_ram(mr, owner_dev); } +/* + * Support softmmu builds with CONFIG_FUZZ using a weak symbol and a stub for + * the fuzz_dma_read_cb callback + */ +#ifdef CONFIG_FUZZ +void __attribute__((weak)) fuzz_dma_read_cb(size_t addr, + size_t len, + MemoryRegion *mr, + bool is_write) +{ +} +#endif + static const TypeInfo memory_region_info = { .parent = TYPE_OBJECT, .name = TYPE_MEMORY_REGION, From patchwork Wed Oct 21 01:07:42 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Bulekov X-Patchwork-Id: 270823 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.3 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, HK_RANDOM_FROM, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0EACBC4363D for ; Wed, 21 Oct 2020 01:15:07 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 5BC3920797 for ; Wed, 21 Oct 2020 01:15:06 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=bushare.onmicrosoft.com header.i=@bushare.onmicrosoft.com header.b="OH38rhc5" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5BC3920797 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=bu.edu Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:54714 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kV2iX-0007LP-Bi for qemu-devel@archiver.kernel.org; Tue, 20 Oct 2020 21:15:05 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44400) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kV2c9-0000z8-Ca for qemu-devel@nongnu.org; Tue, 20 Oct 2020 21:08:29 -0400 Received: from mail-co1nam11on2130.outbound.protection.outlook.com ([40.107.220.130]:28640 helo=NAM11-CO1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kV2c7-0004s9-Od for qemu-devel@nongnu.org; Tue, 20 Oct 2020 21:08:29 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Mg7CzsWsBiPRl/98FPrt5hZwzC9E7SbmjqGuvFmkfgwzo+tp50XeABkof77sD8emBD0dFUFxA9luhCb31Se0VOdwSLRaMMWViRsNRqWjtbBdiLSPGmOb2FsfpWBI21AzY8iTEm1d10hBse8rMKOnHC/ogcINmj8Zm3+Rq38S/j8GzDJ3n06cKvwLAnIaTPJuEiFIp9CF7O9RMteBGqx9xFG/ig/WI/QmvIr+QoOu7BKR9UD01IeSPpVcOFxPVBzs7XSAWGS3AQTd9nNE2nDhuH9ayuUE1eYy2pA0FoJEW6tJT32CckePSNkXSwVM4yInUxm/+LAytrDPfDukxmqI7g== 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=zibG1vb8DHFZlDj8ORt0e1CO8t0QRuCdfxBn+zf9/uo=; b=K+9Vdaz1sKPGpJ5lswHExU1Mxx1wYdG6EQcaZzW4lqTXgTQUYpRAwOcgzNOKqCSy0q+AOjfg661oWk/KoHUsdrySY3yfsPmPCYIt4OJMv1fjuEoR42/KKwc0RZ7/g95ayJj9qRA7sYmXLzjaKNZiJ8Qq3Q4tKfIedfEMARL82w5ABpyEXh2TV48E/KhdotdYaUTgJjq4Ua9sSQJo1+eEen7YtGDVjA7w98Hp2rZul/ZydXAf0D3oyOv8HWknzhOQNowRSF41MeY7gw5RDY1JZ9rG9gKu2vSMvZQ6bketool3jg3rDi1zOyQdX6mN4j/iJfwCynZETdkXT2AqkTnULg== 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=zibG1vb8DHFZlDj8ORt0e1CO8t0QRuCdfxBn+zf9/uo=; b=OH38rhc5rzcICkXywXAiTZuqhrQW74fVAh5ERcUiaFYwvy5Ud137IUYj2+p6IcHy147VllUGKBWTWMJFee05AkzKwgqoTQiY51OWjAMNRJJHN8nXSSKiU/TuR40sY2//Xmdb0p+W6xluZueME9zr8c+7gtZkz2n2Wel5EXwVWvo= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none; nongnu.org; dmarc=none action=none header.from=bu.edu; Received: from SN6PR03MB3871.namprd03.prod.outlook.com (2603:10b6:805:6d::32) by SN2PR03MB2333.namprd03.prod.outlook.com (2603:10b6:804:c::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3477.22; Wed, 21 Oct 2020 01:08:12 +0000 Received: from SN6PR03MB3871.namprd03.prod.outlook.com ([fe80::d520:4c19:8ce6:7db2]) by SN6PR03MB3871.namprd03.prod.outlook.com ([fe80::d520:4c19:8ce6:7db2%2]) with mapi id 15.20.3477.028; Wed, 21 Oct 2020 01:08:12 +0000 From: Alexander Bulekov To: qemu-devel@nongnu.org Subject: [PATCH v5 06/16] fuzz: Add fuzzer callbacks to DMA-read functions Date: Tue, 20 Oct 2020 21:07:42 -0400 Message-Id: <20201021010752.973230-7-alxndr@bu.edu> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201021010752.973230-1-alxndr@bu.edu> References: <20201021010752.973230-1-alxndr@bu.edu> X-Originating-IP: [72.93.72.163] X-ClientProxiedBy: BL1PR13CA0119.namprd13.prod.outlook.com (2603:10b6:208:2b9::34) To SN6PR03MB3871.namprd03.prod.outlook.com (2603:10b6:805:6d::32) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from stormtrooper.vrmnet (72.93.72.163) by BL1PR13CA0119.namprd13.prod.outlook.com (2603:10b6:208:2b9::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3499.8 via Frontend Transport; Wed, 21 Oct 2020 01:08:11 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 75bdbd98-c45c-4df6-78c8-08d8755dc7fb X-MS-TrafficTypeDiagnostic: SN2PR03MB2333: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:308; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: isGhfwFUc2W1SzQ1PqEitORf7OEVulgKtAnMDzKYKtt4RdVQnODKhxGToDhlxrcQItvS56gksK0v5COc/PLd0nSbhFwWZ7ikDlonETpQLOhoAl5Lj7JhjVG7iB3HfVH1luimYSh1jyx7BeAm4Lh6eUQWYhJ/nlzdPIiUOVk0CGxnCglyOsm3jFZqe6dNJvJTw3hYNYQ/n9fCTKRkmEHxNak0kwbP6gZ+M0sFRGEwgyoPDgbEYDhFC575U26M362HRT5NeiHNmQlypmTA8klvr6TAFdCPuA5K34QLzmyGkV9oHcgXMc7rmFdpTK55FjYeU8Hdwbr/v5ybKG6NPcfP5A== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:SN6PR03MB3871.namprd03.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(39860400002)(396003)(376002)(346002)(366004)(136003)(52116002)(2616005)(8676002)(6512007)(6916009)(6506007)(36756003)(786003)(316002)(956004)(83380400001)(478600001)(1076003)(4326008)(6486002)(75432002)(8936002)(86362001)(5660300002)(26005)(16526019)(186003)(6666004)(66946007)(2906002)(66476007)(66556008); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: ntFD+0iumfitxoXpH8+Zv96lynNRFBct4QBMnfulm3rQkFjFjWJzDapYXAHVyYu92F3B0D+1Q18ElUikYjiBKdeqhg7IWLfiS5eK5SYlDbIYyQtnRs9YL+cMIkRRkF8Y50BoquhH1FwMmptA8BagvJyWiyZ71GArOGOwoHf93CrGOtDHJ3sAz5uRBkoOGtb+t8H2MgAIPZWL097qbLvRdnI4iMF93x/NAKWhpVAqpTRjmcK2N+SfhKKziQRfxpulPIdgH8t68nu+QOzhb81dOQaJr2IS1X9T+y9of5DrwUog/krHDatT4elbKNl1qCOVDecHcI3gi9h2yC7Jz8T5HIy/Aoq9IpX7al4aIHG+PKfI46kvHOIEBVAu0jErkFJZ5/jdBi2UNt1+oCzoXnXHnfteqmuYTgUgRI4k9hHqXZIIehLyqhMHG0znbEI9tOqG2LCZPZviHamRwBxlMjxGBoyMZOWd95au85foz4btJRMTHJSlF3SZwZOwES7/8YpIi3PTlb99lPl6dxHoME+SwLfubxUW/AtCUgiXaUB9ZWj1Go9YVOjMukzxtlioKrPVaPjwmcTGACoixwgODzl6r//5evu3bZITJCDzPXfIDRDG60Y3T4ToKX47q3dzbLCfO0Uj01Lr+BP0+laZzHV79Q== X-OriginatorOrg: bu.edu X-MS-Exchange-CrossTenant-Network-Message-Id: 75bdbd98-c45c-4df6-78c8-08d8755dc7fb X-MS-Exchange-CrossTenant-AuthSource: SN6PR03MB3871.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Oct 2020 01:08:12.2408 (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: VBpMy18i/E79r2+Att6joMkGNx1z9vGiVuh2BD/BIoPKqfWBV7Pw/CLgYRhbq6ez X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN2PR03MB2333 Received-SPF: pass client-ip=40.107.220.130; envelope-from=alxndr@bu.edu; helo=NAM11-CO1-obe.outbound.protection.outlook.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/20 21:08:14 X-ACL-Warn: Detected OS = Windows NT kernel [generic] [fuzzy] X-Spam_score_int: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, HK_RANDOM_ENVFROM=0.001, HK_RANDOM_FROM=0.441, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no 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 , f4bug@amsat.org, darren.kenny@oracle.com, bsd@redhat.com, stefanha@redhat.com, pbonzini@redhat.com, dimastep@yandex-team.ru Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" We should be careful to not call any functions besides fuzz_dma_read_cb. Without --enable-fuzzing, fuzz_dma_read_cb is an empty inlined function. Signed-off-by: Alexander Bulekov Reviewed-by: Darren Kenny --- include/exec/memory.h | 1 + include/exec/memory_ldst_cached.h.inc | 3 +++ memory_ldst.c.inc | 4 ++++ softmmu/memory.c | 1 + softmmu/physmem.c | 2 ++ 5 files changed, 11 insertions(+) diff --git a/include/exec/memory.h b/include/exec/memory.h index 854480859d..588668547b 100644 --- a/include/exec/memory.h +++ b/include/exec/memory.h @@ -2462,6 +2462,7 @@ address_space_read_cached(MemoryRegionCache *cache, hwaddr addr, void *buf, hwaddr len) { assert(addr < cache->len && len <= cache->len - addr); + fuzz_dma_read_cb(cache->xlat + addr, len, cache->mrs.mr, false); if (likely(cache->ptr)) { memcpy(buf, cache->ptr + addr, len); return MEMTX_OK; diff --git a/include/exec/memory_ldst_cached.h.inc b/include/exec/memory_ldst_cached.h.inc index fd4bbb40e7..aff574039f 100644 --- a/include/exec/memory_ldst_cached.h.inc +++ b/include/exec/memory_ldst_cached.h.inc @@ -28,6 +28,7 @@ static inline uint32_t ADDRESS_SPACE_LD_CACHED(l)(MemoryRegionCache *cache, hwaddr addr, MemTxAttrs attrs, MemTxResult *result) { assert(addr < cache->len && 4 <= cache->len - addr); + fuzz_dma_read_cb(cache->xlat + addr, 4, cache->mrs.mr, false); if (likely(cache->ptr)) { return LD_P(l)(cache->ptr + addr); } else { @@ -39,6 +40,7 @@ static inline uint64_t ADDRESS_SPACE_LD_CACHED(q)(MemoryRegionCache *cache, hwaddr addr, MemTxAttrs attrs, MemTxResult *result) { assert(addr < cache->len && 8 <= cache->len - addr); + fuzz_dma_read_cb(cache->xlat + addr, 8, cache->mrs.mr, false); if (likely(cache->ptr)) { return LD_P(q)(cache->ptr + addr); } else { @@ -50,6 +52,7 @@ static inline uint32_t ADDRESS_SPACE_LD_CACHED(uw)(MemoryRegionCache *cache, hwaddr addr, MemTxAttrs attrs, MemTxResult *result) { assert(addr < cache->len && 2 <= cache->len - addr); + fuzz_dma_read_cb(cache->xlat + addr, 2, cache->mrs.mr, false); if (likely(cache->ptr)) { return LD_P(uw)(cache->ptr + addr); } else { diff --git a/memory_ldst.c.inc b/memory_ldst.c.inc index c54aee4a95..8d45d2eeff 100644 --- a/memory_ldst.c.inc +++ b/memory_ldst.c.inc @@ -42,6 +42,7 @@ static inline uint32_t glue(address_space_ldl_internal, SUFFIX)(ARG1_DECL, MO_32 | devend_memop(endian), attrs); } else { /* RAM case */ + fuzz_dma_read_cb(addr, 4, mr, false); ptr = qemu_map_ram_ptr(mr->ram_block, addr1); switch (endian) { case DEVICE_LITTLE_ENDIAN: @@ -110,6 +111,7 @@ static inline uint64_t glue(address_space_ldq_internal, SUFFIX)(ARG1_DECL, MO_64 | devend_memop(endian), attrs); } else { /* RAM case */ + fuzz_dma_read_cb(addr, 8, mr, false); ptr = qemu_map_ram_ptr(mr->ram_block, addr1); switch (endian) { case DEVICE_LITTLE_ENDIAN: @@ -175,6 +177,7 @@ uint32_t glue(address_space_ldub, SUFFIX)(ARG1_DECL, r = memory_region_dispatch_read(mr, addr1, &val, MO_8, attrs); } else { /* RAM case */ + fuzz_dma_read_cb(addr, 1, mr, false); ptr = qemu_map_ram_ptr(mr->ram_block, addr1); val = ldub_p(ptr); r = MEMTX_OK; @@ -212,6 +215,7 @@ static inline uint32_t glue(address_space_lduw_internal, SUFFIX)(ARG1_DECL, MO_16 | devend_memop(endian), attrs); } else { /* RAM case */ + fuzz_dma_read_cb(addr, 2, mr, false); ptr = qemu_map_ram_ptr(mr->ram_block, addr1); switch (endian) { case DEVICE_LITTLE_ENDIAN: diff --git a/softmmu/memory.c b/softmmu/memory.c index d3cdb46459..d7fdca2603 100644 --- a/softmmu/memory.c +++ b/softmmu/memory.c @@ -1429,6 +1429,7 @@ MemTxResult memory_region_dispatch_read(MemoryRegion *mr, unsigned size = memop_size(op); MemTxResult r; + fuzz_dma_read_cb(addr, size, mr, false); if (!memory_region_access_valid(mr, addr, size, false, attrs)) { *pval = unassigned_mem_read(mr, addr, size); return MEMTX_DECODE_ERROR; diff --git a/softmmu/physmem.c b/softmmu/physmem.c index e319fb2a1e..a9adedb9f8 100644 --- a/softmmu/physmem.c +++ b/softmmu/physmem.c @@ -2832,6 +2832,7 @@ MemTxResult flatview_read_continue(FlatView *fv, hwaddr addr, stn_he_p(buf, l, val); } else { /* RAM case */ + fuzz_dma_read_cb(addr, len, mr, false); ram_ptr = qemu_ram_ptr_length(mr->ram_block, addr1, &l, false); memcpy(buf, ram_ptr, l); } @@ -3192,6 +3193,7 @@ void *address_space_map(AddressSpace *as, memory_region_ref(mr); *plen = flatview_extend_translation(fv, addr, len, mr, xlat, l, is_write, attrs); + fuzz_dma_read_cb(addr, *plen, mr, is_write); ptr = qemu_ram_ptr_length(mr->ram_block, xlat, plen, true); return ptr; From patchwork Wed Oct 21 01:07:43 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Bulekov X-Patchwork-Id: 302431 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.3 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, HK_RANDOM_FROM, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 65B03C4363D for ; Wed, 21 Oct 2020 01:13:39 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id BC8F120797 for ; Wed, 21 Oct 2020 01:13:38 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=bushare.onmicrosoft.com header.i=@bushare.onmicrosoft.com header.b="P/NZEk+o" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org BC8F120797 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=bu.edu Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:51402 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kV2h7-0005zK-QT for qemu-devel@archiver.kernel.org; Tue, 20 Oct 2020 21:13:37 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44418) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kV2cB-00011X-DW for qemu-devel@nongnu.org; Tue, 20 Oct 2020 21:08:31 -0400 Received: from mail-co1nam11on2130.outbound.protection.outlook.com ([40.107.220.130]:28640 helo=NAM11-CO1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kV2c9-0004s9-Rh for qemu-devel@nongnu.org; Tue, 20 Oct 2020 21:08:31 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=fG8l9WDS9XrYpRApzdB0Mu62ydKPM3gi3Y2TwQDMehZRqGiDpkcwDJGCQWQzUPJ67MhaKd5mvbZc4gTLmN6qVUvMN+A64Es5BMjYvnB7jZk/l8mLcMOZqjocpQLaCkhLuACSxmXltOsRpgXJGJgsc7eArbx+9XjqWRrroUGg3MIm7GIMQdn0sq0jfEEA+H146zsZSyyE6AsGQXJKVGmoWhuqZzOxklQ1/ZcFvZdkjWic/HBFiYvu8XY2KjgtYclM9QAMiTFdCYudPdNJ/Spp5ylbEv3RkZYYkP+RzpdH00iBaX5SDjk4YKr0c02YLvrDMEABozU2xKfBlkxTFsrXig== 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=9JConF3xBRqpbuFwEhD621vHq4kTf2LaXQ5y+kvYOsM=; b=bbSiXl9Jlte6/4+rOH8o1ZDEnk856GzYazcXi6lLRaljqvuuevwwVsELoL3coKIYRCN4MPlOu+hRGS7KtLbrDaY601JaaGM1ccq1DFlPowH/diwiXUPTfkO7MM0y7zoqpUMHWMgMj391ejbazK0YWga4fHQVbutvy4qNvhyHlJ+4v4nbaZnjXduqujsq9KPpZlsXsU4mC+743WGRQ/dcZWJTPgiQwyFPlGPQLx0Yuq6sDFU20vJRKNjSrRMSb7rDWgWIib/WLyUlK4CHmvEvFZaxQbzMQwmLx+7kr60TwMxgKkipYm7onFsdlMQ6RwkESwZ5uVfxVdHGXB5Bype3ww== 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=9JConF3xBRqpbuFwEhD621vHq4kTf2LaXQ5y+kvYOsM=; b=P/NZEk+orsgKer0q3Fn0X4lkF1LC8O5lrR9X38cdULIt0UYxyr1k3blGcLMOqCMdGSOvn0KhOdUavQfjoQGiLfiL7HTRzDxMzUUQu5zx0ZY1uy1uC2+4s7O2IC8xpba/VsLddwQkLTui68JIhjOSNUcX5SPbvjGKjhJmsDNU69E= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none; nongnu.org; dmarc=none action=none header.from=bu.edu; Received: from SN6PR03MB3871.namprd03.prod.outlook.com (2603:10b6:805:6d::32) by SN2PR03MB2333.namprd03.prod.outlook.com (2603:10b6:804:c::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3477.22; Wed, 21 Oct 2020 01:08:14 +0000 Received: from SN6PR03MB3871.namprd03.prod.outlook.com ([fe80::d520:4c19:8ce6:7db2]) by SN6PR03MB3871.namprd03.prod.outlook.com ([fe80::d520:4c19:8ce6:7db2%2]) with mapi id 15.20.3477.028; Wed, 21 Oct 2020 01:08:14 +0000 From: Alexander Bulekov To: qemu-devel@nongnu.org Subject: [PATCH v5 07/16] fuzz: Add support for custom crossover functions Date: Tue, 20 Oct 2020 21:07:43 -0400 Message-Id: <20201021010752.973230-8-alxndr@bu.edu> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201021010752.973230-1-alxndr@bu.edu> References: <20201021010752.973230-1-alxndr@bu.edu> X-Originating-IP: [72.93.72.163] X-ClientProxiedBy: BL1PR13CA0119.namprd13.prod.outlook.com (2603:10b6:208:2b9::34) To SN6PR03MB3871.namprd03.prod.outlook.com (2603:10b6:805:6d::32) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from stormtrooper.vrmnet (72.93.72.163) by BL1PR13CA0119.namprd13.prod.outlook.com (2603:10b6:208:2b9::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3499.8 via Frontend Transport; Wed, 21 Oct 2020 01:08:13 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: e367fa6a-003f-4922-383e-08d8755dc8f2 X-MS-TrafficTypeDiagnostic: SN2PR03MB2333: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:7691; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: QnSSVjUOCEwiLEA2uFYF22NVlteBbhXt0xyuFkPgaJAIpL3n6a4jiszc/nmZ973F1s7GlblySNT76YO0rFngLyTBXi4x0T7wlAjg+MtyjsSAM5zPNzhJjTBJO3vsCEdITphjkO+3N63S1+TYgGF3CDSTHPjS6Jsgn7myek+wh2MxasMM2MeBbMIm4ZpkaSU5tbGyqRDRyaQ3aw/smzhT38GRBJkHAqcF5MdlvaVXP6ffeajzr4GPB0wIND+4USEveAQzktjAdfVxe/yVM1q4a9KknHK+GTr1R7OJwmvNzkYl+UJsdTN7pRUUz0Eu6s4Kb/rqm9Laq8kpcsS0cHGw9Q== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:SN6PR03MB3871.namprd03.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(39860400002)(396003)(376002)(346002)(366004)(136003)(52116002)(2616005)(8676002)(6512007)(6916009)(6506007)(36756003)(786003)(316002)(956004)(478600001)(1076003)(4326008)(6486002)(75432002)(8936002)(54906003)(86362001)(5660300002)(26005)(16526019)(186003)(6666004)(66946007)(2906002)(66476007)(66556008); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: JqwzMQfgEzUGO3NGBvS6YBU8o1wBIbSQ6YqKrhl1WRvHhjjWf1NEnZZalEyZC6iRufxZEh6ui2BLC2TGVQa/dlyLDo/0z/RwLjwXXyl6COwbgAQwbX5/BVBW9mDcIlzg8xLmwjjltbIMKCUHj9NuumB4y+jng+VPVI5HQkXVJXpcsRHt6AlZZ2xO9YNfYL38fL4TZ4nUhWGgKtkhPmYULyDUYnWiPfcg0a+2rpX5Lb4vcBkGU1S9Cgz6EJuj0QGzm6K0ZSnwTCbt0wzdfreS6x66kLGnGTL6B7VjdPCeBV8EHQYjC7kaMSYMT90engu0xyI2oBXPpBBr4ZnjHgb8L70gcPhMyLmbtimGX42TQPVwb7CsRCen5g55FckDkb4wDUGLPBUFNo2Bcj6VG2+BQdHR7RXPJoU2XcCAyj23PDQf+MlI2RM0yY+KvvMcjk2pOE/BSZzyvz0ew1M24U9/XemCpeKjYrDThJVEAhbGTwVa5Az/w5GtC5zrjN1EGFCsd5jemuIx8tLRkqBHCRL877lXPgxxBFbyDoQ3qFFk5K/lyHlk8/k85GOIGJp5UenTpSDrGT35ZrDRAu13ao0sGk2ebN6CXu3lJ4njysfi5TIcLAxLJxmf41QlJGMlOzUfaG0GlUCkOtlA+r2UbqmaaA== X-OriginatorOrg: bu.edu X-MS-Exchange-CrossTenant-Network-Message-Id: e367fa6a-003f-4922-383e-08d8755dc8f2 X-MS-Exchange-CrossTenant-AuthSource: SN6PR03MB3871.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Oct 2020 01:08:14.2417 (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: LrrctriesXVDB6gLB0Oi1cG9rOdGIhI3MhW9ZNXLPRoCkAVfMEN51YzOT1Q1rTpn X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN2PR03MB2333 Received-SPF: pass client-ip=40.107.220.130; envelope-from=alxndr@bu.edu; helo=NAM11-CO1-obe.outbound.protection.outlook.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/20 21:08:14 X-ACL-Warn: Detected OS = Windows NT kernel [generic] [fuzzy] X-Spam_score_int: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, HK_RANDOM_ENVFROM=0.001, HK_RANDOM_FROM=0.441, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no 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: Laurent Vivier , Thomas Huth , Alexander Bulekov , f4bug@amsat.org, darren.kenny@oracle.com, bsd@redhat.com, stefanha@redhat.com, pbonzini@redhat.com, dimastep@yandex-team.ru Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" libfuzzer supports a "custom crossover function". Libfuzzer often tries to blend two inputs to create a new interesting input. Sometimes, we have a better idea about how to blend inputs together. This change allows fuzzers to specify a custom function for blending two inputs together. Signed-off-by: Alexander Bulekov Reviewed-by: Darren Kenny --- tests/qtest/fuzz/fuzz.c | 13 +++++++++++++ tests/qtest/fuzz/fuzz.h | 27 +++++++++++++++++++++++++++ 2 files changed, 40 insertions(+) diff --git a/tests/qtest/fuzz/fuzz.c b/tests/qtest/fuzz/fuzz.c index eb0070437f..7be7226bc0 100644 --- a/tests/qtest/fuzz/fuzz.c +++ b/tests/qtest/fuzz/fuzz.c @@ -118,6 +118,19 @@ static FuzzTarget *fuzz_get_target(char* name) } +/* Sometimes called by libfuzzer to mutate two inputs into one */ +size_t LLVMFuzzerCustomCrossOver(const uint8_t *data1, size_t size1, + const uint8_t *data2, size_t size2, + uint8_t *out, size_t max_out_size, + unsigned int seed) +{ + if (fuzz_target->crossover) { + return fuzz_target->crossover(data1, size1, data2, size2, out, + max_out_size, seed); + } + return 0; +} + /* Executed for each fuzzing-input */ int LLVMFuzzerTestOneInput(const unsigned char *Data, size_t Size) { diff --git a/tests/qtest/fuzz/fuzz.h b/tests/qtest/fuzz/fuzz.h index 8eb765edc8..ed9ce17154 100644 --- a/tests/qtest/fuzz/fuzz.h +++ b/tests/qtest/fuzz/fuzz.h @@ -77,6 +77,29 @@ typedef struct FuzzTarget { */ void(*fuzz)(QTestState *, const unsigned char *, size_t); + /* + * The fuzzer can specify a "Custom Crossover" function for combining two + * inputs from the corpus. This function is sometimes called by libfuzzer + * when mutating inputs. + * + * data1: location of first input + * size1: length of first input + * data1: location of second input + * size1: length of second input + * out: where to place the resulting, mutated input + * max_out_size: the maximum length of the input that can be placed in out + * seed: the seed that should be used to make mutations deterministic, when + * needed + * + * See libfuzzer's LLVMFuzzerCustomCrossOver API for more info. + * + * Can be NULL + */ + size_t(*crossover)(const uint8_t *data1, size_t size1, + const uint8_t *data2, size_t size2, + uint8_t *out, size_t max_out_size, + unsigned int seed); + } FuzzTarget; void flush_events(QTestState *); @@ -91,6 +114,10 @@ void fuzz_qtest_set_serialize(bool option); */ void fuzz_add_target(const FuzzTarget *target); +size_t LLVMFuzzerCustomCrossOver(const uint8_t *data1, size_t size1, + const uint8_t *data2, size_t size2, + uint8_t *out, size_t max_out_size, + unsigned int seed); int LLVMFuzzerTestOneInput(const unsigned char *Data, size_t Size); int LLVMFuzzerInitialize(int *argc, char ***argv, char ***envp); From patchwork Wed Oct 21 01:07:44 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Bulekov X-Patchwork-Id: 302429 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.3 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, HK_RANDOM_FROM, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E718FC4363D for ; Wed, 21 Oct 2020 01:18:16 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 2689422253 for ; Wed, 21 Oct 2020 01:18:16 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=bushare.onmicrosoft.com header.i=@bushare.onmicrosoft.com header.b="D9vnR3wA" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2689422253 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=bu.edu Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:58952 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kV2lb-0000qc-5k for qemu-devel@archiver.kernel.org; Tue, 20 Oct 2020 21:18:15 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44434) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kV2cD-00014F-Ds for qemu-devel@nongnu.org; Tue, 20 Oct 2020 21:08:33 -0400 Received: from mail-co1nam11on2130.outbound.protection.outlook.com ([40.107.220.130]:28640 helo=NAM11-CO1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kV2cB-0004s9-RK for qemu-devel@nongnu.org; Tue, 20 Oct 2020 21:08:33 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=O7s2NogHI8sfmBg7p45vh3PYkCrxnXi/Ng5lJeG/mHq6ptuN25+ioXUiMi2SwfsQuAAy+nvQUlFfwGw2pi8Eq8dB92vLpf7jlWKH9mqamNYmUZiBL9mxjBPCOqsathMX2JHQRxC+oIys13EXfEcVvv8OvJmhjAYnZCyELVAfQ3h4v9YYLvv4+5mJNDBqQBtF6QlQaf1+IbNWXP4Ef2RZejReKwo1nj13iR2HZWq7f2OHSynS5gWveQK9FmdbhhX+N7iHFAoInJFccaAQSymRAO1lLU3beY5RjwCgAYQ2z+JhzGZ+A5EUP9De4sTM+ByQo9BAwJT9wzzcv24Q/OyI2g== 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=mp/v1rzkEfnbsG5EE1P7tBu/Sf4LGkGkjKSHQaOsf7w=; b=JTrRxNWbK1IMUhULqW3eeMGh80CR1BWsU8hbpxo92xySQiFjQs9SvCqBTv0DX7su2dgeAo0ZgIviH1+nanGMfZIP9dK47cEHJs/nC2HanDivvrmhEiAhkgnei6hZpI23tbuXz8TS+3RCexQGXoTHYYdAkgBecYSqwx4rUll+NSri1TGMljD7J1D7Iu6h/Z6mZ5asx10zeL87DEQC6L+iA4xoZsIP6o5aRlmNyaKyngjVi6BsmJ+gCtT9avaAlCZEvWLpgiXh1M2jiU+cdM8FD8z3dT+MavELvlDJ3ZRpx/Zn34pnKRBRKnpPXtuuYmcYmCwhMBLWHl/enR6zxahMiQ== 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=mp/v1rzkEfnbsG5EE1P7tBu/Sf4LGkGkjKSHQaOsf7w=; b=D9vnR3wAA+E7RQ5f5letyNC5VmNxOZKSzYGPJM8o5xTSE/zSJk3yFvMvZbRa6waj7sEHa4fnd2NZPQaIZtbX2k9Bud2wwtJR09V14DtpjKC2Geri3lKtkFlXuIaL87zT29eZ58bg8aEgvhhGbIUq+Mv9sCzkE7U/wrD2KDwWJ8c= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none; nongnu.org; dmarc=none action=none header.from=bu.edu; Received: from SN6PR03MB3871.namprd03.prod.outlook.com (2603:10b6:805:6d::32) by SN2PR03MB2333.namprd03.prod.outlook.com (2603:10b6:804:c::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3477.22; Wed, 21 Oct 2020 01:08:15 +0000 Received: from SN6PR03MB3871.namprd03.prod.outlook.com ([fe80::d520:4c19:8ce6:7db2]) by SN6PR03MB3871.namprd03.prod.outlook.com ([fe80::d520:4c19:8ce6:7db2%2]) with mapi id 15.20.3477.028; Wed, 21 Oct 2020 01:08:15 +0000 From: Alexander Bulekov To: qemu-devel@nongnu.org Subject: [PATCH v5 08/16] fuzz: add a DISABLE_PCI op to general-fuzzer Date: Tue, 20 Oct 2020 21:07:44 -0400 Message-Id: <20201021010752.973230-9-alxndr@bu.edu> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201021010752.973230-1-alxndr@bu.edu> References: <20201021010752.973230-1-alxndr@bu.edu> X-Originating-IP: [72.93.72.163] X-ClientProxiedBy: BL1PR13CA0119.namprd13.prod.outlook.com (2603:10b6:208:2b9::34) To SN6PR03MB3871.namprd03.prod.outlook.com (2603:10b6:805:6d::32) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from stormtrooper.vrmnet (72.93.72.163) by BL1PR13CA0119.namprd13.prod.outlook.com (2603:10b6:208:2b9::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3499.8 via Frontend Transport; Wed, 21 Oct 2020 01:08:14 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 4588b0c2-ba7a-431a-5857-08d8755dc9d8 X-MS-TrafficTypeDiagnostic: SN2PR03MB2333: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:40; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: FvK60AzPjJVBz3IPEcZUR0ZjusT2SIMPLVhYXMCM6mn+W6xa9SUKxz9R0eWZaI/m2zxDk9ma80StQKKQV278bYd8HvpHwsxvmVmeA7dDQbzTGDdmxn6Qt8hmKDqFuurp6VY33qi8ShvNMw/8z3Nh8xjJaNTsJQLb54oHx4en01772d8ne8M5A3ML/31+C/iNmgrFIufbawbdyTvGxnj9iJH+sRwum4fw+gQSE9tx3LXqJMCEKpD3cHGsbW4FBxVGcDNhXzQRuGZudwkLQwBGqyhpY0cZ6GOdzRful95p0+3l6GXA3RFSDDiksVF72vDzZFTp1KV+h7qeZTVa8OV1Cw== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:SN6PR03MB3871.namprd03.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(39860400002)(396003)(376002)(346002)(366004)(136003)(52116002)(2616005)(8676002)(6512007)(6916009)(6506007)(36756003)(786003)(316002)(956004)(83380400001)(478600001)(1076003)(4326008)(6486002)(75432002)(8936002)(54906003)(86362001)(5660300002)(26005)(16526019)(186003)(6666004)(66946007)(2906002)(66476007)(66556008); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: JQ4tu+TvkqjbMhlrpG2jUGjMA1poQbsqdB9xj+g8uY8otYzmJ9lUQXkNlUqf/uMc+Y/Ex8k+dU5S0vvEVjeebyCrP8QRMlJddV7E+z0TbI/9EJxZyKNNKTAaAiFsglbS2yaKI93NuIk4NjI7Aak+QiisLUGZ4WzStspYljS7DLPqJj6KccX9HQ+8z7G1Ow4Aa7B/rUf+gDVkU+9CiYmMUK5xaEXMaXad2epKw3QuB1u4pHKoFG3+pou+wTqbmXDa8vioZueK9A5Uq+on6zKIdYSEl0sILjnyk+2xetfa/IQsYLo6c6IZL5+Y6i/Zumimwrk+uHm3FQ2RLm4IRk/EuKYgCeguIEC5bTdrIbVhWxAgoM5vByOfcpVuL4NsUi+tXx6MBJwSfLc7oq7KHeyhIHw4mK/5gAVbib5xtQ8V5vhOHVghsMdZgCaJMqJUZNsWlns9jqCQpcvQT0Ff30QR49YvZYmN4TIU0adyRYdLGhz7wgQNy0wGLkmoCbdo8uGqNdfRwXckEmVAhEubp94fORGZGvAKICLPXpoaFwt3ZaDS3oUWgsgMeb5rsYdLBAQhtOOBT4/4Sr5JxzlaXZ5CAqZdZPo9Q+cSIjZCf67N01pNspgB+bLnHd73aQY5I40+ZeKy/ua8Vgx3QjIjaSvEkg== X-OriginatorOrg: bu.edu X-MS-Exchange-CrossTenant-Network-Message-Id: 4588b0c2-ba7a-431a-5857-08d8755dc9d8 X-MS-Exchange-CrossTenant-AuthSource: SN6PR03MB3871.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Oct 2020 01:08:15.3471 (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: 9CszKNA2KrTQPeP9JzYOlSsYgQvU3eskEhIttX2GAZGjIONoHSxAiEEkueYyciSy X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN2PR03MB2333 Received-SPF: pass client-ip=40.107.220.130; envelope-from=alxndr@bu.edu; helo=NAM11-CO1-obe.outbound.protection.outlook.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/20 21:08:14 X-ACL-Warn: Detected OS = Windows NT kernel [generic] [fuzzy] X-Spam_score_int: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, HK_RANDOM_ENVFROM=0.001, HK_RANDOM_FROM=0.441, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no 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: Laurent Vivier , Thomas Huth , Alexander Bulekov , f4bug@amsat.org, darren.kenny@oracle.com, bsd@redhat.com, stefanha@redhat.com, pbonzini@redhat.com, dimastep@yandex-team.ru Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" This new operation is used in the next commit, which concatenates two fuzzer-generated inputs. With this operation, we can prevent the second input from clobbering the PCI configuration performed by the first. Signed-off-by: Alexander Bulekov Reviewed-by: Darren Kenny --- tests/qtest/fuzz/generic_fuzz.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/tests/qtest/fuzz/generic_fuzz.c b/tests/qtest/fuzz/generic_fuzz.c index a12dc634b3..b1254f4e63 100644 --- a/tests/qtest/fuzz/generic_fuzz.c +++ b/tests/qtest/fuzz/generic_fuzz.c @@ -39,6 +39,7 @@ enum cmds { OP_WRITE, OP_PCI_READ, OP_PCI_WRITE, + OP_DISABLE_PCI, OP_ADD_DMA_PATTERN, OP_CLEAR_DMA_PATTERNS, OP_CLOCK_STEP, @@ -116,6 +117,7 @@ static GArray *dma_regions; static GArray *dma_patterns; static int dma_pattern_index; +static bool pci_disabled; /* * Allocate a block of memory and populate it with a pattern. @@ -479,7 +481,7 @@ static void op_pci_read(QTestState *s, const unsigned char * data, size_t len) uint8_t base; uint8_t offset; } a; - if (len < sizeof(a) || fuzzable_pci_devices->len == 0) { + if (len < sizeof(a) || fuzzable_pci_devices->len == 0 || pci_disabled) { return; } memcpy(&a, data, sizeof(a)); @@ -509,7 +511,7 @@ static void op_pci_write(QTestState *s, const unsigned char * data, size_t len) uint8_t offset; uint32_t value; } a; - if (len < sizeof(a) || fuzzable_pci_devices->len == 0) { + if (len < sizeof(a) || fuzzable_pci_devices->len == 0 || pci_disabled) { return; } memcpy(&a, data, sizeof(a)); @@ -564,6 +566,11 @@ static void op_clock_step(QTestState *s, const unsigned char *data, size_t len) qtest_clock_step_next(s); } +static void op_disable_pci(QTestState *s, const unsigned char *data, size_t len) +{ + pci_disabled = true; +} + static void handle_timeout(int sig) { if (qtest_log_enabled) { @@ -619,6 +626,7 @@ static void generic_fuzz(QTestState *s, const unsigned char *Data, size_t Size) [OP_WRITE] = op_write, [OP_PCI_READ] = op_pci_read, [OP_PCI_WRITE] = op_pci_write, + [OP_DISABLE_PCI] = op_disable_pci, [OP_ADD_DMA_PATTERN] = op_add_dma_pattern, [OP_CLEAR_DMA_PATTERNS] = op_clear_dma_patterns, [OP_CLOCK_STEP] = op_clock_step, @@ -651,6 +659,7 @@ static void generic_fuzz(QTestState *s, const unsigned char *Data, size_t Size) } op_clear_dma_patterns(s, NULL, 0); + pci_disabled = false; while (cmd && Size) { /* Get the length until the next command or end of input */ From patchwork Wed Oct 21 01:07:45 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Bulekov X-Patchwork-Id: 270822 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.3 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, HK_RANDOM_FROM, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B6955C388F2 for ; Wed, 21 Oct 2020 01:18:18 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 2299822253 for ; Wed, 21 Oct 2020 01:18:18 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=bushare.onmicrosoft.com header.i=@bushare.onmicrosoft.com header.b="55FsZvUS" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2299822253 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=bu.edu Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:59140 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kV2ld-0000vT-3p for qemu-devel@archiver.kernel.org; Tue, 20 Oct 2020 21:18:17 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44446) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kV2cF-00018t-MS for qemu-devel@nongnu.org; Tue, 20 Oct 2020 21:08:35 -0400 Received: from mail-co1nam11on2130.outbound.protection.outlook.com ([40.107.220.130]:28640 helo=NAM11-CO1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kV2cD-0004s9-Rw for qemu-devel@nongnu.org; Tue, 20 Oct 2020 21:08:35 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=IIlAFYas3jRDxvuPwmRUR013i3wBshX9onF8t2X83J+5prwa665eoppypKqYqT3CX1rRMX1Vmw1kiTf102IKAHpaWdRl3yOfNuBxuZetPVG/sZIZjmtGIXg24NiuPauNMFoE6VExmEb032Y4vgTIsxWzFgbtMdik97YqR8/dD1KNzjCWSQFjYR6UQsO4PtWuuzkp36gHMhxsXafJCK0TRA2uaiyPYbNbja0awCeHopLA3UjHXUJFbz7gtHi+eqdotRIe5oztjzu7ttoWX29MMurhNdbH3nBtDWjX8YSwotV/9tJvYrcX47GpjZvNoj9/KVtylF5K/SUdX4uwNnKNEA== 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=suH9REkuZLTDDMTO84INf7b5sOMP9r7ertN0K+0wW7o=; b=h5jyiNhRpoX7Lk4TGeeehebSi89vLE4NOzZTYyvOYNaTv26Z1qGf2N436rlmKDonjDgMOtwlqnUb8NZQh8S7bs80Q34qMQUFjCkY0+vIv3eoDYA3v9zaCClJ5EIiuGHsjBakO6ppOR9dQrZnt8Ab5lsTkk9X3C0FZlHAW9aYe9e+Dre69o+Uiln3v4gNQ0cwd/ONPPP8ZSPJuw8xoOOE1SnhK4SueANMfDVLN5Ry7PmD4uZH22N3aR9IoVOydXrdqFnsuzyKjHNBbJvhqZ1x7tnNDfVeVXxPoB4b7AMDHPTaQXcudAQffJrphpQ20UFoqkLJ2Sl/GIeFku5LUDwIMQ== 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=suH9REkuZLTDDMTO84INf7b5sOMP9r7ertN0K+0wW7o=; b=55FsZvUSTxE+BOK7oMSymoJJuoYHPid2LEMClY3Uq8Lrd4hU/22UW3OGVwW6VbK1J4/Z9gnD/xkmWWhvsteV5+yWG/pmUVTdnbqoIB9thHAEfCAREFF73hBgYaX1Bvi/nalB80jRifHI+cOy+IzH5Xa6vkITuvaNBoK5CHIVBps= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none; nongnu.org; dmarc=none action=none header.from=bu.edu; Received: from SN6PR03MB3871.namprd03.prod.outlook.com (2603:10b6:805:6d::32) by SN2PR03MB2333.namprd03.prod.outlook.com (2603:10b6:804:c::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3477.22; Wed, 21 Oct 2020 01:08:16 +0000 Received: from SN6PR03MB3871.namprd03.prod.outlook.com ([fe80::d520:4c19:8ce6:7db2]) by SN6PR03MB3871.namprd03.prod.outlook.com ([fe80::d520:4c19:8ce6:7db2%2]) with mapi id 15.20.3477.028; Wed, 21 Oct 2020 01:08:16 +0000 From: Alexander Bulekov To: qemu-devel@nongnu.org Subject: [PATCH v5 09/16] fuzz: add a crossover function to generic-fuzzer Date: Tue, 20 Oct 2020 21:07:45 -0400 Message-Id: <20201021010752.973230-10-alxndr@bu.edu> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201021010752.973230-1-alxndr@bu.edu> References: <20201021010752.973230-1-alxndr@bu.edu> X-Originating-IP: [72.93.72.163] X-ClientProxiedBy: BL1PR13CA0119.namprd13.prod.outlook.com (2603:10b6:208:2b9::34) To SN6PR03MB3871.namprd03.prod.outlook.com (2603:10b6:805:6d::32) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from stormtrooper.vrmnet (72.93.72.163) by BL1PR13CA0119.namprd13.prod.outlook.com (2603:10b6:208:2b9::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3499.8 via Frontend Transport; Wed, 21 Oct 2020 01:08:15 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: ddac3663-5b90-4287-65a9-08d8755dca92 X-MS-TrafficTypeDiagnostic: SN2PR03MB2333: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:7691; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: okHzYEZXcKxdZwgMZDjK3NLZN6BpJVrh+RyU746UnTJQBmaEaRwprf2OeifzCdrzmCP5Mpz73b1uRUZlQCn0CWgYxcF1F2Gh8qIHH8yLGZYIdDl5ZO0tWz4H287v9gpjlwyY9r6a5NY+7Cbv3jwSiRCKROfLzfEzeLPrPZwFjfwc3DrEtK8jbNTWhywslHFCdUZo02pcb5xXkqrczAmDyHb+lxdiij0Cd5ZbpUul1dVg/5GG4n2+rfsS0JsngnofHBfe8wO4J4tGtMGtAHmdeve+bPCL/AbXizfh7Xs64NHyGtmYiLRQU2AS7DWHF7oMCg1X0FQJsgEm0bqdHhBEBI1XV0V/89qKv8LN3IIjmWOVnYrPPqfg0cWRmFoWHOni X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:SN6PR03MB3871.namprd03.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(39860400002)(396003)(376002)(346002)(366004)(136003)(52116002)(2616005)(8676002)(6512007)(6916009)(6506007)(36756003)(786003)(316002)(956004)(83380400001)(478600001)(1076003)(4326008)(6486002)(75432002)(8936002)(54906003)(86362001)(5660300002)(26005)(16526019)(186003)(6666004)(66946007)(2906002)(66476007)(66556008)(41533002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: eSh2MWYziB8b6DrSgjYlbYIq9df3mz7O/5tDHr6D+IRLGC+eU684yA3Jr5GNSNNXZat7LMcG38n1iPUD9kwBUarUorj2vVRBbmX/oAyKZT8/NTW4lvHMNl3L+90JSTq4OhFnLH+2sFBPh8aAF3x0y+xrTURREN6Wu2Y5CmrNpS9oRC6+PcvJXRf+dIGAuOrdcIH+Jkikbtl9lhqjuY6Uf3VtYr7pcbFvIW97UKhqaL/ZC6/2VdRdeOE+PVbxkfWuV73PcRCisWlwmAsS4DX06olKCBQq5G01wuUg9Hvyh9rZu2Gdabp5oOwGY2ivzYa0vGEaEAZYPtOg1qNzRy11Vroyj1bLFRgaDhv7nDPns/byItDrsiJs/iSt0ZDueyGq1O44HUjXnhmKc93zXvv8vRZQCAQuuG+xAHHcRLzmQEnAi/1gbrcIw5XR3TwOEBSYwUUYQcAo9nr/2ItfKes88HHnkGhJulnE1G+6c60yDrgh7V31UcjSMSd2Pqv2OJYVup6Hv/bx/cJ03F7CPve8KY+bmY5tmN4JWRY3Sq9J7SueJF6Ln7VXksyCcTBNkqQlQi/5+quUMC2cYGL6oYMJu2LMRcx3B9wmZEMPdY2su/NJli3Ag9csdU9i4m6MtE95fGekDi//RVPN0Lsy7KO6sg== X-OriginatorOrg: bu.edu X-MS-Exchange-CrossTenant-Network-Message-Id: ddac3663-5b90-4287-65a9-08d8755dca92 X-MS-Exchange-CrossTenant-AuthSource: SN6PR03MB3871.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Oct 2020 01:08:16.6424 (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: L22tAV9wU3wfaxfihbj83hv+LY0+Emm8txp+7jykn4+FHFK/7+N/YvCLdt06MX/h X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN2PR03MB2333 Received-SPF: pass client-ip=40.107.220.130; envelope-from=alxndr@bu.edu; helo=NAM11-CO1-obe.outbound.protection.outlook.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/20 21:08:14 X-ACL-Warn: Detected OS = Windows NT kernel [generic] [fuzzy] X-Spam_score_int: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, HK_RANDOM_ENVFROM=0.001, HK_RANDOM_FROM=0.441, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no 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: Laurent Vivier , Thomas Huth , Alexander Bulekov , f4bug@amsat.org, darren.kenny@oracle.com, bsd@redhat.com, stefanha@redhat.com, pbonzini@redhat.com, dimastep@yandex-team.ru Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Reviewed-by: Darren Kenny Signed-off-by: Alexander Bulekov --- tests/qtest/fuzz/generic_fuzz.c | 93 +++++++++++++++++++++++++++++++-- 1 file changed, 90 insertions(+), 3 deletions(-) diff --git a/tests/qtest/fuzz/generic_fuzz.c b/tests/qtest/fuzz/generic_fuzz.c index b1254f4e63..356d171c65 100644 --- a/tests/qtest/fuzz/generic_fuzz.c +++ b/tests/qtest/fuzz/generic_fuzz.c @@ -804,6 +804,91 @@ static void generic_pre_fuzz(QTestState *s) counter_shm_init(); } +/* + * When libfuzzer gives us two inputs to combine, return a new input with the + * following structure: + * + * Input 1 (data1) + * SEPARATOR + * Clear out the DMA Patterns + * SEPARATOR + * Disable the pci_read/write instructions + * SEPARATOR + * Input 2 (data2) + * + * The idea is to collate the core behaviors of the two inputs. + * For example: + * Input 1: maps a device's BARs, sets up three DMA patterns, and triggers + * device functionality A + * Input 2: maps a device's BARs, sets up one DMA pattern, and triggers device + * functionality B + * + * This function attempts to produce an input that: + * Ouptut: maps a device's BARs, set up three DMA patterns, triggers + * functionality A device, replaces the DMA patterns with a single + * patten, and triggers device functionality B. + */ +static size_t generic_fuzz_crossover(const uint8_t *data1, size_t size1, const + uint8_t *data2, size_t size2, uint8_t *out, + size_t max_out_size, unsigned int seed) +{ + size_t copy_len = 0, size = 0; + + /* Check that we have enough space for data1 and at least part of data2 */ + if (max_out_size <= size1 + strlen(SEPARATOR) * 3 + 2) { + return 0; + } + + /* Copy_Len in the first input */ + copy_len = size1; + memcpy(out + size, data1, copy_len); + size += copy_len; + max_out_size -= copy_len; + + /* Append a separator */ + copy_len = strlen(SEPARATOR); + memcpy(out + size, SEPARATOR, copy_len); + size += copy_len; + max_out_size -= copy_len; + + /* Clear out the DMA Patterns */ + copy_len = 1; + if (copy_len) { + out[size] = OP_CLEAR_DMA_PATTERNS; + } + size += copy_len; + max_out_size -= copy_len; + + /* Append a separator */ + copy_len = strlen(SEPARATOR); + memcpy(out + size, SEPARATOR, copy_len); + size += copy_len; + max_out_size -= copy_len; + + /* Disable PCI ops. Assume data1 took care of setting up PCI */ + copy_len = 1; + if (copy_len) { + out[size] = OP_DISABLE_PCI; + } + size += copy_len; + max_out_size -= copy_len; + + /* Append a separator */ + copy_len = strlen(SEPARATOR); + memcpy(out + size, SEPARATOR, copy_len); + size += copy_len; + max_out_size -= copy_len; + + /* Copy_Len over the second input */ + copy_len = MIN(size2, max_out_size); + memcpy(out + size, data2, copy_len); + size += copy_len; + max_out_size -= copy_len; + + return size; +} + + static GString *generic_fuzz_cmdline(FuzzTarget *t) { GString *cmd_line = g_string_new(TARGET_NAME); @@ -821,9 +906,11 @@ static void register_generic_fuzz_targets(void) fuzz_add_target(&(FuzzTarget){ .name = "generic-fuzz", .description = "Fuzz based on any qemu command-line args. ", - .get_init_cmdline = general_fuzz_cmdline, - .pre_fuzz = general_pre_fuzz, - .fuzz = general_fuzz}); + .get_init_cmdline = generic_fuzz_cmdline, + .pre_fuzz = generic_pre_fuzz, + .fuzz = generic_fuzz, + .crossover = generic_fuzz_crossover + }); } fuzz_target_init(register_generic_fuzz_targets); From patchwork Wed Oct 21 01:07:46 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Bulekov X-Patchwork-Id: 302430 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.3 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, HK_RANDOM_FROM, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D5E6EC4363D for ; Wed, 21 Oct 2020 01:13:48 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id F279420797 for ; Wed, 21 Oct 2020 01:13:47 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=bushare.onmicrosoft.com header.i=@bushare.onmicrosoft.com header.b="i3OaJRYG" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org F279420797 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=bu.edu Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:51964 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kV2hG-0006D6-Vm for qemu-devel@archiver.kernel.org; Tue, 20 Oct 2020 21:13:47 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44458) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kV2cH-0001EQ-QT for qemu-devel@nongnu.org; Tue, 20 Oct 2020 21:08:37 -0400 Received: from mail-co1nam11on2130.outbound.protection.outlook.com ([40.107.220.130]:28640 helo=NAM11-CO1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kV2cF-0004s9-Vl for qemu-devel@nongnu.org; Tue, 20 Oct 2020 21:08:37 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=dqBnv7FCQHE339pD3btpr9BL7dCyxaM8IN0CKzKL+/TJFbe5qSsK04VLad1b4dsU7SIiivje+47KZAaVJ7wdZuMgbWS+dDkxIX9SaVQx2FRiuNNAIbi8FjaOKdD/PCj83dgX1CZ82BoaU1w78Yfv41M2WBLAYb6UYFFiCjfCvX08oMMnN09OXAlJy7vT8J3wBnlWasLesYqkE6Z+z+FkT0XXhsCoyf7B/r2TIGpVBbSxWiL3MFWEI5DdAuj8stSPOKLFEKQ5lycsqSIR8qV0/ajVsrovyB9lCjAm6LjV+W2bKcmG9EFKJ3tbGr9oMaOwbv4y3CPU5FMXl+WwyRaV8A== 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=+CZ8jI8JlveaKoFzMY2XehdwH81CyN3BV46AVRbR4hk=; b=LGMV0ruOKsOL/6yRtcUqVVZqHkHiErchCG/Iv340fCXisLzNWGKytkc0eyPr2fL2zo/7pTRyIWxs9H1zZKZu3l+AjbL4mjBleMWRwDEg4B8j9ICO2KmD4FYPcH25QvcUGcJl9gE1mXoVqsW3Noujhv5YK6PICKD1BcW3/j7422oLkBOrHAVm9w286CvfhH2Nh77en8/qkPDVRWvCqYHGDBWXqE3lNxaf4be3pIzqBi/QqjfcLCd2Uo/yMjqfnGaNyVc5tbUIKQplhJDacVx5VklbOGgpHUpnFuCN7c3Y4COAZC6HPf2heK1+rM/Y3qNwtS0pUmHsMrPg72TMA23HiA== 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=+CZ8jI8JlveaKoFzMY2XehdwH81CyN3BV46AVRbR4hk=; b=i3OaJRYGcnAFuKuxAUUGtVcCujd8Dkp4mrWUzxuX3l1B4h6visMKZbT2nW2WuHYdDDQ7OfWwW/worGnVuN8G8+prkf+5S+/jL8SNyOZ25Q85FTUOYCPVmKCghKcUyVm60CABBAxGb4HcqGkTHugGuJktMUBDCgoNtvLrmntHs6c= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none; nongnu.org; dmarc=none action=none header.from=bu.edu; Received: from SN6PR03MB3871.namprd03.prod.outlook.com (2603:10b6:805:6d::32) by SN2PR03MB2333.namprd03.prod.outlook.com (2603:10b6:804:c::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3477.22; Wed, 21 Oct 2020 01:08:18 +0000 Received: from SN6PR03MB3871.namprd03.prod.outlook.com ([fe80::d520:4c19:8ce6:7db2]) by SN6PR03MB3871.namprd03.prod.outlook.com ([fe80::d520:4c19:8ce6:7db2%2]) with mapi id 15.20.3477.028; Wed, 21 Oct 2020 01:08:18 +0000 From: Alexander Bulekov To: qemu-devel@nongnu.org Subject: [PATCH v5 10/16] scripts/oss-fuzz: Add script to reorder a general-fuzzer trace Date: Tue, 20 Oct 2020 21:07:46 -0400 Message-Id: <20201021010752.973230-11-alxndr@bu.edu> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201021010752.973230-1-alxndr@bu.edu> References: <20201021010752.973230-1-alxndr@bu.edu> X-Originating-IP: [72.93.72.163] X-ClientProxiedBy: BL1PR13CA0119.namprd13.prod.outlook.com (2603:10b6:208:2b9::34) To SN6PR03MB3871.namprd03.prod.outlook.com (2603:10b6:805:6d::32) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from stormtrooper.vrmnet (72.93.72.163) by BL1PR13CA0119.namprd13.prod.outlook.com (2603:10b6:208:2b9::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3499.8 via Frontend Transport; Wed, 21 Oct 2020 01:08:17 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 56570c0d-c0cc-407a-a33e-08d8755dcb85 X-MS-TrafficTypeDiagnostic: SN2PR03MB2333: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:9508; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: azzL3Q2hDy6eCA6P8lH2Mx10YB0+SuyNKRtMcIAIRCP0oPCcaArWaPc/vcApan4tfIyFA+Bt4dGJ/T8Trz41rHUjattCy7HgwUqX92frlH1cTCBUv7ctd6uXI/k8bceDherA8YTT7J+o7AJtfAaJUJlDK2UND2pAvTZj69lAzz+2tiTGrcmNzXfI/cub8GcIjUF6/tRrLALpqUycq48NCFxbOxTzpiXnnlKv5Q+WCPKNO+CgjfCWTsIu77tsJc1fyLdi1baeF5fk2fXoWhq5CgXR+vHAJBYnhlosK0OeGJv0Rs4lZWhu7boTb4AEoXtwQukN05oKiwyKfGaA0HYoRA== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:SN6PR03MB3871.namprd03.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(39860400002)(396003)(376002)(346002)(366004)(136003)(52116002)(2616005)(8676002)(6512007)(6916009)(6506007)(36756003)(786003)(316002)(956004)(83380400001)(478600001)(1076003)(4326008)(6486002)(75432002)(8936002)(54906003)(86362001)(5660300002)(26005)(16526019)(186003)(6666004)(66946007)(2906002)(66476007)(66556008); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: 6DJBZ/Kpk8z8wGgloEJwVXgepuiHb+D2+fzQPZkDnm9Bs6pZOW2UO8Q5rcxe7HXMlKfur/sVqCCAgyT8ftyFzP4f1++3rURqNIp/wk9otnDNd634q+IvxiFgYwlE2j23IPdGgCxZ8Akq28NYCQXBXm5ntSJSX9J0qw9jA58QDP0wcKURzlyfOftBGVu3vq1v+6lHSH5BOtHvwDb1wrp1D5y0YUGNIvmrGzqnEcqcim76oW2QPjhh8P6wwBExGwSdKUwSxAX5Cb06IfQzffdwzc7OYwdP8teiTRGlCEYzTA21VsZ0d5bt7eyEOhUoCYoTDW4xFHNMyI3EiE5cdmtPKCMcNYxHQQkwDSNptCPYEThRZbDA4b2HBKLrxWhPffLY9hVp4S9QEVNeTlzW37Vbbdqc35ac+AVX4VLIFcfLyW9E5DNJmER0ejh/UU4JDidieySfvK+X0cdki4ZirRh+g2AGP+67r4v2abhzq28WRuBY5DN7x+Aa8T7+GghF9TCz/mF3VKB3cFKSJ35UKI2lkla2jFuQ2/2Yw8fhn1SqfPROQjvgFj93KqFldZtwFdwVpNwkEqC4NQlH+BqT3o9Hdd61aionzvvFafkmG85FJtQ2HmKXkr/KL2RWiqfqV2EjOAt2KVsiUAk2joxEKDDHow== X-OriginatorOrg: bu.edu X-MS-Exchange-CrossTenant-Network-Message-Id: 56570c0d-c0cc-407a-a33e-08d8755dcb85 X-MS-Exchange-CrossTenant-AuthSource: SN6PR03MB3871.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Oct 2020 01:08:18.4343 (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: z13ocWOo5b3jIg5GiCC5NEJW372CQc9Iu6t6mIOadOtS1lBhP2bB6UZG0mG9sif8 X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN2PR03MB2333 Received-SPF: pass client-ip=40.107.220.130; envelope-from=alxndr@bu.edu; helo=NAM11-CO1-obe.outbound.protection.outlook.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/20 21:08:14 X-ACL-Warn: Detected OS = Windows NT kernel [generic] [fuzzy] X-Spam_score_int: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, HK_RANDOM_ENVFROM=0.001, HK_RANDOM_FROM=0.441, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no 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: Thomas Huth , Alexander Bulekov , f4bug@amsat.org, darren.kenny@oracle.com, bsd@redhat.com, stefanha@redhat.com, pbonzini@redhat.com, dimastep@yandex-team.ru Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" The general-fuzzer uses hooks to fulfill DMA requests just-in-time. This means that if we try to use QTEST_LOG=1 to build a reproducer, the DMA writes will be logged _after_ the in/out/read/write that triggered the DMA read. To work work around this, the general-fuzzer annotates these just-in time DMA fulfilments with a tag that we can use to discern them. This script simply iterates over a raw qtest trace (including log messages, errors, timestamps etc), filters it and re-orders it so that DMA fulfillments are placed directly _before_ the qtest command that will cause the DMA access. Signed-off-by: Alexander Bulekov Reviewed-by: Darren Kenny --- .../oss-fuzz/reorder_fuzzer_qtest_trace.py | 103 ++++++++++++++++++ 1 file changed, 103 insertions(+) create mode 100755 scripts/oss-fuzz/reorder_fuzzer_qtest_trace.py diff --git a/scripts/oss-fuzz/reorder_fuzzer_qtest_trace.py b/scripts/oss-fuzz/reorder_fuzzer_qtest_trace.py new file mode 100755 index 0000000000..47295c9e69 --- /dev/null +++ b/scripts/oss-fuzz/reorder_fuzzer_qtest_trace.py @@ -0,0 +1,103 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- + +""" +Use this to convert qtest log info from a generic fuzzer input into a qtest +trace that you can feed into a standard qemu-system process. Example usage: + +QEMU_FUZZ_ARGS="-machine q35,accel=qtest" QEMU_FUZZ_OBJECTS="*" \ + ./i386-softmmu/qemu-fuzz-i386 --fuzz-target=general-pci-fuzz +# .. Finds some crash +QTEST_LOG=1 FUZZ_SERIALIZE_QTEST=1 \ +QEMU_FUZZ_ARGS="-machine q35,accel=qtest" QEMU_FUZZ_OBJECTS="*" \ + ./i386-softmmu/qemu-fuzz-i386 --fuzz-target=general-pci-fuzz + /path/to/crash 2> qtest_log_output +scripts/oss-fuzz/reorder_fuzzer_qtest_trace.py qtest_log_output > qtest_trace +./i386-softmmu/qemu-fuzz-i386 -machine q35,accel=qtest \ + -qtest stdin < qtest_trace + +### Details ### + +Some fuzzer make use of hooks that allow us to populate some memory range, just +before a DMA read from that range. This means that the fuzzer can produce +activity that looks like: + [start] read from mmio addr + [end] read from mmio addr + [start] write to pio addr + [start] fill a DMA buffer just in time + [end] fill a DMA buffer just in time + [start] fill a DMA buffer just in time + [end] fill a DMA buffer just in time + [end] write to pio addr + [start] read from mmio addr + [end] read from mmio addr + +We annotate these "nested" DMA writes, so with QTEST_LOG=1 the QTest trace +might look something like: +[R +0.028431] readw 0x10000 +[R +0.028434] outl 0xc000 0xbeef # Triggers a DMA read from 0xbeef and 0xbf00 +[DMA][R +0.034639] write 0xbeef 0x2 0xAAAA +[DMA][R +0.034639] write 0xbf00 0x2 0xBBBB +[R +0.028431] readw 0xfc000 + +This script would reorder the above trace so it becomes: +readw 0x10000 +write 0xbeef 0x2 0xAAAA +write 0xbf00 0x2 0xBBBB +outl 0xc000 0xbeef +readw 0xfc000 + +I.e. by the time, 0xc000 tries to read from DMA, those DMA buffers have already +been set up, removing the need for the DMA hooks. We can simply provide this +reordered trace via -qtest stdio to reproduce the input + +Note: this won't work for traces where the device tries to read from the same +DMA region twice in between MMIO/PIO commands. E.g: + [R +0.028434] outl 0xc000 0xbeef + [DMA][R +0.034639] write 0xbeef 0x2 0xAAAA + [DMA][R +0.034639] write 0xbeef 0x2 0xBBBB + +The fuzzer will annotate suspected double-fetches with [DOUBLE-FETCH]. This +script looks for these tags and warns the users that the resulting trace might +not reproduce the bug. +""" + +import sys + +__author__ = "Alexander Bulekov " +__copyright__ = "Copyright (C) 2020, Red Hat, Inc." +__license__ = "GPL version 2 or (at your option) any later version" + +__maintainer__ = "Alexander Bulekov" +__email__ = "alxndr@bu.edu" + + +def usage(): + sys.exit("Usage: {} /path/to/qtest_log_output".format((sys.argv[0]))) + + +def main(filename): + with open(filename, "r") as f: + trace = f.readlines() + + # Leave only lines that look like logged qtest commands + trace[:] = [x.strip() for x in trace if "[R +" in x + or "[S +" in x and "CLOSED" not in x] + + for i in range(len(trace)): + if i+1 < len(trace): + if "[DMA]" in trace[i+1]: + if "[DOUBLE-FETCH]" in trace[i+1]: + sys.stderr.write("Warning: Likely double fetch on line" + "{}.\n There will likely be problems " + "reproducing behavior with the " + "resulting qtest trace\n\n".format(i+1)) + trace[i], trace[i+1] = trace[i+1], trace[i] + for line in trace: + print(line.split("]")[-1].strip()) + + +if __name__ == '__main__': + if len(sys.argv) == 1: + usage() + main(sys.argv[1]) From patchwork Wed Oct 21 01:07:47 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Bulekov X-Patchwork-Id: 302427 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.3 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, HK_RANDOM_FROM, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 96568C4363D for ; Wed, 21 Oct 2020 01:21:52 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id C14A122253 for ; Wed, 21 Oct 2020 01:21:51 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=bushare.onmicrosoft.com header.i=@bushare.onmicrosoft.com header.b="xpd48baG" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C14A122253 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=bu.edu Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:37272 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kV2p4-0003ec-NO for qemu-devel@archiver.kernel.org; Tue, 20 Oct 2020 21:21:50 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44470) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kV2cK-0001Jn-1i for qemu-devel@nongnu.org; Tue, 20 Oct 2020 21:08:40 -0400 Received: from mail-co1nam11on2130.outbound.protection.outlook.com ([40.107.220.130]:28640 helo=NAM11-CO1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kV2cI-0004s9-5A for qemu-devel@nongnu.org; Tue, 20 Oct 2020 21:08:39 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=dWuYGCY7ZTx09R98cgPfGEi4H8R2ICp48lgMc1p16S1XHqDi0r3Yxz/yY+6Y6IE1Cx2iybKMCmIh7Vf/P7StmBuu/7W+ly0kcGPr0ej21VIkrEVYXyWqYZqTywDwjfGKtcUGvWuyrLoNuFi8oXgeHWVbKJrswhVOyy8u+igDYLl210a8/mO1DktITcsl28U1uR4/OxeITNJ2QigugeZwMqBB3jg9TDWUAm2rxKfV7olX86McwT/JQM4f32nr2ZLVtUC36Srrbj59igQjQGH7CaEpU4HgxTNYUZl/Majl4BylnUnzJuf6fTKJiBpC4Hx90c/87PQT1ymIi0iRuw2J0w== 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=hEFUshzLvCD3WoaBe1HXg+kvAmJfN0iQC9/oKOMPCBY=; b=Lil/NSNmxE97g5YLVRBRnxMli0WMyrT0rmEmQJoTlgSxPQK6Ts+3XQVjv7yQmUM82oDZAHOwvPasYXL7wWYzxTOSUe8lvhMLcpiP6MEt5US1caNUGegE4nAtFRFBwSySwV2Q7gjWehntaaJVaVPG8bjpFRAV0ONQIsMJ+0xF0G4RdGk6u3lOQv7AeQsNQuMT3jlaLQLl68o/dZ9GS4czh1ZD1jECylKpeYDAd+Jb2eyAmmZUfgVe0//sCVckSWjxqrndRyL8Jc8oS+9vJFXYEWp+rQgxN4biqz3cnzPA5SJSBmcc0YK+dtwNXqGUv8CO6rc1MQo42Aw/D83CizPm7Q== 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=hEFUshzLvCD3WoaBe1HXg+kvAmJfN0iQC9/oKOMPCBY=; b=xpd48baGUBvtyBmRDIOs6TsdEztyNFBdZzXjs3RSaWPCGA0UQU7gRRQiyyc+pYDIYlQmgE1MQYzhW72Y33HAmomPLWG5GOVw6olJdcMahI5gwnXfIO5YbjodnptHKSzawzMRaWlJxi1uVD3DsmFKvL+95DKi1ChqjR1hnLEDILQ= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none; nongnu.org; dmarc=none action=none header.from=bu.edu; Received: from SN6PR03MB3871.namprd03.prod.outlook.com (2603:10b6:805:6d::32) by SN2PR03MB2333.namprd03.prod.outlook.com (2603:10b6:804:c::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3477.22; Wed, 21 Oct 2020 01:08:20 +0000 Received: from SN6PR03MB3871.namprd03.prod.outlook.com ([fe80::d520:4c19:8ce6:7db2]) by SN6PR03MB3871.namprd03.prod.outlook.com ([fe80::d520:4c19:8ce6:7db2%2]) with mapi id 15.20.3477.028; Wed, 21 Oct 2020 01:08:20 +0000 From: Alexander Bulekov To: qemu-devel@nongnu.org Subject: [PATCH v5 11/16] scripts/oss-fuzz: Add crash trace minimization script Date: Tue, 20 Oct 2020 21:07:47 -0400 Message-Id: <20201021010752.973230-12-alxndr@bu.edu> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201021010752.973230-1-alxndr@bu.edu> References: <20201021010752.973230-1-alxndr@bu.edu> X-Originating-IP: [72.93.72.163] X-ClientProxiedBy: BL1PR13CA0119.namprd13.prod.outlook.com (2603:10b6:208:2b9::34) To SN6PR03MB3871.namprd03.prod.outlook.com (2603:10b6:805:6d::32) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from stormtrooper.vrmnet (72.93.72.163) by BL1PR13CA0119.namprd13.prod.outlook.com (2603:10b6:208:2b9::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3499.8 via Frontend Transport; Wed, 21 Oct 2020 01:08:19 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 3274f936-93f2-42e0-b5a3-08d8755dccf4 X-MS-TrafficTypeDiagnostic: SN2PR03MB2333: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:1923; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ltX7EEx3bBjctky2JL0TeQd9VJBqtbqDXeagBkDAQP7NkJWfXNP5eeXmXQA0yWA942PlVkQrQxxwvx2j270japRbHOjpULOayabOED+n84N85rvY8DiGc6YbkoUZ6igSvXqUCrGMLHqjifPM/Rglf6qr7StKdl7NqlpHVQJ9Osag6XLIopT+WNDXq62ub/mVgFCLe/xk5JV0gM9ZIkG0mLQBpMpndHyU6Np7mlT0mtPWjLiMtkm56fBoGRieDLSjNd5FQ1QlxoX9ZSonmFxGpDKVtl8d710HWUSrKRfI2V+vgzpwV2YIWioZzMH6mLEge0XhbsCYAZLuZB/o2eeAtw== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:SN6PR03MB3871.namprd03.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(39860400002)(396003)(376002)(346002)(366004)(136003)(52116002)(2616005)(8676002)(6512007)(6916009)(6506007)(36756003)(786003)(316002)(956004)(83380400001)(478600001)(1076003)(4326008)(6486002)(75432002)(8936002)(54906003)(86362001)(5660300002)(26005)(16526019)(186003)(6666004)(66946007)(2906002)(66476007)(66556008); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: t4rPtQO0umox/sAO8WzFYqFMNlrFdPZAv+pw6Gzq0OuosmaThkaWE3Jh5Nu8CrqnvTaZ213qyzokwoBTTMlWStmmoazilpZ9Jf0R9jt0FsbX2qsYqcxkN6Alud/cEzcT2xjdu5WWbEDLB/Zjt5CGN0Kn5o76/Ju43DTAN2X76C1uc4TnYzYCezholprWqjqHrjKUD63oI3P5u1LvVz6OAvjCTTmySYfO6KtICHxSz0YIhkziCzkhkIGu0LqfCln79SNwtNksFGnOfpxAjp5Fk7/gzAxUSNYdp4UvYMH6ZAJ1ocxrqPAkmLZTSS+Y4s5NBxw362c/jITTBGKP5Y9bjrU7QE4Ox8JhlQv9G33anR8y++yWLJbjLitmjM0y0aXe50a61GgqdhhsPgsAXIHPMvdAQaS8KZw29LYCsAmJbnQZGakZJziitcJdAhRKPKR0RlPn98CDnLp6JA5O4cSlrrBCCckuimMr5c9YTF42ToUe/uuWjHze59uZ9OQfPHIqSmF/2WSP4EXgfedHzaEFH1Pmv84UeGxlxUeVWpRlI5rb/wffKJMtsuesbWaq9JHhWNNyqCZkNNNgF5Luy8Z9Z18R5UV6LCFUtlnfFlSBHyiuQB/8c/4m6FgzJ3gc7rBlX5mxrcUXKZyIjfIvbwNJ2Q== X-OriginatorOrg: bu.edu X-MS-Exchange-CrossTenant-Network-Message-Id: 3274f936-93f2-42e0-b5a3-08d8755dccf4 X-MS-Exchange-CrossTenant-AuthSource: SN6PR03MB3871.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Oct 2020 01:08:20.5761 (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: JF54VCzAgWM+edGb9KgfmvibwXwMBcp6dKryM63Ihi702HVa5YARv5eAg3tyXviy X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN2PR03MB2333 Received-SPF: pass client-ip=40.107.220.130; envelope-from=alxndr@bu.edu; helo=NAM11-CO1-obe.outbound.protection.outlook.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/20 21:08:14 X-ACL-Warn: Detected OS = Windows NT kernel [generic] [fuzzy] X-Spam_score_int: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, HK_RANDOM_ENVFROM=0.001, HK_RANDOM_FROM=0.441, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no 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: Thomas Huth , Alexander Bulekov , f4bug@amsat.org, darren.kenny@oracle.com, bsd@redhat.com, stefanha@redhat.com, pbonzini@redhat.com, dimastep@yandex-team.ru Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Once we find a crash, we can convert it into a QTest trace. Usually this trace will contain many operations that are unneeded to reproduce the crash. This script tries to minimize the crashing trace, by removing operations and trimming QTest bufwrite(write addr len data...) commands. Signed-off-by: Alexander Bulekov Reviewed-by: Darren Kenny --- scripts/oss-fuzz/minimize_qtest_trace.py | 157 +++++++++++++++++++++++ 1 file changed, 157 insertions(+) create mode 100755 scripts/oss-fuzz/minimize_qtest_trace.py diff --git a/scripts/oss-fuzz/minimize_qtest_trace.py b/scripts/oss-fuzz/minimize_qtest_trace.py new file mode 100755 index 0000000000..5e405a0d5f --- /dev/null +++ b/scripts/oss-fuzz/minimize_qtest_trace.py @@ -0,0 +1,157 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- + +""" +This takes a crashing qtest trace and tries to remove superflous operations +""" + +import sys +import os +import subprocess +import time +import struct + +QEMU_ARGS = None +QEMU_PATH = None +TIMEOUT = 5 +CRASH_TOKEN = None + +write_suffix_lookup = {"b": (1, "B"), + "w": (2, "H"), + "l": (4, "L"), + "q": (8, "Q")} + +def usage(): + sys.exit("""\ +Usage: QEMU_PATH="/path/to/qemu" QEMU_ARGS="args" {} input_trace output_trace +By default, will try to use the second-to-last line in the output to identify +whether the crash occred. Optionally, manually set a string that idenitifes the +crash by setting CRASH_TOKEN= +""".format((sys.argv[0]))) + +def check_if_trace_crashes(trace, path): + global CRASH_TOKEN + with open(path, "w") as tracefile: + tracefile.write("".join(trace)) + + rc = subprocess.Popen("timeout -s 9 {timeout}s {qemu_path} {qemu_args} 2>&1\ + < {trace_path}".format(timeout=TIMEOUT, + qemu_path=QEMU_PATH, + qemu_args=QEMU_ARGS, + trace_path=path), + shell=True, + stdin=subprocess.PIPE, + stdout=subprocess.PIPE) + stdo = rc.communicate()[0] + output = stdo.decode('unicode_escape') + if rc.returncode == 137: # Timed Out + return False + if len(output.splitlines()) < 2: + return False + + if CRASH_TOKEN is None: + CRASH_TOKEN = output.splitlines()[-2] + + return CRASH_TOKEN in output + + +def minimize_trace(inpath, outpath): + global TIMEOUT + with open(inpath) as f: + trace = f.readlines() + start = time.time() + if not check_if_trace_crashes(trace, outpath): + sys.exit("The input qtest trace didn't cause a crash...") + end = time.time() + print("Crashed in {} seconds".format(end-start)) + TIMEOUT = (end-start)*5 + print("Setting the timeout for {} seconds".format(TIMEOUT)) + print("Identifying Crashes by this string: {}".format(CRASH_TOKEN)) + + i = 0 + newtrace = trace[:] + # For each line + while i < len(newtrace): + # 1.) Try to remove it completely and reproduce the crash. If it works, + # we're done. + prior = newtrace[i] + print("Trying to remove {}".format(newtrace[i])) + # Try to remove the line completely + newtrace[i] = "" + if check_if_trace_crashes(newtrace, outpath): + i += 1 + continue + newtrace[i] = prior + + # 2.) Try to replace write{bwlq} commands with a write addr, len + # command. Since this can require swapping endianness, try both LE and + # BE options. We do this, so we can "trim" the writes in (3) + if (newtrace[i].startswith("write") and not + newtrace[i].startswith("write ")): + suffix = newtrace[i].split()[0][-1] + assert(suffix in write_suffix_lookup) + addr = int(newtrace[i].split()[1], 16) + value = int(newtrace[i].split()[2], 16) + for endianness in ['<', '>']: + data = struct.pack("{end}{size}".format(end=endianness, + size=write_suffix_lookup[suffix][1]), + value) + newtrace[i] = "write {addr} {size} 0x{data}\n".format( + addr=hex(addr), + size=hex(write_suffix_lookup[suffix][0]), + data=data.hex()) + if(check_if_trace_crashes(newtrace, outpath)): + break + else: + newtrace[i] = prior + + # 3.) If it is a qtest write command: write addr len data, try to split + # it into two separate write commands. If splitting the write down the + # middle does not work, try to move the pivot "left" and retry, until + # there is no space left. The idea is to prune unneccessary bytes from + # long writes, while accommodating arbitrary MemoryRegion access sizes + # and alignments. + if newtrace[i].startswith("write "): + addr = int(newtrace[i].split()[1], 16) + length = int(newtrace[i].split()[2], 16) + data = newtrace[i].split()[3][2:] + if length > 1: + leftlength = int(length/2) + rightlength = length - leftlength + newtrace.insert(i+1, "") + while leftlength > 0: + newtrace[i] = "write {addr} {size} 0x{data}\n".format( + addr=hex(addr), + size=hex(leftlength), + data=data[:leftlength*2]) + newtrace[i+1] = "write {addr} {size} 0x{data}\n".format( + addr=hex(addr+leftlength), + size=hex(rightlength), + data=data[leftlength*2:]) + if check_if_trace_crashes(newtrace, outpath): + break + else: + leftlength -= 1 + rightlength += 1 + if check_if_trace_crashes(newtrace, outpath): + i -= 1 + else: + newtrace[i] = prior + del newtrace[i+1] + i += 1 + check_if_trace_crashes(newtrace, outpath) + + +if __name__ == '__main__': + if len(sys.argv) < 3: + usage() + + QEMU_PATH = os.getenv("QEMU_PATH") + QEMU_ARGS = os.getenv("QEMU_ARGS") + if QEMU_PATH is None or QEMU_ARGS is None: + usage() + # if "accel" not in QEMU_ARGS: + # QEMU_ARGS += " -accel qtest" + CRASH_TOKEN = os.getenv("CRASH_TOKEN") + QEMU_ARGS += " -qtest stdio -monitor none -serial none " + minimize_trace(sys.argv[1], sys.argv[2]) From patchwork Wed Oct 21 01:07:48 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Bulekov X-Patchwork-Id: 270821 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.3 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, HK_RANDOM_FROM, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 34E8EC4363D for ; Wed, 21 Oct 2020 01:21:43 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 73AEB22253 for ; Wed, 21 Oct 2020 01:21:42 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=bushare.onmicrosoft.com header.i=@bushare.onmicrosoft.com header.b="qiaKGZpM" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 73AEB22253 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=bu.edu Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:36992 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kV2ov-0003W8-CO for qemu-devel@archiver.kernel.org; Tue, 20 Oct 2020 21:21:41 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44484) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kV2cM-0001Oy-5R for qemu-devel@nongnu.org; Tue, 20 Oct 2020 21:08:42 -0400 Received: from mail-co1nam11on2130.outbound.protection.outlook.com ([40.107.220.130]:28640 helo=NAM11-CO1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kV2cK-0004s9-CI for qemu-devel@nongnu.org; Tue, 20 Oct 2020 21:08:41 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=dj4g7y9vkr3x2D3+VfPbyfbrkHyzwQIgk5LMzj8ct6sOw2nkO9b1dVIej3VewNgGCCS7GRjlnJAXtc3N5ivjri7Cz7UTc2N5LwtP4s29Q+npC1BXtOjPRZDdYzPcOah/sWRl67dX7YyODdvtyPyql8M/Bo5afcok5l8awkSTZ01P/73WGd53QuwcRIuQS2r2L0EKXSVllMizlwX/PV+qTOUwj6JGw2ieMhTeqZ9toMhJWMzasYcn0HZASCZkh7GmUvM7aNEua5ZtXpKOuPTnHzZG3hhJsXTfZGfXHlZ5zoecsYgUXLHcl9iEok/6SrLRzL5UFCsgsqt+bx42/GsG2g== 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=ZkPtyz+s8b1KH6hKK/ioFOQE62kpgItYmb7x6kdTH/8=; b=Ykh78gKom7bQiYg8Pz74Hq518iSZPz5pgZ6McJWeaKaEBfdE8iqDQojfyXWqOjSSeuwRMpDK1kwReUKhS25s6EBzz521fkOmFgpEXQ6mHsMDKv0+PfHOtsPSRxOVQMdFpZTcxbxPTwW6+8E277JajpAbf7U7Vkab9b32/r7oW0Yxh5+REUy3756k7QrdrSQF+Ji6gCCk+V0Ap4mHlhDwwIrH4J7xqx1nNoGH6f1J2rRbJbdFTgoNvTCvUsuiViorYS/0OcPIyDXjQqE4qOtn/ZCHMA/FaYwZNd+STrpEef9LOZ4vKJKS7eGzSznn/7hphE+l0BepdMY+5RyERY7Gcw== 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=ZkPtyz+s8b1KH6hKK/ioFOQE62kpgItYmb7x6kdTH/8=; b=qiaKGZpM8rZGHO65cimlyJAsJgcCRmHPbRyXxEKf/q2rh/pHpMwctq+NJdBIQVWuiJ5+BKwI15fTEXMBa3d4PvjWTwKRsaaKA9NHjUA8XgEm+kKeYkdT6/HnW1PTxVLFHlbmAGOHG89atUpjcZ77AfUy6N36hub3kG2YFNNXEBs= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none; nongnu.org; dmarc=none action=none header.from=bu.edu; Received: from SN6PR03MB3871.namprd03.prod.outlook.com (2603:10b6:805:6d::32) by SN2PR03MB2333.namprd03.prod.outlook.com (2603:10b6:804:c::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3477.22; Wed, 21 Oct 2020 01:08:22 +0000 Received: from SN6PR03MB3871.namprd03.prod.outlook.com ([fe80::d520:4c19:8ce6:7db2]) by SN6PR03MB3871.namprd03.prod.outlook.com ([fe80::d520:4c19:8ce6:7db2%2]) with mapi id 15.20.3477.028; Wed, 21 Oct 2020 01:08:22 +0000 From: Alexander Bulekov To: qemu-devel@nongnu.org Subject: [PATCH v5 12/16] fuzz: Add instructions for using general-fuzz Date: Tue, 20 Oct 2020 21:07:48 -0400 Message-Id: <20201021010752.973230-13-alxndr@bu.edu> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201021010752.973230-1-alxndr@bu.edu> References: <20201021010752.973230-1-alxndr@bu.edu> X-Originating-IP: [72.93.72.163] X-ClientProxiedBy: BL1PR13CA0119.namprd13.prod.outlook.com (2603:10b6:208:2b9::34) To SN6PR03MB3871.namprd03.prod.outlook.com (2603:10b6:805:6d::32) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from stormtrooper.vrmnet (72.93.72.163) by BL1PR13CA0119.namprd13.prod.outlook.com (2603:10b6:208:2b9::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3499.8 via Frontend Transport; Wed, 21 Oct 2020 01:08:21 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: afcda1f7-3c63-4eff-b6d3-08d8755dcda2 X-MS-TrafficTypeDiagnostic: SN2PR03MB2333: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:9508; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: gozRIvRj7eMjv0qFtK/wotV+0ihQGiMjmpILyq71uFVg/Tw+UaNTrJr/h080aR0A8qV/uYODsJ9X1qnHSx5fyocjqYqcODcrC09R6uGr81JFW8/DaFRuhIr1jItDqJ+ARAdyZmdDCMEikE4SHSO6MNlBi9ErU3kBSEpPK6QtYE5xCOSsd5Q9wWKX5Sk1fXOsXNHzBodgGd3MA0+uZ9Y/fZgQS+E/m67dMy+pw7GGedPMWN7O5/IOmh2fwy4cX/aWQ7F10z69UEJ+slDD9REkuIndYnWkk7k+xSBC9/apstJiYRD6kquz3VnmhaBQqr4GEkCzX6MM7ehnvQ6t3KHZKA== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:SN6PR03MB3871.namprd03.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(39860400002)(396003)(376002)(346002)(366004)(136003)(52116002)(2616005)(8676002)(6512007)(6916009)(6506007)(36756003)(786003)(316002)(956004)(83380400001)(478600001)(1076003)(4326008)(6486002)(75432002)(8936002)(54906003)(86362001)(5660300002)(26005)(16526019)(186003)(6666004)(66946007)(2906002)(66476007)(66556008); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: JjsSoSkKm60p5OlpwiOxbyIgNUpOsMiPyYeVJfJXucVdT4CLyQ7dANFSBBlYJi/cuDbRC+lZMkPTZmYCgjW8sLqIguZYhWq1Xzt8K8BuObdroQ/pV9xiBXB9uWPnZy+5Cy1YwbDJamaL4SeSWvQGbTF32x6UiaY4onTF1OMBB0NL+IxfaHjadiMYTHAOdSiEi3CxZ1nfU1ckhCLsw1WB6UIRJHPVh9osYzfu2xyF0hfkLiiN8a9GzbxrMsDDThMyQErARipjlRiKv+j2aS/8YWPmYKw5QOCXHElI9iBePDk10dsmBy/5GTcZQoh1HIV0++IO5UdbOIq/gy5HlttMQdKMYI2N9UHllqWr00EtpYempnl2zpkS/00oY/31kZ1APGY7uqAPrkHa4clsF8kGb/TdIAeKhVho8HNmd4nGL3A3wEITMxfuGiE6X+HKz1+0O0mfVEMhcoM/8rY9sNP5ltacOyw/oprakFz6V3a7RAcmtBf2IaU2ep9Kiy6MrD9CWz/KVYSUoPncAGnFWegv3mrBX3g21OGHktPVLoMazoLxl7lLgvze//CDDQZ1ZeV5kNWk1LGOJLCFGQhRTHxsaTvEMRlUVKk3YJ33S+EumO5lu1woatNjk1jHpz5jNIWiPwAwG9FqdWcVDRggrmT/4g== X-OriginatorOrg: bu.edu X-MS-Exchange-CrossTenant-Network-Message-Id: afcda1f7-3c63-4eff-b6d3-08d8755dcda2 X-MS-Exchange-CrossTenant-AuthSource: SN6PR03MB3871.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Oct 2020 01:08:22.3451 (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: E1JAWDBAjwobQbq3nCVT1vrS4Hyf41KOG8pqNANQh/Pu8SeMo5YycAZOCD0H0vsJ X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN2PR03MB2333 Received-SPF: pass client-ip=40.107.220.130; envelope-from=alxndr@bu.edu; helo=NAM11-CO1-obe.outbound.protection.outlook.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/20 21:08:14 X-ACL-Warn: Detected OS = Windows NT kernel [generic] [fuzzy] X-Spam_score_int: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, HK_RANDOM_ENVFROM=0.001, HK_RANDOM_FROM=0.441, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no 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: Thomas Huth , Alexander Bulekov , f4bug@amsat.org, darren.kenny@oracle.com, bsd@redhat.com, stefanha@redhat.com, pbonzini@redhat.com, dimastep@yandex-team.ru Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Reviewed-by: Darren Kenny Signed-off-by: Alexander Bulekov --- docs/devel/fuzzing.txt | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/docs/devel/fuzzing.txt b/docs/devel/fuzzing.txt index 96d71c94d7..c40278fe0a 100644 --- a/docs/devel/fuzzing.txt +++ b/docs/devel/fuzzing.txt @@ -125,6 +125,45 @@ provided by libfuzzer. Libfuzzer passes a byte array and length. Commonly the fuzzer loops over the byte-array interpreting it as a list of qtest commands, addresses, or values. +== The General Fuzzer == +Writing a fuzz target can be a lot of effort (especially if a device driver has +not be built-out within libqos). Many devices can be fuzzed to some degree, +without any device-specific code, using the general-fuzz target. + +The general-fuzz target is capable of fuzzing devices over their PIO, MMIO, +and DMA input-spaces. To apply the general-fuzz to a device, we need to define +two env-variables, at minimum: + +QEMU_FUZZ_ARGS= 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="-M pc -nodefaults -netdev user,id=user0 \ + -device virtio-net,netdev=user0" + +QEMU_FUZZ_OBJECTS= 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= + * '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 useful +for identifying the MemoryRegion and Object names used for matching. + +As a general rule-of-thumb, the more MemoryRegions/Devices we match, the greater +the input-space, and the smaller the probability of finding crashing inputs 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=general-fuzz -runs=0 + +The output should contain a complete list of matched MemoryRegions. + = Implementation Details = == The Fuzzer's Lifecycle == From patchwork Wed Oct 21 01:07:49 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Bulekov X-Patchwork-Id: 302428 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.3 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, HK_RANDOM_FROM, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 49867C4363D for ; Wed, 21 Oct 2020 01:19:27 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 99E7F22253 for ; Wed, 21 Oct 2020 01:19:26 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=bushare.onmicrosoft.com header.i=@bushare.onmicrosoft.com header.b="OhDWJN39" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 99E7F22253 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=bu.edu Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:33258 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kV2mj-0001t9-Il for qemu-devel@archiver.kernel.org; Tue, 20 Oct 2020 21:19:25 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44508) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kV2cY-0001nM-2s for qemu-devel@nongnu.org; Tue, 20 Oct 2020 21:08:55 -0400 Received: from mail-co1nam11on2130.outbound.protection.outlook.com ([40.107.220.130]:28640 helo=NAM11-CO1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kV2cW-0004s9-KA for qemu-devel@nongnu.org; Tue, 20 Oct 2020 21:08:53 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jkZbakZUJfv9wL0lJ0d0YfOUFBobLNtCAoL551wT2JxpSLL7RtE4yDq50PH7R+a1ovCMb3+KZgYYxVEYpfW6c5ewTWM9VYTSYODkOvL24Ssxiz1SsSx4vsHBALPYz5rStPoCMpm/dSUq0BBQZ85UnCaTxT1Nbl59Qe2DAUcnlurw5onFMFS68ZgLT2HPY54U3pSsm//+ztDlUT5zHkpMtYZHklT7avTH/+35z4+n5KLVktfdpBxHwZFIXbnmfwpdLmQ56hdLo8mnHUTFKwSRdMplAhnVEFpwBBqgXlTQEGSvloAHQ8eKbopVOP/PJMyjkRdnXrunXji/BIK5hXjrqw== 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=Ofhel/Y+zk6nPpUJhwyqcyc0WQlzkNTfewTkfViO8DY=; b=IPvgxOcIviYiYjIWAaao8wfrVp3fzZRe+Mglx6oUdjl2urD3755L8GsFWG6eKjNj7gbmBQ14XW13FVt/J4fc3GpF2Z8ckNc1ncWPeWjUk2eyb0aCsnJDcksQhxQ/hA8/j3mRlmGeCj5gANwtLgxBeD5CBnjvqtJ3xkXIJNTRXChhjbqwH6hrKSlt4g8XKhGjEPu3rDvy+dXujjzlaFXkUvJKbm3MRe4+NSql7SVo6H1dbjfS+i4Ex/jXNnZFdtm8ZLhFQSjYTBbGDLlGAsPYPKi+Ix4/VVB1ts8eBK495dTsD5IixwEfp8X1/69dcBc/w2BmQp4YkpaSteRqvLd7pg== 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=Ofhel/Y+zk6nPpUJhwyqcyc0WQlzkNTfewTkfViO8DY=; b=OhDWJN394ayD7fFKOPOz9PrLg+1vk74kAFjvxSiwBTYRuTb/ELi03VIlPSdlZu6TsKe1ofcXuI693lKlEUICSG4Q2nE//KW+mjOFIIepqVQvrQLOIQPfTxEA6TZVs9WVsgh71BCjYyLYF4naa2nCQfc9cD5RdZsvAhQR2u04cMY= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none; nongnu.org; dmarc=none action=none header.from=bu.edu; Received: from SN6PR03MB3871.namprd03.prod.outlook.com (2603:10b6:805:6d::32) by SN2PR03MB2333.namprd03.prod.outlook.com (2603:10b6:804:c::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3477.22; Wed, 21 Oct 2020 01:08:24 +0000 Received: from SN6PR03MB3871.namprd03.prod.outlook.com ([fe80::d520:4c19:8ce6:7db2]) by SN6PR03MB3871.namprd03.prod.outlook.com ([fe80::d520:4c19:8ce6:7db2%2]) with mapi id 15.20.3477.028; Wed, 21 Oct 2020 01:08:24 +0000 From: Alexander Bulekov To: qemu-devel@nongnu.org Subject: [PATCH v5 13/16] fuzz: add an "opaque" to the FuzzTarget struct Date: Tue, 20 Oct 2020 21:07:49 -0400 Message-Id: <20201021010752.973230-14-alxndr@bu.edu> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201021010752.973230-1-alxndr@bu.edu> References: <20201021010752.973230-1-alxndr@bu.edu> X-Originating-IP: [72.93.72.163] X-ClientProxiedBy: BL1PR13CA0119.namprd13.prod.outlook.com (2603:10b6:208:2b9::34) To SN6PR03MB3871.namprd03.prod.outlook.com (2603:10b6:805:6d::32) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from stormtrooper.vrmnet (72.93.72.163) by BL1PR13CA0119.namprd13.prod.outlook.com (2603:10b6:208:2b9::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3499.8 via Frontend Transport; Wed, 21 Oct 2020 01:08:23 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: a53ba55e-8e96-455d-4169-08d8755dcee5 X-MS-TrafficTypeDiagnostic: SN2PR03MB2333: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:5797; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 8/SJNNb5+H+ogSp7nCI314+BzyJ3BvghWWrYLfU4A+nVA2jOJLMXSYIWpSSaqe7la73GgQs6c7BmGOeqX6H+HCoVjPUCMXdgi2ScgPVR0uM59i0LpYICEEc8lSgvvlD7F5z4oPpQqFLII/rghaBElVM9S9tAVI+UXXq1jhBkFSIpgVu/GdeKu8yP100KG+LEhdkTPH9fBbKxhuXasWlS78aVvkub4oG8wD3dJWDp07FHeddNR8tQNuDYoIZCqznq3f7Ant4s54jycEBl7bZBLZAJDIZxWsL24PqMABqFqGbAjjD8jlEjWrZCXIcX7EDoP5H34qMFm0M4miMiUwJodw== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:SN6PR03MB3871.namprd03.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(39860400002)(396003)(376002)(346002)(366004)(136003)(52116002)(2616005)(8676002)(6512007)(6916009)(6506007)(36756003)(786003)(316002)(956004)(478600001)(1076003)(4326008)(6486002)(75432002)(4744005)(8936002)(54906003)(86362001)(5660300002)(26005)(16526019)(186003)(6666004)(66946007)(2906002)(66476007)(66556008); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: bFFyIRFZNicodLeGjwX+gOzF3Ua00i0MybxqlcnqeMEEtrZgMwFRfWAL1m/YOEbXASbmLNgW/PTAtVber6Z51kMu2Faa61BdavZalXt1Tbvnk7zdJrKcY4jCtJPnhXBAqLOTZSL49NRE8xu6quUJbQrOP2dPp7+HrF07GLoo392+ilGkHt0Gsgp/WxS1LdWrNFIzHgYAbvYPvvx7kMYXTOidn8poKLmsz80gf2Q6kgbEGp/X6TkNYTX1M1JXqI4CMEJQIfVet3JOV4BIrdddo2t+hBVNhLMMeCkC1rknIq8J5BknwVmyj0DRfABhy4hTt54iwXfElGQVWzKdFRgVilqpYwJBrU8/I1QXD4IZJfAj3bXQ1sNWwRgDzM2lBNo83A3NB71FWc8xiYfpKNJJWbsFoS3zZkyP5o04gNvngWYRLTi91ihzPe5OWLmi8TjnKuDIrVbcj24PPAg+4Fgh/vQx6m0s0ayLQn3g9mERs24GRDUfGDLCF7+rOdnAIk9qZ4XiSFPnc3zkl+Z4fKyKq3vtfVhZfW/Q6gbG/0uMjDywreUifTzbSmElV6ecZ5l+YW0teZBQ1xdjxTSIXIufa5uacpM/eaZ+WpYBM4SDDh+V32p0B9ffjgBUMNamT7iLcE/gKxH3vthxAizCh5FoBA== X-OriginatorOrg: bu.edu X-MS-Exchange-CrossTenant-Network-Message-Id: a53ba55e-8e96-455d-4169-08d8755dcee5 X-MS-Exchange-CrossTenant-AuthSource: SN6PR03MB3871.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Oct 2020 01:08:23.9472 (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: XIfMyBRAJGSfTYJZTQDatxILhZJ05I55H2gb1QPSGoShVnW8VBq1EZzCpJXnOVfS X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN2PR03MB2333 Received-SPF: pass client-ip=40.107.220.130; envelope-from=alxndr@bu.edu; helo=NAM11-CO1-obe.outbound.protection.outlook.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/20 21:08:14 X-ACL-Warn: Detected OS = Windows NT kernel [generic] [fuzzy] X-Spam_score_int: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, HK_RANDOM_ENVFROM=0.001, HK_RANDOM_FROM=0.441, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no 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: Laurent Vivier , Thomas Huth , Alexander Bulekov , f4bug@amsat.org, darren.kenny@oracle.com, bsd@redhat.com, stefanha@redhat.com, pbonzini@redhat.com, dimastep@yandex-team.ru Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" It can be useful to register FuzzTargets that have nearly-identical initialization handlers (e.g. for using the same fuzzing code, with different configuration options). Add an opaque pointer to the FuzzTarget struct, so that FuzzTargets can hold some data, useful for storing target-specific configuration options, that can be read by the get_init_cmdline function. Signed-off-by: Alexander Bulekov --- tests/qtest/fuzz/fuzz.h | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/qtest/fuzz/fuzz.h b/tests/qtest/fuzz/fuzz.h index ed9ce17154..08e9560a79 100644 --- a/tests/qtest/fuzz/fuzz.h +++ b/tests/qtest/fuzz/fuzz.h @@ -100,6 +100,7 @@ typedef struct FuzzTarget { uint8_t *out, size_t max_out_size, unsigned int seed); + void *opaque; } FuzzTarget; void flush_events(QTestState *); From patchwork Wed Oct 21 01:07:50 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Bulekov X-Patchwork-Id: 270820 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.3 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, HK_RANDOM_FROM, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7CB24C4363D for ; Wed, 21 Oct 2020 01:22:39 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id D3A9920936 for ; Wed, 21 Oct 2020 01:22:38 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=bushare.onmicrosoft.com header.i=@bushare.onmicrosoft.com header.b="dAnwOdnh" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D3A9920936 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=bu.edu Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:39650 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kV2pp-0004eI-V9 for qemu-devel@archiver.kernel.org; Tue, 20 Oct 2020 21:22:37 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44520) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kV2ca-0001ou-0I for qemu-devel@nongnu.org; Tue, 20 Oct 2020 21:08:56 -0400 Received: from mail-co1nam11on2130.outbound.protection.outlook.com ([40.107.220.130]:28640 helo=NAM11-CO1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kV2cY-0004s9-DF for qemu-devel@nongnu.org; Tue, 20 Oct 2020 21:08:55 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=eYHvVTs+bGE5IK+1pCNsJXmnWqK8fJmexyMim25RjEnw84EszUPu53eH4wp5J9vpbzEKwdIX08CdEwp1KGT0v6pGC1GvP7RcFVQ7oWZfpHsOs/0i0Di77c8B0wKa8hbeT0t9SYbYFboWh3KTITkyTThDhlMVnvpL+ttxOrX4c/GuhCYHHCBkJk8SYLmZUlq0o01gca8xA4Kl4MnRYjRFpMXFwmnu0R3bEeDG1NFJDeieke1CF6hqJ885jyNAyM3RM3uET9szEnOfE3y2SiwcYzoXvPQY1GJ75lJs2kP6mOe3Ot3QFrdsoXNLhg+hIb/hTsJR879qgjfFb26+02FcCg== 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=bDTJqGKM64aaMzk3wc49Mh3OiMmPjRoJGLGBFubJf7o=; b=HwtkTLrJvDIvqi0IqjxBrrcRMJK7nmses/CiKjWJzxMTUSAG2J9jQqwBz/pKC+RtuzzCCPLkpPwvRytHUryZLnNGLcpbw5LCAp3HdFDUzY0zT4O+sr/QwezESe3NjnYzg89kQqdqUZFnsK3WeRkSEOePKhNgqBzb7/lOUBvO9m8NXakfyfzUzbrK3av10TeYh1mHruIfvQEzzow1d+HIimbPKIG9YaQHXvwmO1q7weB2PhJX7jebuOCTeTB98h3n7a9PCcSXvl1Rv5RrnOBpYzmvmNVqKkx+pFelRGSpQPJQg6aJbXIPhAapNlnNB3053ulBiR94Xztcd6Kr5An49Q== 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=bDTJqGKM64aaMzk3wc49Mh3OiMmPjRoJGLGBFubJf7o=; b=dAnwOdnhgd8qida4RrsxoWUZvHmD+ZFKjWWVgsaF4k7RBALu4Ifrp8lpEKMBNrvMbuWH0K1tom0jHS3wZQhR8O6hnJpgrwvR6U3rzipq6wClIfTCPy36K+2w6xBhl1rpxqsZ4rkGrhd49goa/RRwkFDypHqFOZWwBhyOGDwUN+Q= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none; nongnu.org; dmarc=none action=none header.from=bu.edu; Received: from SN6PR03MB3871.namprd03.prod.outlook.com (2603:10b6:805:6d::32) by SN2PR03MB2333.namprd03.prod.outlook.com (2603:10b6:804:c::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3477.22; Wed, 21 Oct 2020 01:08:25 +0000 Received: from SN6PR03MB3871.namprd03.prod.outlook.com ([fe80::d520:4c19:8ce6:7db2]) by SN6PR03MB3871.namprd03.prod.outlook.com ([fe80::d520:4c19:8ce6:7db2%2]) with mapi id 15.20.3477.028; Wed, 21 Oct 2020 01:08:25 +0000 From: Alexander Bulekov To: qemu-devel@nongnu.org Subject: [PATCH v5 14/16] fuzz: add general-fuzz configs for oss-fuzz Date: Tue, 20 Oct 2020 21:07:50 -0400 Message-Id: <20201021010752.973230-15-alxndr@bu.edu> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201021010752.973230-1-alxndr@bu.edu> References: <20201021010752.973230-1-alxndr@bu.edu> X-Originating-IP: [72.93.72.163] X-ClientProxiedBy: BL1PR13CA0119.namprd13.prod.outlook.com (2603:10b6:208:2b9::34) To SN6PR03MB3871.namprd03.prod.outlook.com (2603:10b6:805:6d::32) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from stormtrooper.vrmnet (72.93.72.163) by BL1PR13CA0119.namprd13.prod.outlook.com (2603:10b6:208:2b9::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3499.8 via Frontend Transport; Wed, 21 Oct 2020 01:08:24 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: d869fc95-8c91-4803-f213-08d8755dcfb6 X-MS-TrafficTypeDiagnostic: SN2PR03MB2333: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:6430; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: vdCqnpuWPdt9VlyAoLhxj+JBdRnpLzaiokYsAs7HSlk7dOpuhn7ENZvZ/5YHY3scaV2JxRm0HAr6vxU1KP/tIJVKWCWbTHWiAScHo7iyxkCXOecKXkfCv0byc1c8EozTHoli7x95FD/pM776tH8/GNNpdS0soKdqTyFpvdfbdohU+yTRUHHU8agzkUXjo/8s44E7QovDiYNSz0dd4O3okSU05UpKGxHtAyQPU+evIl7dmHf+H9xGu7AvvGBpEOJGtjpS4NmKHfwmTw1EdcCg5Cb2dyYFtT75zmXL0UR2mvmnW0TTuyo8cbaknoQ5CtMc X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:SN6PR03MB3871.namprd03.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(39860400002)(396003)(376002)(346002)(366004)(136003)(52116002)(2616005)(8676002)(6512007)(6916009)(6506007)(36756003)(786003)(316002)(956004)(478600001)(1076003)(4326008)(6486002)(75432002)(8936002)(54906003)(86362001)(5660300002)(26005)(16526019)(186003)(6666004)(66946007)(2906002)(66476007)(66556008); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: Y5wFmgmCFoTJcsxW4bXlR1NGQC84s0PTJbgtUv7yA7FZjZ8iqGsRA/1vWCbM2cyJT/Jnvo/eQJKPLpP7jBqlSArwLuLAiP+DfC0Fugk0Cq5VGVAjmfu3e2F5wd2uc3kT/wXHsJU2NM3B4EzqiDhuvFx9FoDbD8odiDo7ffunjqrlI11V8ZOSV0+Fn4tpipb5PYIKzbgthw+5XllJHIT/U8AMcQ4TVGvMG+GmOwejFfkIqkwhoA2X0BoVv4tPDHerEReFKD427cX1AXpixZ/g8ZbDrgXFYfOZLWn/FUMLqrdY4TUL5hWOV389K54kELX27Q/+onyKk41TZCjTeXpTVUmf1m6BTn3Ww+O2vLge6JYPmX40KTDz5ZnxXqAN7D2+BfqH32N8A2Xx8BE/FvnwvMjpUjWLhS8giF2Z6ROD9+io14fBl9HU8QgVZ7RrWIPU4Ut6ZGBsTyspLpdAgSE2m2YAtyniHkP4yyYU/h+Bt0VZuCNS/89MbKirMraEwd8AFSIAFvjobxwfzQJMZqVGe8BrnT++Ulkw2xI5wXgwOWhoknJUbpT28L2d3sYTBN4d5KxpTuCegtQSJMUgkXEpMDG1iLXZdN4BG32bnvQUR8usctAqGlJAF3YNyWHyv0bbEO7W7cgdaiBJhtWzfMz6iw== X-OriginatorOrg: bu.edu X-MS-Exchange-CrossTenant-Network-Message-Id: d869fc95-8c91-4803-f213-08d8755dcfb6 X-MS-Exchange-CrossTenant-AuthSource: SN6PR03MB3871.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Oct 2020 01:08:25.8212 (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: UPf/N5uYbzRuOaUKvaIxj0lbFvqzNMO3TGc8ayxRM3MXqBUbemxn9Srtk8ce/RVc X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN2PR03MB2333 Received-SPF: pass client-ip=40.107.220.130; envelope-from=alxndr@bu.edu; helo=NAM11-CO1-obe.outbound.protection.outlook.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/20 21:08:14 X-ACL-Warn: Detected OS = Windows NT kernel [generic] [fuzzy] X-Spam_score_int: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, HK_RANDOM_ENVFROM=0.001, HK_RANDOM_FROM=0.441, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no 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: Laurent Vivier , Thomas Huth , Alexander Bulekov , f4bug@amsat.org, darren.kenny@oracle.com, bsd@redhat.com, stefanha@redhat.com, pbonzini@redhat.com, dimastep@yandex-team.ru Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Predefine some general-fuzz configs. For each of these, we will create a separate FuzzTarget that can be selected through argv0 and, therefore, fuzzed on oss-fuzz. Signed-off-by: Alexander Bulekov --- tests/qtest/fuzz/generic_fuzz_configs.h | 121 ++++++++++++++++++++++++ 1 file changed, 121 insertions(+) create mode 100644 tests/qtest/fuzz/generic_fuzz_configs.h diff --git a/tests/qtest/fuzz/generic_fuzz_configs.h b/tests/qtest/fuzz/generic_fuzz_configs.h new file mode 100644 index 0000000000..e1a933f18d --- /dev/null +++ b/tests/qtest/fuzz/generic_fuzz_configs.h @@ -0,0 +1,121 @@ +/* + * Generic Virtual-Device Fuzzing Target Configs + * + * Copyright Red Hat Inc., 2020 + * + * Authors: + * Alexander Bulekov + * + * This work is licensed under the terms of the GNU GPL, version 2 or later. + * See the COPYING file in the top-level directory. + */ + +#ifndef GENERIC_FUZZ_CONFIGS_H +#define GENERIC_FUZZ_CONFIGS_H + +#include "qemu/osdep.h" + +typedef struct generic_fuzz_config { + const char *name, *args, *objects; +} generic_fuzz_config; + +const generic_fuzz_config predefined_configs[] = { + { + .name = "virtio-net-pci-slirp", + .args = "-M q35 -nodefaults " + "-device virtio-net,netdev=net0 -netdev user,id=net0", + .objects = "virtio*", + },{ + .name = "virtio-blk", + .args = "-machine q35 -device virtio-blk,drive=disk0 " + "-drive file=null-co://,id=disk0,if=none,format=raw", + .objects = "virtio*", + },{ + .name = "virtio-scsi", + .args = "-machine q35 -device virtio-scsi,num_queues=8 " + "-device scsi-hd,drive=disk0 " + "-drive file=null-co://,id=disk0,if=none,format=raw", + .objects = "scsi* virtio*", + },{ + .name = "virtio-gpu", + .args = "-machine q35 -nodefaults -device virtio-gpu", + .objects = "virtio*", + },{ + .name = "virtio-vga", + .args = "-machine q35 -nodefaults -device virtio-vga", + .objects = "virtio*", + },{ + .name = "virtio-rng", + .args = "-machine q35 -nodefaults -device virtio-rng", + .objects = "virtio*", + },{ + .name = "virtio-balloon", + .args = "-machine q35 -nodefaults -device virtio-balloon", + .objects = "virtio*", + },{ + .name = "virtio-serial", + .args = "-machine q35 -nodefaults -device virtio-serial", + .objects = "virtio*", + },{ + .name = "virtio-mouse", + .args = "-machine q35 -nodefaults -device virtio-mouse", + .objects = "virtio*", + },{ + .name = "e1000", + .args = "-M q35 -nodefaults " + "-device e1000,netdev=net0 -netdev user,id=net0", + .objects = "e1000", + },{ + .name = "e1000e", + .args = "-M q35 -nodefaults " + "-device e1000e,netdev=net0 -netdev user,id=net0", + .objects = "e1000e", + },{ + .name = "cirrus-vga", + .args = "-machine q35 -nodefaults -device cirrus-vga", + .objects = "cirrus*", + },{ + .name = "bochs-display", + .args = "-machine q35 -nodefaults -device bochs-display", + .objects = "bochs*", + },{ + .name = "intel-hda", + .args = "-machine q35 -nodefaults -device intel-hda,id=hda0 " + "-device hda-output,bus=hda0.0 -device hda-micro,bus=hda0.0 " + "-device hda-duplex,bus=hda0.0", + .objects = "intel-hda", + },{ + .name = "ide-hd", + .args = "-machine q35 -nodefaults " + "-drive file=null-co://,if=none,format=raw,id=disk0 " + "-device ide-hd,drive=disk0", + .objects = "ahci*", + },{ + .name = "floppy", + .args = "-machine pc -nodefaults -device floppy,id=floppy0 " + "-drive id=disk0,file=null-co://,file.read-zeroes=on,if=none " + "-device floppy,drive=disk0,drive-type=288", + .objects = "fd* floppy*", + },{ + .name = "xhci", + .args = "-machine q35 -nodefaults" + "-drive file=null-co://,if=none,format=raw,id=disk0 " + "-device qemu-xhci,id=xhci -device usb-tablet,bus=xhci.0 " + "-device usb-bot -device usb-storage,drive=disk0 " + "-chardev null,id=cd0 -chardev null,id=cd1 " + "-device usb-braille,chardev=cd0 -device usb-ccid -device usb-ccid " + "-device usb-kbd -device usb-mouse -device usb-serial,chardev=cd1 " + "-device usb-tablet -device usb-wacom-tablet -device usb-audio", + .objects = "*usb* *uhci* *xhci*", + },{ + .name = "pc-i440fx", + .args = "-machine pc", + .objects = "*", + },{ + .name = "pc-q35", + .args = "-machine q35", + .objects = "*", + } +}; + +#endif From patchwork Wed Oct 21 01:07:51 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Bulekov X-Patchwork-Id: 270819 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.3 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, HK_RANDOM_FROM, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 93E13C4363D for ; Wed, 21 Oct 2020 01:24:55 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id E51232098B for ; Wed, 21 Oct 2020 01:24:54 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=bushare.onmicrosoft.com header.i=@bushare.onmicrosoft.com header.b="VgK9fv9i" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E51232098B Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=bu.edu Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:46036 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kV2s2-0007Fm-1l for qemu-devel@archiver.kernel.org; Tue, 20 Oct 2020 21:24:54 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44556) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kV2cm-00025V-1O for qemu-devel@nongnu.org; Tue, 20 Oct 2020 21:09:08 -0400 Received: from mail-co1nam11on2130.outbound.protection.outlook.com ([40.107.220.130]:28640 helo=NAM11-CO1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kV2ck-0004s9-Bx for qemu-devel@nongnu.org; Tue, 20 Oct 2020 21:09:07 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=FXOnZ8hh69Ivvgy11dMOFMnAGCW87nv4Xe5b46ITcJ6sKcOoz54sKKMEoUWtasRmFvre+skJec6+0eFj5j8d98Tz+jIiHrytdXwozNYnjvXuJspGi/HiXAsLsMjVrsL/1ZeOC2sDmY+yZIobyq5gs0vU+C7dS7DAQcZzbbajDOrOI+YD4H72VnCHreJgeXa/7mu+4put+R8SEuHmQSSVlicrl3bKdrQas/C1NaOIKskb8e/Q6v1BU8NcvzeaDLcqy8jZvgFScUAVfZJ9I9h+T3LyOpG5Llj6QQZb1fNKVG7dCFDXwx3a85hrV3s3iz8zOXbfCXZ2c+wWqaPgxRFavw== 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=PI7IdsneBURJqy0L2kkLiK29fqZpK9/o2tf77wJ0uvM=; b=B6pSdDm7Kb5TiMdcMRj+gatgr8EIVPWYaoRzmk9rLGCYO7p/6i/3lKxP564qeR+Zam/0VQVRcmATT0CL8n/EojZkbUqR1oSi57qKaXxOTvjVHCL1KSKhm5NcWxjXf5II5pcxuxKC5jLIi6kZT8ciSoF89dEmWc/dYPwXxnoY7fP4Ghdyf7YSHynd9vNLbZxophjfXWD6jMqB2n48wJwROOH9y1mXzvMetEYncrOnB931TeSSlzwBQ7zghL9oIv2El3g8z8VhgVx2Cvit1pWOd1kYQ0y0jr2uXI3gmWnlhj5grO68Z6UntQP0Fh6TrYknQT3HfRya/8uCZb3jCa5PXg== 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=PI7IdsneBURJqy0L2kkLiK29fqZpK9/o2tf77wJ0uvM=; b=VgK9fv9iKiIXjQoRod8acXoaAHfFOd+lfYCPbBumtcDYqCGTrUR1jeiZ0qDQLfZw6KtnqG+LHdt6EDQOKbWMGcsnQZurKYf7Mwqj69P6eJf1e7czlBExaoOIHkfHCTErRVENUnE+Fe74p27Z+oATHhIpwdR4YG1UVJmkzrl/3Hc= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none; nongnu.org; dmarc=none action=none header.from=bu.edu; Received: from SN6PR03MB3871.namprd03.prod.outlook.com (2603:10b6:805:6d::32) by SN2PR03MB2333.namprd03.prod.outlook.com (2603:10b6:804:c::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3477.22; Wed, 21 Oct 2020 01:08:27 +0000 Received: from SN6PR03MB3871.namprd03.prod.outlook.com ([fe80::d520:4c19:8ce6:7db2]) by SN6PR03MB3871.namprd03.prod.outlook.com ([fe80::d520:4c19:8ce6:7db2%2]) with mapi id 15.20.3477.028; Wed, 21 Oct 2020 01:08:27 +0000 From: Alexander Bulekov To: qemu-devel@nongnu.org Subject: [PATCH v5 15/16] fuzz: register predefined general-fuzz configs Date: Tue, 20 Oct 2020 21:07:51 -0400 Message-Id: <20201021010752.973230-16-alxndr@bu.edu> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201021010752.973230-1-alxndr@bu.edu> References: <20201021010752.973230-1-alxndr@bu.edu> X-Originating-IP: [72.93.72.163] X-ClientProxiedBy: BL1PR13CA0119.namprd13.prod.outlook.com (2603:10b6:208:2b9::34) To SN6PR03MB3871.namprd03.prod.outlook.com (2603:10b6:805:6d::32) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from stormtrooper.vrmnet (72.93.72.163) by BL1PR13CA0119.namprd13.prod.outlook.com (2603:10b6:208:2b9::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3499.8 via Frontend Transport; Wed, 21 Oct 2020 01:08:26 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: a433a283-84e4-47e9-4420-08d8755dd0bb X-MS-TrafficTypeDiagnostic: SN2PR03MB2333: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:3044; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ipC1GX47xNiCSWpq6OrqdCQWVqvMHLv1BpiTsmkp7zrhy0LrXEKxm5dPZ8i8BMsWM4UUv7Wk5mqo484yh74EyhnOxl5+TyKxnkFPJh3dzqmC8LkEHptrckMl4ygN6UtEeA0P0wLatsD/K0Sll1bQqUMK06MpUlRzQIDcoUz3Y5FRi6+D8cMEt+zfILVkSfzP919MERTan+1SP0SG1Nw0aEL6ApCcani3IdsRrBbJB0HJeVA6WS28szPbcvesp713OGh8Awu5HmwFKbMIiqgVQ+sFBfDZ8Ox3JETUSZe3A9XCvtuoysRlmE90aPvAfYX9uPNi95lj+EjB083XN0rUUg== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:SN6PR03MB3871.namprd03.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(39860400002)(396003)(376002)(346002)(366004)(136003)(52116002)(2616005)(8676002)(6512007)(6916009)(6506007)(36756003)(786003)(316002)(956004)(478600001)(1076003)(4326008)(6486002)(75432002)(8936002)(54906003)(86362001)(5660300002)(26005)(16526019)(186003)(6666004)(66946007)(2906002)(66476007)(66556008); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: 8ff+x66lPEmLZuf1t8+T4x4jRh4K9I2db/Lz1K/FCrgqvGnSQPm8/0TtjbaXS3W96wWumPcyOxmOvfSEBo0rIXiTR7yX6l9GsG8RNs3dQOqMZTdp6qwcZ+s2kGnErwiLW999VvCN6KW4YRMrv7kg6cy6/lu4Jp+EJ9JVvTa4U6qsiyZ1lddLkF/kgG2ZAaWnR7edM8HnXWr5qiAelzOIiwu2bgprpRHPFhntC7vrcaJCvzhQ2bIPatobWXKEfoVEzGTEmrzd+ld0hkiQLyCOawzwbNMlDMTd/Nqlejk849GiUdBuOvEs9yzXzbUfN9txenteQ09OVUosjxPOYn4uOB/q0nMgfOkEx58G0EqAohq7RMk5gjnn/BVjW9UxrVjm5BcUiTia4nCACiL3a95EXBV2HdIc+5DbOJ5LEP8cDFPBDuK1xvYkSDFyAdZf/VpLH0U/zBweeRSkBa+f+QB8X5K3ECW7GPNCuK55nEbajXJFqa8z5/pycR6ydXBI9tdejWyMMp24TGD+yM1ZLyhHiFuLmovZtZKHiVgFet2jqu08972+Rmu5KfbLnpCNkifafw7FSTdc/7yNF7ZUml90Rk84OeEAdZlaq/r+vtd5LSmXnjQTuniekkbRS/JNBL+EOXvctiDbb17MW47rLf6XJg== X-OriginatorOrg: bu.edu X-MS-Exchange-CrossTenant-Network-Message-Id: a433a283-84e4-47e9-4420-08d8755dd0bb X-MS-Exchange-CrossTenant-AuthSource: SN6PR03MB3871.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Oct 2020 01:08:27.1774 (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: MM1m9ZsEt9PMWkiVDfnx/LLzuVbE4OkNK771SdUPP3VPAJ7zzIl3C82l6sZfvCXO X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN2PR03MB2333 Received-SPF: pass client-ip=40.107.220.130; envelope-from=alxndr@bu.edu; helo=NAM11-CO1-obe.outbound.protection.outlook.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/20 21:08:14 X-ACL-Warn: Detected OS = Windows NT kernel [generic] [fuzzy] X-Spam_score_int: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, HK_RANDOM_ENVFROM=0.001, HK_RANDOM_FROM=0.441, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no 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: Laurent Vivier , Thomas Huth , Alexander Bulekov , f4bug@amsat.org, darren.kenny@oracle.com, bsd@redhat.com, stefanha@redhat.com, pbonzini@redhat.com, dimastep@yandex-team.ru Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" We call get_general_fuzz_configs, which fills an array with predefined {name, args, objects} triples. For each of these, we add a new FuzzTarget, that uses a small wrapper to set QEMU_FUZZ_{ARGS,OBJECTS} to the corresponding predefined values. Signed-off-by: Alexander Bulekov --- tests/qtest/fuzz/generic_fuzz.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/tests/qtest/fuzz/generic_fuzz.c b/tests/qtest/fuzz/generic_fuzz.c index 356d171c65..d159d64d8b 100644 --- a/tests/qtest/fuzz/generic_fuzz.c +++ b/tests/qtest/fuzz/generic_fuzz.c @@ -26,6 +26,7 @@ #include "hw/qdev-core.h" #include "hw/pci/pci.h" #include "hw/boards.h" +#include "generic_fuzz_configs.h" /* * SEPARATOR is used to separate "operations" in the fuzz input @@ -901,6 +902,17 @@ static GString *generic_fuzz_cmdline(FuzzTarget *t) return cmd_line; } +static GString *generic_fuzz_predefined_config_cmdline(FuzzTarget *t) +{ + const generic_fuzz_config *config; + g_assert(t->opaque); + + config = t->opaque; + setenv("QEMU_FUZZ_ARGS", config->args, 1); + setenv("QEMU_FUZZ_OBJECTS", config->objects, 1); + return generic_fuzz_cmdline(t); +} + static void register_generic_fuzz_targets(void) { fuzz_add_target(&(FuzzTarget){ @@ -911,6 +923,26 @@ static void register_generic_fuzz_targets(void) .fuzz = generic_fuzz, .crossover = generic_fuzz_crossover }); + + GString *name; + const generic_fuzz_config *config; + + for (int i = 0; + i < sizeof(predefined_configs) / sizeof(generic_fuzz_config); + i++) { + config = predefined_configs + i; + name = g_string_new("generic-fuzz"); + g_string_append_printf(name, "-%s", config->name); + fuzz_add_target(&(FuzzTarget){ + .name = name->str, + .description = "Predefined generic-fuzz config.", + .get_init_cmdline = generic_fuzz_predefined_config_cmdline, + .pre_fuzz = generic_pre_fuzz, + .fuzz = generic_fuzz, + .crossover = generic_fuzz_crossover, + .opaque = (void *)config + }); + } } fuzz_target_init(register_generic_fuzz_targets); From patchwork Wed Oct 21 01:07:52 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Bulekov X-Patchwork-Id: 302426 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.3 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, HK_RANDOM_FROM, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7DE96C4363D for ; Wed, 21 Oct 2020 01:23:44 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id D73912098B for ; Wed, 21 Oct 2020 01:23:43 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=bushare.onmicrosoft.com header.i=@bushare.onmicrosoft.com header.b="dXp2hMEi" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D73912098B Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=bu.edu Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:43398 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kV2qs-0006AJ-Ui for qemu-devel@archiver.kernel.org; Tue, 20 Oct 2020 21:23:42 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44570) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kV2cn-00027B-QS for qemu-devel@nongnu.org; Tue, 20 Oct 2020 21:09:09 -0400 Received: from mail-co1nam11on2130.outbound.protection.outlook.com ([40.107.220.130]:28640 helo=NAM11-CO1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kV2cm-0004s9-BY for qemu-devel@nongnu.org; Tue, 20 Oct 2020 21:09:09 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=MGjmwzHr59oNcpLTf4EMRWuHRNVwTSM9D4AN6hK9JNqNyY1D7Oe9IJTsB3ndXoCOG0lxlKpw/PuWyjYjHNBm1rNKP/ZG6dQSYBX4j5oSOazOQ8WRjV+RoR9ByA0mttYLiCAzH7LrWeuOl90G/4yScfGNXojiRoJH825DVHkdAC7YjhA+hMycHO/Uo8ONaYk0nO4L4sS24Iefo1u54flHu4FjZ/FLADE8DyUVU+OufdEiQeBBoOCQuZFIUv0htR22AblXJM5UtgOlRetNNgAaLScd0IaQpG1vUorx198loaSz8z3UBiq3OPInJCBO60fOcP+4VEbZA6tIgjiOi/wVTQ== 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=qzftJy83Kkyh0SvycGdUAqsn3APx2vCrNfLWB5KU5aw=; b=autACgSdJNxoCVKWHn+WTAjpuFRCacZB0kH6NDn2l8MFjOXLM1r3iXsvjL3O8Hygf7a3xZmwzg8mJvVP/UlSM4N7UpapGFM5ykEeStgKvmjUQ2E0baF5BEzXTZlYDm+u9d+4j6K4J72kod/TxReDC7AS/lhrqEUYR4hQjTGe07L+n9qQSCfbMvfd3HzmvSPL7ouoz2HkG/SOJmGW8qCpY+xqBxpaW3qEEumzqKulQl3wmesSgTnvVnygZ7z4PEC1npopfjrq02knPD1dB2QLJdNK3xuJuf8gWLRcpAf8mp+hcZlOaY7uKbJMhVaEkuqk80/HTryna+rs0y1dfvWDlw== 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=qzftJy83Kkyh0SvycGdUAqsn3APx2vCrNfLWB5KU5aw=; b=dXp2hMEiv6RuXTl+RNyjZy6/yPXL7IgiTUc2hj0oPwmAz1RnLjQ9B2LZX96A1IbIcgSZSVgfS7gZWxVaVmEUkrveKeKda/e4PEEbhxHdEmapiLYQDW2yIe2U/M2jgSNcDkQVwgre1NCJRzAkVk8i3Wnc4kldorncb63uRVCZwok= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none; nongnu.org; dmarc=none action=none header.from=bu.edu; Received: from SN6PR03MB3871.namprd03.prod.outlook.com (2603:10b6:805:6d::32) by SN2PR03MB2333.namprd03.prod.outlook.com (2603:10b6:804:c::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3477.22; Wed, 21 Oct 2020 01:08:28 +0000 Received: from SN6PR03MB3871.namprd03.prod.outlook.com ([fe80::d520:4c19:8ce6:7db2]) by SN6PR03MB3871.namprd03.prod.outlook.com ([fe80::d520:4c19:8ce6:7db2%2]) with mapi id 15.20.3477.028; Wed, 21 Oct 2020 01:08:28 +0000 From: Alexander Bulekov To: qemu-devel@nongnu.org Subject: [PATCH v5 16/16] scripts/oss-fuzz: remove the general-fuzz target Date: Tue, 20 Oct 2020 21:07:52 -0400 Message-Id: <20201021010752.973230-17-alxndr@bu.edu> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201021010752.973230-1-alxndr@bu.edu> References: <20201021010752.973230-1-alxndr@bu.edu> X-Originating-IP: [72.93.72.163] X-ClientProxiedBy: BL1PR13CA0119.namprd13.prod.outlook.com (2603:10b6:208:2b9::34) To SN6PR03MB3871.namprd03.prod.outlook.com (2603:10b6:805:6d::32) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from stormtrooper.vrmnet (72.93.72.163) by BL1PR13CA0119.namprd13.prod.outlook.com (2603:10b6:208:2b9::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3499.8 via Frontend Transport; Wed, 21 Oct 2020 01:08:27 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 5bf79c84-b71a-402f-3f9f-08d8755dd17d X-MS-TrafficTypeDiagnostic: SN2PR03MB2333: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:7691; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: NjmGIoCqezQgTAkVPJ38JhK3mM89RX17k6XAdN+oT7TNdlBeKiTd7T82lWOxwBhntVe121vSAQp5ur7N03qWG1NkX2KhnmlTKAYzqG5ogyWIqW9bIePffd0HXMajwSaGKsXYlrIpYFz6KW3hYUOBvSklNn2ajv9pnjkdHLkVhh/B1bYtjW8/1D+QRTJQckXKjoHq6VfP+SbsendPAvlpS69eeurmFBaCW0DTqo21lDN6l2HZ9PrLhnMY2lshWZ9nOJ09EmpgC1hRvzqZXmIV4Y25JZWpmdWVyqWzmolZ00R230QkbzxPFAwTcwmIbKqxH4PJu5I1IcyNPixlr2DXxg== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:SN6PR03MB3871.namprd03.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(39860400002)(396003)(376002)(346002)(366004)(136003)(52116002)(2616005)(8676002)(6512007)(6916009)(6506007)(36756003)(786003)(316002)(956004)(478600001)(1076003)(4326008)(6486002)(75432002)(8936002)(54906003)(86362001)(5660300002)(26005)(16526019)(186003)(6666004)(66946007)(2906002)(66476007)(66556008); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: 6WcWdqJIhFidizEQJNc2vs0AwTu9/PnAWWsR7G9l4UffgS2kuQvPCcLmGS5UmLyaYd/l9yY7TYOF/5qXnqasTbVpJP3EuUVbXX3aeA/MflZPJMSKZQq3ZGUyVQCfGBnUAjiwHBLaATTW1yHceVdiDrzic/5N8snLeXhrPhhSA/IGRTUzPQFD4nQyGnICC5emyD+kB2YJuz9hs0+M4L0hxWTRr9JZrKsNOw8AmbmNIAl+6dznth+CSYFoq/THQOrpLROAvd1JAyX8RrIx6iTeFlHqlziSoNV4IFrf7k30WrnYZaQdUoHsY5qGrwhP/oWWwweDEKQg/iD757EyqQyTSY+ydKeQBqJn5UxcAXvV5PbV/7hFEpBBZ8QX3fvHC8HoRWsWyQdDKvAmF60rG0nOXdjxa+uuL9+wJz+CIw4Vzu6NFlvmez7yLWF7pMyB2YFxeqxYV/EYtEdj3GtIUwSgEBQoKmoTsBtvqkJb9p7+P4tmle2PLzAXYYbiznX32lnT4KydzZGlzdPSu9tXccK/EBlyaMu5opdOY5/D7HrwsXDDyiDo4RAM5n4gfgKrbFu8c9hLhMebHgAZz4Dvi2mUEPUU1i8Se9URfNUi0bVofb9SqdJaJ3RvNWc97/1WLKwl2dk/L3Shreo180tEGcrQyg== X-OriginatorOrg: bu.edu X-MS-Exchange-CrossTenant-Network-Message-Id: 5bf79c84-b71a-402f-3f9f-08d8755dd17d X-MS-Exchange-CrossTenant-AuthSource: SN6PR03MB3871.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Oct 2020 01:08:28.2268 (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: XxABPzdIz4kpP2kbjsXr5qqmoeuuhDbDGmKmxk56x5IVm59mjjkHBfRotsyQtA5n X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN2PR03MB2333 Received-SPF: pass client-ip=40.107.220.130; envelope-from=alxndr@bu.edu; helo=NAM11-CO1-obe.outbound.protection.outlook.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/20 21:08:14 X-ACL-Warn: Detected OS = Windows NT kernel [generic] [fuzzy] X-Spam_score_int: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, HK_RANDOM_ENVFROM=0.001, HK_RANDOM_FROM=0.441, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no 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: Thomas Huth , Alexander Bulekov , f4bug@amsat.org, darren.kenny@oracle.com, bsd@redhat.com, stefanha@redhat.com, pbonzini@redhat.com, dimastep@yandex-team.ru Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" general-fuzz is not a standalone fuzzer - it requires some env variables to be set. On oss-fuzz, we set these with some predefined general-fuzz-{...} targets, that are thin wrappers around general-fuzz. Remove general-fuzz from the oss-fuzz build, so oss-fuzz does not treat it as a standalone fuzzer. Signed-off-by: Alexander Bulekov --- scripts/oss-fuzz/build.sh | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/scripts/oss-fuzz/build.sh b/scripts/oss-fuzz/build.sh index 0c3ca9e06f..eed73ea410 100755 --- a/scripts/oss-fuzz/build.sh +++ b/scripts/oss-fuzz/build.sh @@ -97,5 +97,11 @@ do cp qemu-fuzz-i386 "$DEST_DIR/qemu-fuzz-i386-target-$target" done +# Remove the general-fuzz target, as it requires some environment variables to +# be configured. We have some general-fuzz-{pc-q35, floppy, ...} targets that +# are thin wrappers around this target that set the required environment +# variables according to predefined configs. +rm "$DEST_DIR/qemu-fuzz-i386-target-general-fuzz" + echo "Done. The fuzzers are located in $DEST_DIR" exit 0