From patchwork Wed Jun 30 03:41:22 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Bulekov X-Patchwork-Id: 12351145 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=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,HK_RANDOM_FROM,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,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 9B6B1C11F65 for ; Wed, 30 Jun 2021 03:43:23 +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 2EF5661D07 for ; Wed, 30 Jun 2021 03:43:23 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2EF5661D07 Authentication-Results: mail.kernel.org; dmarc=fail (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]:32946 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lyR8E-0004DG-1N for qemu-devel@archiver.kernel.org; Tue, 29 Jun 2021 23:43:22 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36904) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lyR79-0002Dq-4t for qemu-devel@nongnu.org; Tue, 29 Jun 2021 23:42:15 -0400 Received: from mail-mw2nam10on2132.outbound.protection.outlook.com ([40.107.94.132]:5024 helo=NAM10-MW2-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 1lyR76-0007HD-VG for qemu-devel@nongnu.org; Tue, 29 Jun 2021 23:42:14 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jnDb+e2VuU9uJ65YsWR6eHjmYwYHB0N1aHs2QjGg1VTYx6kadavUs8l3Ysm+hipxphoQl0SQaxqkjXPSMHVHDsa8S52T5N5vLO2WzsDj4u9CdVSc8wLci5jC3T/v0TNRxQ7VijRL6OqPgdQm7XYUMaAI1sv6r5EavAVHdsRGykIml/1Rl7Ca/ofwuzAA7VOsO4ipT4nPPAz/IqkoLUT8bjdnYEvzPW0npww/tVrlpYulbEqJ3tZBKk3q0XLryqtdzCwwE0dqm7EWdFk/z222X3YtFrR9Qmjs6/9vBWwOJqyt5YzYwEauVJxS6zF1MiEJM5w2aaEbgV16c5484X3Okw== 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=9imeiB9aCDEIdZCqooCS7CIrBJUip/G8IeHpyIdKgus=; b=S78jJ1oa2fSs5TlXczGnPjWrWv6ugwV8KMonEtbi8jouyudvMmy4oQ1TRMbAUc7o5EZX9bujbQofIzjacoIAjibRBDgIAYoq4KbzsbdOnKHTg7+7xqIlFVbCDNs6nj5qM1FfbHqzn2F1B0CeP4dA4Use46sFROKzLiNdBx2QkJ504JiB5npGCywnBcAnEq3fAOjVmpPFI3dX6pv3eJ8zz2i8Ho8C54gE9LUbxTXBFzgAxNRFCTbS7ke8p//7f8DJvf8xaALMKwjDvhCzYjYECbBAo2W73IBWJJD5f7dUamM9d94sQc9/kUMgCDsDaiSWMFTz+LrvdsGqo3fKzPmppw== 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=9imeiB9aCDEIdZCqooCS7CIrBJUip/G8IeHpyIdKgus=; b=mBl0lcybLlvArcMZ+gwZpsKPC/pekMMOeWyQy54cvWkOM8rNs8AEpIjbigF/FCa4mqz610c/VZ60+qsrl3AfIx2E21tDu8OQVD7zhOle99voBurXT+SeyDJJ45RSnpK9Lhp+KmqOoQjJ95+QYwOEtqd9KV93dvTzgazz/dn9OZk= 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 SA2PR03MB5817.namprd03.prod.outlook.com (2603:10b6:806:11d::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4287.21; Wed, 30 Jun 2021 03:41:36 +0000 Received: from SN6PR03MB3871.namprd03.prod.outlook.com ([fe80::24fc:a5d:be8d:eb3f]) by SN6PR03MB3871.namprd03.prod.outlook.com ([fe80::24fc:a5d:be8d:eb3f%3]) with mapi id 15.20.4264.027; Wed, 30 Jun 2021 03:41:36 +0000 From: Alexander Bulekov To: qemu-devel@nongnu.org Subject: [PATCH v5 1/3] fuzz: adjust timeout to allow for longer inputs Date: Tue, 29 Jun 2021 23:41:22 -0400 Message-Id: <20210630034124.222689-2-alxndr@bu.edu> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20210630034124.222689-1-alxndr@bu.edu> References: <20210630034124.222689-1-alxndr@bu.edu> X-Originating-IP: [72.74.210.193] X-ClientProxiedBy: MN2PR16CA0063.namprd16.prod.outlook.com (2603:10b6:208:234::32) 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.74.210.193) by MN2PR16CA0063.namprd16.prod.outlook.com (2603:10b6:208:234::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4287.21 via Frontend Transport; Wed, 30 Jun 2021 03:41:35 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: ae21d752-12f0-43cc-89f2-08d93b78f650 X-MS-TrafficTypeDiagnostic: SA2PR03MB5817: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:765; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: wPi/uFcRMlo2DyVEYrqbh4W348cucnPgF0U+y0EdErXuBauy6gIhq9pq4iq6UDPfZ9CE7KZ7SgiJ6dAmAsiA/QdsHq/jh6uJ7Y2H2RH0btz6yGKkrl5i8hW7hl0amc37+KchxX/WoiE5h9wWT9TP0Q5JiIoRTih85GbnJVfVVszya3+Sxdu5qIP2EeA0UxYoVw56QXfm6KA2i15CgkChehNyKC5qDJitewfl9/nX/pF2h+ZFbAYa0w9Z8JGpxzBWRW+QQkCM94QeTzksgGpgnljXODVO8y/0CPdfAzjX4dW1/5gn7yJrcJvjq5EdWBJoqHFEgX1IJmssJy13iXh1G+FFrUjXVMoOpd9nLOayiiVx8FW4MH5zoyXM+I7kqot3HXHSbOmR0E+oqaBqAUUu+9GgnOjwpw29YsVL6vOpRy5I/2gv3G4pQXZRWOiyCfywhkz/+TSeRNyNcYJIBLsMXg9uTSa+FGeXVF/CslvmthG2x9XpHZpUYZNUVaIMFGFEVpn2yGM4Ro3gQoHqgzTvGZSNkVJeJtd145B7tAUvyVmnEHnCt54GPXidm9ndL0Ea5r9sK6RTE5V5FmXoSfk9HfV41qIypy3YVU/Q4H677l3Cf+AeHjYr0Po8W7wxsPtJZUr7yT/DYX/RtGNhDUqIMYUvWvTyHavYIELyb5pB9AoRQDNAtfapZaB7SmSRD2MY2RoNxQQ6uCzodw3UPc4C3Owi8U8JI23L6wKe0vCOYc8= 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)(346002)(136003)(396003)(376002)(366004)(956004)(2616005)(66946007)(66476007)(1076003)(66556008)(26005)(478600001)(16526019)(38100700002)(6916009)(38350700002)(6486002)(8936002)(8676002)(6666004)(186003)(6506007)(36756003)(52116002)(83380400001)(4326008)(6512007)(786003)(316002)(54906003)(2906002)(86362001)(5660300002)(75432002)(148743002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: HMFBN12z+fHKIO0LEu9BZ0Il2J6McWlBFU+wgdugMQPTHBQAINoqhB/OfVzz1jTMFf69Ik5BAlwvNMy8wmOP1CW0nQEh58I79w/y4Vrw2cKR+JUTzVakobv4OdVxtlZ/Qy2YTuA2/l09A4xnf9mlBwyQuwIIZaf0koO4rsQO3txVNG80s5oig1DnOIgfhjob8d1k2iaCEEAA238BNRFsiWepDnI9sjnOJCQvTYm5BU4UQdz40PbwM2TODiISl/pVwPJr+zjTOH02+bI7Qh4o8ZKmSyFgCJkjLeWFMFR5LMiyl1kqPEzjlkKn0EFDf5hknioxPL+k7oVri5LvkZd2NegdlTVmaadu9icn7G6eFrtU/5gnGEWlu/FzA97PAXDSodOpdqEg056ep8WvTnb4qgI6JbKmdWRjcgIPV/bbkoWIhaZcZmkueBSKsVp39gtbWOx9wR7MxuRfMh6CVG31saUWTNV4YzP0rU5+cWIbOKwpgPXOI5urX9MVfkXldz4LlKaQiVeX1oaRCLR+0oZ7lo286fIlo1DgYVPYaqXqw6ADw7capGg658tTwojUbVWwZNrcIdxmbe6hgzmqHUqMrXYglimEbw841dVVu6veLV7CUUIqOuodIb4u3gDCbL0vqkRyk7pIdZulSNi6qn3DvPaMiBFtO9KYbuH7jTP8Cje6c7N0hWhosLuKZydUniS1+zWwNoW22XV18S13rK2PHlB1TQ4b6/vIx3eELAVD0vMBqcVvF86eYhKhYDOsk7CuqBr5BpFYuY8ZF6oQ4olqbKW3/ifIh9Klss14CLUa+nG29C7pFxbCZl87o5ryixThLa4/qVkzoATXqknTCvFgPGHjcQ1FyBuBF5yU4PpGSiLKpVlBoNs4KThfvpIC51AMxL/4psQUdAuciirNM6ZobY/LutKghSySLgtk65HrE2Zs8gPvMIJN9bCawF8OUHaxAcOB36VIdN5utfC4V43HrZfcXzGUXjwKODkZ1Qn+v8fBB2gLMIfS1X2UFf6FC5qST7SMrvN/bCH4cPhpLN7Q5KJEDzyzFX8X/TeyeFc4cxr6jtVO+cdNj22wAel2F8PXC2SNkOlHIg1As8jzMG7lndCnQiR+rKXgCfmk7V6rJuP0zmgGFmR2zt4RSzWlR/ck+IyKqSjX0TDyBz0DV/m9sgngtAj1h2luoQpr9XebkF7FP+KRjaB2QKZrEpahog+pNxZYN2Go5u9axuWEDwPfpude4InzjMmr1NK/1wFMF7r77I0US0X9u7ZBtKOtwTL/h4Z2pSXHeRR0PsYi4qbjwU52WIgeMpPmpfpvlbkGucfUkuOUHovTwTxXLkZeNlJc X-OriginatorOrg: bu.edu X-MS-Exchange-CrossTenant-Network-Message-Id: ae21d752-12f0-43cc-89f2-08d93b78f650 X-MS-Exchange-CrossTenant-AuthSource: SN6PR03MB3871.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Jun 2021 03:41:36.6002 (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: vMMJIcuYOc1IwBEMMAtTAQtXvU3wjb3mqsRAxTFtSHGM/XCOTnKUi/QyBAIbGdHf X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA2PR03MB5817 Received-SPF: pass client-ip=40.107.94.132; envelope-from=alxndr@bu.edu; helo=NAM10-MW2-obe.outbound.protection.outlook.com X-Spam_score_int: -8 X-Spam_score: -0.9 X-Spam_bar: / X-Spam_report: (-0.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, HK_RANDOM_ENVFROM=0.001, HK_RANDOM_FROM=0.998, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Laurent Vivier , Thomas Huth , Alexander Bulekov , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , darren.kenny@oracle.com, Bandan Das , Stefan Hajnoczi , Paolo Bonzini Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Using a custom timeout is useful to continue fuzzing complex devices, even after we run into some slow code-path. However, simply adding a fixed timeout to each input effectively caps the maximum input length/number of operations at some artificial value. There are two major problems with this: 1. Some code might only be reachable through long IO sequences. 2. Longer inputs can actually be _better_ for performance. While the raw number of fuzzer executions decreases with larger inputs, the number of MMIO/PIO/DMA operation/second actually increases, since were are speding proportionately less time fork()ing. With this change, we keep the custom-timeout, but we renew it, prior to each MMIO/PIO/DMA operation. Thus, we time-out only when a specific operation takes a long time. Reviewed-by: Darren Kenny Signed-off-by: Alexander Bulekov --- tests/qtest/fuzz/generic_fuzz.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/tests/qtest/fuzz/generic_fuzz.c b/tests/qtest/fuzz/generic_fuzz.c index 6c67522717..43f9011626 100644 --- a/tests/qtest/fuzz/generic_fuzz.c +++ b/tests/qtest/fuzz/generic_fuzz.c @@ -661,15 +661,16 @@ static void generic_fuzz(QTestState *s, const unsigned char *Data, size_t Size) uint8_t op; if (fork() == 0) { + struct sigaction sact; + struct itimerval timer; /* * 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 + * fuzzer, overall. Set a timeout for each command to avoid hurting + * performance, too much */ if (timeout) { - struct sigaction sact; - struct itimerval timer; sigemptyset(&sact.sa_mask); sact.sa_flags = SA_NODEFER; @@ -679,13 +680,17 @@ static void generic_fuzz(QTestState *s, const unsigned char *Data, size_t Size) 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); } op_clear_dma_patterns(s, NULL, 0); pci_disabled = false; while (cmd && Size) { + /* Reset the timeout, each time we run a new command */ + if (timeout) { + setitimer(ITIMER_VIRTUAL, &timer, NULL); + } + /* Get the length until the next command or end of input */ nextcmd = memmem(cmd, Size, SEPARATOR, strlen(SEPARATOR)); cmd_len = nextcmd ? nextcmd - cmd : Size; From patchwork Wed Jun 30 03:41:23 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Bulekov X-Patchwork-Id: 12351147 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=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,HK_RANDOM_FROM,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,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 EA228C11F68 for ; Wed, 30 Jun 2021 03:43:25 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 5737461D07 for ; Wed, 30 Jun 2021 03:43:25 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5737461D07 Authentication-Results: mail.kernel.org; dmarc=fail (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]:33054 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lyR8G-0004HG-Gf for qemu-devel@archiver.kernel.org; Tue, 29 Jun 2021 23:43:24 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36928) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lyR7A-0002Fv-Ub for qemu-devel@nongnu.org; Tue, 29 Jun 2021 23:42:16 -0400 Received: from mail-mw2nam10on2132.outbound.protection.outlook.com ([40.107.94.132]:5024 helo=NAM10-MW2-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 1lyR79-0007HD-6T for qemu-devel@nongnu.org; Tue, 29 Jun 2021 23:42:16 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=lkEi15fOonyKb4z4d20R9D4iNDsy2VvqzQjV3d8ct0+hUnT94y767q9XaQL++fIXMh/JBmBmUAqMHZEeuj6Xb0Xm227+Os1BLr5T+BdEt6oRahdPOVUV0gkzbrv/VFwcAQT1JyzbIbHYuFv+0qEvayvOb0O1akEphzpnanBwugw5jA9Y9EV77OPZ5SsvkNC+2rLBiEnYmWnCBQ6Y604OyhvqAhRBIjWeVDav4/F2mPTkC36cBboDl5yhLFh93YozVR/thHQtrkkuI3wTAY0rf/Y+2eVBcMpEHWVid76qVeJdOGQxmihMNmoDpRh/8BQXxjaTuokp41/va2PdFg1CxQ== 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=IZ3lXN4UUz6DzR0OZYz1o2vxjTy3eBTIvXf0Rmu48JQ=; b=GZoFFr7zkhypSynYO30bp4YU5S3AS2kGz0N/u7tMfgS6QN+VKCKDWE2O4kX1FaPNvJzRNtdhw8bS1zSSCW44Kmz/7sMMpsouWC7ozsReLk+/pM1GZIu71nh6QGUcH1fWv3esb5yQDY3xWMTy6TmHDfjVuJVFkCMc2ZqgTQm8NkLMdilCp1+fmGz6ty5Iy0yyww5L/mjCuCSXNlDRA4VYcmw3Wpv6+zo9mraUyTEXErZPaFUitvehzDwMekSQaY/YFV11JrVwFNACjxpWhuipJno1NpfBuP/muAShqGdUKUAdC0jBYOgSEK9XsB3nt7MFJ3UYuGdY/ZrwFCNbi/ysQQ== 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=IZ3lXN4UUz6DzR0OZYz1o2vxjTy3eBTIvXf0Rmu48JQ=; b=aNvZv5DKk4DHu6CooooF3uj95WzorBWcvOPk/iugODgzIZQ5zfuaS2dfrIyrdMXnXzIKQwMbi4bQLWrRV9atTkXUlGfCj/gVwZS+/m66V5oOVzYpEmK6rP68rFq743nfHLVNQCh/Ycqa05dXreXZfa4HF2lZdMDzR/atEypdyCc= 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 SA2PR03MB5817.namprd03.prod.outlook.com (2603:10b6:806:11d::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4287.21; Wed, 30 Jun 2021 03:41:37 +0000 Received: from SN6PR03MB3871.namprd03.prod.outlook.com ([fe80::24fc:a5d:be8d:eb3f]) by SN6PR03MB3871.namprd03.prod.outlook.com ([fe80::24fc:a5d:be8d:eb3f%3]) with mapi id 15.20.4264.027; Wed, 30 Jun 2021 03:41:37 +0000 From: Alexander Bulekov To: qemu-devel@nongnu.org Subject: [PATCH v5 2/3] fuzz: add an instrumentation filter Date: Tue, 29 Jun 2021 23:41:23 -0400 Message-Id: <20210630034124.222689-3-alxndr@bu.edu> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20210630034124.222689-1-alxndr@bu.edu> References: <20210630034124.222689-1-alxndr@bu.edu> X-Originating-IP: [72.74.210.193] X-ClientProxiedBy: MN2PR16CA0063.namprd16.prod.outlook.com (2603:10b6:208:234::32) 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.74.210.193) by MN2PR16CA0063.namprd16.prod.outlook.com (2603:10b6:208:234::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4287.21 via Frontend Transport; Wed, 30 Jun 2021 03:41:37 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: a36c30f5-cdb5-4c07-8bc6-08d93b78f6f5 X-MS-TrafficTypeDiagnostic: SA2PR03MB5817: 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: zLQSNtxCx/tAlRMxWnllAvEDgmF3h0IcprPFzM8FQIpMDRJAJxv/1fxzXCY142CHxJKdp5dOqX5uvtQWn9Xe8ZGXouAUP+7Sr0KRxAhTAjKwL9TyyqHf6qW5F8XDfeN3d4ITvUzZ9UgnAk1BD7wI4lxNzywCb+5sSbYQYWHrLUf5KFSt2C4T1Jfpf6QtUuMXxiO2U52LycPd5wjh2rDybnK0BCgOR4O5M9K6UM2sS4EOGwgA04ZCaXMLs0Vwlcee1jzn2jdLhQq/lHOvjKD0u7T0jTzeabVeXZdxijLevPG8Nogo2zGQpzM0x06w+uQeV9gLriIW27P7+KUjB+BDlh/LbGDm0N7hvcDvnFvhnbzMxevdvtDk6b4elKIPVrTV/Zfq1JR1NVKbMP4+MxkNlxWT8Cv9AVsrPs6PKl0ESqCoHEauifKjUst0agX/2FiZqs6yLHv5BpDHzjR1TQH8bLcD4fuX+LSUwwhZA0ahoguIRewF+0/ksHtBtxvoDs1U7yUhmBR6vrgw//ogf7OMxByQ45r7k1xMBoxmqObQ026JRU9memTiutj81bhCZPlYESvXAbMj/na0wcvxuWreGSp/0FeoNu1G/9J2OgsUnvEuuq+yzwTEqeZO0kFlmR0dlkF+m9QO6E5pYKSVXfvjG1Jh26dxv0++aQmjN7Gc2ioqK+juftOi7e1Tdp33hHfRmuo1CwGPSQWVizKym7qmr1OQkw2k1GJPv5bgNe+IdgWzX43Z9++pTwXiE20InadbGgtKwxvsMPeBYmm0mKpK/b8z0ofFtktSVcynYAUy29PUT4CEdszFPnD2xUAEuXHCAgwQ41I3EBBMaIsZbs/iFHF55/LEDE6TXsSoyIhAFck= 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)(346002)(136003)(396003)(376002)(366004)(956004)(2616005)(66946007)(66476007)(1076003)(66556008)(26005)(478600001)(16526019)(38100700002)(6916009)(38350700002)(6486002)(8936002)(8676002)(6666004)(186003)(6506007)(36756003)(52116002)(4326008)(6512007)(786003)(316002)(54906003)(2906002)(966005)(86362001)(5660300002)(75432002)(21314003); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: wuiKN7yMBiKkgHH8YbcQc7bbMBQZwFJ5B77mHX29eTO50uVqQnoBls5rCXnV/rmriMWI3Vvfi81pRCNsGFhA8G/1UMtL0VKPYDr7LEXWA8YX1po855JheXv1e38x5bHfXbF1FX/juGCwnPpZ84fDrhl9LMh1QZRw5ht/tgxCAxnw4Z9Gjnqj/xUpFGzg3tjBDNmPCIeGkb4MwZcWgBZ6AJRmCtNIyDYpV0pjN64TYMdNSugf57i2BGesbhFt912pyL/TRu+H8UtL/B1eH9Ygt2Qz/+rGPT1LEzFkOEKx5EfBVRYQ70/8KlK/wMo27AsZdY0qoufHcZY8X9KprBH5hfh6cFeLZ+CrUJ8d3p5VPf34xuZhmEk3l7RGDGBCfz6mWzlUamSm3+Ew9WJYVuz7sxKSZsds5ZaKpDD00zujPY3FOzu/EZNBnHi6d8bjTEBvEPbpdn6IBd0PB4lntuBIWIMyS5lU1VdW72kfA+6sq2R7m6y2vyeIPgw58besR3Jy0EfC9GL7lxUi0xbQJBhzMZ7oTFm9pSeTKpqzZjC/oj28mKbThPjkE7+oaHeJ3GN5huvUrLG425/dL4RsrVLEiSFMqAfVZ3PJTnO2GxI2p8trLf6iApUHUyps+eHrHdCoHHIOzlOWEcae11FKtWPey7fLEnYZF12doxWPhKmhX4jFbycHIFTLQbk6/dvHiGlg1fHjcHyUjcSekU7kHYS7PHReeKbMBtxFVV0eHrboekRyrEY4pHfa+yoWSYCIgegV3k1P64FkZ3ZEXCRSRxXZxkJWf3NKBq3xQYhnjtePcLllhwOppfcfUc8HbmKAWBQ9sOUEt2s2vA7zWyhgHqpMoKmK6znRII34mMv5rMwQNHAAnOoYvJ+qlnCErFpkm98L/RgdUKswI3VEUnnzqY6tp98H1VBt2mt/ORzan1cV70eBD1mMcOjAcx/dJNYLVlCkgLWYO8mKwWCgGf5QTBePL23YKq5mhN7Vl2RdmPS/9eLiFlLvkvDtnAxqp1Vii9LPI9lrV4U8MO9NIma/6jK4kSg3ELG82lytkN1SOfJ3hemwiEMiNYKiSdEJybODnH7YrQ8rptHR7gdM6y2B9vu2ibYQsH8dO3Ax9g863p+wnUKui698sL4PmyPJh7DRAx8RV/bpOUV2fxvXptCt3DlHE3NpfA2ZScsCUVbeSji+Jmv6n/neyL9GHixah0Bi08jQX0wBVYhk5tLxgXVUnyUpM/9jwtHjp0FnwCdif/nWESsx6NfyxipLacMlRfujcma3Q7KkBp0hAHO9CGbnajSvOELKvcTIiSprSOPRfW5e3TAu7WVL8TYJciHS6B1nwNAB X-OriginatorOrg: bu.edu X-MS-Exchange-CrossTenant-Network-Message-Id: a36c30f5-cdb5-4c07-8bc6-08d93b78f6f5 X-MS-Exchange-CrossTenant-AuthSource: SN6PR03MB3871.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Jun 2021 03:41:37.6866 (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: fM0zqcQf9xANUBPz2NW1sZg5vslGuhWBr3B5iiLXUYFlPgKaqv07N7HBc7V3B6cj X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA2PR03MB5817 Received-SPF: pass client-ip=40.107.94.132; envelope-from=alxndr@bu.edu; helo=NAM10-MW2-obe.outbound.protection.outlook.com X-Spam_score_int: -8 X-Spam_score: -0.9 X-Spam_bar: / X-Spam_report: (-0.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, HK_RANDOM_ENVFROM=0.001, HK_RANDOM_FROM=0.998, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Thomas Huth , Alexander Bulekov , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , darren.kenny@oracle.com, Bandan Das , Stefan Hajnoczi , Paolo Bonzini Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" By default, -fsanitize=fuzzer instruments all code with coverage information. However, this means that libfuzzer will track coverage over hundreds of source files that are unrelated to virtual-devices. This means that libfuzzer will optimize inputs for coverage observed in timer code, memory APIs etc. This slows down the fuzzer and stores many inputs that are not relevant to the actual virtual-devices. With this change, clang versions that support the "-fsanitize-coverage-allowlist" will only instrument a subset of the compiled code, that is directly related to virtual-devices. Signed-off-by: Alexander Bulekov Reviewed-by: Darren Kenny --- configure | 13 +++++++++++++ scripts/oss-fuzz/instrumentation-filter-template | 14 ++++++++++++++ 2 files changed, 27 insertions(+) create mode 100644 scripts/oss-fuzz/instrumentation-filter-template diff --git a/configure b/configure index 38704b4e11..3b6ca054b9 100755 --- a/configure +++ b/configure @@ -5189,6 +5189,11 @@ if test "$fuzzing" = "yes" && test -z "${LIB_FUZZING_ENGINE+xxx}"; then error_exit "Your compiler doesn't support -fsanitize=fuzzer" exit 1 fi + have_clang_coverage_filter=no + echo > $TMPTXT + if compile_prog "$CPU_CFLAGS -Werror -fsanitize=fuzzer -fsanitize-coverage-allowlist=$TMPTXT" ""; then + have_clang_coverage_filter=yes + fi fi # Thread sanitizer is, for now, much noisier than the other sanitizers; @@ -6120,6 +6125,14 @@ if test "$fuzzing" = "yes" ; then # rule for the fuzzer adds these to the link_args. They need to be # configurable, to support OSS-Fuzz FUZZ_EXE_LDFLAGS="-fsanitize=fuzzer" + + # Specify a filter to only instrument code that is directly related to + # virtual-devices. + if test "$have_clang_coverage_filter" = "yes" ; then + cp "$source_path/scripts/oss-fuzz/instrumentation-filter-template" \ + instrumentation-filter + QEMU_CFLAGS="$QEMU_CFLAGS -fsanitize-coverage-allowlist=instrumentation-filter" + fi else FUZZ_EXE_LDFLAGS="$LIB_FUZZING_ENGINE" fi diff --git a/scripts/oss-fuzz/instrumentation-filter-template b/scripts/oss-fuzz/instrumentation-filter-template new file mode 100644 index 0000000000..44e853159c --- /dev/null +++ b/scripts/oss-fuzz/instrumentation-filter-template @@ -0,0 +1,14 @@ +# Code that we actually want the fuzzer to target +# See: https://clang.llvm.org/docs/SanitizerCoverage.html#disabling-instrumentation-without-source-modification +# +src:*/hw/* +src:*/include/hw/* +src:*/slirp/* + +# We don't care about coverage over fuzzer-specific code, however we should +# instrument the fuzzer entry-point so libFuzzer always sees at least some +# coverage - otherwise it will exit after the first input +src:*/tests/qtest/fuzz/fuzz.c + +# Enable instrumentation for all functions in those files +fun:* From patchwork Wed Jun 30 03:41:24 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Bulekov X-Patchwork-Id: 12351149 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=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,HK_RANDOM_FROM,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,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 A26B0C11F65 for ; Wed, 30 Jun 2021 03:44:27 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id E822A61D01 for ; Wed, 30 Jun 2021 03:44:26 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E822A61D01 Authentication-Results: mail.kernel.org; dmarc=fail (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]:36402 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lyR9G-0006df-4k for qemu-devel@archiver.kernel.org; Tue, 29 Jun 2021 23:44:26 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36946) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lyR7D-0002MS-4e for qemu-devel@nongnu.org; Tue, 29 Jun 2021 23:42:19 -0400 Received: from mail-mw2nam10on2132.outbound.protection.outlook.com ([40.107.94.132]:5024 helo=NAM10-MW2-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 1lyR7B-0007HD-AZ for qemu-devel@nongnu.org; Tue, 29 Jun 2021 23:42:18 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=GuTTDwcB97Sj7rMeZjdKQTuSqJlZJj2g3OLAfas2EjdShR2PyRPRt42QgLQvocXwDgK3c/f7R6O95/Zwno3J+AQBH+r5nh094VuIE3BaFC6H2ow2DA+LNSUE7STMAz9Fj/a411VIHAfrdkfqm/TtJsoN2M0Q2hjlfXNevdrb4kBXc4IB2b0KkL7iZXWLt+jSiSgNphlmGimGVhlcYYD/PMrKdOc1L/+nQ64v1rwAvLXVph+ojgWomP3ihSZ04Al6Dx0N2HhqMwbbL2GlCVnUJPfeZask3zkL9OQp0J4oAd4jP7prFmsUd6ViF14gBIQjqn4qFNRZvjLsQFWSs9FS8g== 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=wqQYQhMm2XGsqZdWKbgj4vRr5Whd8H0devDPtxIuCyQ=; b=VvQ0HBXdGY2sDCcO/wrP04RuhMj+qd9jUGL4Kdr9IN8flau1q25CNqhf0egyweczmXIKoz1hvNXAdbewe11RUPLHxjBdrIzUnIwxAkgwfCrM9Ejuh44kqFsmBLOsI6a+iPd7u/4Y5U/xYiu7HHyTxsKKOSdLKoh7q5WuLIpZDWjB3xLwgEXO5+uudZG6whMIheMr02OKyh9UConIUB4i1LdnDiKSB6wcHHhVB1vsUsWKyHWkMrtU1THpqlTnnEWiR0x6jHFy3n0F30Nu8aR7d2DhlSdYKjnRYQGYycye3q2YA+vNv15pQY/MPIv9yGztzmyk+mvUOQzEjPwbsOJAsA== 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=wqQYQhMm2XGsqZdWKbgj4vRr5Whd8H0devDPtxIuCyQ=; b=maJnehOWmPqfz0VuZepjWv5apxQA38HWIeCtgwcRMZEV38EdxJJcumnVS2FNjeCo9moMyXP0+QKgHBfAv9Zr5xC9NpjYCAX0ZWRwUrisJfxzDkx4ZZrQE6qwuCZq0Q0Nv166bbbNsVw8wkh6yFl3CtW0NsD0DtDDuVHUxTAABvo= 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 SA2PR03MB5817.namprd03.prod.outlook.com (2603:10b6:806:11d::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4287.21; Wed, 30 Jun 2021 03:41:38 +0000 Received: from SN6PR03MB3871.namprd03.prod.outlook.com ([fe80::24fc:a5d:be8d:eb3f]) by SN6PR03MB3871.namprd03.prod.outlook.com ([fe80::24fc:a5d:be8d:eb3f%3]) with mapi id 15.20.4264.027; Wed, 30 Jun 2021 03:41:38 +0000 From: Alexander Bulekov To: qemu-devel@nongnu.org Subject: [PATCH v5 3/3] fuzz: make object-name matching case-insensitive Date: Tue, 29 Jun 2021 23:41:24 -0400 Message-Id: <20210630034124.222689-4-alxndr@bu.edu> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20210630034124.222689-1-alxndr@bu.edu> References: <20210630034124.222689-1-alxndr@bu.edu> X-Originating-IP: [72.74.210.193] X-ClientProxiedBy: MN2PR16CA0063.namprd16.prod.outlook.com (2603:10b6:208:234::32) 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.74.210.193) by MN2PR16CA0063.namprd16.prod.outlook.com (2603:10b6:208:234::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4287.21 via Frontend Transport; Wed, 30 Jun 2021 03:41:38 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 0fb3ed12-8051-498a-6f79-08d93b78f796 X-MS-TrafficTypeDiagnostic: SA2PR03MB5817: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:323; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ivDXObKJXRXVgIRtiAWGnm8Z6+8LBcY3u+Y4BcQ44a7rEyNMC2oI53HD0VP3Bm/wc7T9nFPrzft4H6rlHSgu8xsyTFa26gHlMJFb6XUBYh0c/+Lqp9wwka7sijdP1zxrQxdr9u28U8aUVNyZLm06Xj6umi76B3UHLl9wDkMImr+XDhq1vVKCHNKgSLOym/zaf3t5IoCb02gBlZpqk0coOVAeQnZZHjC5imXVx7H+6ghcqWYGFqbMz+AgqsBidQm9X1jqOP3bIEs6478lfcqXXVTfQqrdKFFqD7gHKUGnHoyuWSwTZcAYUVTcS+1KT48JuHvzb0KRhVBUJcj4zZGUN/qzuSeXJiAzpsYttli92Q8Ri5Y4QG/l5B+ADnSDup2JVyKJ5tzfPvd+NKj2Q3XQkl79g0zIacs4DANntxRARU+5ybTlvYBU7+8986PLrsjzcB8TW1ZkWP5wJ3KzyZ/sOjZbog8sZzeJv4PCPXk4yLnjSjBEmA2KoQPHKLCIleMRzVk/33UP7T1BF9bBqGXwpbl8zka87S7wgJBgnvdgm8PbI6hfsHH8gxqVrgh5qUlJCd/1N90YQZEfTxGMiMKSHvrPdj1mTVAQael+AlocyOrr+NymH7FltAx/keerA8cyO75l9zGypVg/hLlGc2RgDoCvX7o/Sy3V1hvxSPY2e669ssmx0K2dFuALCZp88OrY 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)(346002)(136003)(396003)(376002)(366004)(956004)(2616005)(66946007)(66476007)(1076003)(66556008)(26005)(478600001)(16526019)(38100700002)(6916009)(38350700002)(6486002)(8936002)(8676002)(6666004)(186003)(6506007)(36756003)(52116002)(83380400001)(4326008)(6512007)(786003)(316002)(54906003)(2906002)(86362001)(5660300002)(75432002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: LcF8Y28rL2tOrnJ8MIFlp1Pzg+fsGdASPHtGKqGT2II3AbsX1I1Ru8+ZUb9U7dBW1bY2p/MdxMtZ6Xk3cAirX5nArJmu4ITFKwKCQbIF+a0KfTxxFfUQVtr8kLT9VG50FyWCnEnmeynn0wRfMspinWzqlikpeWuCLNbaQg4jbARHinMIH5blFNiX1pQ62l3XY4VwWqpcOBAhySE4oBXxLXIok+93cyfpDaWVTwCl1yKE+4Q/q2EBZ8gU8GQwqwcm3+fiP4TP34wVWGqh3KtQ+r8SD3FGrWlCW+660GGQwHDDd2heKw9+Ya47iuekRpjHA999oTDrKb7nVSeDv8g/8OTf18SZrvYA2wv7GxU4r8S8T+HQjfVfpoETcxT/jQr7hfl2TSgt7fHFYnmWoTu8DSGaP1rA46rYph/1Jx+yUh4/ymtk/l14Kyo7be5pQXwqTr89Ry6nLS+oMGDe7sBF5AJBPmvomX/lv83INODIyX0RzlTFqWuAbKeWsyw3q0cYTg9EEnbocNzOgtuEaJoPMWD/rn0FP2f1VaqZSxzP169inFqJwdTJsE6E63mfyhmmRRlgV7fQ7V/r0WfVF5n4Mk3BaFqTEaTVM4nrYi5ZsOqN5V3dh6YCXl/uj6zSsN6USh+WgjpIE+cS+DnCdFydKLwm7G/rE2EGRl2RyhmboG6F1iggPvBxlgHCgGM37VecgEopsg1/kRe0VgZtJVA2qAC/P61U+6LVasGZZXQP/+VxvrR+Fh75ym8Nf4GGabrKQYv2WevelLC9g28xZiKLSgyxf5W4z3P/86diiFwqjsUAq+aBdEIBueePsbAoDiCkRiwdYJUvsD0Mcmi49GPBauR5zwqcziTHggnb4jQXH7qwigox+kjfgAXsWMSJc6kW9L15cYHXBbq2S9ys1cMScQhWPnmQUtR2n0w5e3CnatBw2o3w27L9pvxuUniqEu8sC2Q9D2E3OXtUPtRA2651Jx5EwFtXNfWY+vMcxxbChJRZIMMumwic9SeydXBkeNIzhXBHixYKt0rE4Yo5Z824Q5V3l6/u/2lyZFB8+9/J6K/FV5x3IHE4yPZY2BMvkIeF60Y6d7kFkgdddUTFkM/OXKh0F1L6/p2nKw0tNJanZrJ1sf1gaiiBJOC3kBBxmkSmlIM28EDQg7Ytgz6xkOQdY+wevqY7+Fs6Rz08bPL28vFLGfM6uSXMeOCZonFQUVjwcuE9b4SPR8t2EXfYlnOQtjjT9A2/BI6df+ZnWmdmNBLc3VWb4zsaoCDwpdaURxhxjrTlDZjIzVWogg4I/IBCaSIFWPaUZZmk5meZWB8sF7GTByqY8FHZk/ssEY4cEA/0 X-OriginatorOrg: bu.edu X-MS-Exchange-CrossTenant-Network-Message-Id: 0fb3ed12-8051-498a-6f79-08d93b78f796 X-MS-Exchange-CrossTenant-AuthSource: SN6PR03MB3871.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Jun 2021 03:41:38.7280 (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: MntL2JhiH6391ciC59fOS12PkUrjfZcmXbX3BNkYtdTJ4l7Y80hsmPNWTtcr8ixg X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA2PR03MB5817 Received-SPF: pass client-ip=40.107.94.132; envelope-from=alxndr@bu.edu; helo=NAM10-MW2-obe.outbound.protection.outlook.com X-Spam_score_int: -8 X-Spam_score: -0.9 X-Spam_bar: / X-Spam_report: (-0.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, HK_RANDOM_ENVFROM=0.001, HK_RANDOM_FROM=0.998, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Laurent Vivier , Thomas Huth , Alexander Bulekov , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , darren.kenny@oracle.com, Bandan Das , Stefan Hajnoczi , Paolo Bonzini Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" We have some configs for devices such as the AC97 and ES1370 that were not matching memory-regions correctly, because the configs provided lowercase names. To resolve these problems and prevent them from occurring again in the future, convert both the pattern and names to lower-case, prior to checking for a match. Suggested-by: Darren Kenny Reviewed-by: Darren Kenny Signed-off-by: Alexander Bulekov --- tests/qtest/fuzz/generic_fuzz.c | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/tests/qtest/fuzz/generic_fuzz.c b/tests/qtest/fuzz/generic_fuzz.c index 43f9011626..59be7219de 100644 --- a/tests/qtest/fuzz/generic_fuzz.c +++ b/tests/qtest/fuzz/generic_fuzz.c @@ -751,8 +751,13 @@ static int locate_fuzz_memory_regions(Object *child, void *opaque) static int locate_fuzz_objects(Object *child, void *opaque) { + GString *type_name; + GString *path_name; char *pattern = opaque; - if (g_pattern_match_simple(pattern, object_get_typename(child))) { + + type_name = g_string_new(object_get_typename(child)); + g_string_ascii_down(type_name); + if (g_pattern_match_simple(pattern, type_name->str)) { /* Find and save ptrs to any child MemoryRegions */ object_child_foreach_recursive(child, locate_fuzz_memory_regions, NULL); @@ -769,8 +774,9 @@ static int locate_fuzz_objects(Object *child, void *opaque) 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))) { + path_name = g_string_new(object_get_canonical_path_component(child)); + g_string_ascii_down(path_name); + if (g_pattern_match_simple(pattern, path_name->str)) { MemoryRegion *mr; mr = MEMORY_REGION(child); if ((memory_region_is_ram(mr) || @@ -779,7 +785,9 @@ static int locate_fuzz_objects(Object *child, void *opaque) g_hash_table_insert(fuzzable_memoryregions, mr, (gpointer)true); } } + g_string_free(path_name, true); } + g_string_free(type_name, true); return 0; } @@ -807,6 +815,7 @@ static void generic_pre_fuzz(QTestState *s) MemoryRegion *mr; QPCIBus *pcibus; char **result; + GString *name_pattern; if (!getenv("QEMU_FUZZ_OBJECTS")) { usage(); @@ -836,10 +845,17 @@ static void generic_pre_fuzz(QTestState *s) result = g_strsplit(getenv("QEMU_FUZZ_OBJECTS"), " ", -1); for (int i = 0; result[i] != NULL; i++) { + name_pattern = g_string_new(result[i]); + /* + * Make the pattern lowercase. We do the same for all the MemoryRegion + * and Type names so the configs are case-insensitive. + */ + g_string_ascii_down(name_pattern); printf("Matching objects by name %s\n", result[i]); object_child_foreach_recursive(qdev_get_machine(), locate_fuzz_objects, - result[i]); + name_pattern->str); + g_string_free(name_pattern, true); } g_strfreev(result); printf("This process will try to fuzz the following MemoryRegions:\n");