From patchwork Wed Oct 21 21:09:07 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Bulekov X-Patchwork-Id: 302329 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 E2695C4363A for ; Wed, 21 Oct 2020 21:21: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 18EB524198 for ; Wed, 21 Oct 2020 21:21:11 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=bushare.onmicrosoft.com header.i=@bushare.onmicrosoft.com header.b="0OHseGnw" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 18EB524198 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]:60808 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kVLXi-0004pd-8l for qemu-devel@archiver.kernel.org; Wed, 21 Oct 2020 17:21:10 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42872) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kVLMh-0003Cm-Hb for qemu-devel@nongnu.org; Wed, 21 Oct 2020 17:09:47 -0400 Received: from mail-eopbgr690122.outbound.protection.outlook.com ([40.107.69.122]:45277 helo=NAM04-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 1kVLMe-00083h-Ey for qemu-devel@nongnu.org; Wed, 21 Oct 2020 17:09:46 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=fa5BenvrwSlOGtxrw/6HsLywy1V4VSSPy2dNfrGOiWDATT6rvQmVTTcQL4XPqetw3GbBRKVTHknA5fWmJsOl97g8YkrFSsOhMq/t9RRaPPQzQsAzwUDm3WNnXsc4zz1i/kLQ8kLJOi9hv7JBEAEzcLrN5O+Z7usMR5XlNG/8+QWkpefLOHRu4oKBkesRKLqObSkyswEDU0M4wkuE+pEfCyHY05OM2QHFRqb9Qd4fNeAZbjyc6Y8zcouMWlIplVsANH/dZNdWdbFtAQ4WKErIMxGCjysYui/2/5aE/rOq1bWm2YBL12SZe19ZkDTSl8KkRILNq3pyBnfWHHwLBfineQ== 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=LiwtMOC0J3McpV2DHYYYQNDvnKEIP1ojH0HWlitawLI=; b=iw3Zhh9sPZeb+vzht6AT2GSlZ3uLHqi/Iaq0grbld/rdr6+qUYlHXLaUnmO21MVbkXdvDTtTN93//XXRCa47qtMpcTlEQaPGzvOwjW9/T3oiWTSqPLneF2uk8yL5rQUU5AUobAg4AEPE4LPYpJcVDaLpFr9roymtoXARDJy+hW8+E3uyEdHv9F8oamfsMH4erlenndui20DR3rxhBy0T8CE9bmiR2mTpHBucfaISWj8jRNFhcD061JWKwUgo2Ja8LKj7EJ5fp7VGMS+f+BklYWyOEMCJNHeY1PdwoVwe8LoCPD7YAOg2xxy4Fe4f+25YN0KNLncbzN0qyI0ZjD9pcg== 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=LiwtMOC0J3McpV2DHYYYQNDvnKEIP1ojH0HWlitawLI=; b=0OHseGnwEkXMHtHd1rWy1BEqz+a8lHhfztTsRKarAdVvDwwWVZwYcR9sx0DfIwQeNP1jFTxXoJqkUOWBEQXu0Ky2IgB/u9wEMwpzT56SNO9FYRAw5XoXRb/0L+3IoS91IFhFO0o/Us5ukItXPXMzOpKBZ7g5BWj/XixQORbmNG4= 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 SN6PR03MB4045.namprd03.prod.outlook.com (2603:10b6:805:b8::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3477.21; Wed, 21 Oct 2020 21:09:35 +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 21:09:35 +0000 From: Alexander Bulekov To: qemu-devel@nongnu.org Subject: [PATCH v6 01/16] memory: Add FlatView foreach function Date: Wed, 21 Oct 2020 17:09:07 -0400 Message-Id: <20201021210922.572955-2-alxndr@bu.edu> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201021210922.572955-1-alxndr@bu.edu> References: <20201021210922.572955-1-alxndr@bu.edu> X-Originating-IP: [72.93.72.163] X-ClientProxiedBy: BL0PR0102CA0064.prod.exchangelabs.com (2603:10b6:208:25::41) 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 BL0PR0102CA0064.prod.exchangelabs.com (2603:10b6:208:25::41) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3499.18 via Frontend Transport; Wed, 21 Oct 2020 21:09:34 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 77db1df3-6e1c-4f74-ea52-08d876059cd3 X-MS-TrafficTypeDiagnostic: SN6PR03MB4045: 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: ySM1CWnWd2H0suiaQYaCILNH5JlqHIwZpXd+GXnOcu6XFfMl8s25s5jXR7taKEj3mt3HXxos99O0ISZ+pqIvtOrO1HggMusf2lCt3zJwCp7ale1bdx35fd6mkIRiFRcWut466UMV8juqeCb4OFKCsMKx3caQ2iW1SVqC95RaRDCdHq5r3RA98RII+DfmxDm9XeTDYlBLSyyhNx1/MhaAJ8TNlDPCe3OT7FXgfRKvZbnXEYI87SNwUAf7Nj91h/OqJR87KNQA2GfphYyszrC4x4N+w2Ekv52rAxdTRcR59FadARWHPb/D3FQx+HIX4d6iSEf2/5ZD2rFGT+u7NQYeDg== 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)(396003)(136003)(366004)(376002)(346002)(39860400002)(86362001)(6506007)(956004)(6666004)(2616005)(52116002)(5660300002)(316002)(75432002)(786003)(8936002)(6916009)(6512007)(16526019)(36756003)(26005)(186003)(478600001)(66946007)(6486002)(2906002)(4326008)(66476007)(1076003)(8676002)(66556008); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: Fx+KjYRper504MEy32ChsAAQaVAU2ci0H2Jld5U+28/C7Xgkt1bCvjkeTK0VyqSw5GXU1nbRQbePDC8nWSxryNWEV7lWtGpCkLs65cKHUpY9w5bNcwxjpgcPuEpaHLmSPgoqfP8B44Pt+FPTbxi4LwcI80uw0ZrPtFdKh73rmsiTTVa5/4Kr+ROtc6s7/v3/Jv/cYddryM+CiSK1o9tvQ3lXv4quVxXL24QnKgl8/LyyMKaQD7cpu2Ez7VqnJWHMJdsAH8l33H7WHjST5/+LUZGtPVWi+9UJjaN3fv7mPIDBWrsXljAvgd3BDSpUMuOcLkYeztvrA9+fhGuj0TfyyqZj0sp36ZBevxkAWii4/Udx7Lf/5Lss+Dr2bC+89nGKpVII4UwwkKOL0FHG2TXbvlasMagTNmtvz7hwjnYzwS2Q8SYclh/laf0cL1S7keHjwQGm89HsCJUcSmyVp06WnXLwqbD0S7rXNbRtVXBc8zNRDd7KPxK15xf5OQX8h+FGujnQl3XPS19L1NYFV8JX6LsWwngfI5ft2VaZw4Pp9UYiXCC+7PYLMZOpUHbROw0FTTfMk5gQ4f0O60mF3LV++qHAHr1CzT2zhm93YiYdvLYd9WExn5Xc3YXn7QNERxhr9Cb0HcnXO/ahE0v9SZ3tKg== X-OriginatorOrg: bu.edu X-MS-Exchange-CrossTenant-Network-Message-Id: 77db1df3-6e1c-4f74-ea52-08d876059cd3 X-MS-Exchange-CrossTenant-AuthSource: SN6PR03MB3871.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Oct 2020 21:09:35.3351 (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: EHg0UQVPG9y6JboZWpjyEOBFF9rqAjjGluQi6egwSF2JReEDapTN17pVawPB+pPk X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN6PR03MB4045 Received-SPF: pass client-ip=40.107.69.122; envelope-from=alxndr@bu.edu; helo=NAM04-CO1-obe.outbound.protection.outlook.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/21 17:09:36 X-ACL-Warn: Detected OS = Windows NT kernel [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, HK_RANDOM_ENVFROM=0.001, HK_RANDOM_FROM=0.454, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_LOW=-0.7, 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 Reviewed-by: Darren Kenny --- 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..042918dd16 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)(Int128 start, + Int128 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 21:09:08 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Bulekov X-Patchwork-Id: 302325 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 B6502C56201 for ; Wed, 21 Oct 2020 21:28: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 ED088221F9 for ; Wed, 21 Oct 2020 21:28: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="aXR/c66Y" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org ED088221F9 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]:49920 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kVLev-0003le-Rb for qemu-devel@archiver.kernel.org; Wed, 21 Oct 2020 17:28:37 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42900) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kVLMl-0003MR-31 for qemu-devel@nongnu.org; Wed, 21 Oct 2020 17:09:51 -0400 Received: from mail-eopbgr690122.outbound.protection.outlook.com ([40.107.69.122]:45277 helo=NAM04-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 1kVLMi-00083h-HP for qemu-devel@nongnu.org; Wed, 21 Oct 2020 17:09:50 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=X0bwcTqn6UYXhNRwMJzrirPAxB5udfux8FwkYIt8clK1Rsh7ko0Sd9OQ8m/SRAVD4GovZpZgrHtXqk7Ck41g/da3qg3ynxDnee1sWms6tNr4Po8xW4zANYvF61eovERvlCOP733Ue/NXmoziaDp6egzkqcgS7vOaV5fuIMgoIHiYYj+OmJ0OEMBuCJgLigbPKfxiAWjUgqggEpRvj63A4Tsnh6qIzzzTjDnUXOSyAm1q5GF3LbNwhybz1nmKY//z3a0BNsJOctCCArKjx3GwFpAzfigq8xCv/DMsE405AAGBkskJvH32M6OqDzR0ZgluAwk50DKXva8PFD1QpY66TQ== 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=okksm6Idv69+4YfVTK0NE4GHnYZWkvnypdi+FKBct/U=; b=LhNmv+XzHdGwd3NSaTGpLKyen+rtRwDi5VgTyIrbCqgFT+9BYKkwRHCv1o0LDY4YSop9YFEzblacIeMaIKVIslVz001OyU1M9KK3QPDN4a0g5EZNTkPecuMZjWhFxiHtXtU627qwru9NpfaZlSayw1hocqGzNSn5RyAZ2YIlQIZYOPwbTTygYZoc6AvvFCkgEpnEQ+ySMGxxe7LImT8zbOq8KCJ7xOimUikMdpl3tZqt3jWv2+kCI8/XTbhTo7xXFPvCpxly1fQx5jBeqCi3g3CCzqvivxHNX4QNAvQQbZiFMLHPDvv4CkuLpeIS4wCq3m1I+wgbhCSgtE5rGl4MlA== 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=okksm6Idv69+4YfVTK0NE4GHnYZWkvnypdi+FKBct/U=; b=aXR/c66YcxQVwRZufKiyE5nbtIoHSVlj8G+FXA2IMsvSR13MtnTGdGO77PQesFDFH2g0yWs/JtHHASUsWRHfqwGWVPld6GvOWhoZ8rcu6AK1dVt/bsq1d5CBk4H0E/GrEWiQ/FHD/t7J5as87Pulibvs9U3L2+iCTFS8vaJ2e74= 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 SN6PR03MB4045.namprd03.prod.outlook.com (2603:10b6:805:b8::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3477.21; Wed, 21 Oct 2020 21:09:37 +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 21:09:37 +0000 From: Alexander Bulekov To: qemu-devel@nongnu.org Subject: [PATCH v6 02/16] fuzz: Add generic virtual-device fuzzer Date: Wed, 21 Oct 2020 17:09:08 -0400 Message-Id: <20201021210922.572955-3-alxndr@bu.edu> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201021210922.572955-1-alxndr@bu.edu> References: <20201021210922.572955-1-alxndr@bu.edu> X-Originating-IP: [72.93.72.163] X-ClientProxiedBy: BL0PR0102CA0064.prod.exchangelabs.com (2603:10b6:208:25::41) 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 BL0PR0102CA0064.prod.exchangelabs.com (2603:10b6:208:25::41) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3499.18 via Frontend Transport; Wed, 21 Oct 2020 21:09:35 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 1c17f46d-7ef3-46cb-918f-08d876059db2 X-MS-TrafficTypeDiagnostic: SN6PR03MB4045: 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: e/Mg8/GpMQvNGskHNOj9tLNePbu93KQCWf9TMnHFV6onpqjkI3F1LXJ0ufMZH2IlUAmJ13K19FjBFLG1faCCPbRjYEcQkERCKgXJ+cHd9FH20driNQIiqDMPKtmuIzOxT1YE1/XMAA0OHkKqdTQRTu5TwtfPedIMuzS6HrbZGMoAnL7yN8t0DyJ/V6OqzB0PNBYjsQRGphe70Lp7vJ3slIZgGTj37daDLAR/xJGEZ6lQLqpL53W5JEgzTvmXWclUYPRg5zDVV6RtL9BDQjoYPe/GkrFj3r68O6TKFBoqoUm1naQeR5IvhgqJ7Pzq/oPN84vxXdYKYK7MBZjH2qLyRvtZEtAdc4epzW4i4DFgwmsNV1/AcvQJ+jp6d+2LHJqP 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)(396003)(136003)(366004)(376002)(346002)(39860400002)(83380400001)(86362001)(6506007)(956004)(6666004)(2616005)(52116002)(5660300002)(316002)(75432002)(54906003)(786003)(8936002)(6916009)(6512007)(16526019)(36756003)(26005)(186003)(478600001)(66946007)(6486002)(2906002)(30864003)(4326008)(66476007)(1076003)(8676002)(66556008)(41533002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: hoQv/HbPDdeTANOI8zAvXSsTjMiy6q2m1n6AS+9aM2P1zt1dZd1MED6kEW11Ce17P78XVuHVnbt2ZJwmnKoBn4OcRZEE/YBNOQOOrzB2//wK5QqaYuEu+kaf6qq22yaJZq0YFmo5HMU47Zk9vHCnVASrJP8kXpU1VNd7BTVTNUfHqEnCusO9WADByhMCx+2jdWMTLeNMlkKtaEF2Vw883UfBPpGLHadO09XB1BPVYuYnb8oRycVcwQHtqc/hXOMVyqbpeisKuhqKryCscA+DTgwBx5BkBk343l2ajvQ0QAKeRHIxHRbZq/itt8EZLYNABTVBoI9pVcBPQyd9tz1ZsgoXEXWX2xbDOkLzaLrsEkMtKQky/vuAQn4OV1CXMmxoCUunVye+v3mym3YoEm9dmkKW2sgwv9zhYrsR+h0oSA5IWFUxvcHaNBlR7QazBE1p2HcLVKI1OHSNxZAUnhoyGBX9UQxpcq6fLW4zam23LWCjoOvSeuJC3ni+tWoHWTl9poWXOo5hqCo7zfhJkibKE5AXFwe+zfggDb3Z4xn6eE2MO/3pYNNEnaKnVB3QgKWWRvhi3/UJj7J0Opi/ZsIr3z4TYEweACzofpwivXfiPgNHuV3sv06NckKWBoW7IvXE5eqbM7mZdMF2/LEiBjc3sA== X-OriginatorOrg: bu.edu X-MS-Exchange-CrossTenant-Network-Message-Id: 1c17f46d-7ef3-46cb-918f-08d876059db2 X-MS-Exchange-CrossTenant-AuthSource: SN6PR03MB3871.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Oct 2020 21:09:37.0711 (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: +aH0em5esffNS9dHV5/pg7D1iSLoJYFzCCKZdaywgyN8Cy3rLWqVM0g2zYZdrGjV X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN6PR03MB4045 Received-SPF: pass client-ip=40.107.69.122; envelope-from=alxndr@bu.edu; helo=NAM04-CO1-obe.outbound.protection.outlook.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/21 17:09:36 X-ACL-Warn: Detected OS = Windows NT kernel [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, HK_RANDOM_ENVFROM=0.001, HK_RANDOM_FROM=0.454, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_LOW=-0.7, 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 Reviewed-by: Darren Kenny --- tests/qtest/fuzz/generic_fuzz.c | 512 ++++++++++++++++++++++++++++++++ tests/qtest/fuzz/meson.build | 1 + 2 files changed, 513 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..f69e9583ce --- /dev/null +++ b/tests/qtest/fuzz/generic_fuzz.c @@ -0,0 +1,512 @@ +/* + * 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(Int128 start, Int128 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 = (ram_addr_t)start; + info->result.size = (ram_addr_t)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 = generic_fuzz_cmdline, + .pre_fuzz = generic_pre_fuzz, + .fuzz = generic_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 21:09:09 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Bulekov X-Patchwork-Id: 270721 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 B2791C4363A for ; Wed, 21 Oct 2020 21:15:58 +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 E47C72419B for ; Wed, 21 Oct 2020 21:15:57 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=bushare.onmicrosoft.com header.i=@bushare.onmicrosoft.com header.b="wUtlc1vR" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E47C72419B 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]:50220 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kVLSe-0000Dg-NP for qemu-devel@archiver.kernel.org; Wed, 21 Oct 2020 17:15:56 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42912) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kVLMn-0003UQ-Vj for qemu-devel@nongnu.org; Wed, 21 Oct 2020 17:09:54 -0400 Received: from mail-eopbgr690122.outbound.protection.outlook.com ([40.107.69.122]:45277 helo=NAM04-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 1kVLMm-00083h-74 for qemu-devel@nongnu.org; Wed, 21 Oct 2020 17:09:53 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jJNp4bWQSUbj5yqTBFM3jQGafvOyb7Z3S1zM6dpzssNh1lIdGseMm0NoF3LUCFwBR3EqQL2vlT7FuCQACl1wXSq/4TI57VVANzyGT4PfS+Zjk1qv/0wsv1aQYcwpS2PCRXogWOBs6VEO+hLdhYawfwFMSzYp0sGD6jvvn2BxZeJ9euNfTvG3RSpN/hKMB1i+UXeNYHcFFSZiDhSdOK0NQu7vRViu/4aiFVVKixC73yRZpFdVkm8GfvMWN0pibtH7Ov0y0ZIuT4Ltmm3n80FbJgSWG7a/DBbQec7FuUILCMMnbb3eBejGtkKzeJSUGDXQ1xwr5n4wEYeOlFyJk6fLlA== 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=HKB7W+fzMDCxTdWVDO83cCtE99Mlpb1tnh2BC3fr58U=; b=LqN9ypFMrWj7odwklLbN+i7nh9YD2Ul8Gosppf5BFizjD7Ew6ckMx+cG37mTwJBWA2oIX1bKa1/6V31cx/S8QSGLu/mrLOO+f4oVlqH53HFmAXgi/WBzQGQpu4S3bIq8z7NS7M/36+7n1K7y41zJbz+gy4Y6GO3+QFQLKSh2GieTUpbl4GeM03VXPvgXhuGtWk+ePdema3b6Nl8b/lEDeI6cNTJVi8n4rmrE6Z1DggkbWq6OAPfTOrgl/mctb5Yuf5NcE2Ophuc4MQ/1M2EomrxGZtewLa1j9Odo7Z+5D/A1XLrp+a2Q4/JWEGSXtgl4Yt723llfgB7K+27euXAngA== 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=HKB7W+fzMDCxTdWVDO83cCtE99Mlpb1tnh2BC3fr58U=; b=wUtlc1vRdSj26017lmotUk1Qf2SJ2AiXOT0iwoEI3T+aSxtvl8w3wJm5jn8712bSN89Fz4Mi0fYTB5GEVdC+rneugsBXt8H7Pyl9SuRgEr8UxUR5fBD0fyh/9CqEfa5HnM7z95kty5iuxgLFOaitfajgZ3ZAOTaz2BvW1TzJR/o= 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 SN6PR03MB4045.namprd03.prod.outlook.com (2603:10b6:805:b8::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3477.21; Wed, 21 Oct 2020 21:09:39 +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 21:09:38 +0000 From: Alexander Bulekov To: qemu-devel@nongnu.org Subject: [PATCH v6 03/16] fuzz: Add PCI features to the generic fuzzer Date: Wed, 21 Oct 2020 17:09:09 -0400 Message-Id: <20201021210922.572955-4-alxndr@bu.edu> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201021210922.572955-1-alxndr@bu.edu> References: <20201021210922.572955-1-alxndr@bu.edu> X-Originating-IP: [72.93.72.163] X-ClientProxiedBy: BL0PR0102CA0064.prod.exchangelabs.com (2603:10b6:208:25::41) 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 BL0PR0102CA0064.prod.exchangelabs.com (2603:10b6:208:25::41) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3499.18 via Frontend Transport; Wed, 21 Oct 2020 21:09:37 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: ec91ff00-a42d-40d8-5c32-08d876059ec7 X-MS-TrafficTypeDiagnostic: SN6PR03MB4045: 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: cjil8uwkscKwp02Nb6a+2SlQHm0e4YE9Rac4UjHi8YY1EvYBhv9NpIX1KmBKmx4AQUWF1oONtGEaFIirYEnd+ghCvP3jICJaZp1zFcTyvGRHESx/MggN6MUU0XsJxlDd/PddTMMf85lT/IMUNJGF2rByhlSDGNTd/PBPt5gYZallM41aOyk409z6/St25Mn/4bzpcSd98eWt/6BgAywVSQzgaiNqAdDN1BbEmn6+z4D16wBj/pnhl0It7DE1BGAgWl4O/x+whlp/Bfy2itQ79tGTg5x6X93Wjf1iV9g9PZlu2u5Kk6BDsEm7y/dzYi5pxi/NhVReuPgSJS10dPHlDyY+4fQMASvXac6GleMkhaR7gfknPDDghsmVEXCKp23f 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)(396003)(136003)(366004)(376002)(346002)(39860400002)(83380400001)(86362001)(6506007)(956004)(6666004)(2616005)(52116002)(5660300002)(316002)(75432002)(54906003)(786003)(8936002)(6916009)(6512007)(16526019)(36756003)(26005)(186003)(478600001)(66946007)(6486002)(2906002)(4326008)(66476007)(1076003)(8676002)(66556008)(41533002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: ZQF/uwvPGb9Xuvr3BpC98BHomvg/A5ORfZKiiq+MhWR6Pbz/buXv2y/6kbeh39cKubUff+hxQVZ+8iSfn4XtY+HDa8eUfNQ971hCcVZaodhGrOW4Rgv1Sajd2R6OGxIpj+pAePlNfnFesv9MAXQChf650+zqJJboDM0zuiThQJC3yw9M1p9sOkxuT9exvgDkIrgAQlco/fGKRh6gRVosK/Qa1CcY5JtTA5IFU5MqN+qphtXYgPJv3APY7Y7CNSGoLDs2qVxorcuyWiwoPjURXa/k3ycitDuAMQEBPaw0yb9iAPLIB2U/kxBZ/aS+C6bC806tDnBitRJLh74oZSsHCSB679OmjbFvPvdgMbaHbMH81igHYHUPyQAqAXKbE340DA2wSwDdVRZmBL9QyCvQOW5DTnvEjJyX1T9zMv86oMBH7hBh+SPKEcJSPpHLvO/AgkGFBbRrvN0eA9kgKKLITRC43hpUDGi4tnZILawIKuxL2niztVXZiNgZ4jJ+6QJ3RAXWTfZQBKuIksalZO+QYHb52FDVY+GSBmXEV/GS8AH5jUmA+HUhHyJWZJugZNYxhnsnSF2m6GcrDC9tCocgnMyEWLN1SILLw8pDImcJ/en8KUvj19cQSS7/XftIWiVkwOrWuJ5a7A77tYJEgGOu7Q== X-OriginatorOrg: bu.edu X-MS-Exchange-CrossTenant-Network-Message-Id: ec91ff00-a42d-40d8-5c32-08d876059ec7 X-MS-Exchange-CrossTenant-AuthSource: SN6PR03MB3871.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Oct 2020 21:09:38.9051 (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: a39nc+3pkpv/TrVQXRoGRNBowqeDcUMfuw1/JYoN4yBT+13wHsR4nWyb0pGjBDM3 X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN6PR03MB4045 Received-SPF: pass client-ip=40.107.69.122; envelope-from=alxndr@bu.edu; helo=NAM04-CO1-obe.outbound.protection.outlook.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/21 17:09:36 X-ACL-Warn: Detected OS = Windows NT kernel [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, HK_RANDOM_ENVFROM=0.001, HK_RANDOM_FROM=0.454, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_LOW=-0.7, 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 f69e9583ce..4ab28c2ec7 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 21:09:10 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Bulekov X-Patchwork-Id: 270723 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 79811C4363A for ; Wed, 21 Oct 2020 21:12:36 +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 A451024197 for ; Wed, 21 Oct 2020 21:12:35 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=bushare.onmicrosoft.com header.i=@bushare.onmicrosoft.com header.b="cFYohg0d" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A451024197 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]:41790 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kVLPM-00055t-Ro for qemu-devel@archiver.kernel.org; Wed, 21 Oct 2020 17:12:34 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42866) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kVLMg-0003C5-5B for qemu-devel@nongnu.org; Wed, 21 Oct 2020 17:09:46 -0400 Received: from mail-dm6nam11on2104.outbound.protection.outlook.com ([40.107.223.104]:14145 helo=NAM11-DM6-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 1kVLMd-00083s-NI for qemu-devel@nongnu.org; Wed, 21 Oct 2020 17:09:45 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ZFx4yEj7NJzNH5WNp35xMALnLQ8LncCXTG2qHEru0gvFz4Fd9434/OEuArKf0atXiHFV1bL3gbjaGhjILqCHgNFpdMZt5g9piOZcxp2jQHgB4GHm+VZXn9FSy5yn3scIp7IHGEnNDiVI4wNbztRS3aT4eaiv6BIuAeC1oIsHxEJodP6qLo7YlpAgPp4XEqkNfWfL8R7l6SP4iJdkMozu+RRrj7SCdEDb7XrLPffhB//TfZcmhNsIjDQ0N2Ktb0qyXkkfP0Be46jdiE9Bsctd9sDec/3MWXTpOOi8MvlT01Mqs2bV8KD1Y4R9A3c7ieGN/Ly9Qi87d2ci48PaNj8YKA== 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=bkqGWl72/AdS8gHMBdKtj4gIFDb8FixmA4rFdZf204Q=; b=FNKpg4Rq/BOBqhoTl9P7CAKVIeGz5ZhkzdvcBJUZRm6Q+HkZo9tUv+9mZHmtgCIp3Z2lryoejkLNjUOtH+/JIypntMummms+IBXQgWZhCiSbSk+uTxph80CdqB2zD+rZoMcoWStu8049pPLrwfNRwcMdH6EdgpucPG1+K9ToyuGobAFOT9dOnyMW/m+XB3AJXIvFrU4hoyIld4Uf6awpUeKjSXCULJUkld3GWTvwexdie0StWq9HHXouMYEPfmxkK9oDungxYtlM9GuwXvuqC5pYmv/chTWf1b5lqYXto9tvvVEA2wbvoaLiBL2X8ZmFh/ll7ZloJD2QT2LF9s0rPA== 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=bkqGWl72/AdS8gHMBdKtj4gIFDb8FixmA4rFdZf204Q=; b=cFYohg0dgvVIUTq4/r25LvGipHWxnrYrxqs/7Tw+p0d959UU8rc0HKg6EejY3igQvSaolprELk7Z88gOcEk2mtWXKf/+w9GfyENsqqWoLmrs7iY3QdNtjt4dpctq6ni8ANBlu/tdvSDgm4trs8EuYPoIAjbh15VGRUAjn6OpVlI= 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 SN6PR03MB3805.namprd03.prod.outlook.com (2603:10b6:805:76::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3477.28; Wed, 21 Oct 2020 21:09:40 +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 21:09:40 +0000 From: Alexander Bulekov To: qemu-devel@nongnu.org Subject: [PATCH v6 04/16] fuzz: Add DMA support to the generic-fuzzer Date: Wed, 21 Oct 2020 17:09:10 -0400 Message-Id: <20201021210922.572955-5-alxndr@bu.edu> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201021210922.572955-1-alxndr@bu.edu> References: <20201021210922.572955-1-alxndr@bu.edu> X-Originating-IP: [72.93.72.163] X-ClientProxiedBy: BL0PR0102CA0064.prod.exchangelabs.com (2603:10b6:208:25::41) 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 BL0PR0102CA0064.prod.exchangelabs.com (2603:10b6:208:25::41) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3499.18 via Frontend Transport; Wed, 21 Oct 2020 21:09:39 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 093ff0c8-8446-4a68-c397-08d876059fd3 X-MS-TrafficTypeDiagnostic: SN6PR03MB3805: 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: bPXyDJBMbljJ+nTw6kWqM4b8pFMhHfVQxRzyO3h6MuA3DpJzrnen26JCtKIDamZwZYdNkpaO7i9Pt8qQSvXCAB0Yyoo2MZhbAhuGer6ZRWA0gKs7HP6YfeIICrbWryeImAQ/4VwlWRG8NAUplHmip3AKhe8FQBYo5XGu62XPAD9Gh3mvwvT230RjuAmaCzZUrDw1Gqkl8vN2QY4gLMffi5PICI58XHDyL01dwSrCkLlwYySXaQ4m+9GIne3VfmO57AcEWQk4W5IWl/2u899ERy8C7OJzvgZpqV6O1NF34qhyIc0myWnznOBnyhbuT0mh1/HG34ahhDhs7lNVlps3JCkexsThOpxfWC50mTJOfP11Qrp5kvVJMPWmth18jcWI 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)(136003)(366004)(396003)(346002)(376002)(39860400002)(66556008)(30864003)(956004)(2616005)(54906003)(786003)(6512007)(66946007)(316002)(66476007)(5660300002)(75432002)(1076003)(86362001)(8936002)(36756003)(6916009)(8676002)(4326008)(6666004)(16526019)(26005)(6506007)(52116002)(6486002)(83380400001)(2906002)(478600001)(186003)(41533002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: W6XEdpGAC0epwfHjm+GwVCPuVBoZKPz3bYqacTI0FnaiwNpbT7p5ETKyyo4hbVtiRL6sjMe6tVTKEANGHprwzLWsHeIOi/Dk9aTKxD5RALDRuKe+1Lj+o6SibMGMs11MWZQtXrawX5GH1TGNUcz2iEfddsZt/gKKy5Hhf/DVUnt9pYhAxXyBdyydCGkPZMtqYZhCIQ0e6bpBkgaX/5RIHIvyY+Cxdy1AuKq0Gm1qn54hAyGGI0IEjpKGxpIQPhOQzz9BV4AW4QiRiZGtf34rYDjOrBY6ui27ywSRRNbiTbPHJfbPXRfT7XB8PWXGLJdJDmwvshKgKFLlw3iPmAF5XzF2H59GZHDnDCMe32No6g3eYOTrXkSGtnBORF0K+dokMM0jIANwStqmAQS84SCA9cz5jN4U3/BHotzU3iXyJTmOVD1YXIfv3pEh5jS2QF9FM/FoF3XpKY4xZpsY9ok7O4k5DNkNMAG1Ax0+dKvyi5qOtM9E6G/Vlsbz6N67Vs2WhHstQXYBt30CI4a3arTfm9G7+tY3pnoBNmWubkQA8Ni4RJXEIRP+F1WquIl+ZfGpWiEHx9Zywe1pf115y2fA4w/tzAzLT/QEmRb/Tk156npgGvj0KZmAH5qIVy6jh2Hz9br9nlCMrRWbJnxSh6696w== X-OriginatorOrg: bu.edu X-MS-Exchange-CrossTenant-Network-Message-Id: 093ff0c8-8446-4a68-c397-08d876059fd3 X-MS-Exchange-CrossTenant-AuthSource: SN6PR03MB3871.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Oct 2020 21:09:40.3933 (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: rWaJiakUJgNWg+gSBwOpEHHHlpINqsrnuhItAl8qoMusmuElEDhotZ2beaA/XJ62 X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN6PR03MB3805 Received-SPF: pass client-ip=40.107.223.104; envelope-from=alxndr@bu.edu; helo=NAM11-DM6-obe.outbound.protection.outlook.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/21 17:09:42 X-ACL-Warn: Detected OS = Windows NT kernel [generic] [fuzzy] X-Spam_score_int: -13 X-Spam_score: -1.4 X-Spam_bar: - X-Spam_report: (-1.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, HK_RANDOM_ENVFROM=0.001, HK_RANDOM_FROM=0.454, 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 042918dd16..93d27bff26 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 4ab28c2ec7..e356873ae0 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(Int128 start, Int128 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 21:09:11 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Bulekov X-Patchwork-Id: 270717 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 0B5F3C4363A for ; Wed, 21 Oct 2020 21:25: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 61B3720848 for ; Wed, 21 Oct 2020 21:25: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="0fCPgezt" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 61B3720848 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]:42422 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kVLbg-0000WE-9i for qemu-devel@archiver.kernel.org; Wed, 21 Oct 2020 17:25:16 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42890) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kVLMi-0003GC-Vs for qemu-devel@nongnu.org; Wed, 21 Oct 2020 17:09:48 -0400 Received: from mail-dm6nam11on2104.outbound.protection.outlook.com ([40.107.223.104]:14145 helo=NAM11-DM6-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 1kVLMg-00083s-C2 for qemu-devel@nongnu.org; Wed, 21 Oct 2020 17:09:48 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=R5i2zG/bWZrG+C6h7SsQ/gF+Xq7gXw+FQWGrVka37vni0TGM0DnBuAhMxOXDrfKfvF9gpwnbEF5RmRl9Q+TJBGEPqwaiXuRVh2SrlpjwcpS67gFdnlRmJ8a82LfeJBEQsPBY0OsYKH5IXEG7UaWG3DqoUaVPOXel87SS1JsdecMzWhY34oLOjT4h+ZWIXZ7Fha0q+JjopIrHpKRxdpc0Gj+WmtOf0AYgB0Gm8Z3KHhF0YvT3UM6n2SkS19ZoVn9IvXpUy+qL4BMRGZXudIb1IpD5n+E5H/pQX8/F71114IXWopoc3zzW8QQ/8Vo2pVd9Vz6xX8KXpvk2Hesy6N+hEg== 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=CJWtcKGdCrIgy+DnhGK07FATuF16MbrEOt6/ngD77Is=; b=Tc/aA2QaOo4lrBWSbw9v4NLJOkdK1SE2uclirURjQQfBVeYb3x81mTdIfFqDEO5TeD1tGxaL69KsIpHB+iI+1GosCyGWnRIPaV84CQThVSdTRdh7RdskgQTHoIA+Ohj5EwrW/+pPGfH5ic4nrBbo2f6lNGXZV0ThClR+z7vhJ7m1fMxoX0WuRPp1CEjCc+2A3dyzdlY4Rm1itz02UO9XTIGn2S45mV6MgN1rcoRG/QO3F1MW13+6C/Eb8+zJp7EZ+ixq/Bu37clCGo2ibBt5t+XjZCtwNCg3o/wry+NROnhCeu7cQa2jsXEwVRmQJaXppLrqSK8asgknfxfx58BsDg== 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=CJWtcKGdCrIgy+DnhGK07FATuF16MbrEOt6/ngD77Is=; b=0fCPgeztKxgKFlFaiLKwSUuw4OtQVVjlt2lu5pNaW6tIvyr5XaGM/bk535arG+mRl9laAUYdOD7NkC0G8Kf3ylOVjqZ14LiBLuXaU3yObBGmDX3Zwz36ZIrPwMlnnBGRfymvR5DttRH+A4dAkir0DGklugZOvWZ5UfwlRf9m3uA= 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 SN6PR03MB3805.namprd03.prod.outlook.com (2603:10b6:805:76::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3477.28; Wed, 21 Oct 2020 21:09:41 +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 21:09:41 +0000 From: Alexander Bulekov To: qemu-devel@nongnu.org Subject: [PATCH v6 05/16] fuzz: Declare DMA Read callback function Date: Wed, 21 Oct 2020 17:09:11 -0400 Message-Id: <20201021210922.572955-6-alxndr@bu.edu> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201021210922.572955-1-alxndr@bu.edu> References: <20201021210922.572955-1-alxndr@bu.edu> X-Originating-IP: [72.93.72.163] X-ClientProxiedBy: BL0PR0102CA0064.prod.exchangelabs.com (2603:10b6:208:25::41) 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 BL0PR0102CA0064.prod.exchangelabs.com (2603:10b6:208:25::41) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3499.18 via Frontend Transport; Wed, 21 Oct 2020 21:09:40 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: bd674818-57dc-485e-1258-08d87605a08b X-MS-TrafficTypeDiagnostic: SN6PR03MB3805: 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: FBhow8vrWRdO1BK7uwnSQeWwcVFFx/FNpBlCsKpD/PbawEnHeOid3Nx7voGr+5JlJpilNXu3UgmAi+ji+HfzE0q6uewp5pJRy/RyOldjbgm+DTcmbC9fhgysXgCOGDrklp9WffqYOd6F8dZVX9yMWOdskWDNVZPzjJX+CCw5gApyqeBW5HT2q8qVzZaH9XmtNXL5n0tI3aeHOVPaCa2BiLHPb1uQUxfEuOJiLu5GvaiXe6/qI809KwxmMubmEHEyd8kACUVLjF9JYZmtO214z7PFRqllutXFs2JSAEdIMGNTMNjDngBsPgrP6f1ZSVm7lFcYLicTfReashTr5IPkIg== 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)(136003)(366004)(396003)(346002)(376002)(39860400002)(66556008)(956004)(2616005)(786003)(6512007)(66946007)(316002)(66476007)(5660300002)(75432002)(1076003)(86362001)(8936002)(36756003)(6916009)(8676002)(4326008)(6666004)(16526019)(26005)(6506007)(52116002)(6486002)(2906002)(478600001)(186003); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: mShhr0UwCug/aEK7ELFEOdOCkKRnBxr4zyz10YO6k9E7diYSC+N5OKlHYWD/qtNEYomfUV1RI8a9YZ6tGVdnwBeuJ++O/KqyVtulUuWRYYUaiu6NnM4KwIjsTIrUVOqZgbLVt51s+mEWQpN0Dp8WFWmJkIgKNf2SqCjQ1QnsnfOWC8NVjpzLJVCYJvp/kBXo0J0QoMg9kI5VCyHMtSH5uL5XWH94w2yTg07KwoxDWBzKWTuS8JF6ngiuJ68cwFkOB0hIIf4L8Jky0o8ro9JqKHXuRaZuHOYsNKxGAR84IXmVhxM4QWokdWxrw6Zm4cQFLuuvGcxf3WrgVuANwbwbLuKzlpxN05qM7QUhQWxgQGp8rGcURgIi3BoihhyMudrp9N4bar2M7+1fh3g6q7QTyuaE/gMbvt1dOoCDTZcggByHZMthmd5DgHZ7u1cD+f6yUWmj8wNugqEnSK2A5asN1p05djTLa7KVPyUGZakTq/th5KkqlZK/GXnmcxbcFhvz009kxrJoqRVLG77u5JyLzQy5I9z7wa1VUi6WPZJmeTS5mtbNlnT67T/7NYsl4BPUBSLChNUus4zTX81ceCCKXK+vmmrpWtK0A5jL+/uVVyFW68wXJpfHGNct1yWhuVOTD54Agf6sjkfMEWnf01Z2YA== X-OriginatorOrg: bu.edu X-MS-Exchange-CrossTenant-Network-Message-Id: bd674818-57dc-485e-1258-08d87605a08b X-MS-Exchange-CrossTenant-AuthSource: SN6PR03MB3871.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Oct 2020 21:09:41.5316 (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: lAntzl2wgwEz13hXzV1nJPlfytADKCKQki9m/czYF9ISx5xLRlgbpiz0Zu91YaNq X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN6PR03MB3805 Received-SPF: pass client-ip=40.107.223.104; envelope-from=alxndr@bu.edu; helo=NAM11-DM6-obe.outbound.protection.outlook.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/21 17:09:42 X-ACL-Warn: Detected OS = Windows NT kernel [generic] [fuzzy] X-Spam_score_int: -13 X-Spam_score: -1.4 X-Spam_bar: - X-Spam_report: (-1.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, HK_RANDOM_ENVFROM=0.001, HK_RANDOM_FROM=0.454, 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 generic_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 93d27bff26..4aaf578ce6 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 21:09:12 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Bulekov X-Patchwork-Id: 270714 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 E8CF8C56201 for ; Wed, 21 Oct 2020 21:32:25 +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 2188A223C7 for ; Wed, 21 Oct 2020 21:32:25 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=bushare.onmicrosoft.com header.i=@bushare.onmicrosoft.com header.b="7ZB3MyQq" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2188A223C7 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]:57406 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kVLiZ-0007Cb-W1 for qemu-devel@archiver.kernel.org; Wed, 21 Oct 2020 17:32:24 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42960) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kVLMs-0003gY-SE for qemu-devel@nongnu.org; Wed, 21 Oct 2020 17:09:58 -0400 Received: from mail-eopbgr690121.outbound.protection.outlook.com ([40.107.69.121]:59894 helo=NAM04-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 1kVLMq-000854-FK for qemu-devel@nongnu.org; Wed, 21 Oct 2020 17:09:58 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=SRpeKA4gZ+4tVuMpY+1Na7XNC364UqgoctsKxC0b26ZjSUUgML7R7WIRSMtRMe0XZiyTVEu6wwXGAIAuwkj7H5KdqY4Z2OgbHnyIVc+mFslrpoQ8bV/eGm5u1DN1Cmehe58GddGjJ3mOhbnvt1Xs2IXDtvnKU/qcS67bwKn7w1dk96W1o+g48zW4CeeLbRWm0EZ1PpT0D0lR/+5vPtlGI9Hmkitqy+++7xhnpROinQpBqXQJjtqzmjs7rZtKr+EMq+M8duoNvzf29nf4BfAcuesG2FmcPioXcIbFEtXfRmxYkRndUFFgRWLNqL35W3R+Ygf8o774dfnoaNES46Swgg== 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=c62lnWo4TMSHlW70n/U5wErlOVj2YlTkB4zrOCMyrTo=; b=XOs6sd7v3RdZpYMx7bx9TNx54WgjTviPAHy7DfAyxVOf81/0hdzi7jYw6rP3PKwm5S/+KVDCBg+pk1amydRkkKEFPOISD52F4pIehprmP+gPQKuVm9y+OCGBrUZIU1URelf042puu4ofIEb86du3l+K6cZ51gbrta6Qognmm86b7fMJYXWgypDIXatVuDB/ELOq7wK8AznMb7r5MMEurgMk7ozzYXIWQeTG8+ybe9vMb4iq3Ab9/JIZPvEK4jOLnRup2D9y/JIQx2fSo5sZ1zFF5ldFxewo2wUBsCRzil4cwARTl4lt29elNQblxMWJsSOlyZxCQ44CEOjl7SwE2Mw== 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=c62lnWo4TMSHlW70n/U5wErlOVj2YlTkB4zrOCMyrTo=; b=7ZB3MyQqzQmrPPt/swiPAvuxxqC4e7ZzGPhUktC5gUDpyPES5M7jTBO971SvVvUXGjev2cE03rLLuUyuRRE9TfCgbMEiv1cY+lopqzOhgy45UnoypV0a6rPAH/WP6MaLdQXBB53AiFR+nYKBiEOXu2Bv9GzLjF3RFUP17jX+cdc= 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 SN6PR03MB4045.namprd03.prod.outlook.com (2603:10b6:805:b8::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3477.21; Wed, 21 Oct 2020 21:09:43 +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 21:09:43 +0000 From: Alexander Bulekov To: qemu-devel@nongnu.org Subject: [PATCH v6 06/16] fuzz: Add fuzzer callbacks to DMA-read functions Date: Wed, 21 Oct 2020 17:09:12 -0400 Message-Id: <20201021210922.572955-7-alxndr@bu.edu> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201021210922.572955-1-alxndr@bu.edu> References: <20201021210922.572955-1-alxndr@bu.edu> X-Originating-IP: [72.93.72.163] X-ClientProxiedBy: BL0PR0102CA0064.prod.exchangelabs.com (2603:10b6:208:25::41) 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 BL0PR0102CA0064.prod.exchangelabs.com (2603:10b6:208:25::41) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3499.18 via Frontend Transport; Wed, 21 Oct 2020 21:09:41 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 7cfaba74-4753-407c-b81b-08d87605a13e X-MS-TrafficTypeDiagnostic: SN6PR03MB4045: 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: VMbI7rEC0gvWKUgIST/dUBHXUje9VUMipmqDmCfs1cDW3z0p/wiMg512HysTGXYodG8fIUONaOVCpmxDt8h9Va+6NrgbxMSqksjYwNDtn0BAMiTI1SWjhnmW5opZpxq6NQpQX6NfxWLJ5PRezIL4FoSb5/M8yLV7DlKI3JqpIrhY7pc8yKD/CiqVyORKfFzTufpN18XtT5fKMv6oWQZxKHZT11D8OuZjK53v/hZIeAKzMSwVDxp4NUXTSPSqk8HdA8P+1dSm809zXXsqJaUSXl+fHGybTD6wX1AzINu4+Ap049tQzMuUV6tQfXfTGRjYaO2rKl1l10dMuV5r/OYoag== 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)(396003)(136003)(366004)(376002)(346002)(39860400002)(83380400001)(86362001)(6506007)(956004)(6666004)(2616005)(52116002)(5660300002)(316002)(75432002)(786003)(8936002)(6916009)(6512007)(16526019)(36756003)(26005)(186003)(478600001)(66946007)(6486002)(2906002)(4326008)(66476007)(1076003)(8676002)(66556008); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: HZjd58nB4wka6es+Tg206MpE+Ntoe88vjfVEwJqY2cyLHkhgundkFa49n2K/c+YfQg5MEeiYxQK8f9qJENtjI2f3jFtCRaOESWA40DjwPIYwA7Fa1lijjnA2kGlCe39QTh+608Xb4IGgrtu5VH/ChWziruikkbb4fEfkhckJmspuEvSNhRRdLzoGkAnVXTiNgsRa/0FWbFDQMdAafZLBcMeKqb+nvlgSq9T1o3D/dWccUHZUjyAfleDao7oWhNjMIZmVdyLQNL+j+pvEEkFc2HnmmBlhWdJHsP6iCocqgbno6gukUJ+ZYyunvKCt/Q7m9ySHbWNIxBn0eDomPuTzAnKqJKf/EECi5DWE3lW8Xw3iiONXE/ydpf6EqwV30Oee189ZLWXe64kcaQQhBoP2+FFrpFqLxWtgc2jf8a9MnYiX9/kHK23NtuXDkj++d6aeTrdKzti8p7nCGDwDnUWUcNpHdyOEzg9yoTCeMHckh5s4tAEjdQOWzKUt2SLNKK7LtTkFNslFJA0gGHTHn2lhmXQ4XDf3QtW1vJgCsC3dCXz3CWmeRpk/fYUhcNAvnEzbFDftqyTwar+8zUVIxbXC+5fW621Ukpad49/GMrEgn3+Ddih7jIHZylbin4RO3M9p7iw3mz/V7GCMeDZuks+4jg== X-OriginatorOrg: bu.edu X-MS-Exchange-CrossTenant-Network-Message-Id: 7cfaba74-4753-407c-b81b-08d87605a13e X-MS-Exchange-CrossTenant-AuthSource: SN6PR03MB3871.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Oct 2020 21:09:43.0968 (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: eJz05KFb6KQM5kW7mAFNsAuvs1YYgcAinPRZyovhPPTb3xDCprWlwvMUrniOIRPS X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN6PR03MB4045 Received-SPF: pass client-ip=40.107.69.121; envelope-from=alxndr@bu.edu; helo=NAM04-CO1-obe.outbound.protection.outlook.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/21 17:09:54 X-ACL-Warn: Detected OS = Windows NT kernel [generic] [fuzzy] X-Spam_score_int: -13 X-Spam_score: -1.4 X-Spam_bar: - X-Spam_report: (-1.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, HK_RANDOM_ENVFROM=0.001, HK_RANDOM_FROM=0.454, 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 4aaf578ce6..aff6ef7605 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 21:09:13 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Bulekov X-Patchwork-Id: 302328 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 90712C388F9 for ; Wed, 21 Oct 2020 21: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 D7C642145D for ; Wed, 21 Oct 2020 21: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="64Gf8KW/" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D7C642145D 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]:40914 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kVLbJ-0008KT-OT for qemu-devel@archiver.kernel.org; Wed, 21 Oct 2020 17:24:53 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42950) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kVLMr-0003dX-LC for qemu-devel@nongnu.org; Wed, 21 Oct 2020 17:09:57 -0400 Received: from mail-eopbgr690122.outbound.protection.outlook.com ([40.107.69.122]:45277 helo=NAM04-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 1kVLMp-00083h-W3 for qemu-devel@nongnu.org; Wed, 21 Oct 2020 17:09:57 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=he1sJHOS5weafBlZO600EFdtkaMXJUlHeQXLNFrWzKsYF0xQK7lkAMZpEZULzLD/VTbIwzx7JVwrSc8UVhJW+VLpeoj6iLHen3HFNOpCZ2j2rumN8EOOrIJbdd7Yll8kwl+tWJ4gpsPdUjNOUI27IxDWFzI6xKasehwLHg2hGTLBGeHXLxRwUqIvDfw0RHDyUKwBsT2qG6OFVelcubxClVPrZzSTBEMsPy9IYrSau1VSD6jZ8oIyNG7mzf64Hk1Q++FVtAF+VqjtS+apqpLA0i1nI2ythcXF7TefVtsdGBy5LHrE0EgrT5wMlPtws83TgfFL1euyAFtRDXzVPPO38g== 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=ONf+q0vq8W5rf2FX/Hqx3SrG//MowtFITOzrIY+9iBFdorie285rGaPV1ncZ5MUV6e9IUWMGY+6u7h4dX3UnEhd8GkF3Ou2XlJ3z6y98RnDCgpVkQeteHlXs3gHfZq3TIG1dxryJGPhHp3uQOC7CBYQR+9MffAfG6myFaU/u7Mw5VSA1QJc+/KDIEDuFV1RUIaiikw54bceVQYtOvnB4Rb9+fjfbaL0854nFrlZ7zB8g8MT4Z5UTyOL6KWHvk9bLDwVSwpnQNIso/XWCNF2p6Qks+ZuFlUsaOCaEQQYux1ShnF8aq+WqLWq2fwd7waN3rdygWrRWxYg1l1NgCDzUYQ== 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=64Gf8KW/H5zpb3fD2wvq1Nihaps+nLDkoC0ZX6F/EeE6S65pv60ZMnALydbEY+M9nmBBED+7Yhm35lTsq9ZAt8EjEwIxBxYUBne/saiPsIavZXFaSlKyAvshE7Opgv5yHtyLnEQ/z9tmCgESeB1Us6yZAfgkz9ZGtd+RI3Iiz28= 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 SN6PR03MB4045.namprd03.prod.outlook.com (2603:10b6:805:b8::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3477.21; Wed, 21 Oct 2020 21:09:45 +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 21:09:45 +0000 From: Alexander Bulekov To: qemu-devel@nongnu.org Subject: [PATCH v6 07/16] fuzz: Add support for custom crossover functions Date: Wed, 21 Oct 2020 17:09:13 -0400 Message-Id: <20201021210922.572955-8-alxndr@bu.edu> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201021210922.572955-1-alxndr@bu.edu> References: <20201021210922.572955-1-alxndr@bu.edu> X-Originating-IP: [72.93.72.163] X-ClientProxiedBy: BL0PR0102CA0064.prod.exchangelabs.com (2603:10b6:208:25::41) 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 BL0PR0102CA0064.prod.exchangelabs.com (2603:10b6:208:25::41) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3499.18 via Frontend Transport; Wed, 21 Oct 2020 21:09:44 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 8901c859-1f86-4dcb-1799-08d87605a2c0 X-MS-TrafficTypeDiagnostic: SN6PR03MB4045: 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: Ty3bI9J0wBv3Ey5g4AKQ8VsBoJAsws9OcMix4bayM1HY+y437s/qMU8r0uTcVXftmHVaOLvO0a1ETxSblNDn99nNJ2ZC+ck5cJHRsdeQVe1xArWI17Z9Wsl24u4ztJnovJPl1MG4fwQgOOfEqfsx8yuBmfPkGS/FdtMUj5R1hwsProD0qixmuDsW4LsZMUD9hwNjeeR2dfJM4lkKNrBLAMyrglb/jEaivxJOHIAYsqEJNOFD1Wcypx69DuF9hbBuRauAQqk2hgf/UKRlM92ef8NB6Ylzj7ePBQm3p43gNs8A9RI3GFFT13izjMTcZ3oK49mQ2qodZ+KVTLrj7KDZFw== 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)(396003)(136003)(366004)(376002)(346002)(39860400002)(86362001)(6506007)(956004)(6666004)(2616005)(52116002)(5660300002)(316002)(75432002)(54906003)(786003)(8936002)(6916009)(6512007)(16526019)(36756003)(26005)(186003)(478600001)(66946007)(6486002)(2906002)(4326008)(66476007)(1076003)(8676002)(66556008); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: WNShwcge8O0/YQobMQ0cQqDB8hJPr1wNDX3ONmUgPbiprl3pEoxkZB/ieVhGxzVtDn+v1qpnf96b7OB4c+PFPGN2clF9jGZn9jE8GVglxX2QLZsrT+0SeqZ8hBSj6CCf6/UizFZdDdr3YepgWSjcxs9OWK77gAB7FtfOVYoXWCq4q8wZ6T4cgCFONJH5qoYO+3ONbydnOhRzL/0Fqis8EQToYYnkBKwtT/6TKxI0IboEAE+5nwFXzmbeQfK2VinxIJ//qNlxCM2F/fMJ3H59Sn/HIl96R80sW5bMAzAfj8JpL2N7zjaJjCE3CedA+Dwj56ONStrIktqD4Sr5mVXnUkuYNB/22a8X4cMBRyTAsz3kRxoJ7lkNQItaug2Jy8ccGMLRmr6RlQPEqNtuz4kHYgmSJlboXkY4otWCzSL0YW/rtep5ZX2HNIcTf767UO4Qahas44hr60Xy8Ly2sGSfDKi6tpRs3aryXJPL6l4T6twemzGPrukAkKu41Fyg8PWISUfSvF3KBT1hStsN6pajaNi0ry5C5TEzA7lmi72gWBkcGJ+r2+BXLfkp7sNoqwQqBl4RRDxpyeCSjq3L+TjD6fLsO9Oguc2mpKb3/Cs/LD2JzX6hUu0F4sygP5Wh+RgnI3b2K1lUlZvOYE4mqNowug== X-OriginatorOrg: bu.edu X-MS-Exchange-CrossTenant-Network-Message-Id: 8901c859-1f86-4dcb-1799-08d87605a2c0 X-MS-Exchange-CrossTenant-AuthSource: SN6PR03MB3871.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Oct 2020 21:09:45.5004 (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: 9pGKF3HAFaWA8gOl+vd2MdKbUUQpuuGwMoqcxf9K02maQs2Xi5QMOCxOnIxqdQHo X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN6PR03MB4045 Received-SPF: pass client-ip=40.107.69.122; envelope-from=alxndr@bu.edu; helo=NAM04-CO1-obe.outbound.protection.outlook.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/21 17:09:36 X-ACL-Warn: Detected OS = Windows NT kernel [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, HK_RANDOM_ENVFROM=0.001, HK_RANDOM_FROM=0.454, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_LOW=-0.7, 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 21:09:14 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Bulekov X-Patchwork-Id: 270713 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 37E5EC4363A for ; Wed, 21 Oct 2020 21:35:04 +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 6F630223C7 for ; Wed, 21 Oct 2020 21:35:03 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=bushare.onmicrosoft.com header.i=@bushare.onmicrosoft.com header.b="CVVdag/3" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6F630223C7 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]:35762 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kVLl7-0001Xy-UR for qemu-devel@archiver.kernel.org; Wed, 21 Oct 2020 17:35:01 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42976) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kVLMu-0003l3-IR for qemu-devel@nongnu.org; Wed, 21 Oct 2020 17:10:00 -0400 Received: from mail-eopbgr690122.outbound.protection.outlook.com ([40.107.69.122]:45277 helo=NAM04-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 1kVLMs-00083h-UG for qemu-devel@nongnu.org; Wed, 21 Oct 2020 17:10:00 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=lpEY+n3e4uZMayXN6vTaqiOAXUIRPWc2rCC51VPVW3Xyz5ODiV+U+9WzXagBxu6q+VMQgk/19/u76r5yncHe4JXiU/6dt5mlmMytbkj3kLICT/7R75dq7qWIO/veSP1GMr+KU+0V5aAKCBxZEjctupscKm4dXBMJlDBTLc2U8dMojeIGT73bAwrr50X35UKIz7fnfmeqcXprZ55Q7dLXOm4bxfYIl6CtN3JH/zGuyy9Clhhsb68ZIWP1m6xDL9ZCHKWK1EocyKyW6puYa/N9Uc+WAL8q4t0YPCXBh45euwvbUZCvV2HoAy/LVnK1h4UxetQKS6cNQQ1cGx+5+wHvGg== 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=prR2VcJPy11g1lYvJvOtXdyDVCI7aeQhomYO0r2COKg=; b=jaHOGs0IvpRVOhnsonX4/stfTmn3fWWwtYNmh5o4SgaZVgT2+zeb3x/hjjGgPvep2yMlADN7Hm+wmxyJpmKz5EERC+KD0kdTkzK4asOzxl9BrR+JWZPyNl7NzIUne/1pXiZWmk5seHYgrRJ4dhukcFhg+UAKuiUKXVU4WbNWUVkkEnT3gj5ngObYNSKJOQhTbtmPQUvZ/mPE1pfWIEKwLZHA6abLuJrR20s9ZpGLgIvOcpLbJFmd1oV6PiQisR8GgMfD7ajCQPYod6gwM0APbaskW7RqaME/ryfFsrcyRnsWaNNEKmlIC1cE0IFJ4+nde1HPZEf6e42tjw9DoL4BgA== 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=prR2VcJPy11g1lYvJvOtXdyDVCI7aeQhomYO0r2COKg=; b=CVVdag/3j/JPE4Jz6uI3xrO8Nx+OKTpl5z1ukDEjJ9Uya3aym5pFXoUJevFbqxeY+6hjsBG7L22Q7RM4BrCh+h80F2YKlhsO9IUx5Rw4+zVi17SHQXi6kR9d2YprSnhjgVt2iT5xuQtE0pIF/4moWhOEtmFE/AgczYbNh76OMd8= 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 SN6PR03MB4045.namprd03.prod.outlook.com (2603:10b6:805:b8::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3477.21; Wed, 21 Oct 2020 21:09:47 +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 21:09:47 +0000 From: Alexander Bulekov To: qemu-devel@nongnu.org Subject: [PATCH v6 08/16] fuzz: add a DISABLE_PCI op to generic-fuzzer Date: Wed, 21 Oct 2020 17:09:14 -0400 Message-Id: <20201021210922.572955-9-alxndr@bu.edu> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201021210922.572955-1-alxndr@bu.edu> References: <20201021210922.572955-1-alxndr@bu.edu> X-Originating-IP: [72.93.72.163] X-ClientProxiedBy: BL0PR0102CA0064.prod.exchangelabs.com (2603:10b6:208:25::41) 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 BL0PR0102CA0064.prod.exchangelabs.com (2603:10b6:208:25::41) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3499.18 via Frontend Transport; Wed, 21 Oct 2020 21:09:45 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 8c75b4bb-ade2-43e6-52a8-08d87605a39a X-MS-TrafficTypeDiagnostic: SN6PR03MB4045: 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: Y7wqPmi75V6yDXEEUfVK7MgpMrO+XLiBG5ALhnIk2i+JZaE+G+Uj+BtoQ9r/qkb57mDbKitZhVu3Q+88kFQdquiam6GcHUq3kudEojWX2Qt9dI9J4NkKTyw0qfdnLPjY0o3X8Jir/l1voDFcH5gk0iDXy5msECBBHE+pOgqSkA47TAGj1R9DaOgEiVyMAwMHlAVki7MDKXwCjLgTd0/kQG+fFODF3RBD36DCO2ig17v46dhMbzvhH0cgke9C+Tnt2m065MbfA3kt5ytJAAaZC41tTqMurZ1dFxGHkRC1iSREssa4ogwaXvZgmLJP8RsU+Pj6MRXzu0fD2LrPNhizczR9qo+SAg43OE2AwItwd6Mt3yZQQGgB/f6PZ9QJ8yY3 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)(396003)(136003)(366004)(376002)(346002)(39860400002)(83380400001)(86362001)(6506007)(956004)(6666004)(2616005)(52116002)(5660300002)(316002)(75432002)(54906003)(786003)(8936002)(6916009)(6512007)(16526019)(36756003)(26005)(186003)(478600001)(66946007)(6486002)(2906002)(4326008)(66476007)(1076003)(8676002)(66556008)(41533002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: fT5wo5Iu3fPBfZg3CGKqmNS79BqcXPd2VqfkjusnhduEeAt4rGkcstUxAjnQZAyE7zkt/J6/nBkGvy59RzBfM4rt5MUwDgQDWPHguUJHnNIrZnuXwo7FVH9U37ytfCOT+MGmHX5Eg3zGVt+0ZyhuMWdIteuww35LTVauQPQW9AcTPTu8qURmvmkd+R0TGgEliBEJFrYfZvblLojhmNz+z56rHcngomgz0r7NOFjY5+ynmxYMaIMEp1vTDs2qbydk2iUeNEN0zKWkaWpRGQXFnPEHSmUZ6T4GiVpw2rVZCiAOwsAPAWpFEkHsf7S3ICKjcOBjITvHg8+ni/bF+Q5Wn/pRI6OMP5MC5sQ3W0cftii4LlIp69J9lcRQl6V4mjb5AEgAhU2Zqag9fV8fVrbvEXuXDdjuhJoBDShoAbRs2CqXk7+iWKEBERyU+3VRtBYUMd1kYSjqiKorUTgivRteDEO4aWjRwxLVwq5o3TIZm7w9yDHsGXE0tGZTCyCO6153qQWob6qB8RzIY8rAgmo2ZTPCh5NHXB5fx/iS1ULiRv7n4BSvBa7fRW/dR2l+OTAcwXyfEWhTz1z7pK0h9XR+fF8MyQ8Uyg1eahNt6t0m1stojQfblhuJJNiwO9Rj+QrsVM6/LzyhwOWcCff/0Qis5g== X-OriginatorOrg: bu.edu X-MS-Exchange-CrossTenant-Network-Message-Id: 8c75b4bb-ade2-43e6-52a8-08d87605a39a X-MS-Exchange-CrossTenant-AuthSource: SN6PR03MB3871.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Oct 2020 21:09:46.7057 (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: 2DncB3zMIy1QjscC4l433gkH0n6uV24no+M4vs5xMI88pNWedqAAuIOoNiRFOEF7 X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN6PR03MB4045 Received-SPF: pass client-ip=40.107.69.122; envelope-from=alxndr@bu.edu; helo=NAM04-CO1-obe.outbound.protection.outlook.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/21 17:09:36 X-ACL-Warn: Detected OS = Windows NT kernel [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, HK_RANDOM_ENVFROM=0.001, HK_RANDOM_FROM=0.454, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_LOW=-0.7, 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 e356873ae0..fb8bf4a112 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 21:09:15 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Bulekov X-Patchwork-Id: 270715 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 8CE66C388F9 for ; Wed, 21 Oct 2020 21:29:02 +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 E5B43221F9 for ; Wed, 21 Oct 2020 21:29:01 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=bushare.onmicrosoft.com header.i=@bushare.onmicrosoft.com header.b="eQhtttzx" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E5B43221F9 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]:50744 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kVLfI-00049c-MZ for qemu-devel@archiver.kernel.org; Wed, 21 Oct 2020 17:29:00 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43006) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kVLMx-0003pI-3x for qemu-devel@nongnu.org; Wed, 21 Oct 2020 17:10:03 -0400 Received: from mail-eopbgr690121.outbound.protection.outlook.com ([40.107.69.121]:59894 helo=NAM04-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 1kVLMu-000854-8e for qemu-devel@nongnu.org; Wed, 21 Oct 2020 17:10:01 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=k6Yx/slHYmxJjh/E92w+Hs3DXjCQ9fbD4aypOZUdxE1Ag7UEvJc1IgBOSCB2/GD57w8dsyxB9rZ9oSWYQh+VcAWFpJC1dsP6Wp4waZVVmsYKdQIN1hBc3EXWENd3NIQ4luuZXmGGDstxxA8ilXxDIms6GreHEyB6UzALkweSsvfxZHXfoJbrt6BrSilXyne3jC6fqeLhoT3Uanfsl3wGutWh2LjMR4tlTpe8xQG6cY2I3/n9F98JDMyeNrUBAY4vmQy9XNsNBdS2qQlZm3qbFUTq5YYtmIb4AdZQlmdpmVyvrI+31yzeMb7Ztkns35t1vf3LXbNssyGPVpJ7KGdaUQ== 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=gxNMWGYIFb0Nkl764JduutpjvICbdzPu7mim2ONy+NA=; b=DGpha6KM4U9yvxZu5ohhXA0MKdF60Mf2pGWohgRwZBd1tDCVs0FyCX1oG1y1/yBnSLCf6u+dQ4aSRHiBAM3FTUOrJP90GEHMSpzmIO4F5I7nRj1maOIWLnywLhsys0txf+oSzvbb2kSthNNn6iGLbvNz86jdXm8mauwFlAq1sTZ/yLU25g9vAPl9ioAj85cn/81BxUhC9c8S5iUFiue2wb7jw/3Ko2TdOWGfIqVV1j6a8w5MhEr7NP32zobEFEHKITPR9PH87cY6ACtRXKUAnWnN7kUpaQdJNoiBGFtWo4HcVQn6ls8L9a6JMm7OAszv7c3MuqFtE0g3E50MIf3peA== 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=gxNMWGYIFb0Nkl764JduutpjvICbdzPu7mim2ONy+NA=; b=eQhtttzxhuKy3QsgOgOa9CzfkB5KYR8UuxwKqCx8U68bCmuwc308f6BQl1Z8UPSEQPyUvT2M9UCaqeRWSLUGs+BYVp3ZCu4RyY8dpiSDsIyp7GdKWgQdv3w4G9Y/zAYQqJmiI6vpn2TYsmtQiyq/81eU5WhzIPSnE/RnqMC9VKw= 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 SN6PR03MB4045.namprd03.prod.outlook.com (2603:10b6:805:b8::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3477.21; Wed, 21 Oct 2020 21:09:48 +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 21:09:48 +0000 From: Alexander Bulekov To: qemu-devel@nongnu.org Subject: [PATCH v6 09/16] fuzz: add a crossover function to generic-fuzzer Date: Wed, 21 Oct 2020 17:09:15 -0400 Message-Id: <20201021210922.572955-10-alxndr@bu.edu> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201021210922.572955-1-alxndr@bu.edu> References: <20201021210922.572955-1-alxndr@bu.edu> X-Originating-IP: [72.93.72.163] X-ClientProxiedBy: BL0PR0102CA0064.prod.exchangelabs.com (2603:10b6:208:25::41) 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 BL0PR0102CA0064.prod.exchangelabs.com (2603:10b6:208:25::41) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3499.18 via Frontend Transport; Wed, 21 Oct 2020 21:09:47 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 85e73c19-5741-4296-8f8d-08d87605a459 X-MS-TrafficTypeDiagnostic: SN6PR03MB4045: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:7219; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: BAs9+5bXW0e8u+9QDDGMBwboX4a6oACTmEMtE5q/5ORi7XYyAlwmzO3/cTnOvW24CffFKC5SDH/BGe781RRWtg8U9FJ5IkjiPTxHuVwZuiaFheZYrWAqCIzFNkDZFgFsAMmZATj7/sK8qeKa7YPtSm6U1QNRVO6ALj7GR2oj+ox5Y+/A7G834hTOPwbYFXAkbAQD+7yWbvFh3crcga42sC35a5i3vG6wcxbn5HeATU7437i5CX2BPlwMUAcdEHJtYLxStCzoHfFxTkB2op4qLctuCiFfMEuZjrjYo/RggiIRK2K1P4wIcY+NiCx/DeplZo1ZhD8tsepcwoxzq2hAkxzGGORv6l0o61XNSxUWOr7KDc1MVfDzdg224IRb4I/8 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)(396003)(136003)(366004)(376002)(346002)(39860400002)(86362001)(6506007)(956004)(6666004)(2616005)(52116002)(5660300002)(316002)(75432002)(54906003)(786003)(8936002)(6916009)(6512007)(16526019)(36756003)(26005)(186003)(478600001)(66946007)(6486002)(2906002)(4326008)(66476007)(1076003)(8676002)(66556008)(41533002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: Km1xa3pjfHPIBP+ndJhpvSD79qNTrlz55y1/CSDmk2NeUAhEIYOr1U7R8Q4Cx8u3KHTU90bQavUV9xtV+ygI9f8Dy1NMvR7AGk3AZAawCh7GXLZM191Dkhjac+g9ej2SqnJNSCw8KmE/Id4mz56KeMo/V+7uBRGYz2E8rVTkjkP+/4yltrXvI6h1Q8xjlXsszuZ4j+jo+x85VwNVq/xd+BM8ED9yKtUzMsK/D2PJ2dK93aTQvXhvQdjd1G/mJT3T7WEZfizPc3RH82gLKpqtAuI+badJ3WBu47dgE8nuA8bkXxCFqZrNjkrlOKRR1cGuqOTvjAnMtdfurK3DnFCd6WcT9nbPRuBsVjew1z1/826mClT7crCGlmLGzJOgqRcmBY8vxjyHO7mdJ9yxwfJan+5BKtU11+orM4Tdba875SjWkBY5O6Yp6VRlQkNkbPIvRZQeknxLiK/y/CRFGROswBqeyDEHlkh+uk82XLI1zFkT8Kml3K6NsqXbPbJUW4C77Tde4gVKua5P+nMmT2HRTBYNaS5lX+n2WhgagBGKy0s1HKU7azuSq1FSWsz/WhgM1spKtLlyMKDvnIt6+Bna7W7qQrUodwCXb/pN7PwBdrsvtINds8lEOQtKmCD2h/ldSHdGm4ZZ0stiejZ+0FMTVQ== X-OriginatorOrg: bu.edu X-MS-Exchange-CrossTenant-Network-Message-Id: 85e73c19-5741-4296-8f8d-08d87605a459 X-MS-Exchange-CrossTenant-AuthSource: SN6PR03MB3871.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Oct 2020 21:09:47.9150 (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: 906lw8pPGDIwb4QGGiVE6Lyq7aKpYiMi/VEv7+LWjyNjy/iUgcApzWxsDPJCVWSE X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN6PR03MB4045 Received-SPF: pass client-ip=40.107.69.121; envelope-from=alxndr@bu.edu; helo=NAM04-CO1-obe.outbound.protection.outlook.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/21 17:09:54 X-ACL-Warn: Detected OS = Windows NT kernel [generic] [fuzzy] X-Spam_score_int: -13 X-Spam_score: -1.4 X-Spam_bar: - X-Spam_report: (-1.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, HK_RANDOM_ENVFROM=0.001, HK_RANDOM_FROM=0.454, 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 | 86 +++++++++++++++++++++++++++++++++ 1 file changed, 86 insertions(+) diff --git a/tests/qtest/fuzz/generic_fuzz.c b/tests/qtest/fuzz/generic_fuzz.c index fb8bf4a112..f739937827 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); @@ -824,6 +909,7 @@ static void register_generic_fuzz_targets(void) .get_init_cmdline = generic_fuzz_cmdline, .pre_fuzz = generic_pre_fuzz, .fuzz = generic_fuzz, + .crossover = generic_fuzz_crossover }); } From patchwork Wed Oct 21 21:09:16 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Bulekov X-Patchwork-Id: 302326 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 43122C388F9 for ; Wed, 21 Oct 2020 21:28:31 +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 76047221F9 for ; Wed, 21 Oct 2020 21:28:30 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=bushare.onmicrosoft.com header.i=@bushare.onmicrosoft.com header.b="skBG8XcK" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 76047221F9 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]:49188 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kVLen-0003Ta-BG for qemu-devel@archiver.kernel.org; Wed, 21 Oct 2020 17:28:29 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43018) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kVLMy-0003qw-UV for qemu-devel@nongnu.org; Wed, 21 Oct 2020 17:10:04 -0400 Received: from mail-eopbgr690122.outbound.protection.outlook.com ([40.107.69.122]:45277 helo=NAM04-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 1kVLMw-00083h-U5 for qemu-devel@nongnu.org; Wed, 21 Oct 2020 17:10:04 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ay9vA1s0SKvbvJBKbfS/goJDz2uxEyxM9b9m24DBOkzVkq8YOXUga88HzNfiIZWI9kuw6gyxFzKjbnRZ9xCIc5D7by0NWuC3eMA1zYLqJxToUju3LsdsbsD6WeQTrcVF++M1I4w76wmXyJavlk9wBWvNs4MhFWqaqN/oCXveubQCp71uuLqwElcthCpcawAoMQy8u0Kwfba6M7cB6Kj7lb0DPtcAM3t+gq1ps4IqlUWjC1h63yHPQKBf742fYgVBbOPdtq2PfaN3C8GgubdOEkbmKVL61POsGWPsNl9vjPR6x5nQAlW6sqwJsggY7qqMunGwJUDWiFRVbZ9L8pFcIw== 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=q+XUaLwe1R5Fqm7MRcPnIpqJcZJrniiyxg7bx88+/2Q=; b=GZlMpQap9XJBoe/l3dayquYsaU0q7nmweAbzm0L7xbBYp1QnJphu3XRTHrG71DeCqQlcAifXLNc5agKkGHhDNYhC8pjENO/X66kWPh2Q50KvN5c3eajBU757Yk0axiE75Jq94N3OyqgdhZYdFsBnLOn9p3UTcu3IoHMVcEsq5gdKf6S5XRRfY+CTOE3HKj8pYRva9MznCjyQPN5F/pHwobsPSa53lXwAVuSev7XU2ZtZwUAOgfLhBR1Kh7JjCQ91sk6wYoup7WMD+FBWKmJHOIjsJSUdz2KiRPeHWw+hiRmRqoU5XrIL11RyC80Du9p7X0byuE9HbR87JMuXClGRgg== 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=q+XUaLwe1R5Fqm7MRcPnIpqJcZJrniiyxg7bx88+/2Q=; b=skBG8XcK1UV+dLzqKVoMFxHbCpZpJ5Db17OegjBu3ffgq0DMrE5IlWORDNt0wWRDJvZ6NvlWvoxd+h5SwV14vZouTnHsc4P56m3nUHIXq3deOFv4hDXo1oLQEaazJsKbdWrlKiGxGgIM6mhmKnFYQznUvZtiCTk2r46lHGppkq4= 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 SN6PR03MB4045.namprd03.prod.outlook.com (2603:10b6:805:b8::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3477.21; Wed, 21 Oct 2020 21:09:50 +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 21:09:50 +0000 From: Alexander Bulekov To: qemu-devel@nongnu.org Subject: [PATCH v6 10/16] scripts/oss-fuzz: Add script to reorder a generic-fuzzer trace Date: Wed, 21 Oct 2020 17:09:16 -0400 Message-Id: <20201021210922.572955-11-alxndr@bu.edu> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201021210922.572955-1-alxndr@bu.edu> References: <20201021210922.572955-1-alxndr@bu.edu> X-Originating-IP: [72.93.72.163] X-ClientProxiedBy: BL0PR0102CA0064.prod.exchangelabs.com (2603:10b6:208:25::41) 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 BL0PR0102CA0064.prod.exchangelabs.com (2603:10b6:208:25::41) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3499.18 via Frontend Transport; Wed, 21 Oct 2020 21:09:49 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 1da3265a-746c-4ed7-1337-08d87605a585 X-MS-TrafficTypeDiagnostic: SN6PR03MB4045: 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: t8dKizyyCw1gyXEsJoh9/+cchST4YyNauZZIylR6ERt/ggRkv38qr2nkaiAzCiutydl6dCuBCEx7ttxUvjFse+4B5LxKRLKmrbsBENEvGn87eomZ6UZiiMiir5APm4txEUDNu6XPod1kQf5hTbld4LhIrYwAJvpJMM42XUS7QrmRAJAh24KY5UBq348biTQdaYkSEB/JOmflu/+qHkaAwo2vfA4TTmDBp8jv58jcURlopaw+UXY4xvHTRuDOqCHS6KpERom1uWCu62gqvRVHsw5/mLYECt7xaoZrXB8TRNZJhuWv39F/mCGPuoDEZpnVae2f9JLGmjDjJB29CTdrDLtZngbS1y8FQOVZMhrKCIMhMluBURG5IjVjH5mrlqV7 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)(396003)(136003)(366004)(376002)(346002)(39860400002)(83380400001)(86362001)(6506007)(956004)(6666004)(2616005)(52116002)(5660300002)(316002)(75432002)(54906003)(786003)(8936002)(6916009)(6512007)(16526019)(36756003)(26005)(186003)(478600001)(66946007)(6486002)(2906002)(4326008)(66476007)(1076003)(8676002)(66556008)(41533002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: lUyhmb1bQAlfXcZI0Wyx7zvd35B9BSQA2xof1xoynGupm2ulcE5nVXmOp1LQvmfMYDKQ2rTAB3AKkWkw928yGbHUsKmKDcszdeK2gQCwqW1jxtySKUxuEunlI8Pn2VP5TzSupvRAu5xEIh2w1rx4oT6J6CudcU9kMquPla7h+Q9+ChHZtVR7LC92sz1MI2NyDPPUAUlmzvjBi6mhSgcTJUhPRkiNiGYdgEt9OtN7aaDjzxWORs8I1Ud2Mv9eJC+0Mf9uT1euWdZE3rJOgB6AM1LnrbNcYkVlEfldXW35RxK4GygHgXsnMaB7NKytuQK0rbg//s16LS7yU0CPxmKUr+p93Mfi/+2uh7EFgaNWUAG2AxsXfVrC4Ggb+9w810DdVUns6b5SeqRJXBd3RCoR7Ywz7w3Sk9Fv9ST/Cu2C1ysURYEZMyCG+Zy8LjQWQLIXrPZqdZXVbULaIqHdwtY7RY2Ve21U/2WHvQJ43D7VJesonLiDSW8zA5KABVE785Je5ioXcOAfFafmM5WEIeWHFssAQsGNoeqVAALZqbzxhaO1Bws3GP5GLkcL7L0QPHgMQjc0wac9RmCLLoCmEAD+mJuE+dCbd8uaYoPA5Ks5wcFI1lEOqoxTIm0c857K2N/gO6YwU7EZGnsuFMHvf8w4bQ== X-OriginatorOrg: bu.edu X-MS-Exchange-CrossTenant-Network-Message-Id: 1da3265a-746c-4ed7-1337-08d87605a585 X-MS-Exchange-CrossTenant-AuthSource: SN6PR03MB3871.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Oct 2020 21:09:50.0069 (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: w9U0sk1iZWYCLt7bzCbRjaXJUv5a675DzLOKShbqSuQZIsyK8C60BeW/OPZQoAkC X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN6PR03MB4045 Received-SPF: pass client-ip=40.107.69.122; envelope-from=alxndr@bu.edu; helo=NAM04-CO1-obe.outbound.protection.outlook.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/21 17:09:36 X-ACL-Warn: Detected OS = Windows NT kernel [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, HK_RANDOM_ENVFROM=0.001, HK_RANDOM_FROM=0.454, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_LOW=-0.7, 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 generic-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 generic-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..890e1def85 --- /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=generic-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=generic-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 21:09:17 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Bulekov X-Patchwork-Id: 270719 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 C51BAC4363A for ; Wed, 21 Oct 2020 21:21:40 +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 A34E924198 for ; Wed, 21 Oct 2020 21:21:39 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=bushare.onmicrosoft.com header.i=@bushare.onmicrosoft.com header.b="jv5OnELh" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A34E924198 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]:33260 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kVLYA-0005C2-Io for qemu-devel@archiver.kernel.org; Wed, 21 Oct 2020 17:21:38 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43028) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kVLN0-0003s7-Eh for qemu-devel@nongnu.org; Wed, 21 Oct 2020 17:10:06 -0400 Received: from mail-eopbgr690121.outbound.protection.outlook.com ([40.107.69.121]:59894 helo=NAM04-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 1kVLMx-000854-FH for qemu-devel@nongnu.org; Wed, 21 Oct 2020 17:10:05 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=l1ns0SXcpTQuNSbxy+EDmcX2AI08cTcNRCg4IcGGuzMLaMnoc/dJss/NyAADcZ5Q5/j8DnT/56G6tjWS5fUOSUeMXj2U3e8lAKS+j1Eg8l1F1BI7GRfdhcUso4RoRoePx1dy2iN3gXYm0ApBg3BDrwwHxB5x+tRcC26khTJslrgHukx8w4CxaAucQ5DNlbEOz/wZKLeH8sY7i65I1lxxZUpBx9fja7Mwb6BUWAXqT+XIZ84h8xlf20+Nh8uW5i7lz7EIeWpsGastmUWhPzxx515rLgkSs9vJE3yv7wxGawKAT/vGyvpBukU97C8mrGTT928AX+lXTUoP/L0SsZQgHg== 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=PfCjRvO5dWo6w8rmj2GOemCET8su2yi8elsQQcNhtfyFldmkoK/NY6i+flyLMHk1disZUY4UnCoGjPlH0vErdtWyoTZwhe7Bk5hwob6hDZugATGN/njmGfCRLunBZUSStvhRYoSmr6zHNT1xAPIlAeikkR/zdeoPT6R3DvHstMxgwhjjacIAeYz0meWCpjZeNkcG7KVZmmC4w3vK9wny/ah9mTgHIq3lOnweFsC/UE0HHOXEABKoVl4ACpu+pI2D3BYfWOjDRBrPbtAE/X/Kq5sO4cEmz3W00on0eGDQGbPM/aZHfZUQ+GT5fvqxv85BA6Jdv9MrindwyPCG8R2efA== 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=jv5OnELhG5vVWpURyM6IupZ5MkyjL4dMTkj1ma/FVL9D2WrJ47Cbg/ky2c50maALD5P568bkKLsbtf8BAfIiTDtbTj3oeLkbFYzxrOW2b1tsbdY4NS5uAhFuzEIGcNPWcVcG1KZJqYHCYqizuJzjhXTr7yTTzg4HT+VsHN0KYDo= 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 SN6PR03MB4045.namprd03.prod.outlook.com (2603:10b6:805:b8::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3477.21; Wed, 21 Oct 2020 21:09:52 +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 21:09:52 +0000 From: Alexander Bulekov To: qemu-devel@nongnu.org Subject: [PATCH v6 11/16] scripts/oss-fuzz: Add crash trace minimization script Date: Wed, 21 Oct 2020 17:09:17 -0400 Message-Id: <20201021210922.572955-12-alxndr@bu.edu> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201021210922.572955-1-alxndr@bu.edu> References: <20201021210922.572955-1-alxndr@bu.edu> X-Originating-IP: [72.93.72.163] X-ClientProxiedBy: BL0PR0102CA0064.prod.exchangelabs.com (2603:10b6:208:25::41) 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 BL0PR0102CA0064.prod.exchangelabs.com (2603:10b6:208:25::41) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3499.18 via Frontend Transport; Wed, 21 Oct 2020 21:09:50 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 9f8743ba-9208-4158-4890-08d87605a673 X-MS-TrafficTypeDiagnostic: SN6PR03MB4045: 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: KkX2YSJo3v/vV1OFOxmRWbU21lUfpF8SucjwnsF1na4/ApdMUXgstYHmCo7ZZ+5NDNdhO8dMnuXhzDWwG88ptqkQAFaBejsJ+IZmgo5k7lhtCTtKUla3kxzJqTrWI+qRMEH2e6s5M3+ZppCCmpt3D15cO7q//gaj/6NGtqQiMZAWo3E3IvxwxcIrfv4LQ/43OudgUlZr7R4/MRLiCBthNzOzgWAsfr3bC8CNlLN2dv0PoAnOLCJkEWh3cOHKkYHvXosqHJS1Tqnm3ow0zKpvwL9fQVb45CewNCPbzzMDZJGKXL9fqzGuB8bgrXOgRAtkPEAwVFdSExpO3pY4U9BIuw== 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)(396003)(136003)(366004)(376002)(346002)(39860400002)(83380400001)(86362001)(6506007)(956004)(6666004)(2616005)(52116002)(5660300002)(316002)(75432002)(54906003)(786003)(8936002)(6916009)(6512007)(16526019)(36756003)(26005)(186003)(478600001)(66946007)(6486002)(2906002)(4326008)(66476007)(1076003)(8676002)(66556008); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: JASsFSwMZ6xLAnoryZldX6eOcp+qolKREKQ1Lxx6J65NteVW8ZOTxuuCxJ15HhaCSpxZoqDIDgns4qeynsL1e6RFttiqvxIlyv20rGcOoErGwj/aYBep2m60cvCsoIcRDTrEPmZ2GWUEvWpKyMlbekmWB9EMGUkyQK857ZR7gPhbbO9AhuB+xkODRHCgSSDseSvrcMxNmR0XJGug+4w46UlSN+T7g7L9lSCTn4g8JS3yg+5FkH9mxDwdE2pyYTl9puLCh9LEdZmfFnylZ89Dqd7RrLSgi6alrGb2j74eo0X4UwwChN3Y6xe62g5LFB0KFxPGcmq8qTpGYwT+jZVdMyplzRPbIonQfSyV1FDFfJc3OK7bMDzxUQkYaCEw6hWOQftQ14j96O2TP5JGKNwQcmwSR/RC+P6Mc7rhv44Uy/8cdut/1qGUwHdqfZ/5trksQaC5jX50NIIWwrGCSIDi1BtbpqCLPI/fZkhkAM254Bh7txE3w8N5wDftKZHLZW/QsVyTfSLxjgzSBAKl7p9+HCr49JR9+jvP1zZOHqlP3KVS/lYmbkC4wTFMhpkw99IUT9/thtbUvQpVmgY6TOsw8CCsFfpFESX12WpXykxviGAFvTlkuOvkjhPi0fBM1ru1NOelK0js1TfGMmZQQbAZ0A== X-OriginatorOrg: bu.edu X-MS-Exchange-CrossTenant-Network-Message-Id: 9f8743ba-9208-4158-4890-08d87605a673 X-MS-Exchange-CrossTenant-AuthSource: SN6PR03MB3871.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Oct 2020 21:09:51.8528 (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: /yuswq9e09MIY9fuNgbtqmhvbyzyVfXG+MC8SZLwV/g+drnSXuMke72PJ1RQtk4f X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN6PR03MB4045 Received-SPF: pass client-ip=40.107.69.121; envelope-from=alxndr@bu.edu; helo=NAM04-CO1-obe.outbound.protection.outlook.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/21 17:09:54 X-ACL-Warn: Detected OS = Windows NT kernel [generic] [fuzzy] X-Spam_score_int: -13 X-Spam_score: -1.4 X-Spam_bar: - X-Spam_report: (-1.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, HK_RANDOM_ENVFROM=0.001, HK_RANDOM_FROM=0.454, 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 21:09:18 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Bulekov X-Patchwork-Id: 302321 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 A6281C4363A for ; Wed, 21 Oct 2020 21:37:56 +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 D8DAE223C7 for ; Wed, 21 Oct 2020 21:37:55 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=bushare.onmicrosoft.com header.i=@bushare.onmicrosoft.com header.b="wgzKkVnm" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D8DAE223C7 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]:43140 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kVLnu-0004xg-Ry for qemu-devel@archiver.kernel.org; Wed, 21 Oct 2020 17:37:54 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43050) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kVLN3-0003uO-1t for qemu-devel@nongnu.org; Wed, 21 Oct 2020 17:10:09 -0400 Received: from mail-eopbgr690098.outbound.protection.outlook.com ([40.107.69.98]:60229 helo=NAM04-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 1kVLN0-00087u-OZ for qemu-devel@nongnu.org; Wed, 21 Oct 2020 17:10:08 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Cmk79XyK9at51ZYYrP9J3D6sBWQAC2dS7hV2YB817vQjj64ncd6YkGVdICM+BonCcPoTGEp3k34whAYdeqjeljKUw1ctNDwfKpfx+EoJQ5x5dlxBlcm75LvB6YwXi7KBccZCRLc750VS2mUMcJAp5qPERhl65sYSorLMvp8lF/FzEW42KUlG4siGZaS59E18LsjGdj0zqpOmEHjv1QZllG7dg5MBgiT2hVSNiERfgcfR56grZgpiLDvKCBcAa8d+NlUiegJU7b8F6hWhub5CFhKFpd3Y8QkwdpScTOrzJ4UJn0qUh1jhKIJLAzvifa/RclMQzI+fAZ8Ky7SCrNm8gw== 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=hrRR7nYIMtECdJdBZYUDCaRERiVxsTzNuITF8efYZ9Q=; b=jtzeqaqlADKFVGEU6BD9iqX6b1dRFSmOFbE1Z4kUXnrg3qSPaLpuf85PgueUkXaPVp6HMKfhbhHhB7XloP+6A6K4J6f9nc5HWOcpC5RrtZs+Bc4059Drdehy6LN+2S9Rx5+yTItXw652RRLhGogDS0cf06O3erHgfNpmZU72YfkdYKTVRY8MQ91QOirKk8pZPY7F3S9u6zpDjMh63Gtl8Z8iN0DdoMuyjf40UPPx2Px2YoCNSdvPviSI696IzE9S1ukTO3lIy5XV9sB/p1NMKHzsErjM3FXDV9lmOOToH4bFjCqswBDMmP+tvOHiLavrCt5jAr6LYE3QeOCfC069sg== 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=hrRR7nYIMtECdJdBZYUDCaRERiVxsTzNuITF8efYZ9Q=; b=wgzKkVnmiXt9yAyACiTLPvDHhkEYXsK6hWrgleVY3phOI651vm1kqiQdHNqjGw4PFhjx2m4yXyTcpKX4JPn8nQpJO84reWijP3Bbbl7mb+kZ+2ON84x/pF3SBmv0EbhxAWqnhm+zceqDKcKuL8vJ7FW/vM2XIn3vmS0/fHvY/Xc= 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 SN6PR03MB4045.namprd03.prod.outlook.com (2603:10b6:805:b8::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3477.21; Wed, 21 Oct 2020 21:09:53 +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 21:09:53 +0000 From: Alexander Bulekov To: qemu-devel@nongnu.org Subject: [PATCH v6 12/16] fuzz: Add instructions for using generic-fuzz Date: Wed, 21 Oct 2020 17:09:18 -0400 Message-Id: <20201021210922.572955-13-alxndr@bu.edu> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201021210922.572955-1-alxndr@bu.edu> References: <20201021210922.572955-1-alxndr@bu.edu> X-Originating-IP: [72.93.72.163] X-ClientProxiedBy: BL0PR0102CA0064.prod.exchangelabs.com (2603:10b6:208:25::41) 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 BL0PR0102CA0064.prod.exchangelabs.com (2603:10b6:208:25::41) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3499.18 via Frontend Transport; Wed, 21 Oct 2020 21:09:52 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 03f08d27-8152-41f1-cb66-08d87605a76a X-MS-TrafficTypeDiagnostic: SN6PR03MB4045: 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: YG21RJVF8KyS7Am8rM3dbjQvdL3BpwdYY/rM0CKrH4U2HZ5jmToMm2m3tWbRNYtP4nw2MI/F6e6oVfhL4iV/UYKgkE9xq8bMoMW0A24KhqM8D3vi38McRe+bOEmGOqwyP7uAhNi+K5D00bs4v0+Odq9BbLNR6oBplxMvm0w0YiHbviqLv5zUeEKCt5Ux8eIMMa9xSdoePdPigizSsD/L1Ag4VnkaLRz0u8TGE3YSXIzjBF0jDwSdTlWlPRnR73/ZMsbFV/xl1VdtIXvdMKxdWUZQKwVOLJTxRIQ13N6lPRynqXdwTeyiIDdvvQbCFwnXbKqq9T1Ht+wV4wsw1mjuCrOm6e1LnGrbWB//TppupUqxkbDONfCAr7U6hgJZzI1r 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)(396003)(136003)(366004)(376002)(346002)(39860400002)(83380400001)(86362001)(6506007)(956004)(6666004)(2616005)(52116002)(5660300002)(316002)(75432002)(54906003)(786003)(8936002)(6916009)(6512007)(16526019)(36756003)(26005)(186003)(478600001)(66946007)(6486002)(2906002)(4326008)(66476007)(1076003)(8676002)(66556008)(41533002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: Chd9jt0Tu1obzZvWuWpGA//pqPJGP5sPjH90YCtf296D0vPDiJUw98N0krcf5IsGmZcWz3qOamBlKoENiRF/J0wsdtK64e+s3lcl2gNKe2y3iponrPvvhR1IPqrSpScYW11fY2EzcL27O0VTlPp0piD+KiJKuwkur6wDI92Je94UmEKVCeSGjXUYZOzgyw3NwhmjDQgu05ppoR6/KWA0ZB7/93Z1HCZHmDe+KJpn9I1mmJYqNv4l19HXqjj3eG/q1iogucxF++RgGPKEVWVba1m1yOcqsUwNOWghGBff4EZUyi5Lv2TXO+CRnT+5nsJeYtcfrhkSgxwyLrOXIWSgngxRZo5XA3D9nnUFGib7kETC4YSB8EJm/AMsWhugFxfNvndIlPSxZWPDxPQ6a3U+IK6tk5n+R0o9k0LVyhxG/BVHaR/C3DzOh1EpEox7Q8Tmjcvcg+zEkZDmA+OdEIZgUJ4X5dZ31Quk6bnQW1lfcmXoIQfAGjyglWhsuETff2JMhtAzNrilJJN5NXWjN87UfWPOU6gbrp+lzUbu59tT0Zbo/89sXTHxI1nhO40za++JkuI3bfzlTwXj4q7/48D5rwVMX11w8izaviGM6MIirrBePDZDJ2CdvEXB2WY+UnjJ2YBg1ERv3LsqzkCSlsm1Mg== X-OriginatorOrg: bu.edu X-MS-Exchange-CrossTenant-Network-Message-Id: 03f08d27-8152-41f1-cb66-08d87605a76a X-MS-Exchange-CrossTenant-AuthSource: SN6PR03MB3871.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Oct 2020 21:09:53.0232 (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: MzLaZj3W6mVvTndlMfFKSrDENCwaszXCQk9Qdg4sl+lTJPT6bTIhQmTUStNINCSg X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN6PR03MB4045 Received-SPF: pass client-ip=40.107.69.98; envelope-from=alxndr@bu.edu; helo=NAM04-CO1-obe.outbound.protection.outlook.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/21 17:10:05 X-ACL-Warn: Detected OS = Windows NT kernel [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, HK_RANDOM_ENVFROM=0.001, HK_RANDOM_FROM=0.454, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_LOW=-0.7, 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..03585c1a9b 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 Generic 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 generic-fuzz target. + +The generic-fuzz target is capable of fuzzing devices over their PIO, MMIO, +and DMA input-spaces. To apply the generic-fuzz to a device, we need to 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 generic 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=generic-fuzz -runs=0 + +The output should contain a complete list of matched MemoryRegions. + = Implementation Details = == The Fuzzer's Lifecycle == From patchwork Wed Oct 21 21:09:19 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Bulekov X-Patchwork-Id: 302327 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 024ECC4363A for ; Wed, 21 Oct 2020 21:25:05 +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 347D920848 for ; Wed, 21 Oct 2020 21:25:03 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=bushare.onmicrosoft.com header.i=@bushare.onmicrosoft.com header.b="MUJNS5H4" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 347D920848 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]:41646 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kVLbS-0000Br-0Z for qemu-devel@archiver.kernel.org; Wed, 21 Oct 2020 17:25:02 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43052) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kVLN3-0003uR-14 for qemu-devel@nongnu.org; Wed, 21 Oct 2020 17:10:09 -0400 Received: from mail-eopbgr690121.outbound.protection.outlook.com ([40.107.69.121]:59894 helo=NAM04-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 1kVLN0-000854-SI for qemu-devel@nongnu.org; Wed, 21 Oct 2020 17:10:08 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=klefLHG85UNRXjqCR7okK9rh1e5me6TLo4ej+ztfDotnuy7lz4ibOHFVOFCURrJKZBCJmJETlxaxExLu4284qhFQ2kKk37PTiSLEeI8xcJ44EonGTOxJYT/b0AhNmFpQlV0XWOdp+V2MMwHwTdLyO2ChwHP2MoUCL2Jkc+wFsEqsaZGBAsFSQgiW0v+NJ5dLkG8id8E9Wh/6AymM1D4SAQU5FZZZx/la9zpqqxAIP5HVnns9O1R9phpU6omOA498zWvBeNifmHv9vlqdSySaWm88oFjVhQlQX+BrUZksF0R0pMS4PTb+xbOffkmrg37PsEWhes11jv7iLyuKDotgcQ== 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=KzYUGUP4Z7wkXguIJPdVZlGQe66He7jp/uhM8Kbquc26j6vrzQEpmuJSPGlIdualVz8defdl3rZaXdiHz7EBN48lxee8QTiuuYSM/lfhVN6jG4KY6IF30r4yGHmstX9hUZDxvGnMBP5fU13ki3fPAwADH5BxI+di7DMiUAuiEIbWDV2yx7uH5fmyvKMgPm6vUjgrx1/5TJ4iaaQdVzrSHnmA4yIpyHfMGcbHD8aIWv8jGmWgetP0xoTcrbOOV5CRcllc/KE9jzi5BQQq07ZtsbCt52omm+1IR2qVoNAqOl1u8zrOvJwG6RpLXtJd+/YukLPdKSHzTPVd9q8MoRHNBA== 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=MUJNS5H4me0iT5+WOt0zX7v+pu6xsCFSiu7TV6aO2JWgKQ6JZQbCJ+R8dkHG7SByAwX30Qx4PNMJqpp/0SbDv6hpCwkFusvGWbcobkt5aFs3mSjPn4BGYaA3l09c5ePgFNlz2aNbpWMOVtwWTNsMonW+iG0O/tV5xUfQK/4lVyk= 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 SN6PR03MB4045.namprd03.prod.outlook.com (2603:10b6:805:b8::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3477.21; Wed, 21 Oct 2020 21:09:55 +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 21:09:55 +0000 From: Alexander Bulekov To: qemu-devel@nongnu.org Subject: [PATCH v6 13/16] fuzz: add an "opaque" to the FuzzTarget struct Date: Wed, 21 Oct 2020 17:09:19 -0400 Message-Id: <20201021210922.572955-14-alxndr@bu.edu> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201021210922.572955-1-alxndr@bu.edu> References: <20201021210922.572955-1-alxndr@bu.edu> X-Originating-IP: [72.93.72.163] X-ClientProxiedBy: BL0PR0102CA0064.prod.exchangelabs.com (2603:10b6:208:25::41) 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 BL0PR0102CA0064.prod.exchangelabs.com (2603:10b6:208:25::41) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3499.18 via Frontend Transport; Wed, 21 Oct 2020 21:09:53 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: b4fcd7d1-4ec8-4971-5865-08d87605a84c X-MS-TrafficTypeDiagnostic: SN6PR03MB4045: 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: 72/82u0h+ZwTku0lrdqMSFZ2aw/ddXw9bTawG0H8YkeBCicSJRn+qdVXD1DyeDhJv1TAoQ9JVMSJXp/lO4kx5xGrWq9K8s/NXL5OLU8Hvfjdxqfr3Ij8vnLyJmdnwVtNIu306rvYkC83fYEXH4pZRcUBSgx3evOwaFp6mZtA3mB2LnP4lF9Dt3EcbgwL0pU+OHAwG+F74c5QBywog8oft0+igkrH/ZcjLZfEAYO4OMiaryc8Dc+hTms3SWJfXEM7pJpqo3wyC4Ht5Yete4fxyEg7vwnVp52pwmSmLcJPeM0xAcXunl4cCcPJ4phro/0g+mpOCnjvWryXE70C98aXTg== 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)(396003)(136003)(366004)(376002)(346002)(39860400002)(86362001)(6506007)(956004)(6666004)(2616005)(52116002)(5660300002)(316002)(75432002)(54906003)(786003)(8936002)(6916009)(6512007)(16526019)(36756003)(26005)(186003)(478600001)(66946007)(4744005)(6486002)(2906002)(4326008)(66476007)(1076003)(8676002)(66556008); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: Wokg1UlwOr0n0+lQjRL02LK3YsjZdUIIQf4YA/Q6oMxLpIv63ztKTwM01yxx01ltOyCnG3vwuTpLBSaEDIsAAZC7hW+17/cCoxwHkaWCqeCfVk41nD2LDHiXtr50bdML2fDkMCeU517yS7FOz/TeHqyGI0BUhSQRZ9UEkwyDef+cVx3GR+aag2lXRpc6G0jKPPYkx69kZCXYzlVoUASLNSib27IpG90n3F1WZ30Q8D7re71myxfHL56xyPH7Ef2ajkGP42jKU4Jv7WfGqyyyaje3tOsF4XmOm1XkLqH5rBXdomEPLK78IwbOyLukxDC4H8k4U60iDhrriy4CA7Y0lJh21ykeAv/FrPK9OPz6RCnVkrnzuUF58XqGnuiIOFpl5V2HGB12d8DCee/SldafpaHBMWsyc0Cni9XWkd4tQqGnbEQynWWxkf1VkrS/kHX1CWq2HMRJKJfVBRw1+ZTtjw9Y697XWTL8/gZsP+F0bx6VLj5AxfA9GLKaZvvw4znzSicXWUUpkXz+Rt0rs0sglC/T8CUCoGPAGr3wPPKmEI095/baTVn3gnlvvvJiwDkkPKodaJnzX8ebal/i5YBG/g2jf+lRfhY7JYLoC92i3v8nKzm05L/mxofrt4HOEQKaJBqI17rFT27m7LE0Of4ulQ== X-OriginatorOrg: bu.edu X-MS-Exchange-CrossTenant-Network-Message-Id: b4fcd7d1-4ec8-4971-5865-08d87605a84c X-MS-Exchange-CrossTenant-AuthSource: SN6PR03MB3871.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Oct 2020 21:09:55.0420 (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: rtl38Vza5wo2vYsRxwpvxlEWZWQd52F5arH+VvXVgZRwGN6+lcSzx48TGnQ0iYLS X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN6PR03MB4045 Received-SPF: pass client-ip=40.107.69.121; envelope-from=alxndr@bu.edu; helo=NAM04-CO1-obe.outbound.protection.outlook.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/21 17:09:54 X-ACL-Warn: Detected OS = Windows NT kernel [generic] [fuzzy] X-Spam_score_int: -13 X-Spam_score: -1.4 X-Spam_bar: - X-Spam_report: (-1.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, HK_RANDOM_ENVFROM=0.001, HK_RANDOM_FROM=0.454, 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 Reviewed-by: Darren Kenny --- 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 21:09:20 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Bulekov X-Patchwork-Id: 270710 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 4805AC388F9 for ; Wed, 21 Oct 2020 21:41: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 939B3223C7 for ; Wed, 21 Oct 2020 21:41: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="RbrbDAqh" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 939B3223C7 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]:51754 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kVLrC-00007o-5t for qemu-devel@archiver.kernel.org; Wed, 21 Oct 2020 17:41:18 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43078) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kVLN5-00040Z-Sq for qemu-devel@nongnu.org; Wed, 21 Oct 2020 17:10:11 -0400 Received: from mail-eopbgr690098.outbound.protection.outlook.com ([40.107.69.98]:60229 helo=NAM04-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 1kVLN4-00087u-3e for qemu-devel@nongnu.org; Wed, 21 Oct 2020 17:10:11 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=XkZmOKZoQ+7y+ds8fZyvr7eCcaIxil6FbrYI+N65serwRWb7yb8klbYc6tqGoaYAYvR4ykv7OUFi0JoiT018CQOF1GuG9m9tJjdk/dXd2SFQ+S70sUdMiZF0Pa8mgjQyQsYK4pJ9mToTKL2ljKkCXwZ2wdm1qJmNa5U4QrT1+uQtPaBp8diur7wI4Zh6EUmTBRq5Masg9tXyzWLY+iajs/VFAmMPh9n4yZZ8cvAGRbJymn36X005wERPuBkxPG5KkXskXybtZTcR5eel9e9mw/VmpMHiIx8mF/uwvWhsaok/VW1eVK0orrf+JdGr8+NjGPXoJmSGLNyoF9Bg485hrA== 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=5BK40eN1KuFxJSGsahq66EgtM3CjPt47xb8vSELlLEc=; b=iJsW2/YFoDaejgpoP9Dx7Ja/XL6HjvhfMC7F8mbo7IrXX743WOA51YLIsvL1FofK0+yhwVtk2H3enjVAn/A6e0erzFNJ0xSM4cA0hTRbvonacygHYKm0TZ/Kc0Wk+W47kat1d07h5m2mkpDXrsSQxznmlQ0Xi5Y+JIK90z5gHcf2bjXwEb+tT6ejvZ1UV4N4pBtsI96LpXLkNeOlAo4lIWAKKJUbKZdCOFBq/sPXMLpq0IT3jsxbYw2E5V8BOs5j+JxfB4I9IuPwhalcQ6i9wprDBCU1eotsPwFgqAzWkVCjT4tN0u4zIoydgCjZnNLofoZsM+k0Aog1wX6T87muVQ== 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=5BK40eN1KuFxJSGsahq66EgtM3CjPt47xb8vSELlLEc=; b=RbrbDAqhQW12W1SSWpr9l10CNhidHphlHpWaHl6j7vwcxuQa6bEdYNC1AFR7nsHf1GfJNejIs3PD7/cXrjG+e9XkmgBNOLwQ0h1LnlPFRjoN90Ol7bEA7yXI7HBswC2+igCjwzJykCInDUE3/v8/eZn10sYFnVJ2jy8+aPV4mcU= 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 SN6PR03MB4045.namprd03.prod.outlook.com (2603:10b6:805:b8::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3477.21; Wed, 21 Oct 2020 21:09:56 +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 21:09:56 +0000 From: Alexander Bulekov To: qemu-devel@nongnu.org Subject: [PATCH v6 14/16] fuzz: add generic-fuzz configs for oss-fuzz Date: Wed, 21 Oct 2020 17:09:20 -0400 Message-Id: <20201021210922.572955-15-alxndr@bu.edu> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201021210922.572955-1-alxndr@bu.edu> References: <20201021210922.572955-1-alxndr@bu.edu> X-Originating-IP: [72.93.72.163] X-ClientProxiedBy: BL0PR0102CA0064.prod.exchangelabs.com (2603:10b6:208:25::41) 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 BL0PR0102CA0064.prod.exchangelabs.com (2603:10b6:208:25::41) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3499.18 via Frontend Transport; Wed, 21 Oct 2020 21:09:55 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: b22e0450-763f-4429-2058-08d87605a948 X-MS-TrafficTypeDiagnostic: SN6PR03MB4045: 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: KI+1W1oXDTDuAeV7fNzMSo9LdSmM9NjJSX6Ay+nSB0JlIDRi+KJQIqC6ZEfDOzFCUf5FG0VCOiofbKfigsKEghZJqUK5lXwAqQ4Tx1kLlgj4Zp7kjQwtxkDPA8RyqUCBN3+RQmGbg2/qjDH+lxfW9mCCN4WYP3kGrDj0O6k7nhTyCSxOF3I7L1hzJnQfq7qzCBLMhJ3H0Y/BQLzcQb1d2g1LSJ7eAztasyXgGJ/qDlP+bwSz8jQ9LIVKIcyJW6trA8l0obfAwwiri2B8ePhsWN1D0FPoQESYU6dd433sRteSwmOHiLaz6p2dETxn/XiNl+Zi1nXGBnSVKSOq4H+LhhSbBCf8Vnks10/zMAdi6POTOhrM8tiEkevLIJ2ycECP 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)(396003)(136003)(366004)(376002)(346002)(39860400002)(86362001)(6506007)(956004)(6666004)(2616005)(52116002)(5660300002)(316002)(75432002)(54906003)(786003)(8936002)(6916009)(6512007)(16526019)(36756003)(26005)(186003)(478600001)(66946007)(6486002)(2906002)(4326008)(66476007)(1076003)(8676002)(66556008)(41533002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: 5AmPLioJaGc0WSalbPM3H4dFkVI6qDdgkKU3J6Cobac5HIL2GXdrL55S8aaB6Qg4lhXTa9gptR/RVt/YAvYJ5Hm8y7G8jLzZkx/RwQaZxqP1cQbrypjU+pQHFk/pHqwgRS0j7YoijMewyvHnQMaqMfx7mlWsh6Fz778wg/lJ8PyJx/pameGetWyUsMlgX7CSLLKIRZo/WRS2VhfWs91G/85P4pFXEbB1iqsGTM13PFXkCsVy8jWF0lHfkALmNz4Wv1fdRjYpI+zVOFSpJpzxRsHGOuf/A61hZvMgrIPNJRkuMv5L4wtU9EL7JFlh3r1M53JfS5uGw/TSB2sipLmn67fyx8f+ad8C+ftA7ev9Gzls+0UNRqon8nHQBAupAxEB9iZx9iaWif4XSUlvleUIrcRPLbdKp5TvLLd2eGCVA41tP3eZF48Uyvc/D8j9XvjXoiT/bsSNd1AclGSCneiZgdNoZdcAbBs8U+RpTwmBo1r0WXOsT/1uByMO4howXodd6ecEk60mBdx3kZnmVEx2kONNy4XRJOHsiyM9+qciSUETQIuIiivNuD1v54nLcKDENmjc2N0tpQ4kZZ8lNAHxK8ULmiPz4ziilkvXdmZbs7zvhJZ/iYk52wMeqZep2YXP/Y9XxFI84ZuVf+zWGA3LZQ== X-OriginatorOrg: bu.edu X-MS-Exchange-CrossTenant-Network-Message-Id: b22e0450-763f-4429-2058-08d87605a948 X-MS-Exchange-CrossTenant-AuthSource: SN6PR03MB3871.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Oct 2020 21:09:56.3323 (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: eYhM0swC1Y2ND02MYQRJGm769JV4OHI35gMgfR99b5IdWgoB3ntQ+gZFzkM5UA7t X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN6PR03MB4045 Received-SPF: pass client-ip=40.107.69.98; envelope-from=alxndr@bu.edu; helo=NAM04-CO1-obe.outbound.protection.outlook.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/21 17:10:05 X-ACL-Warn: Detected OS = Windows NT kernel [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, HK_RANDOM_ENVFROM=0.001, HK_RANDOM_FROM=0.454, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_LOW=-0.7, 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 generic-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 Reviewed-by: Darren Kenny --- 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..c4d925f9e6 --- /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 21:09:21 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Bulekov X-Patchwork-Id: 270716 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 438F2C4363A for ; Wed, 21 Oct 2020 21:28:38 +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 96873221F9 for ; Wed, 21 Oct 2020 21:28:37 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=bushare.onmicrosoft.com header.i=@bushare.onmicrosoft.com header.b="TdQIE7UY" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 96873221F9 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]:49796 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kVLeu-0003ik-7j for qemu-devel@archiver.kernel.org; Wed, 21 Oct 2020 17:28:36 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43080) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kVLN5-00040a-UY for qemu-devel@nongnu.org; Wed, 21 Oct 2020 17:10:11 -0400 Received: from mail-eopbgr690121.outbound.protection.outlook.com ([40.107.69.121]:59894 helo=NAM04-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 1kVLN4-000854-7i for qemu-devel@nongnu.org; Wed, 21 Oct 2020 17:10:11 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=HdjdiU38kWGXZ6cHReiR68KH/ApW4UKRz5bQlueRN02/JRidbcV+KQtd++YqimU7ZRdQ9gA9dLKtOTg+Q5XPdmlaGhxj/hDhVfVFTheKJxhxfahlefn6M6/nU1/F6h1axIpe4exrxGPenfnkfmu/4omspxL7MDh6SN9n9p6eFUCXBk8jYS7/aJyk5Gc8KrIiexILi9Rq8Kz00n+0d8vu8s3i92OTMuuGAa12Rq1Lf6RNknlYy8M+RPwLtbDWbG7AR0a7WLd7X7rcIRqisAwJJMH7cKO4hQIXI9wk9RX0nmS4zAaHpGS4AvhtPeYH8orQqFMyhahzZxjmn8GNuL+3/Q== 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=eIOJz3HarIqvZwwJqA4Sgru8RgMfbE2D1j371/pyyBM=; b=bI0m7mJvqXnoTprLuglLfM0Fr0ek5XRu9M7xH4n4klk1i+uXmR5PegBHtmzN0GydFl0X3OU5TFKfNwYjdV4zlQ3tIhEAzkYLqn58pd6lYjP82uHHwB8DdE1rk8Aa6ViJQT8S5/ZYiNoogY+0F3YiglvNK2agOfdAoCGPImppcyZPnbwrGCcp8pErsiUs1KHoAf/Bu+uqS8SSIkd5Mkl8ui3zTkM9FHh+QTs3NjZT6djx0lpHfMsgtAZNcIUHHwUa34jfqhUvxOywCVTQ+76CCMfaMiKqbHwED3+w7ur9dGt6kcXFs5O3/0opXbg8Ssi/ICEopgmzTvSBVC0g7OAGKQ== 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=eIOJz3HarIqvZwwJqA4Sgru8RgMfbE2D1j371/pyyBM=; b=TdQIE7UY47B8oRLBon0QYUgVZBd6014kJo4kk81sqNi0k954ngMHcHpisITH3Y9zLFpMAHHT8wg7OYTdsRNnKWS10rOR4MaQ9H2Yqzgy6bdYsOYu1NttUhoLSTLxCA5I7gmo4Idx6lIkZQ0RfjEIC9FtTIctkZ3F7zpXkURIRqQ= 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 SN6PR03MB4045.namprd03.prod.outlook.com (2603:10b6:805:b8::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3477.21; Wed, 21 Oct 2020 21:09:58 +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 21:09:58 +0000 From: Alexander Bulekov To: qemu-devel@nongnu.org Subject: [PATCH v6 15/16] fuzz: register predefined generic-fuzz configs Date: Wed, 21 Oct 2020 17:09:21 -0400 Message-Id: <20201021210922.572955-16-alxndr@bu.edu> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201021210922.572955-1-alxndr@bu.edu> References: <20201021210922.572955-1-alxndr@bu.edu> X-Originating-IP: [72.93.72.163] X-ClientProxiedBy: BL0PR0102CA0064.prod.exchangelabs.com (2603:10b6:208:25::41) 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 BL0PR0102CA0064.prod.exchangelabs.com (2603:10b6:208:25::41) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3499.18 via Frontend Transport; Wed, 21 Oct 2020 21:09:56 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: a24ca16a-a575-4fcf-56e8-08d87605aa24 X-MS-TrafficTypeDiagnostic: SN6PR03MB4045: 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: 0YSgx9nLZB5sgeffZNimVnfDHO99mV2IV6PvU9MX2i/O/ZTB2aFOWl7PE05UtgOzrXcGKzmIWwDzWkD48dKonZqZ1Ewf2SRBjLdinBK0PJxDmzoTA72EaIT0+rxVuQhe2ga50W6065peLlbBa/KGwxZgxClirU1nBSwiSIB2dIPdkCrZ7HUetm7uOkUEV15lOC6gLFVNl/GyiIf40ECf55opQuAaJNFcVVlIjiQwUav5EiXY/4tPah10qhjbLQBpOIeQ7ce/9Nius0waZjWWkuwryFxG1cKHYJ1jYmB32C8sCEeh3+yhLICyOfu+7HMgFu2siEjFrPe04QfqWybpPk3YsE1noiXtT8r2jYEQAFU7aM05gPLJ86CNOWLp5dfk 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)(396003)(136003)(366004)(376002)(346002)(39860400002)(86362001)(6506007)(956004)(6666004)(2616005)(52116002)(5660300002)(316002)(75432002)(54906003)(786003)(8936002)(6916009)(6512007)(16526019)(36756003)(26005)(186003)(478600001)(66946007)(6486002)(2906002)(4326008)(66476007)(1076003)(8676002)(66556008)(41533002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: 9lVa21Y6eDANSFwBZyzwgc17kEkDtU1XoYjlBqo7KKx2JofvOhwboR6o5y8wZ1FiUMpV9xO2HCr52pHIxvM4RKvUsW1evBqYCe1m3BAkmwqYkV4Igrd7dkzinYNxVR/UyYBFLjUL5ZKqsYG5WWRRXnr3f9gHxRdBHnzvotP4ML4Qpc3LnccwAwpER0E4z55BxYuhvzeqBnxNG+HUq8576V6V7OR/ngMzRONNqcyCXqKI2tpOysVePQsJCxS66FyBbL3hljz6UzGX3YqXaLT3R1MtK96w36/Lb8jNQGUgfiuKutlzHqZ+ezjFfiOD29lP9gmnZvcnTc8/pkpF4d8sBUSMOMY0bsEGQnyIbeHEZgINIEg3YSiRxMwupQ6dOM/uYqFe/I41F0ik4qiOcUY12z/HrpD4REjhnsAN5cgzgATnefZbb5qjT4HcHfMcK6r8Hm6jeIGQv4jh7ZHDrT6z13wK/gq7ftK/FglXTn+iEnqrmD4rDG3i/0xvSNqY3uI6I/jouBGC6RTmP1F1+2wEtVJEnBretU18mzqfltG3yaz2Y7d7sNPjI7CVnBfQNG0v5Ei29C2MUxqOlRfZXaOx9xIPYInRRTEnLHnXUskjkYBXr+WNztqqLXzl8Ru2HRaFUt2h0Y9jYYPeja8CwnpKpQ== X-OriginatorOrg: bu.edu X-MS-Exchange-CrossTenant-Network-Message-Id: a24ca16a-a575-4fcf-56e8-08d87605aa24 X-MS-Exchange-CrossTenant-AuthSource: SN6PR03MB3871.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Oct 2020 21:09:58.0943 (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: UQttEETCt2VP+xNDNaUxQiR111GXQVFYktBI0Vl29jKLWBvCLcTo/NwKuj4BFwvW X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN6PR03MB4045 Received-SPF: pass client-ip=40.107.69.121; envelope-from=alxndr@bu.edu; helo=NAM04-CO1-obe.outbound.protection.outlook.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/21 17:09:54 X-ACL-Warn: Detected OS = Windows NT kernel [generic] [fuzzy] X-Spam_score_int: -13 X-Spam_score: -1.4 X-Spam_bar: - X-Spam_report: (-1.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, HK_RANDOM_ENVFROM=0.001, HK_RANDOM_FROM=0.454, 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_generic_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 Reviewed-by: Darren Kenny --- 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 f739937827..bff98fe3c8 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 21:09:22 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Bulekov X-Patchwork-Id: 270708 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 6CB7DC4363A for ; Wed, 21 Oct 2020 21:44:26 +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 B1051223C7 for ; Wed, 21 Oct 2020 21:44:25 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=bushare.onmicrosoft.com header.i=@bushare.onmicrosoft.com header.b="RXj+JM+/" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B1051223C7 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]:59832 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kVLuC-0003ZX-Jk for qemu-devel@archiver.kernel.org; Wed, 21 Oct 2020 17:44:24 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43092) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kVLN7-00044D-R9 for qemu-devel@nongnu.org; Wed, 21 Oct 2020 17:10:13 -0400 Received: from mail-eopbgr690121.outbound.protection.outlook.com ([40.107.69.121]:59894 helo=NAM04-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 1kVLN6-000854-8u for qemu-devel@nongnu.org; Wed, 21 Oct 2020 17:10:13 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=RMRhOEhUrEuPd3tcQirpDCX/hWbqbhrrYx3ZXop6Hi1eXuUzTYy4MmfXHpVOZyfBwYO/g8T/fRw4NmIvtPb5gcRqEURbrLQgvRXb6CQOKQKG9JdsP7Z4LCEkHazLFKdaA7HF846OnER/nmCqx5N0IeIa9E/IPDsLNjTOz/82ADfd1rQdFpANp65GbBlXByj35puMve8THlKYdaZMqYyMROoLkw3a2do4Cn6WpeQtXOiuLvspO3Ds6ASoEjCaAlWnUQoTTyW4DXaMdpIKpgIdrao5MRuCMGxAvZL67J4bAyb1Adb3oIFTfHR1gUx0Ygmtq3oE+9jYXEw5Lf78y2RHGA== 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=ZxtNA+rxOzB5Fcmwil+SAPPdrZJWlTXOFS/n4CRIGV0=; b=ZBqaRSBLAVDgkKJS2MDiSuCzsoHc31JcYlKNEyHB5YKmIvJZJ0oYjkq90jRlXoR89vqq1F5BxxMsNWC7k1HjpEnsMyVDBpOR2eLKf9p6zC6f5N+U1r8gY2Zp/l9LNnskVgXALHzy+28gI97EhFoEBNAE274jxMu3r3IGYro5Vb4Vh+a4U837Sewn41jgMdpb1o5Kohr2dC1LSaz50iYTqNAZqK1H3Wma4QP8kS/X+GuyNukBdkoxIMJrbZswdPeKuWuJdy6VKi5rJglmjwaCBB1wsRAYvySFXDJz68XHgIGaKb0t8rLooAEo4P8w8Cygr8PQ7pcAG7olLPXyNXkmfA== 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=ZxtNA+rxOzB5Fcmwil+SAPPdrZJWlTXOFS/n4CRIGV0=; b=RXj+JM+/oKZ4LgYzTZFyu/U+D5v4EAe3cr8b6fNsqYawrZNvh2aLt3Kzo7AyeMk5q47tUzOPthti9mfBNz27G2H5VvhLELBGbvO9MpRBomzDImsA3OTFa9Yj1awpjzijYfe+jpXu8XeKKKn6cBOw39VdPSW1y06ifYCJf3Uc/nY= 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 SN6PR03MB4045.namprd03.prod.outlook.com (2603:10b6:805:b8::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3477.21; Wed, 21 Oct 2020 21:09:59 +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 21:09:59 +0000 From: Alexander Bulekov To: qemu-devel@nongnu.org Subject: [PATCH v6 16/16] scripts/oss-fuzz: remove the generic-fuzz target Date: Wed, 21 Oct 2020 17:09:22 -0400 Message-Id: <20201021210922.572955-17-alxndr@bu.edu> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201021210922.572955-1-alxndr@bu.edu> References: <20201021210922.572955-1-alxndr@bu.edu> X-Originating-IP: [72.93.72.163] X-ClientProxiedBy: BL0PR0102CA0064.prod.exchangelabs.com (2603:10b6:208:25::41) 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 BL0PR0102CA0064.prod.exchangelabs.com (2603:10b6:208:25::41) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3499.18 via Frontend Transport; Wed, 21 Oct 2020 21:09:58 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 4d923693-22ff-47c7-fbb2-08d87605ab26 X-MS-TrafficTypeDiagnostic: SN6PR03MB4045: 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: OaBN8lY9n5jlppDxZjNCq7EGe8M87VtS7V+rcgHT6fjmUAMygRrssFXLdivb0GmzN2luKyiEsErK1oIO9Iw1vkkEE+lBjn266D9d9zJEmq9bc3GgQ8wVFoz9Vqhnq6rbXKRe7CQXhS14RX4jctYTeC1pj5iygQ5/ph1PwfHaXYIr7Lo5mss8NfgSV9jd8LP/Y2/6l4XHctMMpFEg/49pTjiD6TAIAhVry6tfDUJb3H1YAePnlFrwZ30b3VFrLOe0AtsZexn3+SdNZSw1YR7Kc7m/Yk/plore4C7hIZXLZp17lX2POg4rgk7oOrdGNxTSeBBEhaL2EvWgFaXuIpWwJOMXuSvdHzZYkQ0IuFqxxxQxEtFKwpCCZW0g8Z5hAMhe 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)(396003)(136003)(366004)(376002)(346002)(39860400002)(86362001)(6506007)(956004)(6666004)(2616005)(52116002)(5660300002)(316002)(75432002)(54906003)(786003)(8936002)(6916009)(6512007)(16526019)(36756003)(26005)(186003)(478600001)(66946007)(6486002)(2906002)(4326008)(66476007)(1076003)(8676002)(66556008)(41533002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: hrgciy6vS0WAp0qyqmqW0DQo1vtElHZdqBJKRdUwu8Gf90wyPCNaq/Wa5fyP7cschVKfczE/MbnN/cBTibW9EkHlY6F/uBUptdJFuT4ECYQCKvF0a80pXDD3xjc4ppM88P2x60o6+kUB3hLB/8ij2wyJgyi2Jco9n1inGlevvg+dJXrjHeNMbwbLCuLSyxuw2iNFkBAp+JOCvPqoKjxBA7eqd3cTbOErEa8+rA7cmUmYej4cvMlWkTL6hqyGAnqYm31WVKTr/bhUqF4KConOehJLd+sSI15dgYn13pVPcXn+CNyJxh3GJZbb3d7uyI6+/oUHXkatSSU2NKJRwCFicPwRZCl5IydM5yU+ZdCA6rSdOtZUIErkMkULMkfFtAjnEZWCh1fvM+n6Q4SF+qrIJjO+ShuJvNxgHVKqsD0qpPggtllNPj+6xLSg8ob1GxGAjNuUEeD3HnwQ0MssjfX8Xbmou5SJTjxVPQhQw92U/x6thYmaPK7Q/x2B6xUYXuq6WkBHf9OUAXSVoGb5aGzo8pnkTAoRBkjk0YGywi5coZdbEMRvymlMBFckQRM9cAmRHqHc5SuW0AdNq/RFiqqY0HHY3uFHm9LIctymvf9MTpVppwiSoujh8neLyDWARBYYQe2vTx++MXlu/HExVFBzYQ== X-OriginatorOrg: bu.edu X-MS-Exchange-CrossTenant-Network-Message-Id: 4d923693-22ff-47c7-fbb2-08d87605ab26 X-MS-Exchange-CrossTenant-AuthSource: SN6PR03MB3871.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Oct 2020 21:09:59.5795 (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: FICF+7mZk4Hf+M9yvyFG/NfE8ZCUCmWD8POpo2wGV1Son5HYregqSygcvw6UZ25b X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN6PR03MB4045 Received-SPF: pass client-ip=40.107.69.121; envelope-from=alxndr@bu.edu; helo=NAM04-CO1-obe.outbound.protection.outlook.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/21 17:09:54 X-ACL-Warn: Detected OS = Windows NT kernel [generic] [fuzzy] X-Spam_score_int: -13 X-Spam_score: -1.4 X-Spam_bar: - X-Spam_report: (-1.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, HK_RANDOM_ENVFROM=0.001, HK_RANDOM_FROM=0.454, 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" generic-fuzz is not a standalone fuzzer - it requires some env variables to be set. On oss-fuzz, we set these with some predefined generic-fuzz-{...} targets, that are thin wrappers around generic-fuzz. Remove generic-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..37cd7f9e25 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 generic-fuzz target, as it requires some environment variables to +# be configured. We have some generic-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-generic-fuzz" + echo "Done. The fuzzers are located in $DEST_DIR" exit 0