From patchwork Fri Oct 23 15:07:30 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Bulekov X-Patchwork-Id: 302179 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.1 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 68837C4363A for ; Fri, 23 Oct 2020 15:12:46 +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 897E6207F7 for ; Fri, 23 Oct 2020 15:12:45 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=bushare.onmicrosoft.com header.i=@bushare.onmicrosoft.com header.b="1NMkVXcF" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 897E6207F7 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]:50250 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kVykG-0000UE-Ey for qemu-devel@archiver.kernel.org; Fri, 23 Oct 2020 11:12:44 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54014) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kVyfr-0003W6-Kk for qemu-devel@nongnu.org; Fri, 23 Oct 2020 11:08:11 -0400 Received: from mail-dm6nam12on2109.outbound.protection.outlook.com ([40.107.243.109]:44513 helo=NAM12-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 1kVyfp-00076m-Ut for qemu-devel@nongnu.org; Fri, 23 Oct 2020 11:08:11 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=SSoPSvQSfyQ9wNjibhw5HCTZgVawK6+XG4jGjQe5lKZA5HlnVD+MMsD5SdeoBlXQVWgybqdIElk9f6A+9AsSntSpGA63LffewuSXldOqgqTCwiL52DsDuZNs9TkG2gT9A/K1AuNnRjyELhaMGYp6Bh8l4Z7xux1WHdUc+gL5FdOWqSbqbrvgKT2sxYo8u1VCzMtw4nW2Wqp/+rN0ZfA1ZyIgzISbFedoO5Im1sz0/hA0fOYjz6fcXxWjOPelpotDFUi+tfflXWgLeDHDwX+pevR9iAjb4+EIiVj04VXVwua2bqJX3ByBud8peuCN/W4TYWVdgCteU6Gle6V9HhEj+w== 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=oS+x2NyRq3SEc2lMRVqPaA/yOwChrjZZjY9J7JLnJvg=; b=hU+8wfdDvr1ncTg23bsQa3kw+mL5tBwAc0GHXxrtTgZV8s+iAqFIk5SQ8G0ifBVr4AF21qAUhcK7pGWakmdlK2YWyCSFk7vs8OOYwI+tyXugUuELyE4POeTacBqdNKk4aw1Dm4b27CFO2zoTeaILXqd709bRKXwa8twVKgPbBUwYL3iX9mxUlOEjR/7koQlZuPx4ksQnNXCS+/sqwfWvlZfWTkYc+qvrlFaFC0LCzwBn4tzR34txS86CSI5CEfP3IU5yiTz5P4ZCeOJyJDZsXsNhoZwHUzfPTd53Tf901c/Synf5Sx4cgHqQkfwFRY02iwbTxb056ue/aSeeYnz70A== 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=oS+x2NyRq3SEc2lMRVqPaA/yOwChrjZZjY9J7JLnJvg=; b=1NMkVXcFEDvIwdthLiHa6cC8ndX4+5MJBmn+jAnpXwSPhsGa+XYA/lpaWfGU5jA/LEQWUODkvSDIGnBFD6zHKGKhbJ64YxQlb5WiYP8FpF1fR1FpVlzdMJAYMPlHREov9+FLnHigPov2n+1L5yV/XFR62H9azQ3J3UmAC5mqQOw= 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 SN6PR03MB4368.namprd03.prod.outlook.com (2603:10b6:805:f4::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3477.22; Fri, 23 Oct 2020 15:07: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; Fri, 23 Oct 2020 15:07:59 +0000 From: Alexander Bulekov To: qemu-devel@nongnu.org Subject: [PATCH v7 01/17] memory: Add FlatView foreach function Date: Fri, 23 Oct 2020 11:07:30 -0400 Message-Id: <20201023150746.107063-2-alxndr@bu.edu> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201023150746.107063-1-alxndr@bu.edu> References: <20201023150746.107063-1-alxndr@bu.edu> X-Originating-IP: [72.93.72.163] X-ClientProxiedBy: MN2PR01CA0065.prod.exchangelabs.com (2603:10b6:208:23f::34) To SN6PR03MB3871.namprd03.prod.outlook.com (2603:10b6:805:6d::32) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from stormtrooper.vrmnet (72.93.72.163) by MN2PR01CA0065.prod.exchangelabs.com (2603:10b6:208:23f::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3499.18 via Frontend Transport; Fri, 23 Oct 2020 15:07:58 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 45e1f9b7-81f4-42f2-d627-08d877656dc1 X-MS-TrafficTypeDiagnostic: SN6PR03MB4368: 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: e/HUf5BlVBggLXvLPH/afUjPGRVsjyb4O7PAw+q4LVrjjZUDzY6biSSI+/VC3WEUqsO93cyg1Y3qkOJAonaHrkTu19UX+1VwLMUZiduHPTXNCyaH1eNSKZ+EM1IeIFnkHaka6NEDge0KUVOlMMNJzZ4MaUxkQc/Ux2wKEcpPpf7cRoGzTJgiUooFyQymWRi6vRUpTY3bWewdnhwzvTeY8etJIn140FN+y8mQ/CJ5RtjYQeY1+kuqtPxixWMNaoI8IL0Qei0erIQQ6FzJ3bDt1o9Rf3FmaVGuXfM42UvGY7QChAv0fK/rXGGdO8flYMYaN7kSORwOEk7rloCLUK5gQQ== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:SN6PR03MB3871.namprd03.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(39860400002)(136003)(366004)(376002)(396003)(346002)(478600001)(956004)(8676002)(1076003)(186003)(26005)(316002)(6486002)(16526019)(8936002)(75432002)(6506007)(786003)(6916009)(86362001)(66946007)(66556008)(66476007)(6666004)(2616005)(36756003)(52116002)(5660300002)(6512007)(4326008)(2906002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: +7EqVMLmcUBSYVFAtGW6HO+uhYspjcpVm3t52MCxqhJExWAGrng9XV2l1LAFpw5IE5/m/g7P1YBSoVwnKpUQmlRRjo9DBj82jY1FCY1vpfUjk1CoLMFHq2rHyvZrOgaAY+RJv7DThwgDU/SLoh2EU3NSrBtdj7wsDx4uVXZOtM3DQSteCOL7DNHwPHcqdsHNGPLVJV7B5OjRmv4yjLiNvEZqmri5Bv+oerBffO5EC1z7AGpjrJLlPlspQkQayCnC6U6CxiPdIDSFt2y6XqABgJ11fbmmW/HSqg3qJghQ2g8das6IfowwTX+eg4tQvGy2U+99oMoGdB2lWQKvZN+2lIDwVY9tNEn+nCPg1iXnKypZrCgHKYMvOe/vxgL3elWRkxFbCEeIzFDUp7OXy/1ziY+E1xzMXTXR5dN3PMhhx+UUv1RqBnIHic8fkdWfWvNuxIeLi8/CJYFPD+ff9E7Q/6LPPA+OsftNsqGLwLeLP5zZLCNRgkhFffAnjJsQhsZ5Hg/Z02GXW/8lr2VGp0gTHAqguFOylFJHBUMpDaVoUAnvc17X6dxyGvvb/QAE6CvaT3o4KsgDjoLAS6vPx8z06zV7+IDrGQcZahMGvMHVdbB+FSJEtGnF3JgivVaVtsTXDmBcbXSWlsHXVb1f0Sp72w== X-OriginatorOrg: bu.edu X-MS-Exchange-CrossTenant-Network-Message-Id: 45e1f9b7-81f4-42f2-d627-08d877656dc1 X-MS-Exchange-CrossTenant-AuthSource: SN6PR03MB3871.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Oct 2020 15:07:59.2105 (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: Z3Q7njSRBRj0qTvlxYARhK6EpGg6KxqDc3USQz+Kaw0ioqOgXiXF7Mi+ubuYvbd3 X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN6PR03MB4368 Received-SPF: pass client-ip=40.107.243.109; envelope-from=alxndr@bu.edu; helo=NAM12-DM6-obe.outbound.protection.outlook.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/23 11:08:08 X-ACL-Warn: Detected OS = Windows NT kernel [generic] [fuzzy] X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, HK_RANDOM_ENVFROM=0.001, HK_RANDOM_FROM=0.63, 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: thuth@redhat.com, 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 Reviewed-by: Darren Kenny Signed-off-by: Alexander Bulekov --- include/exec/memory.h | 5 +++++ softmmu/memory.c | 13 +++++++++++++ 2 files changed, 18 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..a5d1641820 100644 --- a/softmmu/memory.c +++ b/softmmu/memory.c @@ -656,6 +656,19 @@ static void render_memory_region(FlatView *view, } } +void flatview_for_each_range(FlatView *fv, flatview_cb cb , void *opaque) +{ + FlatRange *fr; + + assert(fv); + assert(cb); + + 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 Fri Oct 23 15:07:31 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Bulekov X-Patchwork-Id: 270566 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.1 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 19EA8C4363A for ; Fri, 23 Oct 2020 15:13: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 7763E208B6 for ; Fri, 23 Oct 2020 15:13: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="iqTpdMK9" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7763E208B6 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]:55648 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kVylQ-0002jl-Bk for qemu-devel@archiver.kernel.org; Fri, 23 Oct 2020 11:13:56 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54078) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kVyfu-0003ek-Ke for qemu-devel@nongnu.org; Fri, 23 Oct 2020 11:08:14 -0400 Received: from mail-dm6nam12on2109.outbound.protection.outlook.com ([40.107.243.109]:44513 helo=NAM12-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 1kVyfr-00076m-R6 for qemu-devel@nongnu.org; Fri, 23 Oct 2020 11:08:14 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=STyMuTm+KnLVvzsFtpw8X91YGyW18S46Jq7I/IybL7+V7OO0kpw4ZH2ra6BokefmwwTtBYS0F6DHRCDaakN7fyYS9HAWnDoIH+ps6w5J80QAYbfRus7vZylzzaSjEXWoTeDhw5Xuc+XL/O9fGamKdor7Ea6fdnle8avHGgJnH35ISAKxNGKWyrl5nwiPz7/1HmvHqOdBRa/rR01KlhKNL7aFbXJKu/OUcbj/z95x27sy16cfJPEWWT7FoJWZukeRX+7051fPuiH9DUFtpJeVa1p9iqFP8u6KnfzNe5nd39adbJASfFz9pkxs5qgxYzqFu6WiQMn+95uYQL+0O6KKXg== 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=kRz2odmRiiOKvlNw8+AcHFOASG7zRh/PtxYBlK7JyR8=; b=GMeQnZae/iKfSSIf12YRfx/EBSdI5A4h3MeRZOSbNLaZ/9JysK2iTqf7WLtiPcDf57NFG0WTuw5Vil9dG98Giti3SuM3Zb8IWOE0i+VWtH3syh7oAEyj1uIwHBhVsOAvT+Au2sM6+B3X0a05d4Q7u1JwVXCsC5ZRJcxYnD132HoPLf2Phn2ItaVVxI+7glorsfSh8XY7lx4WyvT3PaQwk5FTRF4Qgc3N64KP4qo3HFZF6f8TElHwrwVn3s/ZgkNqyC8AM/ms816gyraY4ixBzdsoJf3n7bPkVYh5tMhOeOo5cbCLwasyuD5npCGgnpB2rIPepzJea+P7uKSQZJmdxw== 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=kRz2odmRiiOKvlNw8+AcHFOASG7zRh/PtxYBlK7JyR8=; b=iqTpdMK9NNHex1+Ars3ZZJg7rTI+vUYk8lmJpo6JGNJUJhK+PCCGHrPCjiC0eEPhFF221cgZ91b756oFtYgZ6gbUnccoLRkahjvU9l6fcZBHZAqWI9zzIxNUupf1v1kbUBburL4S1yJDQLUEK1rsVaYuon4cTDli9SRJUkD9h+I= 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 SN6PR03MB4368.namprd03.prod.outlook.com (2603:10b6:805:f4::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3477.22; Fri, 23 Oct 2020 15:08:00 +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; Fri, 23 Oct 2020 15:08:00 +0000 From: Alexander Bulekov To: qemu-devel@nongnu.org Subject: [PATCH v7 02/17] fuzz: Add generic virtual-device fuzzer Date: Fri, 23 Oct 2020 11:07:31 -0400 Message-Id: <20201023150746.107063-3-alxndr@bu.edu> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201023150746.107063-1-alxndr@bu.edu> References: <20201023150746.107063-1-alxndr@bu.edu> X-Originating-IP: [72.93.72.163] X-ClientProxiedBy: MN2PR01CA0065.prod.exchangelabs.com (2603:10b6:208:23f::34) To SN6PR03MB3871.namprd03.prod.outlook.com (2603:10b6:805:6d::32) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from stormtrooper.vrmnet (72.93.72.163) by MN2PR01CA0065.prod.exchangelabs.com (2603:10b6:208:23f::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3499.18 via Frontend Transport; Fri, 23 Oct 2020 15:07:59 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 026868ad-3a90-4907-802a-08d877656eb0 X-MS-TrafficTypeDiagnostic: SN6PR03MB4368: 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: v51Dr+4vuunQzMKbzkj+NqW/D7x76p0iO8wKZUrsQfUkoMeCpF4b1k9hSL0oD0NxsJ0ZI890HIS/Wwt6hKXzpeKTOxZJKG9t5WqBOJc32aV/fPuNBD0tykmH6CKiou3QT73TLwrNOAxsmdjbNLwhBDy6TgcZd2X9kaBMkSBcAwTwHk99OFNUMKHGXoV77+98kcoCnIBERUCsJIqsxhl7B4/TaRvKlAdJ8lY4bp24JmLHLqTIH9PCg492PlhvondOqigaWl+yyA2bJiCarcpYkI4pSAAxZhoBdMsreITZcQQHDJcJ3F10e930+c8Piy/AilI3JHMw2DWN33rIwLS4BmuT6YY17Cs+zoeRpR8dCc5p/AkrAJaCx3Tie3F1EZZp X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:SN6PR03MB3871.namprd03.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(39860400002)(136003)(366004)(376002)(396003)(346002)(478600001)(956004)(8676002)(1076003)(186003)(26005)(316002)(6486002)(16526019)(8936002)(83380400001)(75432002)(6506007)(786003)(6916009)(86362001)(66946007)(66556008)(66476007)(6666004)(30864003)(2616005)(36756003)(52116002)(5660300002)(54906003)(6512007)(4326008)(2906002)(41533002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: v2coaHzO2YLIHQIMXt5XtoN5uDIix9X9eG2EpMFOTXm4frqSLeWfJBCKP3fTd3gv91mdejvAETzpYi7Hq7H0uMyDUT51xKgZjWyWb+gLBcYmvxdP2uzl53VC1Re3PVSZvJ2/2eBEYVsHtreYjdZ7oMJH/zfgV1LdsHXZRT67EBX3ONUvVWYO/41nAQd1i8x43r/Gfkjd0hVbbuqlZU6W4tmYNJA/MyHZ6eAIhwyf4DJx+w+c+vPCf+XWIL03qKlwaAkbMNleN0q0uYKu4ABwygAhSlvQkqYhjdRDeXBE8BCxqFYI43aa57vk/fBtGlkdxsWOqawYMbC7gxoTageXIkT5B/bayqn0gN6qX3dRpy+UnB/JRyYSiQ9vGAYB/NwrweOiXrTVXWDcK7UqC2KHqEiG7R8gVZBd39FE3BLkon8dSthlWrXe4Lz8CVDXdgLwFqH5IQSlUXo4rZuCHP1pZdWlDwUfXR59wKKwHNfUgLb5T2YJrmS/RBmSE8ob0sKqS5EPOXWiiB8P0srki8liEqNsDLOgwjwhz1OApPeFA3RXWL0fT/i1zMW+cqkLxYwJsmkBRbx/ka6aztzcRQOioVvpNcHyklY0R8Fd/cdcJtFH2IWcvzD2HqacxPdJZTG+D41HhDjNNFcxrkQlG+GSig== X-OriginatorOrg: bu.edu X-MS-Exchange-CrossTenant-Network-Message-Id: 026868ad-3a90-4907-802a-08d877656eb0 X-MS-Exchange-CrossTenant-AuthSource: SN6PR03MB3871.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Oct 2020 15:08:00.7996 (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: ZVaoZeRCrNN32V95Oe/Guowsfd4f302An3MpzcUIVYlqjn3MYuDXWJbqX/+B6w2u X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN6PR03MB4368 Received-SPF: pass client-ip=40.107.243.109; envelope-from=alxndr@bu.edu; helo=NAM12-DM6-obe.outbound.protection.outlook.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/23 11:08:08 X-ACL-Warn: Detected OS = Windows NT kernel [generic] [fuzzy] X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, HK_RANDOM_ENVFROM=0.001, HK_RANDOM_FROM=0.63, 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 , thuth@redhat.com, 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). Reviewed-by: Darren Kenny Signed-off-by: Alexander Bulekov --- tests/qtest/fuzz/generic_fuzz.c | 516 ++++++++++++++++++++++++++++++++ tests/qtest/fuzz/meson.build | 1 + 2 files changed, 517 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..6e3faf4e92 --- /dev/null +++ b/tests/qtest/fuzz/generic_fuzz.c @@ -0,0 +1,516 @@ +/* + * 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 Fri Oct 23 15:07:32 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Bulekov X-Patchwork-Id: 302177 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.1 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 6B34FC4363A for ; Fri, 23 Oct 2020 15:14:57 +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 CCD3F208B6 for ; Fri, 23 Oct 2020 15:14:56 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=bushare.onmicrosoft.com header.i=@bushare.onmicrosoft.com header.b="Guvz706N" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org CCD3F208B6 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]:58664 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kVymN-0003xw-Lo for qemu-devel@archiver.kernel.org; Fri, 23 Oct 2020 11:14:55 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54118) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kVyfw-0003kX-Tq for qemu-devel@nongnu.org; Fri, 23 Oct 2020 11:08:16 -0400 Received: from mail-dm6nam12on2109.outbound.protection.outlook.com ([40.107.243.109]:44513 helo=NAM12-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 1kVyfu-00076m-R5 for qemu-devel@nongnu.org; Fri, 23 Oct 2020 11:08:16 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=NrFOCgSVAphNQxDD+4vbaO/Zec869mIIpzEJUaZ5w7odu23N/tNXe+qig6TP3pbnA2glo0Z/muOv30/QUJSkVUW4k9kQQb1tvpg3yf+9MFTASYBuhya30yKO4NkZN+KZd6vHQA3ttcOb8eVHBa/+5w5KmzCQU/ky6nHcIMRa1HnD+h6bxrgSC49MFVg46r0zAHvmT0kIj5x0FIykQux9s7kOuE++MtnfG/wkFWIqJsa3L5kqv/Qwkcwih6Uemi2dNvwGFI0/tH4vjHv9d7ZFInwnzEH33I8eBYUZEJ4W64oh/Gc9+oLyH74EamTaHX97XT/fFh/54EpRZUngZqfv2Q== 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=8sMX1hNdvlHfr6f5HlrET37EfLP+rqpEgLKJ8/dMnIA=; b=AYXgPdWF4Y2F4Ppc5MHGxWpf9GiNiV/TK65I/WZ8W0PL7zoXdhDpkamCTG9NA8ulZpYqOojfts35Opk/IQQ4VUAJ2uB/OuKNBKhCu8NmlVk785i9SsbQPuI8bXxgGy0NtU4+jB1wD+f1RvzCwu3yaPLtieujK2QzSS+6kQZVe4yTQmPj1TZtDX3RIh9Q7AG2JAi5iyUArDJpVT7scd0bORCnPGGcQVOYyNs/VCiHX3FXCgjmqCLs70yhKkad8Ix87d67ay1MhAZRZ+iYMvxRllVg6hfUjv67F70P77t4aL5YHtDhjd2s/M+kPBmuDa/iqy+iB1Icqy4R6nUAzn5Jfg== 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=8sMX1hNdvlHfr6f5HlrET37EfLP+rqpEgLKJ8/dMnIA=; b=Guvz706N1Osk4RCZjKNNur4UgIp4IDc1RHXAjr/YBhWPSzAstiJFqnp0S4bvm0bUdj+Gpe+Vj4bStRgh++ryEmPWYHo+zID1OH/IcjiFaRh7EiytW0aiCCRzwGEWS6FIDE000h2ZZb8gUN3PnTDlNp6B2sleUV8yuNB3Rf6NsHw= 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 SN6PR03MB4368.namprd03.prod.outlook.com (2603:10b6:805:f4::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3477.22; Fri, 23 Oct 2020 15:08:02 +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; Fri, 23 Oct 2020 15:08:02 +0000 From: Alexander Bulekov To: qemu-devel@nongnu.org Subject: [PATCH v7 03/17] fuzz: Add PCI features to the generic fuzzer Date: Fri, 23 Oct 2020 11:07:32 -0400 Message-Id: <20201023150746.107063-4-alxndr@bu.edu> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201023150746.107063-1-alxndr@bu.edu> References: <20201023150746.107063-1-alxndr@bu.edu> X-Originating-IP: [72.93.72.163] X-ClientProxiedBy: MN2PR01CA0065.prod.exchangelabs.com (2603:10b6:208:23f::34) To SN6PR03MB3871.namprd03.prod.outlook.com (2603:10b6:805:6d::32) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from stormtrooper.vrmnet (72.93.72.163) by MN2PR01CA0065.prod.exchangelabs.com (2603:10b6:208:23f::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3499.18 via Frontend Transport; Fri, 23 Oct 2020 15:08:01 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: dd87bc92-c8f3-4df6-3e92-08d877656f73 X-MS-TrafficTypeDiagnostic: SN6PR03MB4368: 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: +RA04KZYdMJkDYlC186ZwDnj9WNJtuIE0SFLQ9KjZq2ZonR/m+FtmxrdGM/5V0CquTJ+dpXoHpDThqaZ8VoF4mr8uhOn3kPazAq/GVIAbQMF73K50pUmedLZ14v9DBHxV7/ok1PJoBcbnQPvEwOfMeko2piXtn22iq0BrNfq2Z9kR4cYdlr9t5mLyVUImE55+x+cIx3ZlbyQkfJJbeHx1ccYgnit6FEFCuJ9QAmapB6XYbGvywhJwrs9LNXRyJun9LDBXQLq/3jNCKdr3EeZ+x/97bRBjhvDcaS4oEZihHLDiW+znurahjRyubpLS/WiyuZGwW+TSW9o3v8+LiHfttvijQ1qZPmaHGnsGYdbP8+qElbevMVMDGKrbUR/Gasi X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:SN6PR03MB3871.namprd03.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(39860400002)(136003)(366004)(376002)(396003)(346002)(478600001)(956004)(8676002)(1076003)(186003)(26005)(316002)(6486002)(16526019)(8936002)(83380400001)(75432002)(6506007)(786003)(6916009)(86362001)(66946007)(66556008)(66476007)(6666004)(2616005)(36756003)(52116002)(5660300002)(54906003)(6512007)(4326008)(2906002)(41533002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: t2/GFKoWXjPARVXJeIWsO9fA4fiQwTVe6Q722/P0OeZMDZM6pvtbi0+kppZUVUqSUUh/UHp9APvLkiiEzV1RZgsUilfF2I1zLmEPsTijccfz/i6yLEaurdqfKQnbpCXej3loIE06bPFmWRLIn3cKezjeI9noGj6g4FD/Gn2TxR6s502/kovcjb9hq7jwtAJ3t4CFOCSMEEJA5KJjQAVk6bm1USrouallhrIvIfyD2hSw/orSKybJ4oQTBUBgWnjGKFTkxCYJZ17B5l3QpABXmBPgVt4wq7MR56u26Go5qpTtpPRi22dZpRo6y3KGSl2PW2lZbfEQk/I0br3OGqqaJ+wTDbEq4G1QPxe3Fbd3aqa2l757ARJmsUgt0CMoH6tNMxrIr4URPFiNaNkMr1mnHDV+ksZmZKhn1ZnY0XkX587LwiC8q4yuKHnyP1pZ9hRIoIFEUIlHB5DPaQxtzCciSZ6OoCDViV9eOrEcHgrddnan2qZI5h25zqFGFUkbKSRQGG4b/qwXplWT4LanghMyGhber7FehAjlf04fL4qMssNgvSZIKq53fp/qsRoTU8Wo55AES6mgV6heKr7CK3U66iRDYc1zuyUaucSDRxtaxuaLUQE+zEU/xRand0rh2fYfNKuqlTR5DalUPGUDvT7QwA== X-OriginatorOrg: bu.edu X-MS-Exchange-CrossTenant-Network-Message-Id: dd87bc92-c8f3-4df6-3e92-08d877656f73 X-MS-Exchange-CrossTenant-AuthSource: SN6PR03MB3871.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Oct 2020 15:08:01.9490 (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: Oj1fwYYBwY0eKk6Gm2mPh964PqUo+x2RfAblw4u1ZfJbNt8sgiaDnvdjvtdCgTG+ X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN6PR03MB4368 Received-SPF: pass client-ip=40.107.243.109; envelope-from=alxndr@bu.edu; helo=NAM12-DM6-obe.outbound.protection.outlook.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/23 11:08:08 X-ACL-Warn: Detected OS = Windows NT kernel [generic] [fuzzy] X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, HK_RANDOM_ENVFROM=0.001, HK_RANDOM_FROM=0.63, 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 , thuth@redhat.com, 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 6e3faf4e92..483d41fb2c 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; @@ -283,6 +290,65 @@ static void op_write(QTestState *s, const unsigned char * data, size_t len) } } +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); @@ -341,6 +407,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; @@ -432,6 +500,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))) { @@ -464,6 +544,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 Fri Oct 23 15:07:33 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Bulekov X-Patchwork-Id: 270562 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.1 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 E5AE6C4363A for ; Fri, 23 Oct 2020 15:21:10 +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 2D8B921D47 for ; Fri, 23 Oct 2020 15:21:10 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=bushare.onmicrosoft.com header.i=@bushare.onmicrosoft.com header.b="gkDOgPjA" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2D8B921D47 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]:45978 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kVysP-0002Pp-4p for qemu-devel@archiver.kernel.org; Fri, 23 Oct 2020 11:21:09 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54164) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kVyfz-0003qf-Am for qemu-devel@nongnu.org; Fri, 23 Oct 2020 11:08:19 -0400 Received: from mail-dm6nam12on2109.outbound.protection.outlook.com ([40.107.243.109]:44513 helo=NAM12-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 1kVyfx-00076m-3z for qemu-devel@nongnu.org; Fri, 23 Oct 2020 11:08:18 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Y10dImeJdrh9HP4wlw6DANMBafhrYmSOAcLjtXK13OZx93nQv59olrS2CEvuR66vw9p7pNHNQQ5vKPWief6zeYK+0CsoBNLQFRwhzxf/O3BpnGUG1uLwtYYTH8sjxTQd8vSBQ4Geo+6gGtCbdbv4ti3IUZ1IW7MKScgkPs5TLXqhTahotg+Hk8oTvtwJGXD317PYuzlE6Htqb1MiLNAosk7TSAo+bH/fzzDvnG6h0mDyQ+MxFOLD8yub9cYhSHKmeBw2nxoWu5raq+kvqAr1sHCRc4bLCB1HhqH1ceg1W779FtCvTbJ2vdn0kZLQOw31+qyjU9dZpW49CplZMRukBQ== 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=cNh0+4rDCiqh7oDMKxCGZ7eJ7MLrqJKBZnpYJUufLzU=; b=KM0IQgGbcsUJztlWam8+U4HIwxuG8vFK9DooZdhggr6nAixHj3entsPUMG3aFg7j/9XPpSpD9Ph6SrFA4OpoNlRE25xYtng6csdv2515QGJTTOInv9EBpkCHlzwbUC6zdQRu0AO4u+JrbT3F9YoiGeU/5qBvDSvnLkRzCYQjoeXLCUljkg4NQhQcwjtG5QDIcNLIbOZA6P9zs/tUw1c++BsOHkVMvhxEv1GBhOPF3EsQd5iXW2jrMVhfsJC9t4OGtU/juEyBSrgIBFLbDitN8dqGOZGlHR36W/5eda4IEOuEWtYwPZwzblArxJrdRFVI0RPVexMFbPMaqbkjJq4OOQ== 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=cNh0+4rDCiqh7oDMKxCGZ7eJ7MLrqJKBZnpYJUufLzU=; b=gkDOgPjAcxsn2aBtgCPS4Kx0IHhgJ6K6u4Dh9p/XKiQ1/RGlncHbJr4FaenBZHBUpsZUj5PCPnNHq+LeEBs5HZiq/ZjLpdWWrUqNnMvmkAPU28lLYbOvlfma5xJQlECwG1uiqb2O+XJGwdmtLQsSGAQvd6Xo83PYHFTOAw5cndo= 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 SN6PR03MB4368.namprd03.prod.outlook.com (2603:10b6:805:f4::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3477.22; Fri, 23 Oct 2020 15:08:03 +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; Fri, 23 Oct 2020 15:08:03 +0000 From: Alexander Bulekov To: qemu-devel@nongnu.org Subject: [PATCH v7 04/17] fuzz: Add DMA support to the generic-fuzzer Date: Fri, 23 Oct 2020 11:07:33 -0400 Message-Id: <20201023150746.107063-5-alxndr@bu.edu> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201023150746.107063-1-alxndr@bu.edu> References: <20201023150746.107063-1-alxndr@bu.edu> X-Originating-IP: [72.93.72.163] X-ClientProxiedBy: MN2PR01CA0065.prod.exchangelabs.com (2603:10b6:208:23f::34) To SN6PR03MB3871.namprd03.prod.outlook.com (2603:10b6:805:6d::32) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from stormtrooper.vrmnet (72.93.72.163) by MN2PR01CA0065.prod.exchangelabs.com (2603:10b6:208:23f::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3499.18 via Frontend Transport; Fri, 23 Oct 2020 15:08:02 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: d4b15ac8-fd44-4d28-7175-08d87765703f X-MS-TrafficTypeDiagnostic: SN6PR03MB4368: 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: 4QMDUEuCrSJ52T8xoxURQGmr/G7PvGp5ZFGsSrOypd0FbafozxaqCsaD5bzbJJ2nSG0Avels822V2VYfRPghm46NCuHDae1qbC9FD15xRuurRJk0b6VugpUMAcpq9uyFc4kgn6tiGdATZJBq/pikaEz3XH6Iinm2WNrYOH5BD8Q3kU4668NzQDeLCT4mcWwx52aWu1hAiPtGIbrQ8cfCKFLdliJEyonWmSCjrjqxu1KEUuQXaiPwI7ojdU/4wZPdFcWiMXWjKFECPrhg67U+8ynsr4McoHb+QVw+jf7PFn7EhUc21H/lv5gpzovdG/FMqo8yDIJ9a2NFA0KY+1ZS+h91PHw+hGjNIWmRQC8SwhBNUihw0tNAgQuqErnHLSZx X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:SN6PR03MB3871.namprd03.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(39860400002)(136003)(366004)(376002)(396003)(346002)(478600001)(956004)(8676002)(1076003)(186003)(26005)(316002)(6486002)(16526019)(8936002)(83380400001)(75432002)(6506007)(786003)(6916009)(86362001)(66946007)(66556008)(66476007)(6666004)(30864003)(2616005)(36756003)(52116002)(5660300002)(54906003)(6512007)(4326008)(2906002)(41533002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: vuRu1f3TfWO51K+HjGV6VZXZPgHnjzrX0nNG+gApv4Ymm88q4bPUphSXl5pX9BA9lOb9GdS+i3hIBqZ4KABIk+tIpiIwyB/LxDyC9efY+Zf7BjyQP7QpmJAFE5uAEhdl2baONz0Fu0Ls4jWmwk7tZ1FRocK9Y23MWCCWAv1LntT/pu12f44WUFrTlA/Pv25uNizyy8+CEtI2unTJEjx2vekZ98KK4DZ7MGIAs3E/9Tw2IG4x2/TRVT3sBLpixtJDKdss2TPVgbc6XE9RPMe6wyMMDD6V+HYdY801oG27G3mjtVoESeV7yeoYoBtZcVsTAAI6UoAugQpO/CVpNKAnoHSBeBQGIFqZnDc+5Si1qR/GiCXq7XcU4TsxmhzFCTBoxHi8i6FNrkPRLaRkB27q3acjlvoRaSYgsL8C0PFhOCy5j7dL+apu9P0kTjwYiRv74i+AWqW7Vl8zZRKqd/MJ9tIum4vFJtAp42b0NAoEApq9q3pomBMZVItcFb7C9pmEHLerCcpRP8oxnVPGuElmYQa0ximHG2kJPwZj/FzxFzFT+HwbghMX2l1s1nynO7FPHJKpElAQishBi3flyFwoyxjidOVFBTnM2Y5GQq8CedEB9/QdbsVYwb1JgYFWax++BsuMqKa/Pk6o2P7ewlK/hA== X-OriginatorOrg: bu.edu X-MS-Exchange-CrossTenant-Network-Message-Id: d4b15ac8-fd44-4d28-7175-08d87765703f X-MS-Exchange-CrossTenant-AuthSource: SN6PR03MB3871.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Oct 2020 15:08:03.3412 (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: 7U7MekaCtquTeiQC+CGWzwcR8ehYQSlyBEkjfNmhLEOyW2lwMqmjvJcRU8h9ujcX X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN6PR03MB4368 Received-SPF: pass client-ip=40.107.243.109; envelope-from=alxndr@bu.edu; helo=NAM12-DM6-obe.outbound.protection.outlook.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/23 11:08:08 X-ACL-Warn: Detected OS = Windows NT kernel [generic] [fuzzy] X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, HK_RANDOM_ENVFROM=0.001, HK_RANDOM_FROM=0.63, 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 , thuth@redhat.com, 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 483d41fb2c..e6b18e4276 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 @@ -349,6 +533,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); @@ -409,6 +622,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; @@ -438,6 +653,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)); @@ -454,6 +671,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 { @@ -468,6 +686,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); @@ -539,9 +760,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 Fri Oct 23 15:07:34 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Bulekov X-Patchwork-Id: 270565 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.1 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 AC7A6C388F9 for ; Fri, 23 Oct 2020 15:16: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 1B48B208B6 for ; Fri, 23 Oct 2020 15:16:05 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=bushare.onmicrosoft.com header.i=@bushare.onmicrosoft.com header.b="tSwGXSCm" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1B48B208B6 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]:34110 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kVynU-0005ca-1c for qemu-devel@archiver.kernel.org; Fri, 23 Oct 2020 11:16:04 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54210) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kVyg1-0003vV-8Y for qemu-devel@nongnu.org; Fri, 23 Oct 2020 11:08:21 -0400 Received: from mail-dm6nam12on2109.outbound.protection.outlook.com ([40.107.243.109]:44513 helo=NAM12-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 1kVyfz-00076m-Ic for qemu-devel@nongnu.org; Fri, 23 Oct 2020 11:08:20 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=I8T/wVwkGdhsHK2d4anWJIOy6NvKnW4Y5LyKKPjFYLxhXd50Da9o6lpSPaSGJ12uid4OX/S/Pav650W7gjHw76yyRN2XMXTCNG/lurHcCkK35uUUyhbV8oZBoBhDuafgO/psziLKlQXtgCOobZD5icerou77WpHmeJgEFnMChDra3CB20GmAnFbIx+Ef8aM2B3Cji1BKm77JLN+pWN0G/DJoK76TSTIT0Vsnd8N35pnS0ma0FlsAvJBnqjuyWULPFicgdA2U8qmM0uEXiLY+ikHSBC/cRh1U9ANx3lxoq7W/miiCcinknq6F0IqhLL17cYDYNoclTTa2qvX/Evx79A== 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=OrThrEXIy/m5+pUPzQD82XQDJOsA+TG3bGCe6vBg2NI=; b=n2RLLZsCnhqmZtwvNHjZkgLfhwtrFwbup30fPwuXm4zh5cUI5ta2y1Aj5/Aet4ofhEIUDzCxLEEygDeuHhtPi6tIBXUfVbmiGAvtsNK2nqnXrJKcJAQKSCjVCf4rHvXxIIKPFhoxJetU6l2o8fUXR5a0PijczW3la1kJjRLJ6UbgoS78gPlqperx3+hW9bvtYqCiT1oTv4iu5jtsim8A1bKIBv5O/nURUoYRDA6caxtvCBNFnEDRN05jSJVIffVzYT1IKO+dhE5XtfwKQyL+6yYj1vPHGMCBDGWgJTAcqv8BuNjrYsstx4a7/ODnW5UkpRL/tK72G6RN/jHry3o4kA== 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=OrThrEXIy/m5+pUPzQD82XQDJOsA+TG3bGCe6vBg2NI=; b=tSwGXSCmVFJ3lm+dOKtVbAItRTlkaWegzNVOJbdt1FgFondQt2gWV7hqBhwYVzrKMUZKEHrX0KD5mcfGAhpNbr2gkxeUjD3pqEeEr4r/dQZTLNRM9C+TvqW4ozEiCcXLhtf9hFgRDi+VR9zip4jqQ7YwMAsF+xJyddtLvoiTD94= 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 SN6PR03MB4368.namprd03.prod.outlook.com (2603:10b6:805:f4::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3477.22; Fri, 23 Oct 2020 15:08:04 +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; Fri, 23 Oct 2020 15:08:04 +0000 From: Alexander Bulekov To: qemu-devel@nongnu.org Subject: [PATCH v7 05/17] fuzz: Declare DMA Read callback function Date: Fri, 23 Oct 2020 11:07:34 -0400 Message-Id: <20201023150746.107063-6-alxndr@bu.edu> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201023150746.107063-1-alxndr@bu.edu> References: <20201023150746.107063-1-alxndr@bu.edu> X-Originating-IP: [72.93.72.163] X-ClientProxiedBy: MN2PR01CA0065.prod.exchangelabs.com (2603:10b6:208:23f::34) To SN6PR03MB3871.namprd03.prod.outlook.com (2603:10b6:805:6d::32) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from stormtrooper.vrmnet (72.93.72.163) by MN2PR01CA0065.prod.exchangelabs.com (2603:10b6:208:23f::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3499.18 via Frontend Transport; Fri, 23 Oct 2020 15:08:03 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 11edf5ec-9e20-4886-cdec-08d8776570e7 X-MS-TrafficTypeDiagnostic: SN6PR03MB4368: 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: E8PX9bTRQUY6MDKnq2yRsSW/pUvpoEqJXliosH6LTHOowg33k4Ra/qu5RNmU2XmV8xDZyEtsEUxBGeBOOuKVd63SlJaoGhUT7TE+KYIWwuVIXtLH69oTCvTq8tbFTNxo17JnqcypMnF8j2c8MdO1pAJus8nGuo9FgrF9pQl2hP5u/s28P4pT7+TEmaDOdq9ZHwskdVG8W4MtuQ3kODaMXZJZKilJbHKmrLKQ+d6E2KA5S9KZ1kgFnXIxVPhEigOzeHMuhaTcgJH2nTDNsiEpkRnvhGwXx2QeVwdjfAABP8RKAnVDKtifudzvFzyywAkUAXOPrZ9xkalMmH683rDCCQ== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:SN6PR03MB3871.namprd03.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(39860400002)(136003)(366004)(376002)(396003)(346002)(478600001)(956004)(8676002)(1076003)(186003)(26005)(316002)(6486002)(16526019)(8936002)(75432002)(6506007)(786003)(6916009)(86362001)(66946007)(66556008)(66476007)(6666004)(2616005)(36756003)(52116002)(5660300002)(6512007)(4326008)(2906002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: bqw1ny072CWa7Xvpec9b/yjax5KC8zl9xKV/THxpZH2DcRY5nW9U4jZ7DZQ0/cx1pLJBIR3DGrmQ3HHz1ij9Hh4elLWPu9l62FEMpJADjYao/Bm1AmFRLM5+IlkrYsBmrwi37hXNEcyME/fkCBCe68RYAfz9uSeffDhDe82Kd1k1gjjGUtiuD6RjUv55lnUrRmMO6XMEHUtVHtemwUVtcxRMfMiTtKskMqAr3ybnwNR6TprPeiQe6whu7esYaQBSgQ2onU+wRbHNdL5TjNFC3jNg0kz8yFyJpnyVa2QSOodoFDsq3vmH4VmNdg8MaJml7dENFoipjS9W+ImyEVKyWKmp+HEt61Eo/0m+bxfWrdRlA6XekcD3TSTcKVebAXYJBS9U8xu/sT67vc5yn+D80OJaWxNDPxqwxXBoa7n1UqSZxDGzxLOVpvvJaJ9gWxqdP+1HvnvH7bvXKdbgrlOm1Cq28N4OthxlyOkw/yFCkVWfEwJwB7A24Dcfov9h2AD1ABzbyHe4k34LpoUorOGr6pKYsW38RIX0sRDKAcygrv8k1ScNOqqMBN6dt33Uwwm5RZJpLThMRZjAxlO8GGu9YuXZ86ngyfVHA6Yki6oFj7lkXUhcAgUt5vrcOwCZ6uHBmnAcG3SBOYkoWf1UPswDyw== X-OriginatorOrg: bu.edu X-MS-Exchange-CrossTenant-Network-Message-Id: 11edf5ec-9e20-4886-cdec-08d8776570e7 X-MS-Exchange-CrossTenant-AuthSource: SN6PR03MB3871.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Oct 2020 15:08:04.4586 (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: bd48sK4JABxSzGzARrMlGQUOg3UOc2xLWYbAGfM3AHsXosoA2IikUCdcAUWVhpWt X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN6PR03MB4368 Received-SPF: pass client-ip=40.107.243.109; envelope-from=alxndr@bu.edu; helo=NAM12-DM6-obe.outbound.protection.outlook.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/23 11:08:08 X-ACL-Warn: Detected OS = Windows NT kernel [generic] [fuzzy] X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, HK_RANDOM_ENVFROM=0.001, HK_RANDOM_FROM=0.63, 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: thuth@redhat.com, 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 a5d1641820..cec0e0f743 100644 --- a/softmmu/memory.c +++ b/softmmu/memory.c @@ -3246,6 +3246,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 Fri Oct 23 15:07:35 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Bulekov X-Patchwork-Id: 302181 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.1 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 80696C388F9 for ; Fri, 23 Oct 2020 15:09:37 +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 E1313208B6 for ; Fri, 23 Oct 2020 15:09:36 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=bushare.onmicrosoft.com header.i=@bushare.onmicrosoft.com header.b="CnqOPcnV" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E1313208B6 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]:41814 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kVyhD-0005Hs-FV for qemu-devel@archiver.kernel.org; Fri, 23 Oct 2020 11:09:35 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53984) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kVyfp-0003RZ-LY for qemu-devel@nongnu.org; Fri, 23 Oct 2020 11:08:09 -0400 Received: from mail-bn7nam10on2090.outbound.protection.outlook.com ([40.107.92.90]:50400 helo=NAM10-BN7-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 1kVyfn-000767-Fl for qemu-devel@nongnu.org; Fri, 23 Oct 2020 11:08:09 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=YxgETuMcEX9uNCYQU5rcDm6M7yFjx3aTq61Lp6sU1apl8xg1lp7/20OqkVNIjyb6eleYqZgcSghDrsLIWCsl7wgwW55fbo/D3SZsYYhu498sliFcvZrAPoiDmtj/ERglvICuuRFyc4X1yDBiXFOa5A7lwkERzcB8kewBMn1TvdkArjDv/wMb3Hfr1TAh+uerKdbrZdKEsqvaLKrTeGSAJn8MPh9C6Gf9a6ZQtsazqKzkMjwInsHmt40tYdpKyrO8SeejJgIzVCSuwkviJ3P+ys4F6KFcpf49YWYpyYh7S7amKnTnHvnOvzoOTEHU//VsLmOzC6Sn+4josbaly61bow== 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=rfU0YUJm6e42MqiA0sP0ieULgwK672yOxRQSk4yJWHI=; b=KkrJTN2Lu9iFRrRekOkauAl8KfWeUXNUPYm9NSakdXp4suulsL2VJv+0yZwxDYqvoaImPU08LrCp5GSSZ8XHRaEJYW+ObWDx3MJJBzTUfKJnc0DsKeXlT9pbCN3tfeXULchJobSRV32odHTdjuwGwR6HCFAKiRN58TKJHJsxs/c/5E0Zr2wDK0KFd5Zy2JUhlx8ArdEG3/0tb8l8iBJtWbIB20+PRYPda4MAFJMpN8ZOCzTDoHTQE9LORcq0ZTCh0Lb6N3oSs8VfCVwaQW8Cv25uwjWaMdVgu9T6Gs/eX2OnQZnOd75LpsIVmByo78PdmuVOmvfzC+f86zl1u4zp0g== 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=rfU0YUJm6e42MqiA0sP0ieULgwK672yOxRQSk4yJWHI=; b=CnqOPcnVX8PZgaf6ffl+JfEzgr8j9yg0/7lLEWN3eMjL33Tkp2PbrFjt/UNzPaRHJeY3gzJVbvrjja/GPKf48D27o+FlQoCn1rg++4i7Y645TFlnVXcVVcceyoBapFXAikmeNMfa0imWN1LPP5jFp6P5AW6oWBjrHzzbpMFGyYo= 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 SA0PR03MB5516.namprd03.prod.outlook.com (2603:10b6:806:bf::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3477.20; Fri, 23 Oct 2020 15:08:05 +0000 Received: from SN6PR03MB3871.namprd03.prod.outlook.com ([fe80::d520:4c19:8ce6:7db2]) by SN6PR03MB3871.namprd03.prod.outlook.com ([fe80::d520:4c19:8ce6:7db2%2]) with mapi id 15.20.3477.028; Fri, 23 Oct 2020 15:08:05 +0000 From: Alexander Bulekov To: qemu-devel@nongnu.org Subject: [PATCH v7 06/17] fuzz: Add fuzzer callbacks to DMA-read functions Date: Fri, 23 Oct 2020 11:07:35 -0400 Message-Id: <20201023150746.107063-7-alxndr@bu.edu> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201023150746.107063-1-alxndr@bu.edu> References: <20201023150746.107063-1-alxndr@bu.edu> X-Originating-IP: [72.93.72.163] X-ClientProxiedBy: MN2PR01CA0065.prod.exchangelabs.com (2603:10b6:208:23f::34) To SN6PR03MB3871.namprd03.prod.outlook.com (2603:10b6:805:6d::32) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from stormtrooper.vrmnet (72.93.72.163) by MN2PR01CA0065.prod.exchangelabs.com (2603:10b6:208:23f::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3499.18 via Frontend Transport; Fri, 23 Oct 2020 15:08:05 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: e84123db-4709-4b96-6888-08d8776571ba X-MS-TrafficTypeDiagnostic: SA0PR03MB5516: 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: Vf75SrdFU6Byoi7g7JXy7wK4esprfGBkqEkZ9psznLHh9bLMKGOa18zyc6mjqa2OtmkVD9k9VODK6UuVs3+8kz6HQSjp2fQp4XpL9Qz7/25iDT8CoHfEf3KIXU9N7iK/EdZjFw1Wjw4Zro3VI9Uc8o50FUyRELvi63Pm5Jp7sLNqg9E8GQPqiXL3Rh5KGVbX8tHzdzfDtYkPNeYtVBaBXfia2Fq214ezIOpf/YuMzLpyP7CCoA3Vfji1nRfPgSImClXnXyWcxNe2Ry9uQDKk3Vixw/11ST5uYm08e65xTCRmQ8kfLGwhhZ7MdTp6DB3WUXK0/tk6mnuuWvizh0pS1w== 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)(366004)(396003)(136003)(346002)(39860400002)(376002)(2616005)(4326008)(1076003)(6512007)(478600001)(5660300002)(83380400001)(8936002)(8676002)(86362001)(2906002)(956004)(36756003)(6506007)(66476007)(6916009)(786003)(66556008)(75432002)(66946007)(52116002)(6666004)(186003)(26005)(6486002)(316002)(16526019); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: koILefOSOUWPyWtzTJKD/d1N0ceiku9MfPTz7zvQDk0hPRUQj1KgE5/Eq6mADlVeaEtXDJosLHz40EPf2UsibK3zfDi/PkB+XBz2J41fJ02Pd3UqYJ2oyol5D2bYvLHm6INcNKN1emXpR2G4wfEVj0W3RSWVVG9U7pTwm/Fm+J+coi2GNWSd/BEL7XvosqEJisR/cDxEBxfy/Juv1o279Jev2G47+O2ERKwZWLdxwGMaGszP8mdGo3kRy/XUQfg4L9EaEc7KGT5E9YZtWb8Z9/7cvhJZbx8D26lblcgs3au1k/gb6MKh1A8i6CDys/eig47msCX1yac0/nf8hBgCqFLj8jPdZfgOm11vn+tw6hCW/Zgp91Gkheyh5FxG2dWmG9ksJtmWFO8tMr+SE2aqnREJ0Fx2KSvMQyKv6D7mjf/5HFkUh0LDOezXZQQfryCtfnfjG5jWlufNrzQWIVf4mSvhh/YJJjSazwLPdP+2o5mL0J15Vb34U6AVOqY+xYOsA5Cz3ryisoLZZVmbwvwOr0JxnOMpsZL4HAYD+EKMgINTO8G4DS0xIj4Sm5q03Nf7DEtulpBFHiD5KsSTM66s/2XKyBnF67sp/rmV76n3q+uFpLwlnA/lt+ArKt5iKnXzp61oYD5WPr9ap5TPDRgpnA== X-OriginatorOrg: bu.edu X-MS-Exchange-CrossTenant-Network-Message-Id: e84123db-4709-4b96-6888-08d8776571ba X-MS-Exchange-CrossTenant-AuthSource: SN6PR03MB3871.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Oct 2020 15:08:05.7788 (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: UEPu11tFJBW/dXhPysexT3tXPpdJSCq834mMqNJZ8wMDATyl/Z1TM8Ho1w0F8DHa X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA0PR03MB5516 Received-SPF: pass client-ip=40.107.92.90; envelope-from=alxndr@bu.edu; helo=NAM10-BN7-obe.outbound.protection.outlook.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/23 11:08:06 X-ACL-Warn: Detected OS = Windows NT kernel [generic] [fuzzy] X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, HK_RANDOM_ENVFROM=0.001, HK_RANDOM_FROM=0.63, 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: thuth@redhat.com, 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 cec0e0f743..ee4a6bc168 100644 --- a/softmmu/memory.c +++ b/softmmu/memory.c @@ -1433,6 +1433,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 Fri Oct 23 15:07:36 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Bulekov X-Patchwork-Id: 270569 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.1 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 0D33EC5DF9D for ; Fri, 23 Oct 2020 15:11:00 +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 5602822210 for ; Fri, 23 Oct 2020 15:10:58 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=bushare.onmicrosoft.com header.i=@bushare.onmicrosoft.com header.b="McN5WE6b" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5602822210 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]:44312 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kVyiX-0006Ke-R2 for qemu-devel@archiver.kernel.org; Fri, 23 Oct 2020 11:10:57 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54012) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kVyfr-0003W1-K5 for qemu-devel@nongnu.org; Fri, 23 Oct 2020 11:08:11 -0400 Received: from mail-bn7nam10on2090.outbound.protection.outlook.com ([40.107.92.90]:50400 helo=NAM10-BN7-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 1kVyfp-000767-Ph for qemu-devel@nongnu.org; Fri, 23 Oct 2020 11:08:11 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=IKh9wDHSH/mHjY7fkMNd6m3G1NMb6uV6kycC0hDpBUlPcJkhL4h/M5SJr1daWPsdpOCF5Prk21bfpBBaDQ1bJ8el8fv/f1HZ7PIdA9Pmiurxihpwn+fUiy51WQfdY83FjPfITe+rqpASBnLM7TkTYPWChmzdhYb7ndJ45g1j4bOmZPjf35vB2KU/yzaaxMbHDb4ZHZfeO52Ce7mGNWGyDTQA+rTBm+WQpT3TlTPBObThSbQSFWzjM1UURmc7bBXVOPRTmYnSJsrxJLKcVXBl60BhhAVZetsy7Is3FX8RKdkiSKp8GiAw8awKcYiKD0siMhHxWR1L6NaDhnnsa1p2VA== 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=Du1CfS+WHxe29VssebPfxiJoVUZxarKaGCMUumgruZO3inYSo7CR5Dd+MsF1rGB2pZaorcMaQ8lHjNnv1Mrc3+PUYqw8MNRGRna8c9oOfDYeQDDWOeH9Sy7GJfN16OxmabOTZyVuDgTUri7XocmWGrI+PMCIXOuPJ8uFLE9bEme3aUAxBZMGHYLLZ05AP9ww+cjlSgj+rpsT/sGyRxdZXcNFUWKurRSkR9/dPgsXv9WzyF0VyL+NhyEQp/U78iB5LUNFqRRWtYta3eSbX5dedap3v3k/4JKM9nnPogoMOBR79x4rBcRODvxY26M2algU4BpsfRVuWVxqmcUzfvEBbA== 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=McN5WE6bWKDkvnS+csq9WxV8C2CVOpYPNsW1P+fKYtlcxPJdjH/DchVw+kqFRDP/W38ytrmarhEZrpHy4vf9mTbzJYx6d0k9B4KWil6owC/JSRtRZnGWX1i+ODTP7os57btkUdzbV2HDZwJLb8fboBWH6XyTgPeUpk6jWXKj5N8= 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 SA0PR03MB5516.namprd03.prod.outlook.com (2603:10b6:806:bf::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3477.20; Fri, 23 Oct 2020 15:08:07 +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; Fri, 23 Oct 2020 15:08:07 +0000 From: Alexander Bulekov To: qemu-devel@nongnu.org Subject: [PATCH v7 07/17] fuzz: Add support for custom crossover functions Date: Fri, 23 Oct 2020 11:07:36 -0400 Message-Id: <20201023150746.107063-8-alxndr@bu.edu> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201023150746.107063-1-alxndr@bu.edu> References: <20201023150746.107063-1-alxndr@bu.edu> X-Originating-IP: [72.93.72.163] X-ClientProxiedBy: MN2PR01CA0065.prod.exchangelabs.com (2603:10b6:208:23f::34) To SN6PR03MB3871.namprd03.prod.outlook.com (2603:10b6:805:6d::32) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from stormtrooper.vrmnet (72.93.72.163) by MN2PR01CA0065.prod.exchangelabs.com (2603:10b6:208:23f::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3499.18 via Frontend Transport; Fri, 23 Oct 2020 15:08:06 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 6fc1c726-e2c5-469b-ddfa-08d877657271 X-MS-TrafficTypeDiagnostic: SA0PR03MB5516: 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: GKirD1C0Eu3KLc7XlidxFXINw7oT3NmdX+2MtRQ7VWomdcstN4YPap12PCU5kgISjfJJ1HgiG0Z8yM6jWZHqx7QC8SSwJDo8k+6EusKA0mw5plvAuO+UNUxFKhKCOFNcU/wXvhAMyRe09LyyYp2yNjFf+fyDTG4CXWyHhkc9HPSJhWkULV/htYEwfH+dS9HzWNoBKWZdSwCgb4Dgjk32PkxalD6WOJyQ7oRtaTP7B4to7BGWdxLgjuZtpsAaAkIpk1Bxk3efOwDm5BHDzHx4//PNUXu7GUub6odcSdHDH5BgsJRTFXoZz+tT6a5j+BDFEk1dUheqOOfBU9fFU7J2Qg== 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)(366004)(396003)(136003)(346002)(39860400002)(376002)(2616005)(4326008)(1076003)(6512007)(478600001)(5660300002)(8936002)(8676002)(86362001)(2906002)(956004)(36756003)(6506007)(66476007)(6916009)(786003)(66556008)(75432002)(66946007)(52116002)(6666004)(186003)(26005)(6486002)(316002)(54906003)(16526019); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: KDVYZgxdBfRNy6EUBua4MIUt1uBFGv1It03JhvBZONJX7ReuXnnf/OCiiiuASpJhfsX9jgmrsP0qpwcjG+h8PJLGtiAQJ/UfvF3Z87ZHy+6PAAcS0Qfy2gXW1I9LRFQxEZVenEbGFsOWgbWG+kU+FNN5N7vfGB3NiNLxUHFGhL2j4+YKVOyB97LOYIaQ8VYopwKpbm1fvy+jUFeDX/g+eHwjrVmiplHOW2a4X/g1MagALvDhW2Gn7RkjlWcmP9QFnqfr5Daz0UYx9AdiOtwc3/f8TijAaJH+47J8UnCawfNyN1m9Tzt/g5uWUe9AOL/WN0by2jWwtbxn8CLKPMaNrDmU7gP3DsEm1mSAZNfTxu13Zj5+5rZkoSpLyQxv8ov1timypwODmd8FgrUtYa2Zo9VdlMj+vY1Qbd2eY+Ux8iBuGWjjW2mtnMEulCTCl44I48E+EyKMVLj5Qq9sLVstwlM6vI+VkzbAWoOVXM+m5tyJQWh10KWcITgJL4ZH/YXo9CHF8XWw2CmGa8mu7mNxs5VQjoOElVp95oOzvjV5uD4Qk1RDyUshzXrJT1acKBXAEJ64aUtYAZOOkutx3TmR/8kScvv5QlnTatZSqC//2TwVq9gtyvi337+EG4C961qVi7OS0stb4+4kWHExnVqCgg== X-OriginatorOrg: bu.edu X-MS-Exchange-CrossTenant-Network-Message-Id: 6fc1c726-e2c5-469b-ddfa-08d877657271 X-MS-Exchange-CrossTenant-AuthSource: SN6PR03MB3871.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Oct 2020 15:08:06.9681 (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: C4+ifnoVyIxh8BNtbG28sBxMdf/+tOxl1w718FX5zFqHssLU0H69QZBYbt9xSzok X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA0PR03MB5516 Received-SPF: pass client-ip=40.107.92.90; envelope-from=alxndr@bu.edu; helo=NAM10-BN7-obe.outbound.protection.outlook.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/23 11:08:06 X-ACL-Warn: Detected OS = Windows NT kernel [generic] [fuzzy] X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, HK_RANDOM_ENVFROM=0.001, HK_RANDOM_FROM=0.63, 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 , thuth@redhat.com, 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 Fri Oct 23 15:07:37 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Bulekov X-Patchwork-Id: 270568 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.1 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 218E7C4363A for ; Fri, 23 Oct 2020 15:11:16 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 9A92D208B6 for ; Fri, 23 Oct 2020 15:11:15 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=bushare.onmicrosoft.com header.i=@bushare.onmicrosoft.com header.b="7+ZqbfJH" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9A92D208B6 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]:45828 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kVyio-00075H-KC for qemu-devel@archiver.kernel.org; Fri, 23 Oct 2020 11:11:14 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54058) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kVyft-0003cZ-O5 for qemu-devel@nongnu.org; Fri, 23 Oct 2020 11:08:13 -0400 Received: from mail-bn7nam10on2090.outbound.protection.outlook.com ([40.107.92.90]:50400 helo=NAM10-BN7-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 1kVyfr-000767-Pe for qemu-devel@nongnu.org; Fri, 23 Oct 2020 11:08:13 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ij7LTS8b55G/VBLyZkcwpAqPsJ+S2DTiw+nH6/DFbnjXEofVzcEtvf1Ike7b533v1EgeJ453NI6XbbV9OyF9681g7bJF+HVGX0G8CGtbkOR/tY1BH4Joc0yYT3M6tyt30UCjxBqkb6KcXRz9f1p3EpvuBZ18mQBIlBcYH2QLyX+jAo6INF6wL4AhFHOmJWoAYqtC+6W42LJ8viDKn81zVBR61OjVyY60nPXsnj80A6aGiyx9PzAcjeoKbo4n1hJ4wNnrLHdCGXb1+5w5UlDY/WS5Fw3ooS4aepe4jSzxi6gQ7a7akbcayNAprFSqv3pqjYCCgnjz7uLlUDoTuQC6+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=jwIF3gf92vZDxFBP03YeyaRybQtRjP+EanamgiyoT6U=; b=jDFXcQCl+WRgmdZ/JYummOO7/xV+S0b1bmnSLibRbRix7Hwh8RGsJwWUhIjcUy3FL0xqw3clmThE3wEUdzEmhPL733amlzEntbphg9JHtpMIfW0ID723VGiuivh4UoXbRtYkFPwJW9HMgh6jW1NctczdZhk7PN3yfamqlvDCJlMKgaygjoQVsRRFA42LUz8FLfDZ0cwlA8XTmP/3Xp3mfB27PuZNs2YGhALjSPliKxGzyJ5uA6kD6XebJ9KHFdqfsBxCV+kjkJTjbMrwFKN7ZDLIZuoXYpdsF1BLXzFWURwoZqf1/d3JvAF95lk+nodbtkKL8aUKi0GoCpEndsa2pQ== 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=jwIF3gf92vZDxFBP03YeyaRybQtRjP+EanamgiyoT6U=; b=7+ZqbfJH3AVJWP6GheaX1mE5d7O3+imlQPJ8DPufkOfMf42F3OQNkfHLW6HvgdXlBDYox+qsqV/m0lLTTH+bVqJEJ8MhSiIYdfBoWs2nK0dwdC1wHmjpzSVjxeZ2U+WxBq8fQJj9u/Z2ME+I/IvBcRQJLKOCbjK7VkEJWgmkVMI= 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 SA0PR03MB5516.namprd03.prod.outlook.com (2603:10b6:806:bf::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3477.20; Fri, 23 Oct 2020 15:08:08 +0000 Received: from SN6PR03MB3871.namprd03.prod.outlook.com ([fe80::d520:4c19:8ce6:7db2]) by SN6PR03MB3871.namprd03.prod.outlook.com ([fe80::d520:4c19:8ce6:7db2%2]) with mapi id 15.20.3477.028; Fri, 23 Oct 2020 15:08:08 +0000 From: Alexander Bulekov To: qemu-devel@nongnu.org Subject: [PATCH v7 08/17] fuzz: add a DISABLE_PCI op to generic-fuzzer Date: Fri, 23 Oct 2020 11:07:37 -0400 Message-Id: <20201023150746.107063-9-alxndr@bu.edu> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201023150746.107063-1-alxndr@bu.edu> References: <20201023150746.107063-1-alxndr@bu.edu> X-Originating-IP: [72.93.72.163] X-ClientProxiedBy: MN2PR01CA0065.prod.exchangelabs.com (2603:10b6:208:23f::34) To SN6PR03MB3871.namprd03.prod.outlook.com (2603:10b6:805:6d::32) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from stormtrooper.vrmnet (72.93.72.163) by MN2PR01CA0065.prod.exchangelabs.com (2603:10b6:208:23f::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3499.18 via Frontend Transport; Fri, 23 Oct 2020 15:08:07 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: f54048dd-6fbb-4d52-eb17-08d87765732b X-MS-TrafficTypeDiagnostic: SA0PR03MB5516: 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: pTvhuzz+gzXajfgm023fp2VbImuGmvQNXwKxdXwDtNQ7z01nxZQqDZkV5tJHeyF4P+EhIG+lCk8O/hvfljfpmkGYyFjVSfKDJGqmYXCBTwsbN62dIL8EC7ePpPedljjtdl+uLLF3UiYuXFpOvqtLfkQX3llGRbzMkYAOgWqKz2L8OKH0IpGWtp+OYzUm4ARd1YumuAtgF1lc5DAIksr/Ro0whNJmoTmtTiGXNk3U0Sja69EaEphMZ/eLWXIrtqabb3GjRZgaet6gwIgcwtpyob+zOxIID7kUBRxcgP0Bxt7TwiVI0LcJ4XqpkRB0Bu5ap0gsa8JfpUjZF7FYTNqjBFR9EqvT4yIuLkV37A1rAaZ0PEQpO/JeTQ0N/gs0RRPn 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)(366004)(396003)(136003)(346002)(39860400002)(376002)(2616005)(4326008)(1076003)(6512007)(478600001)(5660300002)(83380400001)(8936002)(8676002)(86362001)(2906002)(956004)(36756003)(6506007)(66476007)(6916009)(786003)(66556008)(75432002)(66946007)(52116002)(6666004)(186003)(26005)(6486002)(316002)(54906003)(16526019)(41533002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: JJy2YBxsfIfCVIs9mbrSr+m8XWvGBwMmKVv+QJtSphEArAG9I+q9oXJ5JeJJu1/9WDfzCnZi0exUW+XTVN37SqsjyWI6q5Wblwm0cZzwqaat2F+uoeddd+ETnhozLdcVXFD66Hm1lXT6e4YCfM3fnwXh0oYo5FCrzJPrRZSZ6NZMyyejmeSXjqYLhNtGti3SEiRTJIj3EonhSENXOKor+a1eczIhMeYi8i3Vb7EFm3n8ffOwdpbVDpP+fxT5/tdJzCVpvex+IyuvKwO5yONeb/27/FSXZP2SwPp/8tVNZeC3Tu9o9GJVkWnrlkv+ITfDBKGptvn3RyOXN25V1f4j92dFacjaBgP9iiz4QfA7Br+xzfsG7TDX5S4u5j/TyEIn0nmgqr8Uv58fPiZTj8FYo9n9cqRwdbzw4PG3WN1c+SXoEiGLLbv9oempW+jfQBDQPXPJxCOh+P2iVyNOVXE/TvLUCdKpBRCSxR+YbxS3JwUzMfQmEPBpvs57HCI/412vpLXof5y3n05XtC8nXxeExN4vy9Qzne3OwgPdEZ8w9peLtz4ANqOKgSWQ/fkreFPDAZSQ1Xgh3sMmy2p1LuBGM7W5TnUHH2igs3cT6nAIzzWLQTV5/ubxoDWQQwXKsLufNkFXyn0vorwMzzkjA8WbvA== X-OriginatorOrg: bu.edu X-MS-Exchange-CrossTenant-Network-Message-Id: f54048dd-6fbb-4d52-eb17-08d87765732b X-MS-Exchange-CrossTenant-AuthSource: SN6PR03MB3871.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Oct 2020 15:08:08.2114 (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: r5gszpib11gVgr1BoAgPdX9qiR3eI1EZqf2xLvjPDw/Miz8iXbDmBiCCY8QD/KUu X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA0PR03MB5516 Received-SPF: pass client-ip=40.107.92.90; envelope-from=alxndr@bu.edu; helo=NAM10-BN7-obe.outbound.protection.outlook.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/23 11:08:06 X-ACL-Warn: Detected OS = Windows NT kernel [generic] [fuzzy] X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, HK_RANDOM_ENVFROM=0.001, HK_RANDOM_FROM=0.63, 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 , thuth@redhat.com, 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 e6b18e4276..d8fb78d13b 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. @@ -482,7 +484,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)); @@ -512,7 +514,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)); @@ -567,6 +569,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) { @@ -622,6 +629,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, @@ -654,6 +662,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 Fri Oct 23 15:07:38 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Bulekov X-Patchwork-Id: 302180 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.1 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 3ED7AC4363A for ; Fri, 23 Oct 2020 15:11:09 +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 A4DC8208B6 for ; Fri, 23 Oct 2020 15:11:08 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=bushare.onmicrosoft.com header.i=@bushare.onmicrosoft.com header.b="dvb0P9K1" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A4DC8208B6 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]:45198 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kVyih-0006pq-GQ for qemu-devel@archiver.kernel.org; Fri, 23 Oct 2020 11:11:07 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54100) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kVyfv-0003hj-Qh for qemu-devel@nongnu.org; Fri, 23 Oct 2020 11:08:15 -0400 Received: from mail-bn7nam10on2090.outbound.protection.outlook.com ([40.107.92.90]:50400 helo=NAM10-BN7-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 1kVyft-000767-W0 for qemu-devel@nongnu.org; Fri, 23 Oct 2020 11:08:15 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=YsCV2zx/xZglNVWyhrxuxwP/2OVue+VUfvzTSb20zKzEVpttlLSPpSMi/LuEz1dnWAc8e50vNQ4wg2LSpxdpk7o/u/YRpNKWL3jwsuMXGWNxRSiRVbxnIpO52gFCcs02S9Rs9ZcvsXyENZFjTsTXOlBTP4numOA90mmjP+JnOMP80+DoOTqplKB27Ez7QYdbLYuAPB50NicnrcTU0WJzizWphKZstu/PJcJHQHEifTcsbBdXaw40t/+QYFB3XaAlKvx9yXNuMnE0sSKIAZOyyk8g3tchNjQgDGPKq4VsH/0BDCqqATW/L6qui2XLxdGVulCae1fkGrDj//TdhbPR3A== 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=Ijboq53E0ffl27ylMXmPDv3YcQtx1rxw+6EHMhfq77o=; b=l6ZQeBPXavvCz4OQcO4v7AeV861FpnVoD6ClxJpJJZzMTodkJ9XaUpFFuO82d2z8c+anINsPctJX9050sQOVSaoMGZajBuqlxgmoCsufdxjrU2N3icsuxJbsZLM9ebWGho9qgN2oxpQg/mrG+6u9UK27O8LvUJJOKvn+xeber5hT8rEM7+nEzQ+zUchtfB2bqQL/FBp3XMQ4h/V0Yxd2lNI3Iu8bMKdd4RXqrdzZtfzJ/fH2EflRx3Xq+y2iXH09tY/WZw4XiC3Qa8EkSduDln05iumFDEPpk8tUhDVXxBMUzotIVMCW1Q98vhd2EyUk8KfbGZ+ZQkvQVey+C1Rcow== 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=Ijboq53E0ffl27ylMXmPDv3YcQtx1rxw+6EHMhfq77o=; b=dvb0P9K1dcfQl5gksmOOZa9vPuMAvWapkTynT4qiUKXqP/A51eQ++LcBaVeL0zy6BVauHRF84josoASCjxmf1xPkh+xIXk0crC6PYwMJQZmMvS5MII5oV9RFhkjQoMhMJyreY4ndXxxJGT34YJaq/59qS+e77rTnF1NHswmUkyw= 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 SA0PR03MB5516.namprd03.prod.outlook.com (2603:10b6:806:bf::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3477.20; Fri, 23 Oct 2020 15:08:09 +0000 Received: from SN6PR03MB3871.namprd03.prod.outlook.com ([fe80::d520:4c19:8ce6:7db2]) by SN6PR03MB3871.namprd03.prod.outlook.com ([fe80::d520:4c19:8ce6:7db2%2]) with mapi id 15.20.3477.028; Fri, 23 Oct 2020 15:08:09 +0000 From: Alexander Bulekov To: qemu-devel@nongnu.org Subject: [PATCH v7 09/17] fuzz: add a crossover function to generic-fuzzer Date: Fri, 23 Oct 2020 11:07:38 -0400 Message-Id: <20201023150746.107063-10-alxndr@bu.edu> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201023150746.107063-1-alxndr@bu.edu> References: <20201023150746.107063-1-alxndr@bu.edu> X-Originating-IP: [72.93.72.163] X-ClientProxiedBy: MN2PR01CA0065.prod.exchangelabs.com (2603:10b6:208:23f::34) To SN6PR03MB3871.namprd03.prod.outlook.com (2603:10b6:805:6d::32) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from stormtrooper.vrmnet (72.93.72.163) by MN2PR01CA0065.prod.exchangelabs.com (2603:10b6:208:23f::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3499.18 via Frontend Transport; Fri, 23 Oct 2020 15:08:08 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 1d6d8ebb-49e4-4507-af3b-08d8776573da X-MS-TrafficTypeDiagnostic: SA0PR03MB5516: 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: roIVUzaBXAoZYTdNH5sV6PCe30Bj/sFx0KGGeKMrILI+5gTFCrej3CIxW91mekl4EX/0vJGiUmfSXf7FuHKgfF9amxGi2AMD/CRYP914Suzyzrjsyucq6EsKwWc6NKfcy/K6NLoyaBbF7AIDDVyLKNg9a6FHsBFR6OIxIJeVdgDActOE611/TS40oQTE8NeRVMz9a0j2DcspYoyHOsM+mTawSgM/5iIMNDz0tfp0+jpgFww+pBl3eHt/PXgyAQt+eoLe7R5Asqjyv3b+o7uhPx//8pqCYzYfnVdnvCNvLZNZjH7R/f9BQJT1/ucwRwRo9MP8ZgOfpoRuLAadDOr2OU6H4qWuGtzIrPS5feM3lbizYJdgv2RsvNhE5TzgjVWH 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)(366004)(396003)(136003)(346002)(39860400002)(376002)(2616005)(4326008)(1076003)(6512007)(478600001)(5660300002)(8936002)(8676002)(86362001)(2906002)(956004)(36756003)(6506007)(66476007)(6916009)(786003)(66556008)(75432002)(66946007)(52116002)(6666004)(186003)(26005)(6486002)(316002)(54906003)(16526019)(41533002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: 2InbQFbC0Wn85E3cd9BbSDEMFe6ATJgbXI0gOAyhqyEHnRWSJiwYeNXOvHHkgHK/e1gTPAif4dZgON50hTSaa1I5RVsM0EVqhG3GOHIkFWyVGR5C0kJjOiPDfW+8uhdJKYGuhyGi1uqiC7EB0gngRVrV2qjF5+WIo8TxoYQet8WXzD3tmvTXSFvyJjHqxM/WVMne3dxAYK6MPMcG6fJZgjIMvJKh6jpqa+W8KG/yoExTTTWYbBGpgDj5jWy9PQCiaJobO8fo9WEHsDbg6ddVa3UysS+jIRSmpjhuMozgA1RB5/vSQxwdo5xhIkA+E8e8NR5LwvZ1aW7rZ4eEQH0B9RZhSmawYOzYEC2C6wQL7rB0F4uJhdY5/FZ8Qwh6wWwgV6SI4ClaveOgj6uNcWEfkOHig/xskGx9OMduIHUnkmhUXrjsUU8TLdhIc16a1QPQvJckoBejj5Dub543w6jPOAwxbZzmcCJaZSivTS9aRTqDM9zuCAqVqVa38fnyptxXWKnbSUyG6lhSDhxyLrnE+Plt9cp1t7r0KC30q0m1PZpOA9nZiNuZhDOjN1kK3sDonTzIFWfds9t5EUT4V6dNIXtCpvlbnExw9GbD9zt0KEiW2jWki9X7Tbh4Ksz1xC4//PODCklGqtlBGP2AHnhPbw== X-OriginatorOrg: bu.edu X-MS-Exchange-CrossTenant-Network-Message-Id: 1d6d8ebb-49e4-4507-af3b-08d8776573da X-MS-Exchange-CrossTenant-AuthSource: SN6PR03MB3871.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Oct 2020 15:08:09.3648 (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: we8PWyPqNLpO5YQlua91lJbRB+dYWOiu9hbAUfZOsAmjojGliBo2qw/HOwyymWPN X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA0PR03MB5516 Received-SPF: pass client-ip=40.107.92.90; envelope-from=alxndr@bu.edu; helo=NAM10-BN7-obe.outbound.protection.outlook.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/23 11:08:06 X-ACL-Warn: Detected OS = Windows NT kernel [generic] [fuzzy] X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, HK_RANDOM_ENVFROM=0.001, HK_RANDOM_FROM=0.63, 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 , thuth@redhat.com, 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 d8fb78d13b..1a1bb7b9db 100644 --- a/tests/qtest/fuzz/generic_fuzz.c +++ b/tests/qtest/fuzz/generic_fuzz.c @@ -808,6 +808,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); @@ -828,6 +913,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 Fri Oct 23 15:07:39 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Bulekov X-Patchwork-Id: 302175 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.1 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 44B85C4363A for ; Fri, 23 Oct 2020 15:17:51 +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 A7A7120770 for ; Fri, 23 Oct 2020 15:17:50 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=bushare.onmicrosoft.com header.i=@bushare.onmicrosoft.com header.b="X+Emmj9Y" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A7A7120770 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]:38854 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kVypB-0007fM-ID for qemu-devel@archiver.kernel.org; Fri, 23 Oct 2020 11:17:49 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54142) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kVyfy-0003oS-A8 for qemu-devel@nongnu.org; Fri, 23 Oct 2020 11:08:18 -0400 Received: from mail-bn7nam10on2139.outbound.protection.outlook.com ([40.107.92.139]:64992 helo=NAM10-BN7-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 1kVyfw-0007AB-D2 for qemu-devel@nongnu.org; Fri, 23 Oct 2020 11:08:17 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=LdfM70DzKnFolijpmWnkk9tEsHhShlKHXDXpnGRXPm+ibW4FMBtONLsWzSs95m41BTmoZIZIH/BxQJ6yjmM/FxCT+Qt+MGwbc5QFHMGb9EJHr2141gKctu+BxEMyw8wqdn9kL6MIyT5k1RtdylliWXawZ3l0movi45PzyYestrnOq1lZkaHIC/ghzRUs7BJn9VGYJTgwti6ZD+Vq7zeU/vaIpfEtFqTC0hx845a782O/MqdBSko2rs6y299l0ck8/fc5CifzmLUd+o0Fb7lFgveXdDHzVfW4yIcpngh1BRbKwCbc8X06YDwFfp8Lj2l4vaj3CopSGWU0jBM/HHo+wA== 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=XD3NZTTCcoSF6I9yTDfpAl15+jM6pDAispeUMheSDdI+3pqvcThQRtkcneJLTILSSIwsGhfgi64/7QmtMQbRVFgn1R266HnZpQ/sa/s+TxNGEFmKK14wT2rH3QDxEdPUDbedXcgGGY6nV9m8n9njoNzYQpq1Esz89DjWIdKzvALA+QQviOwbq4xDTsqzbTwurzo1M/k3Wsa/SIdiGomgP3jkxPsfGWs4xe2U2NeZ69UX6J9zrJu0EOBOONo/sXrvQSu9LR1ULZTU+R42q8mgPmgbTlCNn6LNKi5X1DIkhq0qmQd9D2HyS6BYYgtrPuFSPApvgU13cOfGAkXSOgMlew== 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=X+Emmj9YvF9T7BC1dbHQZabuH/RCyuAI/PFMAECEEhGJ7j0jOrNHniJZpCSK6YcmcIRzYaV9AWiA6BWrzzhe4+aVjOvPYjuecGXUY07hJQjhG6tM6M5Ycpi54xZSHuw6yuEIYdPwIE6lOmemqSh/P6KI/Sdfd/X58Y8B2cv79nY= 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 SA0PR03MB5516.namprd03.prod.outlook.com (2603:10b6:806:bf::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3477.20; Fri, 23 Oct 2020 15:08:10 +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; Fri, 23 Oct 2020 15:08:10 +0000 From: Alexander Bulekov To: qemu-devel@nongnu.org Subject: [PATCH v7 10/17] scripts/oss-fuzz: Add script to reorder a generic-fuzzer trace Date: Fri, 23 Oct 2020 11:07:39 -0400 Message-Id: <20201023150746.107063-11-alxndr@bu.edu> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201023150746.107063-1-alxndr@bu.edu> References: <20201023150746.107063-1-alxndr@bu.edu> X-Originating-IP: [72.93.72.163] X-ClientProxiedBy: MN2PR01CA0065.prod.exchangelabs.com (2603:10b6:208:23f::34) To SN6PR03MB3871.namprd03.prod.outlook.com (2603:10b6:805:6d::32) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from stormtrooper.vrmnet (72.93.72.163) by MN2PR01CA0065.prod.exchangelabs.com (2603:10b6:208:23f::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3499.18 via Frontend Transport; Fri, 23 Oct 2020 15:08:09 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: cecb9230-c4d4-4bff-2da1-08d87765748e X-MS-TrafficTypeDiagnostic: SA0PR03MB5516: 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: OOkJFBdY6TrKEajvAL/+5vUEpOJoNDU6FrvV6kQjTC9qHLt3MLNt/jtivLGur7KFME9sIdde6MWIb6x6w6tnALT7tD9WMFi1F4lc5LASSM7L6/8aaG+wkhyZek2vnfzCM3dWd2uWKU5mrBkoa/kRSCDWnmuKElbkhMwgxvkuq5y0jMW3LaQ9H3lojOH0lro47GAIFoceOWQ+yCJikDetm3fH3CMI7Lz7jTToXqIrUzSMWMCvi7h1vPneS/M6NxW/zi5l9RntrqLluo8UYzTwFeYP+D+mFsfT8mxMZdxfStkpnvcYJ4K+1VEPeK68DC2y0yOI+hMzz1Y3q2qMcdbNvl0NvQVWn52pXPrAMiJBzgRRHCGSaDu++2HaCalSC1EN 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)(366004)(396003)(136003)(346002)(39860400002)(376002)(2616005)(4326008)(1076003)(6512007)(478600001)(5660300002)(83380400001)(8936002)(8676002)(86362001)(2906002)(956004)(36756003)(6506007)(66476007)(6916009)(786003)(66556008)(75432002)(66946007)(52116002)(6666004)(186003)(26005)(6486002)(316002)(16526019)(41533002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: 3xD1NfmaPjAAabABxkXtj34jD84fAQBpALAAXp+Lmo7dxL2FJ5BqAgOxT5qHOtm3/MMUYGxIj2LbhDJj+7UWt3stIuqX8JOa3w/iSMairk34l5FPavbqrTO2TA+5jmLXjmVZiToQBQ9hnt3Pfq49L7bQAPLDKNJCO8DXwiwHIM/nK5qDSmFmu6+F8g+NBFCrTlIbIcFF0sp3UTF2XNhDmIrVZdYfqDrt+T27WxeZcG0Ck/K9YdxUuJcFTKKXX7tWG2npGjMqUZJKGwtO/U1biLy52re2ihCQNXtBt3AMl8RdRgn1y5AFGfD8XS9Gq+ftN7T32Cpx8tG2XbzjRcqA4TvoJ1XSjceTwuixiCYEHS9einJT/nyTdpYqCx20L+BAdgfaKvYdUsfcnEdQm+7Y05W1JvH/gKC5gF8Hm4PZu95CRTCgrCczLhQC3+T/A8u50kUqhK82YZhoUo385M/3B+lGG5OB4hVbV+broSDXJ+4lTD2ivKtYQe9NFE7DAiuu1+JP8w0nntlNYNF8rH9WWdpwdyYZU4VHTvgBnC+o/ZCBp5hKgk+wXd0u6elJwCKh951g2UGXeeW2MS7bIyeP1Ou5Eyusv9S+N6UFcFcfJiuYmnx9FMRaH3jCML9wX8i0JcM3FJ1cWfFjcLbWFW57Ww== X-OriginatorOrg: bu.edu X-MS-Exchange-CrossTenant-Network-Message-Id: cecb9230-c4d4-4bff-2da1-08d87765748e X-MS-Exchange-CrossTenant-AuthSource: SN6PR03MB3871.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Oct 2020 15:08:10.5911 (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: 7iG9woAVUBHQNaKnLgZzD06tohsF3LUw8UEDsZ22xOxO/PgJPyPdLb7jKTYSdYxk X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA0PR03MB5516 Received-SPF: pass client-ip=40.107.92.139; envelope-from=alxndr@bu.edu; helo=NAM10-BN7-obe.outbound.protection.outlook.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/23 11:08:15 X-ACL-Warn: Detected OS = Windows NT kernel [generic] [fuzzy] X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, HK_RANDOM_ENVFROM=0.001, HK_RANDOM_FROM=0.63, 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: thuth@redhat.com, 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 Fri Oct 23 15:07:40 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Bulekov X-Patchwork-Id: 270567 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.1 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 72F69C4363A for ; Fri, 23 Oct 2020 15:13: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 C5658208B6 for ; Fri, 23 Oct 2020 15:13: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="pJOBGvDY" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C5658208B6 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]:53978 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kVyl8-00023s-NN for qemu-devel@archiver.kernel.org; Fri, 23 Oct 2020 11:13:38 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54178) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kVyg0-0003t3-Ab for qemu-devel@nongnu.org; Fri, 23 Oct 2020 11:08:20 -0400 Received: from mail-bn7nam10on2139.outbound.protection.outlook.com ([40.107.92.139]:64992 helo=NAM10-BN7-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 1kVyfy-0007AB-Dj for qemu-devel@nongnu.org; Fri, 23 Oct 2020 11:08:19 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=feKwHl4AQ9I/pIs15ID59GlPmcQhafO5O11jX1yyCYGnrsCzU9GDOdiYuLuismSgD9fA6dvEJyaWSkbmQ0tWWoIgAf+G7yLI3GInfOwlQ/RCAh3vMQEx63r+WtWr3aCmrQ038C8wOwVhPccM0zbCJNWIWk9cs9817bcXMt3E/dFiGvG1oP7tmJMWk3ehbO+PIoAM147nPZcl0cBtvFR5E6PZpHFhFkcjZy4MyZ41FVfVg1XZjFBsKLCOYR9XhRcw+UvzZdeUepkdjow4Jv48FLa/b3URgNr+bX87FhsHM3NtLbZymIqWe+5mmnKmiwxtSEwnB5HPFtTzjZNzeBvtlg== 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=esYDQ+yH++FHDqLUoL3G9yF8fTWCuLAdP7AheGfxkDsFYH2Sr/ImoWN3rTOid8Qcp8bn/8MR5VyJorsUlsGXrxGuzLY55XSrIGcRhXp80EHGduMUpl/qwhEL7CRyyvv4mjI5mv+LJuXlzBk1MNJnBYt2KHf4Fd6oiiCoS59NsvbFjvYYL9Sw3NBNHLgB2zk5Ix7ADzAqbEWgBLinswID5ATx3MFBCawwQQzkvbL7djJBLJ2aQpr/pP8c4dFlxs3P1XswceR68r3TXUl7hyJ/pS/UvY7GJHsstR300ZUgMSuKsBPn63zex2ebcJnziKHbmdd8kf6GZzwrrZNlMv79Bw== 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=pJOBGvDY1eGIirvH5CivGG06cZAjOJLMcsr/467HWnTc2lTSXN46joqQNiYxesSGEJvz36+O+xHQWOWVbKUKhvmfQ9pQpae4w2TTJ2dMkODtXZNESFEFQeXa2YK2L74KxA0YnVACCs1x0qJ2+Fm+PNdo+lDeO3Qk5QBohylB/ms= 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 SA0PR03MB5516.namprd03.prod.outlook.com (2603:10b6:806:bf::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3477.20; Fri, 23 Oct 2020 15:08:12 +0000 Received: from SN6PR03MB3871.namprd03.prod.outlook.com ([fe80::d520:4c19:8ce6:7db2]) by SN6PR03MB3871.namprd03.prod.outlook.com ([fe80::d520:4c19:8ce6:7db2%2]) with mapi id 15.20.3477.028; Fri, 23 Oct 2020 15:08:12 +0000 From: Alexander Bulekov To: qemu-devel@nongnu.org Subject: [PATCH v7 11/17] scripts/oss-fuzz: Add crash trace minimization script Date: Fri, 23 Oct 2020 11:07:40 -0400 Message-Id: <20201023150746.107063-12-alxndr@bu.edu> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201023150746.107063-1-alxndr@bu.edu> References: <20201023150746.107063-1-alxndr@bu.edu> X-Originating-IP: [72.93.72.163] X-ClientProxiedBy: MN2PR01CA0065.prod.exchangelabs.com (2603:10b6:208:23f::34) To SN6PR03MB3871.namprd03.prod.outlook.com (2603:10b6:805:6d::32) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from stormtrooper.vrmnet (72.93.72.163) by MN2PR01CA0065.prod.exchangelabs.com (2603:10b6:208:23f::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3499.18 via Frontend Transport; Fri, 23 Oct 2020 15:08:11 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: f34b559c-9858-4c94-1723-08d8776575d2 X-MS-TrafficTypeDiagnostic: SA0PR03MB5516: 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: loTf01Pq0dKG/d5ml4kNQu+jOnEk+UILGjbTMmD4QRfDQZMmBIZseeVAiOJCDt36h0v6bcQV/FuWa8by5dmJjvCLr/No6Tioctunudqo1c2fcAcA+wbuEZMrsGsaE6UU40qO1s2v3rh9fB7bQwS1NFwwaMu/+d5Y4CP6MS7/34yUccA1Sku1lch7cVRTklnfeCGFIbYxN5tM70vLq03xJCrk7OgL6bWeqXgGERzBx5u/+fbAUmifgDhVNc6Eu5XMasp0YsY3md/lI+nsMXQdOjMgoa9KQKwUvUE5x+yN5EbswxMK70TRbF6tQ3JWV65GyqaHDY23Z4TeQq97J3isHA== 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)(366004)(396003)(136003)(346002)(39860400002)(376002)(2616005)(4326008)(1076003)(6512007)(478600001)(5660300002)(83380400001)(8936002)(8676002)(86362001)(2906002)(956004)(36756003)(6506007)(66476007)(6916009)(786003)(66556008)(75432002)(66946007)(52116002)(6666004)(186003)(26005)(6486002)(316002)(16526019); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: mpvV3ZXZABem/WIQl+GnDn2bjnpADfDyADs19jwOmUUvccxZfDvTj+yT+OOkmoYmGOHO55KJJ81il/mS8olorcsyyP+owz1AhACz33QyCLEHgIVLYCuNnx2UeF9mKBluhmwOW5rpC9/fdY0SQiyIk9HHRb6HgDvMDyQwpWLxsB3IidYzvVKRNpNDgkXGYrj7eI/GqvLS+Um7donxukBZxjqWlTvPkacpfPZfw+WVhRfc//+xZheFuZ56zEYMXbzdu51dobmmXnN/BO08J6CT5Au4pTWdufm7vJn1U9vnO/KrHnfgMVygxPzo9pp0w8PRBQah/bTv71kg+xjWlaza/tXgM15WA31EmfPAXUOpGJQAEC8hrvMLB6DYY/gKOI1QTunq+1JHuKRLSpJpiqAO91aLA00b3HJ3/9dU8egsIWkntVRzNrQWexwU7RvgKd9D7ckRwt8BSFWtkLYxFrF2c0iso5lj1CBioV/YXakrDcJUjQpZdlqI12KaqvTbm85FUP0beuLk/cM8obm0OFrEoGY92KE1hkLxqSe21mjrNNbKGktsiLJYgymwtrdmlNSAMWAvtsqdAFiPHwj7+0NRqG2ieWMk2MHH/SudKzz1WaKnjbqBqBIngXaBHt6ghkCF7hYQqhxhIlrttlQpzYU+fg== X-OriginatorOrg: bu.edu X-MS-Exchange-CrossTenant-Network-Message-Id: f34b559c-9858-4c94-1723-08d8776575d2 X-MS-Exchange-CrossTenant-AuthSource: SN6PR03MB3871.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Oct 2020 15:08:12.6679 (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: H84UwE5HdFthB6mvAcOYJxC67Rpl7cs5LWl7RbZzfVOlMvjSd4NWYO0uLfkmp8CJ X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA0PR03MB5516 Received-SPF: pass client-ip=40.107.92.139; envelope-from=alxndr@bu.edu; helo=NAM10-BN7-obe.outbound.protection.outlook.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/23 11:08:15 X-ACL-Warn: Detected OS = Windows NT kernel [generic] [fuzzy] X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, HK_RANDOM_ENVFROM=0.001, HK_RANDOM_FROM=0.63, 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: thuth@redhat.com, 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 Fri Oct 23 15:07:41 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Bulekov X-Patchwork-Id: 302178 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.1 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 CCB7AC4363A for ; Fri, 23 Oct 2020 15:13:44 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 45DE321D47 for ; Fri, 23 Oct 2020 15:13:44 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=bushare.onmicrosoft.com header.i=@bushare.onmicrosoft.com header.b="HUMTv+r/" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 45DE321D47 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]:54398 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kVylD-0002Eg-47 for qemu-devel@archiver.kernel.org; Fri, 23 Oct 2020 11:13:43 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54238) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kVyg2-0003xy-Mf for qemu-devel@nongnu.org; Fri, 23 Oct 2020 11:08:22 -0400 Received: from mail-bn7nam10on2131.outbound.protection.outlook.com ([40.107.92.131]:42497 helo=NAM10-BN7-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 1kVyg0-0007Ao-Ka for qemu-devel@nongnu.org; Fri, 23 Oct 2020 11:08:22 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=GNswOKa+u/ULWNV4A1dBic6eAI9XktuN3QcV0Or6tuMF+bkVnW0AmlPpLkd2QQLffzNmTf6umw4o1syD0qd68cxLozNU8MvAmZC6CXrQZfatFes/vJNJaqhTQpOZkOyUwknbcCM0SuP+ngr1vRTVXwDUBBfuQDFM37VG4uT6im7ZwOrUZBCkFQqt4VtsA/OxU7EOiFM1a0ExEMGA34vfHx1JSJbzk+WkhvPlYcltBKv06BU980euk+DmPWLS7ny3PSdYqpZBJohPLKX3QV+Ir6MZ6ysWeb20w0sfOD+v36sjyC3fkXpmX9mdWDovt3vZQxK4/20xkR8qplzK4ttBlg== 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=Fb5GLXSP6TVeTbvgkvYZfC2PGNrY1gkFuP+wcwxxtX2DGGuykNmXeqxGVDSQMKoS6MG9w0MYXmOX0PM8aKyk++vszfBAqnW1Cdfb0eVAlU+Vq5R7FGkvIX4VsJMSFtWhp00QrgDUOPdwxzbBnH5ZIM4rVVnOfml42WLX/Xt4TvvLHezK/nMn/GM5MQWNicpADYvWwp9ke+TGHdF8QXTJ0g6FLevOWU6jUADGW2eaSRW6YxzI62q1BshsEHJEYhsnDSt4VR/c/FyeW8+ReGm9V9cufe64yBg5M6rlPl1xIfMyh3W3aNvmZOz8Ll4rUU1rQk8gL8qkydH+s+KLGW/ONw== 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=HUMTv+r/564bHede3nOGESeM+kOyW7c7NnjLxOm+H86h+h43n+jadKH02dzkRHpNJQS2JOw8ZQ9OgtRw2X11gZArs+OQOB3XTc4VCuZhw3u6pAul3Bc2DYQ7VGlXB7rTOU+Hd8InbjboNy1xxnmLvKnKoNTOJlnj782EYn5Wcdw= 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 SA0PR03MB5516.namprd03.prod.outlook.com (2603:10b6:806:bf::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3477.20; Fri, 23 Oct 2020 15:08:13 +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; Fri, 23 Oct 2020 15:08:13 +0000 From: Alexander Bulekov To: qemu-devel@nongnu.org Subject: [PATCH v7 12/17] fuzz: Add instructions for using generic-fuzz Date: Fri, 23 Oct 2020 11:07:41 -0400 Message-Id: <20201023150746.107063-13-alxndr@bu.edu> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201023150746.107063-1-alxndr@bu.edu> References: <20201023150746.107063-1-alxndr@bu.edu> X-Originating-IP: [72.93.72.163] X-ClientProxiedBy: MN2PR01CA0065.prod.exchangelabs.com (2603:10b6:208:23f::34) To SN6PR03MB3871.namprd03.prod.outlook.com (2603:10b6:805:6d::32) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from stormtrooper.vrmnet (72.93.72.163) by MN2PR01CA0065.prod.exchangelabs.com (2603:10b6:208:23f::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3499.18 via Frontend Transport; Fri, 23 Oct 2020 15:08:12 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 8ae08ec0-7391-4b72-96c7-08d877657673 X-MS-TrafficTypeDiagnostic: SA0PR03MB5516: 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: cGtc6QM7zWmI5CJ/cEn2sz73K8eq/uIjHZha/2fiCDs6kf/e9s4eJNxiFdudesyHO5OFIGJX5nae5lwes26iAqX23ztpfZoQI5MMortmJ9Iic9JUOYh6oe68D1ZfsqEeW9XZYIEea+spGzTb2Sv17RFxxGnvGcRdag6KKRCZ9L/nI+oOQOWHC+qtlP+Wp7XuaXfze+VMIStG8wmqy1lQ3hhcIGlLLaYpwrhxh72fCTqdnnu4s6ch9I3HJPTPotyXceEsOdFKQqAOmBXA/tqLfrUMv8qIJ4a+Ec2XyeD5Kd1eqlYdO8/3y5PBt/N3bsWwk4VuTINxIi2YTRshzA44hSR09vG3dEVx5pXrb5jbcGSoHkPLw0RTlT/VmRzruaop 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)(366004)(396003)(136003)(346002)(39860400002)(376002)(2616005)(4326008)(1076003)(6512007)(478600001)(5660300002)(83380400001)(8936002)(8676002)(86362001)(2906002)(956004)(36756003)(6506007)(66476007)(6916009)(786003)(66556008)(75432002)(66946007)(52116002)(6666004)(186003)(26005)(6486002)(316002)(16526019)(41533002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: ceiBp9RqjWopwCvRJKqYVRTKbrpJAfVJ23o0rv5aDQ0zYl1HwSkYQQPy4HvJMFnt6C6mWTlpLZC9lymEvrVnshdXDDaOUqKcHU7eP94cDsjr6Tt1Y6BFIK/m9FH01f7jMCsWuZN5hWqqNzYoGJyyddbEpBHLfjmsvjh9U9j5jXA1umXmj5+bkmL1IwBhDCXsr80J3P/KwTFIJSuHU4PY6ND6iTupyvS06GbhhfK6iC2EVU1UPMB0fgRQo+UwWinAivzB84+frvricHJPtswNCsDRRZ/Vsb8LAPVtUJJHLPJJcaRikowWaAwL61VcaU4adb6pKx1QPK8XCDoMZtLouOz/z5Qiq5cR/Y7NuM0Pj6CdyDwm289LxdOGvE/f8Gbgi0lpUOul8PvtDjw9OTHz3I4oWyPxl5hDaSoW9Itl09vhcdaG91e9K8tZ241aTYAuNjyR2LSmVqKGdLwawkR7XPPHeEppoaWdDmhcmH1by95QisuEWuXPjWLKeEM4DqtIGINkiSzdO2V/8kiG/8YxjD4Y9yRigToqlUqsF62U5KCRbUCGGETU8rpB86+3TlAVPYWmqD/ZkQOP9Ul5ppFU3bALAxOGNuSKqofgM4CCwMUtzQhC04QoEHJFaGfQ8vMKB6qIHZqakzsYKhUoHPk1yQ== X-OriginatorOrg: bu.edu X-MS-Exchange-CrossTenant-Network-Message-Id: 8ae08ec0-7391-4b72-96c7-08d877657673 X-MS-Exchange-CrossTenant-AuthSource: SN6PR03MB3871.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Oct 2020 15:08:13.7263 (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: /EU8OLjeX+UAkWIliD3m9FwApqNOXabA/CPhE9NHq8ozVxin3JsfEMeHtEGlOCtc X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA0PR03MB5516 Received-SPF: pass client-ip=40.107.92.131; envelope-from=alxndr@bu.edu; helo=NAM10-BN7-obe.outbound.protection.outlook.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/23 11:08:19 X-ACL-Warn: Detected OS = Windows NT kernel [generic] [fuzzy] X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, HK_RANDOM_ENVFROM=0.001, HK_RANDOM_FROM=0.63, 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: thuth@redhat.com, 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 Fri Oct 23 15:07:42 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Bulekov X-Patchwork-Id: 270564 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.1 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 32F83C4363A for ; Fri, 23 Oct 2020 15:16:54 +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 72416208B6 for ; Fri, 23 Oct 2020 15:16:53 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=bushare.onmicrosoft.com header.i=@bushare.onmicrosoft.com header.b="jY22bhUu" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 72416208B6 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]:35948 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kVyoG-0006NM-B6 for qemu-devel@archiver.kernel.org; Fri, 23 Oct 2020 11:16:52 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54222) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kVyg2-0003wt-09 for qemu-devel@nongnu.org; Fri, 23 Oct 2020 11:08:22 -0400 Received: from mail-bn7nam10on2139.outbound.protection.outlook.com ([40.107.92.139]:64992 helo=NAM10-BN7-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 1kVyg0-0007AB-Fp for qemu-devel@nongnu.org; Fri, 23 Oct 2020 11:08:21 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=A/3VesC3AQ6ZvCraTeMIDoMQSOKbm6lvrCnZuJil/2DtbLnVUPP7tVnSO5HQvb3Wkpar+XVkTSKk3jSMehjs+epzcg1PRjvoA/+bqVmupxJJ988JnMdkonnmjVs9QxVcl6sL77Dj6E9rYjzOLuhHl3+fMcU+yUxv3nmLAlBVjOYQSJ7uwzod755KGluRwfjZ/wllkqZMHnd9dVsP6KoL2WsgDSsjrIVtXqegVjbTS5bn/uHcDbUsHGTE9mOnV+GgddTmvqD+CXPIvMnIb0hygR8baZulHTFzVG+zFKPbKhASDHpduY7N7zSNOL0s/Bb7G5jNB6sWEK53qyw+JBRPNg== 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=fhub4K0MscenTNQAKzz7uu6HWMoeyiVockrHhmm3j1Q=; b=HsB70NBdumDMzomNhq4iCcAI/v9lnfXangED5JR/NiLCDJHSMDGN5hubFNYkLlI1QRTZCTVjKmzghKueBi5bH91lGiAEtQoFgkJAU/8k3Sz94QApvM9SQ+D8U3N9wceP36tZEK0vrTafe9XleZvnbh0djjZPCLjIeDN1HawCoifNSKRRBKXrhSLgAi7g97oUYTF/5j0M8i27nTMCimUusM5tayca6vggbqhutZyytjSuDesMbBeqC/CWc9c2mQ3IlAv+d+R/BdlZ5Hnu73kLONUQ1Cf3HxcB3LBHuxEIPbmm/13UddMJu6yUwALWXMTftJr/0D88HwAekm2LoSCZrQ== 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=fhub4K0MscenTNQAKzz7uu6HWMoeyiVockrHhmm3j1Q=; b=jY22bhUuBpd+EJE/4NWMSUw1GDVeBlSi0woz7vPothN2XZxhYaCgwCPgrqgu0EuPiRyylVuaMxb1e/OxypXK2wR3SmexSx5XfcowKPR4KC2DS3C3K8BOBWorAQ8ZjoROndVXFx+JwWgTyw44oRCfEW79E3E9cZzxYryVjOZaVBU= 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 SA0PR03MB5516.namprd03.prod.outlook.com (2603:10b6:806:bf::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3477.20; Fri, 23 Oct 2020 15:08:15 +0000 Received: from SN6PR03MB3871.namprd03.prod.outlook.com ([fe80::d520:4c19:8ce6:7db2]) by SN6PR03MB3871.namprd03.prod.outlook.com ([fe80::d520:4c19:8ce6:7db2%2]) with mapi id 15.20.3477.028; Fri, 23 Oct 2020 15:08:15 +0000 From: Alexander Bulekov To: qemu-devel@nongnu.org Subject: [PATCH v7 13/17] fuzz: add an "opaque" to the FuzzTarget struct Date: Fri, 23 Oct 2020 11:07:42 -0400 Message-Id: <20201023150746.107063-14-alxndr@bu.edu> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201023150746.107063-1-alxndr@bu.edu> References: <20201023150746.107063-1-alxndr@bu.edu> X-Originating-IP: [72.93.72.163] X-ClientProxiedBy: MN2PR01CA0065.prod.exchangelabs.com (2603:10b6:208:23f::34) To SN6PR03MB3871.namprd03.prod.outlook.com (2603:10b6:805:6d::32) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from stormtrooper.vrmnet (72.93.72.163) by MN2PR01CA0065.prod.exchangelabs.com (2603:10b6:208:23f::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3499.18 via Frontend Transport; Fri, 23 Oct 2020 15:08:14 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 6dd3b082-a572-4b71-a7c4-08d877657734 X-MS-TrafficTypeDiagnostic: SA0PR03MB5516: 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: D1OiE2ueIIOHQurZwJT9iubX0BDWjhE0FIiZ4KRzFEFhI25u+JmnrMwbd9ozCgSk/AwnPsg4eyI0p8sVq4GNju8bZOLSOW/h0mhuSXmtOS57K9zei8XppVHsIY50VEhmBwxioC78tk1M0zRkSGEwIbYylXFqWigbJUZq58lk2ym8AQdQnwtHJKsdwTWYj5UqtY+/m7L6zD3naUtZf5H48HHyNDcjMYEH9X7T6V2QVjmvNbs4olFe9u5fahjDV1vNFXaVWStuCqfIbOeyTmsIAk+biafI2reCNZ7lfSmOKg4ENzGQrXsE7iuMvG5146j06IlkJwFcbYVZISE97j+LPg== 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)(366004)(396003)(136003)(346002)(39860400002)(376002)(2616005)(4326008)(1076003)(6512007)(478600001)(4744005)(5660300002)(8936002)(8676002)(86362001)(2906002)(956004)(36756003)(6506007)(66476007)(6916009)(786003)(66556008)(75432002)(66946007)(52116002)(6666004)(186003)(26005)(6486002)(316002)(54906003)(16526019); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: qxldeaxiztSo1tSHgQoNosccUil3N+trqL/OPHQFPCKSXNkotTR+0MBOCD+Vqi74s1Op4I9Z9+IYSf0bZh6LIxigJVTO/Jrid0y5/byJQEgIpnzUgHJkAJzkx2hFp6mg5iUg5vLxP+nUUgRLwD7nsZmyGeXiEIu2INLD4HRf/ts074yyKFgJQdfGjP4ZJx84uBaJqY/U3XVZSWz/e7bqe5z1Hxt7paiUrYbnEfcMO6PDT576VESba2FDRmSg6HxbueKKNMoJzIxpWnkd3e753vRoj0whOQp++wEpQ9jiRwc4R3zpBgVtwp3qdARGJk9UgDk5RYRR3ioISeL0v2oCD1QkeKJP7Jxri9qQm+B8hUPMAIMb0scEWSo3PJDvbfIeMmylF3tz15Gyr6ApzY3cW3iQWosqwrOrePuBj04jvCfOnl/7waIFB/NI8nESqxh2IpOm+jMXZOd1N0iJonZ4hgLypy2yRSHV+WkiJgda4RyOCgUM8fPYhsFLcL+G8M9PJ2MBxUiOzxrG9e37RoCJnWgbtnsMFlXKKENJMkhfbKPuXbZuh6TyHEUbliqVnrwxQSZXnpn1lGOdEM5ZijI0bqXyyzR708Sx0OIyxP9nAbkZELGizfBgmS5vnkydIplSNkBz2LXSk8GiQgRX906glA== X-OriginatorOrg: bu.edu X-MS-Exchange-CrossTenant-Network-Message-Id: 6dd3b082-a572-4b71-a7c4-08d877657734 X-MS-Exchange-CrossTenant-AuthSource: SN6PR03MB3871.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Oct 2020 15:08:15.0545 (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: VzKf6pd7m+ayosRZOguCxhg1YZ9FUWwQ3iFozjyXJneS4aUdm8a2UVj74NF2T+NP X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA0PR03MB5516 Received-SPF: pass client-ip=40.107.92.139; envelope-from=alxndr@bu.edu; helo=NAM10-BN7-obe.outbound.protection.outlook.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/23 11:08:15 X-ACL-Warn: Detected OS = Windows NT kernel [generic] [fuzzy] X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, HK_RANDOM_ENVFROM=0.001, HK_RANDOM_FROM=0.63, 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 , thuth@redhat.com, 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. Reviewed-by: Darren Kenny Signed-off-by: Alexander Bulekov --- tests/qtest/fuzz/fuzz.h | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/qtest/fuzz/fuzz.h b/tests/qtest/fuzz/fuzz.h index ed9ce17154..08e9560a79 100644 --- a/tests/qtest/fuzz/fuzz.h +++ b/tests/qtest/fuzz/fuzz.h @@ -100,6 +100,7 @@ typedef struct FuzzTarget { uint8_t *out, size_t max_out_size, unsigned int seed); + void *opaque; } FuzzTarget; void flush_events(QTestState *); From patchwork Fri Oct 23 15:07:43 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Bulekov X-Patchwork-Id: 270563 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.1 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 6DC2AC388F9 for ; Fri, 23 Oct 2020 15:19:33 +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 A276F20770 for ; Fri, 23 Oct 2020 15:19:32 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=bushare.onmicrosoft.com header.i=@bushare.onmicrosoft.com header.b="FJWeYDtM" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A276F20770 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]:41724 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kVyqp-0000WR-NX for qemu-devel@archiver.kernel.org; Fri, 23 Oct 2020 11:19:31 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54266) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kVyg3-00040M-TF for qemu-devel@nongnu.org; Fri, 23 Oct 2020 11:08:23 -0400 Received: from mail-bn7nam10on2139.outbound.protection.outlook.com ([40.107.92.139]:64992 helo=NAM10-BN7-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 1kVyg2-0007AB-50 for qemu-devel@nongnu.org; Fri, 23 Oct 2020 11:08:23 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=J8AUbgaGxsvkYYXJNC5xpcg0THrZwE6n3FGaiCOHqGEOj4XV/DOj56xxThbsGJ7rRfkTmiBsAm2bceE4H3r86OcAaMXXJmWvznLptnj152680a7K6gZpK4Bb8m2Gg1ZWEsjUI51lHH4uo5/CXjCYE/+RqIv8uAOO+QSo96wgF36iJ79eFPYNQAJc5vSU3gmZatA2KPHFP7kYlksu7aF2Qb/F4TeRPTdo/uLUKU2IcUXOce/vlsfJqH8ThBet+hVOU+7hsZaFyi0uZcs1xpZKIF6xyTYYM7l1ju0YPxTRH8zjCH/QPrG8GkjBsx/Bu0SjaP7NPoaQBWxMAGMZlprFGw== 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=2hxvvmoN0/A/Xlg4izaGtkZCY1hDif4TQgLt+baD4u8=; b=MmcnEzn+hcR5hKoEjPUSkthWH1MWH6vwbmDA+JLmusY2TntV3fV9AHVHr5V728bNd3QApLvXxQvSJNQuTX2UIswAT63MrzdzDSiWPHKFZIFXu32fAvhbXMkzx01ZAmLZyHW1t/gQ2P/lvS7MHJi7kZDvARNNZwxV04YUbyye7f3o4huCvtwA3uZ5WDP6q5BzKHQLIfM5e21dIR5QUTLwl6qsQKiFvsQnAcAU3oDOfajnh5zhjrW7KN0vGPw9cwzuVjyVSQ0If5sjUjUBjA0ekx7w48JIVoS/fScddHDkuv8as2lMH2AtQBLCm7qp+/if8P1LElLOZCpu5FqUQvv1Pw== 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=2hxvvmoN0/A/Xlg4izaGtkZCY1hDif4TQgLt+baD4u8=; b=FJWeYDtMBI2/BvC+0xgVaCFok2xUINuynpEQZdQ2bIVNtP856yGRv2uiImH1et4Mya5MTmvRh7wRM9nNgIt7DrPLB6AImYVfhc8ijCwM2V+ygRdMUDxc0R7WLiD5YqEEEjolII4CJio0PzVuGobXWQWL1pJjQp6VrIZ+TAsUOuU= 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 SA0PR03MB5516.namprd03.prod.outlook.com (2603:10b6:806:bf::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3477.20; Fri, 23 Oct 2020 15:08:16 +0000 Received: from SN6PR03MB3871.namprd03.prod.outlook.com ([fe80::d520:4c19:8ce6:7db2]) by SN6PR03MB3871.namprd03.prod.outlook.com ([fe80::d520:4c19:8ce6:7db2%2]) with mapi id 15.20.3477.028; Fri, 23 Oct 2020 15:08:16 +0000 From: Alexander Bulekov To: qemu-devel@nongnu.org Subject: [PATCH v7 14/17] fuzz: add generic-fuzz configs for oss-fuzz Date: Fri, 23 Oct 2020 11:07:43 -0400 Message-Id: <20201023150746.107063-15-alxndr@bu.edu> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201023150746.107063-1-alxndr@bu.edu> References: <20201023150746.107063-1-alxndr@bu.edu> X-Originating-IP: [72.93.72.163] X-ClientProxiedBy: MN2PR01CA0065.prod.exchangelabs.com (2603:10b6:208:23f::34) To SN6PR03MB3871.namprd03.prod.outlook.com (2603:10b6:805:6d::32) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from stormtrooper.vrmnet (72.93.72.163) by MN2PR01CA0065.prod.exchangelabs.com (2603:10b6:208:23f::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3499.18 via Frontend Transport; Fri, 23 Oct 2020 15:08:15 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: aa9265e7-93ef-4f4a-cddf-08d8776577fd X-MS-TrafficTypeDiagnostic: SA0PR03MB5516: 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: ITDh/MHOmPBkt335Biz84uHmWbJiOnpuYuYoBqhx2WreyPZfJYSR8RBEIWRNx02/smFV0LzgwZPU6E3YOPyVv194SREak6dxCGvYPhs/LWNwZw9itvUmgLnPd/ybTU/EvCQ4FOEWTOkroI8HZIyHq6y/O05ot2Kw5sTFXKXTBQl6O71xeJD+IQJkrWvL43lV8wpLiic+wa0lTdNkZqomZEpvxKzy2LSJQSQc6VOUYaao8goDmO2N1bzRyiQQ6fzTNPL9YIYors+CERuHuFYiiEzkLeQCkTHgD2VtNWSUynZdjX3xUerM/UUGF2Sr8sz2nNkZR7HuFVeODBX3jQOoxkm+8B772Habh2JvWkc7Lxeoc71M0E4FWaqoRy/HYc08 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)(366004)(396003)(136003)(346002)(39860400002)(376002)(2616005)(4326008)(1076003)(6512007)(478600001)(5660300002)(8936002)(8676002)(86362001)(2906002)(956004)(36756003)(6506007)(66476007)(6916009)(786003)(66556008)(75432002)(66946007)(52116002)(6666004)(186003)(26005)(6486002)(316002)(54906003)(16526019)(41533002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: lUFFaaC5PvXpWA+p2MYEEyuF35x5YoYUCA4iNiEqqz1rBApIpZhu8IqfqUnKBTtcNGAoqIfcjuwopSIifR8ctJWGFrjJQJSZWraQ9YOX5YywhEh0Vp5Il1ol6qYn5nkoKIUkVE/TfUj10BQ93pXl1fFIoQc6ReOrlozlhx8rvssE0qQTL/D/bDckxVpoH4sS2uV/iSOZxH20uGMUWfYrQ2Ox2t4yXHzsB1nR7Hm1hPs9BGCiUgTMSrjoySEXAk0vDaRKv43k7yWrIfwNpKD2Wp9RReY1y7Kc3zCI51m6qdl3q1C6UubRYI0Nd5J8HrjdD7lA9mrOeo6wy00vZC67xXFbkWbb4B7EmVV0WjOrHK3+EHTw3/+KXOZM9n0dxOzJpyDg+bqM8GS7CJkoSFFRlVmv4KFps9Q7kvjvcnhGQc4TVavErf5m0BdqO7uAwi8kE9N4wDaXTcLIxFQJBINp8kuzuQkWdUkNV8WweipY0usfEyBNJSEiV0DWJTaAdWcm1F43XkI4SVrgs8LMADIpm517LBWhLj1hicR3kwWsSG66P9UmKB4LKYQ7ZJSdBMYDiFR1rpcMUlAsmT/hkqSTF3ick2ABf+4mQfIZow/W8wYYttwk8k1vKA+nMoniDR3PDi1ZQxcHwg1mjROCD90zuQ== X-OriginatorOrg: bu.edu X-MS-Exchange-CrossTenant-Network-Message-Id: aa9265e7-93ef-4f4a-cddf-08d8776577fd X-MS-Exchange-CrossTenant-AuthSource: SN6PR03MB3871.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Oct 2020 15:08:16.2718 (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: 8rtzZYmlPMcNmAwBv2cC3x7O6kObpjBbAZCqVheG8r4m1VcqUdoHUGD1evyN18lb X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA0PR03MB5516 Received-SPF: pass client-ip=40.107.92.139; envelope-from=alxndr@bu.edu; helo=NAM10-BN7-obe.outbound.protection.outlook.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/23 11:08:15 X-ACL-Warn: Detected OS = Windows NT kernel [generic] [fuzzy] X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, HK_RANDOM_ENVFROM=0.001, HK_RANDOM_FROM=0.63, 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 , thuth@redhat.com, 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. Reviewed-by: Darren Kenny Signed-off-by: Alexander Bulekov --- tests/qtest/fuzz/generic_fuzz_configs.h | 121 ++++++++++++++++++++++++ 1 file changed, 121 insertions(+) create mode 100644 tests/qtest/fuzz/generic_fuzz_configs.h diff --git a/tests/qtest/fuzz/generic_fuzz_configs.h b/tests/qtest/fuzz/generic_fuzz_configs.h new file mode 100644 index 0000000000..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 Fri Oct 23 15:07:44 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Bulekov X-Patchwork-Id: 302174 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.1 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 962F4C4363A for ; Fri, 23 Oct 2020 15:20: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 04C0C20770 for ; Fri, 23 Oct 2020 15:20:04 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=bushare.onmicrosoft.com header.i=@bushare.onmicrosoft.com header.b="scRYE2Xm" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 04C0C20770 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]:43074 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kVyrL-00016S-Uc for qemu-devel@archiver.kernel.org; Fri, 23 Oct 2020 11:20:03 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54282) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kVyg6-00042Q-1e for qemu-devel@nongnu.org; Fri, 23 Oct 2020 11:08:26 -0400 Received: from mail-bn7nam10on2131.outbound.protection.outlook.com ([40.107.92.131]:42497 helo=NAM10-BN7-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 1kVyg3-0007Ao-13 for qemu-devel@nongnu.org; Fri, 23 Oct 2020 11:08:24 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=oXBZ/cCcApQGW0G25fCV+FA6obCW1fs+AYU68EdyWJ595TGSDCsyKprPy97bimMOHRvZnZ4siiRjNb+O4bnb1B5MUjxtYU4GN202WJfzb0PIJcfo1TTyT/M031sfWej8mIkOVXS8h6ELSekekGRLquVeReqwUp5tfNz9cgw11a8OvKQ2iluuRM/PhVXjjIt9AN+8yF8WvSjnOBP140PmfEJyeb7WRF+oq2nJRofgYBwxrwZSYq+mOog8KqEjig2wJiMA6r9KdE1tAhaEyC5E1R/4zfyNtC7cXyWEwyprswAppNTeb+OOeQ4C34n4fpzDCdg9Ysy6nflIEiMxL5d2ig== 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=tINxldT4C0l9E8W7lCTauA7MwQ6SKdH6F6ASy+HY2BM=; b=b3wvMedxT0Vn9f7rtmcNZRQk83+CIjDlcjtqB8aTZFItCx7yAlLegd2LogtHTNwtQqN5Xv3rZLYdRmrRpIsHxUnpAj0+yVKkDqef+rkBbmunwQQAMnH8OkyGX7sbAJNMycnXaaPDO1mZEcX8/FHzimZiLi7eEGA+jWv1MjaVfF0Clxkr9vMfPzw0gph/hF48GmTH3/ZpfnfcUizLEJTXKQr6eGKO895f2deiUYCeuySVJQEJKzfp6ixWZ+ZJBJ1uB66chttQGfLZBqcZN7SMvqvz1q1SnnudyDTnIXV0p7yM4kmwU65Dv7dsaunvK4wqyw7ILG3iaOCxRiUkyWq17Q== 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=tINxldT4C0l9E8W7lCTauA7MwQ6SKdH6F6ASy+HY2BM=; b=scRYE2Xm0u0oriYWmKLKslN8+SkZ7Yhb9xzhBNRcr5V/naRpZyrcP1lsTjXRR5QnLOEXb7RofHsNhfcoWfiQ7lOu6iL6VpH9wEQj6n57BEc3Jv0mkCiTy1U6mxDOtbt1Rul58NERKyf5oPLvVlP5MscRnGLoq7FbIltwtabbOXA= 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 SA0PR03MB5516.namprd03.prod.outlook.com (2603:10b6:806:bf::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3477.20; Fri, 23 Oct 2020 15:08:17 +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; Fri, 23 Oct 2020 15:08:17 +0000 From: Alexander Bulekov To: qemu-devel@nongnu.org Subject: [PATCH v7 15/17] fuzz: register predefined generic-fuzz configs Date: Fri, 23 Oct 2020 11:07:44 -0400 Message-Id: <20201023150746.107063-16-alxndr@bu.edu> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201023150746.107063-1-alxndr@bu.edu> References: <20201023150746.107063-1-alxndr@bu.edu> X-Originating-IP: [72.93.72.163] X-ClientProxiedBy: MN2PR01CA0065.prod.exchangelabs.com (2603:10b6:208:23f::34) To SN6PR03MB3871.namprd03.prod.outlook.com (2603:10b6:805:6d::32) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from stormtrooper.vrmnet (72.93.72.163) by MN2PR01CA0065.prod.exchangelabs.com (2603:10b6:208:23f::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3499.18 via Frontend Transport; Fri, 23 Oct 2020 15:08:16 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 7ddf5275-fb4f-456c-3a61-08d8776578b9 X-MS-TrafficTypeDiagnostic: SA0PR03MB5516: 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: 3ELhuNHd7qDSmpeS3FJbDUSvIkXCLX6JSHsMlKoTPDap/FtvjghsIwdaJexi1KsPAOcp27S0wC21sspEi7HHrOUKu1MoTSlbwpp4IPRKl+v2Paww3MgAVucOeBWe6vyLHQ+s3gtMoPqp2T2IYt0Yk1e4xJ0Pe0yhTwKeANBZakYvykKdEhFg+X6/vD9fuuKEKDu7JCMMZu8O4iU2NamGatazaMe6LlJ1yjKaYradTqkmoPJvibi1jgBm3wrTZqktxf76VgVt6U4JSZlYb8VursyOHONtrIkHNATM5ivuBndXi1hOAOkTroyDlToePL6a7KgDeCkeVB5NOpbAazRUMzs8+07MzAbweg4hbLK/HQ+r5igY+OanFVvMAiHhemtl 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)(366004)(396003)(136003)(346002)(39860400002)(376002)(2616005)(4326008)(1076003)(6512007)(478600001)(5660300002)(8936002)(8676002)(86362001)(2906002)(956004)(36756003)(6506007)(66476007)(6916009)(786003)(66556008)(75432002)(66946007)(52116002)(6666004)(186003)(26005)(6486002)(316002)(54906003)(16526019)(41533002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: GIKKG61hSvRpq/LIckinDmPf4x9wuKCbzRrI6VUIrBFg9pF9pg2Va1kBsNaAYHV/wi7OeyYE70UcmOzP+gvA0gxU8bVIlY3bOmlNnx7JmZX8gGtko6VSz4ZlNiT1l6KoleQjE2wX/lDR31h4fCM7bl9804d006GdeHee4E5/7wUU8iMyZh+OEL8J78/ZOI41dCbgo1mCg/Ac1tWwV0NBLfkmNLEBi7FmrU5NJ6Avt5Q1rnXsOQ/PJN4bb33kOsuP91Tuokb4F278ejbXkngv9DRhr0piJTuBOMwYWxwVLWBqJqFW//HJAL58dFqRyI8p/rIQthPB2cabhl5BpGbQslKRNQyeiGYQSh6XMhBQo8tEN+HnI3wZXXU4X/CrPzRTD7rMC5nj7e955K9uQOBklaX64EmutZE332EzcSx1sdukbDEozUD9uiFQtzf066mGLB6xIm+5c8BjQRuOHfAYC0+5r+DIevEPcBOwJMl/5MYXk68oupdGAL8xwWDqJiJ+yqmNZ2fKzwfNlUQGq2smqzr3/9fgLnFKpSxMjDVLspS5KxMiTdG1o2XI5Y7nG6P4k+ejHWDy8M/lD81MkaSrNghoumFFP+V+IX6g81k4+R+v/Y47655zReEPkPRBf+2C9M4l+uYeqgfZa5tz5CVRPg== X-OriginatorOrg: bu.edu X-MS-Exchange-CrossTenant-Network-Message-Id: 7ddf5275-fb4f-456c-3a61-08d8776578b9 X-MS-Exchange-CrossTenant-AuthSource: SN6PR03MB3871.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Oct 2020 15:08:17.5261 (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: jVKTQl6yOdlTc9s1y7qnQH4WsASY8qiGMbyMaLrtb/nNhblK+aaRtK7udS6xF1Jh X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA0PR03MB5516 Received-SPF: pass client-ip=40.107.92.131; envelope-from=alxndr@bu.edu; helo=NAM10-BN7-obe.outbound.protection.outlook.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/23 11:08:19 X-ACL-Warn: Detected OS = Windows NT kernel [generic] [fuzzy] X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, HK_RANDOM_ENVFROM=0.001, HK_RANDOM_FROM=0.63, 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 , thuth@redhat.com, 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. Reviewed-by: Darren Kenny Signed-off-by: Alexander Bulekov --- tests/qtest/fuzz/generic_fuzz.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/tests/qtest/fuzz/generic_fuzz.c b/tests/qtest/fuzz/generic_fuzz.c index 1a1bb7b9db..96d78fa5c6 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 @@ -905,6 +906,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){ @@ -915,6 +927,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 Fri Oct 23 15:07:45 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Bulekov X-Patchwork-Id: 302172 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.1 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 69D1CC4363A for ; Fri, 23 Oct 2020 15:24:44 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id A4FF021D47 for ; Fri, 23 Oct 2020 15:24:43 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=bushare.onmicrosoft.com header.i=@bushare.onmicrosoft.com header.b="GlhiulRU" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A4FF021D47 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]:57852 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kVyvq-0007QV-KD for qemu-devel@archiver.kernel.org; Fri, 23 Oct 2020 11:24:42 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54280) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kVyg5-00042O-WA for qemu-devel@nongnu.org; Fri, 23 Oct 2020 11:08:26 -0400 Received: from mail-bn7nam10on2139.outbound.protection.outlook.com ([40.107.92.139]:64992 helo=NAM10-BN7-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 1kVyg4-0007AB-3A for qemu-devel@nongnu.org; Fri, 23 Oct 2020 11:08:25 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Hxf5P4iphHjtV8lxPyQ9i+/SLatnFekwIII6sCX4z3LPstPtREJgpqhuviCvy8v5oT4IaNSyYyBA+Et/lCYLkPElyHK4c2Y1ib4Sz9JDx638rcMC2f6/v/+yMLglmAJoLvtq9+XYR51nlVaeaoNt2lEHaKn2Wym96XVWpLIll3rIvb/hPD8VScNXwMGKQyWDK3RX1c1AjNi/KBNMbJ11L1juR6DTXOVavZr9jOzVpIWLAB2FQNeJ1RSeKvYs8r1hCnYADO24FV/dQS+f7KXG3BnqxLn3UrKUNaawBhxjn8z7bUQkcWTDkzy+oSH2ye25neFSxY8T1KxHNihb/FAYAw== 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=XMwZiaGn6GlPnRuClAbQ6TPmMCq0hfYdl1tadXQ67sE=; b=XLrjpbSCKDaFLogln74NegrzAyXGYD+04kibEI7onIyiFYi8Vyl05rt+AOXcfkAI/g+snwydm8Iwz/U7Nv65X9ZZjQPdMstjutNW2sS2QBafRdBlZlCslhA3ZQ58QFaoEHGqOdfO3NPd7XP16eY8xO2rBz1RBDecuORQIUZRYL6sF1ufq2nSoLEyx0aFBH1xYk77+Ie3t/yJSNJjNjOu7jDJoEBsWCgyjiT+5PTIQzPGh6fktTcI2C5HWREOsKqJSPdkGnzy+KNu/ft+Uz3mPY53tfzMk3K0z53UQPTxqHb1QAipqaX5fZn8/3QmBgvU0c85Tuolx2dW/IhVOtE8sw== 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=XMwZiaGn6GlPnRuClAbQ6TPmMCq0hfYdl1tadXQ67sE=; b=GlhiulRUwt+wDoahxNqiq++GZk1RfX9P1HSHA+mu46qbt4ynOfy856R9CUBONLUyCynr8Z2yrU8AYjxiZiOsrzO/yTLr/HmgU9FAfYLBpB1Vq9iNluUGxNCS39QbXBkllS/rAR9SJtAQ8kpwx0aCDJKPAtJDnaPgkX7E3N1rYME= 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 SA0PR03MB5516.namprd03.prod.outlook.com (2603:10b6:806:bf::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3477.20; Fri, 23 Oct 2020 15:08:18 +0000 Received: from SN6PR03MB3871.namprd03.prod.outlook.com ([fe80::d520:4c19:8ce6:7db2]) by SN6PR03MB3871.namprd03.prod.outlook.com ([fe80::d520:4c19:8ce6:7db2%2]) with mapi id 15.20.3477.028; Fri, 23 Oct 2020 15:08:18 +0000 From: Alexander Bulekov To: qemu-devel@nongnu.org Subject: [PATCH v7 16/17] scripts/oss-fuzz: use hardlinks instead of copying Date: Fri, 23 Oct 2020 11:07:45 -0400 Message-Id: <20201023150746.107063-17-alxndr@bu.edu> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201023150746.107063-1-alxndr@bu.edu> References: <20201023150746.107063-1-alxndr@bu.edu> X-Originating-IP: [72.93.72.163] X-ClientProxiedBy: MN2PR01CA0065.prod.exchangelabs.com (2603:10b6:208:23f::34) To SN6PR03MB3871.namprd03.prod.outlook.com (2603:10b6:805:6d::32) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from stormtrooper.vrmnet (72.93.72.163) by MN2PR01CA0065.prod.exchangelabs.com (2603:10b6:208:23f::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3499.18 via Frontend Transport; Fri, 23 Oct 2020 15:08:17 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 65ecc236-3539-47e1-7066-08d877657958 X-MS-TrafficTypeDiagnostic: SA0PR03MB5516: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:8882; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 6OTNfy69Thd2TmEEJiHWxAFjl1+abnGDclhujXk3mw2cBaKxGbBr7Y6PbSG1oKRdYRb7XAiqyiSe6aaw1yJMDG64xlnDsLRoYDUb14K7NWRB/Hi32g9npKois4YPd6N7nA4SV97kX63vpApx6cL27N39bmsJhX6ZoYsoCL9LlhO5POna7PPkjAj2TUej0A9zqimFYGGy63ldwxItSKdCQI9yTCEfrl7Epo6924K+FjugT69Cnc4wHEyLsWI8xPfqu2nRjT9T6k1+A1zP44bmoMCSsf5auQpD3PwWChrdmIlYJK9+kObMUiKwBHjTJLWG 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)(366004)(396003)(136003)(346002)(39860400002)(376002)(2616005)(4326008)(1076003)(6512007)(478600001)(5660300002)(83380400001)(8936002)(8676002)(86362001)(2906002)(956004)(36756003)(6506007)(66476007)(6916009)(786003)(66556008)(75432002)(66946007)(52116002)(6666004)(186003)(26005)(6486002)(316002)(16526019); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: Blar1jZS4UNDngsiyhEK+Ijri+mmYlMSEL3fQUH4juyh4uNIGkVCglA6iRtaaCejcyR+O4w6z1hKOMlb65jkNxPFjqpaGhhidzFEoLYmUCqjP149uGKoSD8Nj5Xx7wm12Dbw46hZIxhrylLcApJJ0sKg7/0q2rmSYgRng6A2L+lKIakLs4QQEwCp2YRi8kshFPBHGH42HLJBy3u4SuaUc94tro8i99pxLHUecJbEYRc4kgWU0zDh4SH7nfM/+wCPI38ocprc6uIdFgeT5EwAve5PUlz3Op7qpukolX7qmHV+6PbzVlO3Ofh6ZCpNh9H9JU3ybxSweVq/GReVNxUgkhzNrmvSCNtyC7x6EkKYK79/aVx6ujWhdv4IKAUiYd7Nre9LeFsuV816o7pK4fqy/NE8ZFUmu2PygoAUYjD1887iVmLOVuutCpSfR/QbhcK2pETTGCar5eEBSdboqQkihBh2nd/SIUpwRqN6YrQdy+ngt5z5SGVY2iA0BMMn6i8R1b2D0LTazi/V08JUOnbh+O8q5U025GF20tynRN/ZjWrG1lAUvh25LwV4FDlSW5XmdvmlO9cUe37wMScuf4vsJm6liJyhqlBhjbyj+eaeXUcU19P7xX6ehIvrwd99w5RHOT1o7XfwtPyFZ8jrrz+pLQ== X-OriginatorOrg: bu.edu X-MS-Exchange-CrossTenant-Network-Message-Id: 65ecc236-3539-47e1-7066-08d877657958 X-MS-Exchange-CrossTenant-AuthSource: SN6PR03MB3871.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Oct 2020 15:08:18.5585 (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: 0K+7h/iLc0iyginXN3UrWCB5At0k6zLe1k/kGrMVscV6ZzT0XxyE0E5qR8/fP6oU X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA0PR03MB5516 Received-SPF: pass client-ip=40.107.92.139; envelope-from=alxndr@bu.edu; helo=NAM10-BN7-obe.outbound.protection.outlook.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/23 11:08:15 X-ACL-Warn: Detected OS = Windows NT kernel [generic] [fuzzy] X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, HK_RANDOM_ENVFROM=0.001, HK_RANDOM_FROM=0.63, 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: thuth@redhat.com, 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" Prior to this, fuzzers in the output oss-fuzz directory were exactly the same executable, with a different name to do argv[0]-based fuzz-target selection. This is a waste of space, especially since these binaries can weigh many MB. Instead of copying, use hard links, to cut down on wasted space. We need to place the primary copy of the executable into DEST_DIR, since this is a separate file-system on oss-fuzz. We should not place it directly into $DEST_DIR, since oss-fuzz will treat it as an independent fuzzer and try to run it for fuzzing. Instead, we create a DEST_DIR/bin directory to store the primary copy. Suggested-by: Darren Kenny Signed-off-by: Alexander Bulekov Reviewed-by: Darren Kenny --- scripts/oss-fuzz/build.sh | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/scripts/oss-fuzz/build.sh b/scripts/oss-fuzz/build.sh index 0c3ca9e06f..0ce2867732 100755 --- a/scripts/oss-fuzz/build.sh +++ b/scripts/oss-fuzz/build.sh @@ -62,6 +62,9 @@ fi mkdir -p "$DEST_DIR/lib/" # Copy the shared libraries here +mkdir -p "$DEST_DIR/bin/" # Copy executables that shouldn't + # be treated as fuzzers by oss-fuzz here + # Build once to get the list of dynamic lib paths, and copy them over ../configure --disable-werror --cc="$CC" --cxx="$CXX" --enable-fuzzing \ --prefix="$DEST_DIR" --bindir="$DEST_DIR" --datadir="$DEST_DIR/data/" \ @@ -88,13 +91,16 @@ make "-j$(nproc)" qemu-fuzz-i386 V=1 # Copy over the datadir cp -r ../pc-bios/ "$DEST_DIR/pc-bios" +cp "./qemu-fuzz-i386" "$DEST_DIR/bin/" + # Run the fuzzer with no arguments, to print the help-string and get the list # of available fuzz-targets. Copy over the qemu-fuzz-i386, naming it according # to each available fuzz target (See 05509c8e6d fuzz: select fuzz target using # executable name) for target in $(./qemu-fuzz-i386 | awk '$1 ~ /\*/ {print $2}'); do - cp qemu-fuzz-i386 "$DEST_DIR/qemu-fuzz-i386-target-$target" + ln "$DEST_DIR/bin/qemu-fuzz-i386" \ + "$DEST_DIR/qemu-fuzz-i386-target-$target" done echo "Done. The fuzzers are located in $DEST_DIR" From patchwork Fri Oct 23 15:07:46 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Bulekov X-Patchwork-Id: 302176 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.1 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 A7013C4363A for ; Fri, 23 Oct 2020 15:16:09 +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 25504208B6 for ; Fri, 23 Oct 2020 15:16:09 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=bushare.onmicrosoft.com header.i=@bushare.onmicrosoft.com header.b="5ICYjjYa" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 25504208B6 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]:34526 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kVynY-0005nO-4F for qemu-devel@archiver.kernel.org; Fri, 23 Oct 2020 11:16:08 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54298) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kVyg9-00043M-Qu for qemu-devel@nongnu.org; Fri, 23 Oct 2020 11:08:31 -0400 Received: from mail-bn7nam10on2131.outbound.protection.outlook.com ([40.107.92.131]:42497 helo=NAM10-BN7-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 1kVyg7-0007Ao-IU for qemu-devel@nongnu.org; Fri, 23 Oct 2020 11:08:28 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=RZ/1m7MWnLKHq3A7WhDCMCtsEl/B+OMB6D87D/TaLeeDmt4OGC+va6/crNcZ+NNrxvjDyH25DlDOSprd6I9/fT1WqFFH2kdeU3QseTg0QptK91rmoJYMsM7wzngvuzTBDRE3Ms4jwS3Qn/RMx8aPyqDHgIgIP41moUf2xeYLK0S/ZS/06zIHgHKFwv+GOwjKctIF+X133HT5jOjv0qeXES/ynZizPXXqM7k8twlke1N4lX2z2ZnrKnG6lk+v0QD1om5vac5HmCAWDQQQQzxStu2x8i8Qm9vQJxmIrVE1kgX8CzDBS8qkq003GG3Vu9fEBPQADmeS8/yVWDr+sPYvcQ== 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=MqH9vnWqMAR2Mfmm/R7rEWV0ea8cuyiyLEoww1AqzTI=; b=KD/YxOzK+obl1nr8QMdBzB/2tIjwFoOpMAb7/TvOtpYZ6WPM5I+Fvby+gJvVdXvrZoeAUDrKnZpTJat2KoolBNp60LgJHwDW0otBSSUkNipAfy/wi+N3EmNj91c3s7AjlDBeY6MhnWmGChuKSqryAyl8rR4d1AtGP9vQW3s9gQrQzsj8R1N9juja5wZOcBVnw4k5jhzxeLmbNfJydEiZ5dyDAteYea8OIk4bdeT5Sys4/4cXWbdruci/B4dTD5sEAK5t0LLQuufBv1lyx+m9xS1vc7BYQHbonFSoxFo+tkC5gO4iL+D9OjQARkAFhuSlzVDK83BhNu37FDU2nQq9hw== 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=MqH9vnWqMAR2Mfmm/R7rEWV0ea8cuyiyLEoww1AqzTI=; b=5ICYjjYavd6r62txFWFCpGNKK/7/VHnIIE/I8dK08/8mG/1pjgZhGjrAWtTByiqMI9KxkF96tyJFmYvmQ91AccqiUep4Obnslm+SJCU9xLEB3/lujSTg4uKiwSBcxpEMGJosI/9EYBon4Cs0/Q3VAVO6hi8gDymXDCxWT3U/5YU= 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 SA0PR03MB5516.namprd03.prod.outlook.com (2603:10b6:806:bf::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3477.20; Fri, 23 Oct 2020 15:08:19 +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; Fri, 23 Oct 2020 15:08:19 +0000 From: Alexander Bulekov To: qemu-devel@nongnu.org Subject: [PATCH v7 17/17] scripts/oss-fuzz: ignore the generic-fuzz target Date: Fri, 23 Oct 2020 11:07:46 -0400 Message-Id: <20201023150746.107063-18-alxndr@bu.edu> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201023150746.107063-1-alxndr@bu.edu> References: <20201023150746.107063-1-alxndr@bu.edu> X-Originating-IP: [72.93.72.163] X-ClientProxiedBy: MN2PR01CA0065.prod.exchangelabs.com (2603:10b6:208:23f::34) To SN6PR03MB3871.namprd03.prod.outlook.com (2603:10b6:805:6d::32) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from stormtrooper.vrmnet (72.93.72.163) by MN2PR01CA0065.prod.exchangelabs.com (2603:10b6:208:23f::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3499.18 via Frontend Transport; Fri, 23 Oct 2020 15:08:18 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: f1f8863b-7ca8-4e02-3494-08d877657a07 X-MS-TrafficTypeDiagnostic: SA0PR03MB5516: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:8882; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: BdC9CrylQOpoYnQqTXJ6Y1FinrO+sY18BOm01MG00tyV82CHyv8PHzwiE9CI3lLNN2yGqNHPDsY2NlHAGBXUSE5R282aummFAoy0DKtnulK0Y3027G5Xo2YkIA7WzmezBRWKX0AdcktWLV2byBWfA8J+k+MKKiOnpUzvN0wLlK0XJUunCvvZEQkbt9tn5QJVI40pCnvvS0h+xDdMWKfC9W7rGN8myJueHs0UzUtvPoZMSJP2hLQaP4i3NZtdhBYQIoiCd8j0+ld11/cLiXZ3KzMLCyi+A6hqX0rRqklwAHCsAjAJchjzWhgXk1AaM4wWAelb1W5yz74T3qr4JNNnVvjNY2/Q8HgnFGX+lqfd9m8fPJ1+18juM0eNzhIJMF2a 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)(366004)(396003)(136003)(346002)(39860400002)(376002)(2616005)(4326008)(1076003)(6512007)(478600001)(5660300002)(83380400001)(8936002)(8676002)(86362001)(2906002)(956004)(36756003)(6506007)(66476007)(6916009)(786003)(66556008)(75432002)(66946007)(52116002)(6666004)(186003)(26005)(6486002)(316002)(16526019)(41533002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: 5PE9Xl7cCx7AROr9W7bL5oelJa31T4QrTYsKFHLb8Qi5yAiKoCfjzrPOr3j8EKaYCyZJadWkr7JAcH3h7iafFy7cYgmROUaI+uqQPYSJeCUat2fBMbMzFTsO8rJreL1Odo2Qjme6rPMm7083jFuwWDkjCbj8551kZ3ZLllcDB1XFCU4y/8uGUROPHzPqLAr8q8F+SIQmYOdPKWBjNP+w8EUKIEWe9St7T5M5S61pfbmZVFb1ZjvkN11WND/sT3F+A5yMBhXI+nawL1+ZpMLUYfFyzEtajyQ6pxoxL4HpbqdJyLZKJj+j9jvpStFnsJlnD/ja4cdOD1+i40AV0T+HzzWnt8anQ5resq/NqLQMptYxsW7W2SCLndK8Nj0YlZo1fZZ9li3IV4wXnMnNP/llNisJfLvFfbfXbq8eOimhR4VXHjPtu0NFLi3UZCxJm0Xa/tQn0QbJ3OWM9WcPl5Dj3g2SCO6M8+gnvNu27Rvxc/2e0U2CQPFFp9Y6Wu5DX19Dtne/0Hzx1El3IdjdQ3LOlC+uIkwB/UzPeDfkHcBN6ojfMSoOhlStD/fP/ccDNCv+OOpdYk2agPgHE9OucviG6Jolea9XjCioG3utQtjGLR0EA+DUD9lZLfJ4Lfi5lVRfWVZgapVb31mUBhDpEO5aJQ== X-OriginatorOrg: bu.edu X-MS-Exchange-CrossTenant-Network-Message-Id: f1f8863b-7ca8-4e02-3494-08d877657a07 X-MS-Exchange-CrossTenant-AuthSource: SN6PR03MB3871.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Oct 2020 15:08:19.6819 (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: 5WJrsOkx4fZaYMjQ1YzI9xN/QiVYdtpMonaiJ0oworOCtfEHNtcCYLiSqkQvFuCa X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA0PR03MB5516 Received-SPF: pass client-ip=40.107.92.131; envelope-from=alxndr@bu.edu; helo=NAM10-BN7-obe.outbound.protection.outlook.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/23 11:08:19 X-ACL-Warn: Detected OS = Windows NT kernel [generic] [fuzzy] X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, HK_RANDOM_ENVFROM=0.001, HK_RANDOM_FROM=0.63, 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: thuth@redhat.com, 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. Do not make a link for the generic-fuzz from the oss-fuzz build, so oss-fuzz does not treat it as a standalone fuzzer. Signed-off-by: Alexander Bulekov Reviewed-by: Darren Kenny --- scripts/oss-fuzz/build.sh | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/scripts/oss-fuzz/build.sh b/scripts/oss-fuzz/build.sh index 0ce2867732..40e15985cf 100755 --- a/scripts/oss-fuzz/build.sh +++ b/scripts/oss-fuzz/build.sh @@ -99,8 +99,14 @@ cp "./qemu-fuzz-i386" "$DEST_DIR/bin/" # executable name) for target in $(./qemu-fuzz-i386 | awk '$1 ~ /\*/ {print $2}'); do - ln "$DEST_DIR/bin/qemu-fuzz-i386" \ - "$DEST_DIR/qemu-fuzz-i386-target-$target" + # Ignore 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. + if [ "$target" != "generic-fuzz" ]; then + ln "$DEST_DIR/bin/qemu-fuzz-i386" \ + "$DEST_DIR/qemu-fuzz-i386-target-$target" + fi done echo "Done. The fuzzers are located in $DEST_DIR"