From patchwork Mon Jun 28 05:23:47 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Bulekov X-Patchwork-Id: 12347237 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 10826C2B9F4 for ; Mon, 28 Jun 2021 05:26:02 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 76FAC61A0F for ; Mon, 28 Jun 2021 05:26:01 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 76FAC61A0F 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]:44260 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lxjmS-0000rJ-By for qemu-devel@archiver.kernel.org; Mon, 28 Jun 2021 01:26:00 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33574) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lxjlA-00078T-Tb for qemu-devel@nongnu.org; Mon, 28 Jun 2021 01:24:40 -0400 Received: from mail-bn8nam11on2137.outbound.protection.outlook.com ([40.107.236.137]:14944 helo=NAM11-BN8-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 1lxjl8-0004bu-Gj for qemu-devel@nongnu.org; Mon, 28 Jun 2021 01:24:40 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Ly7USAo2q4fAHtpkAPeBQsNZozd6bJN320RrctWQ0kYV6JuuQH54Gilsgjdf6hK6zniP/uIvNwc6mq3stN2LSUQ1o0n0FT8C8zBDtXoE2B4Ah3rUGAtfxERRyeOfIYI9g4TNgRjTdwdOVZcWIee+8ckNtizHVacGkwx54ClZRcUAevQvElWL1ab4bjZJloXtJdSKnqDgjTKxs3AHQxeXuGP+ce7xCetUQ9CxVJ/ZDDCFv8IgWdbmQPy/utIIPx9B7SS5HJ6K8GOKzY7JzTmFgoLvll+8o715Bf0pZBiwe7dhKltCppD6Y8kneB+k7ME8KyX9tdAnRENy/czPTSfgJA== 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=n5JwGs66XBU5IsrbGqM2g7dJaqSzusrpNTPzZotlaOI=; b=lji1ThNcRG8NVGwZsP9V4VryKn5npXeU1y2kygSFeckoIL3wl7RHIWw632nOhjYE8bkwzmzdtkYhsTvHUrlqlk8+3bNkNzAx6dfCygLbapToj15B50PKogNlP7KB2zeuUQFvpGVqGEy89/ZvGPOdorjzUuXng7/PBWXHXIowTqq3J1Dsfko9VAOszsWuW6B/X7R1HiTNq0qRp+67CV/HVBkMeS/mGgEM9msT+sqaWN3GUXAvIwcn2d6UWUMnivNVgEzPLUYhJHPKhijucKg9Bw/ykbE9fram3D/SMh+x/QyE10bcpHYe9LOwEnhfxwAJaGvZvv/BGrE1FMwneYHnag== 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=n5JwGs66XBU5IsrbGqM2g7dJaqSzusrpNTPzZotlaOI=; b=uBbyhXvOny6gnQwontil7ueAyekrKdbm/hd3Hl1KXdoygoXDMifl0LDJrpMp04I4YSBeEGbRcvCjRFoV5cx2q4w7vjkDEmAUnj/BLNrF4tyBkwWWuwLhxhQDZ6Q82qvSS8IQayzcgDNWFPgm2ng7MPOT+QiH5Il/4QWpZ8SoEKQ= 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 SN6PR03MB4446.namprd03.prod.outlook.com (2603:10b6:805:f6::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4264.20; Mon, 28 Jun 2021 05:24:05 +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.026; Mon, 28 Jun 2021 05:24:05 +0000 From: Alexander Bulekov To: qemu-devel@nongnu.org Subject: [PATCH v4 1/3] fuzz: adjust timeout to allow for longer inputs Date: Mon, 28 Jun 2021 01:23:47 -0400 Message-Id: <20210628052349.113262-2-alxndr@bu.edu> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20210628052349.113262-1-alxndr@bu.edu> References: <20210628052349.113262-1-alxndr@bu.edu> X-Originating-IP: [72.74.210.193] X-ClientProxiedBy: BL0PR05CA0013.namprd05.prod.outlook.com (2603:10b6:208:91::23) 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 BL0PR05CA0013.namprd05.prod.outlook.com (2603:10b6:208:91::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4287.12 via Frontend Transport; Mon, 28 Jun 2021 05:24:04 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 0ac96244-b67d-4886-be06-08d939f4f277 X-MS-TrafficTypeDiagnostic: SN6PR03MB4446: 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: B4b9PscMG1AcinB9Sy0jj73zVlXjDM/e8IBQ/BaWy7tC6WWOgS0dy4gP0EItMRRAkkumyJWuQtTFG9voaqSKstvbRjvM2WrylIKukbocRd8557N2BLghiqiSRDnFU2gVdi63kNo8335OwUzp8OOeoIAv+2Az/P1yJ+AyCIZLmWo7aMKnmbGzPGhAuh616q+aGNIMupPJYFJz7a8SXIeWVZn6YYTHMVOxbxrUDRVTv3vb1vYZ3afq9frGZLwioBBffolgzxiVo5nYn69rwnCw0I1q5/XST1J5zBVdbaPPcgRH+XAh8oOGx+0MdAtiycBZXUXAH1wJg9qkP7Sm0oDdVlr8SI8txeLZ6QgBGZY+lXHyxvblrwWkuMwPQXWyxHdGAValCRdsKcv39q3syU6zVQgOTEkhnrUKlzJ9Zh5lURCafJTE6rzyPjskGTsZ0J9EDO7nw6IfMdA3l0zJ/fvJM2LgM0+QkyjYLLeTGMJdaizWkGOoZXgP7euZwey+bL5w17PKn6PM7JbTrVAP921ZElTJ1WwevoUyz1RPRJ9xfFNjX7M8+4pijF4brj3KlEj303FujkvPxtQK7kd5cK6srkVbbCZYmeATdoMYcnIqpESGRGQh+mXqGxFE9AapfO1XdRvdTQvyR77nv0gf8tWKiCD4hdKS1RI6/uFuzQ4D74A= 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)(346002)(366004)(396003)(376002)(136003)(39860400002)(86362001)(16526019)(26005)(6916009)(52116002)(8676002)(786003)(2906002)(186003)(6512007)(4326008)(2616005)(36756003)(83380400001)(38100700002)(1076003)(956004)(316002)(6666004)(478600001)(8936002)(6506007)(38350700002)(6486002)(66556008)(66476007)(5660300002)(75432002)(66946007)(54906003)(148743002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: SGHS3CoRQtTgkAKt1t0Lwx8BFiw/BeCY7fgpHrZnDCob6hSkZke5dDGmNt8kgtLYgXHsy7o9PR3MX+BvnoOfDHv8+Pc8opQD+ZBSds4u45NwNl4xUqA47jTgwjflENN1yzu+h16vI0KIeFDXOCjyVsaxT8gHu8wa/eo4d3djvIxXIJxM/LF8p6KJmu8AFoD5ncC03XspGvAxlz7kNI7Oj+1G5tXJPfvtiR0PPAxVpx5PKgQk6Ej2ylrTbx08eGAhvvfpj+7Qaj0o1vuxCnn7QcxlOI/KFxsd2vRkpFReLLJPyyKpP6RqymhN2WxaU/KCN6vAgpN4ELBXvIPImWT2DUBFwI3CIcPER52tqMe+kYwNn83gXnOckXNpLgZsv6IjMs+VVsZ3M6hru88VSm53fgXUiFk5IF3EqwCl8dlDNA/Yz+ZrckfCQhq6NP79npIiLRTbz8DS1JQyEzvQkI2clyZr3kj5hUbSukUy5ZJgUyQsJSdyuR+h7E/qrWoJOP3z2yAqlavtqEyKyacoNafTlBAlbHB4ST1rR873gqxY3Cyq2D7tLagAG7nSCq0YnWt+gvYDz3+YTzg8qbAN3/Ol8/H0UuZr+q7NQb7eB2uX2f9W4O9rta4YHSZ9eOgzbwK5nEQT+X0vkOnB8Knxr6fVx7GD5V1F8WcyuU6mSfQsu4hp6lYOKORD/CYAqJqBDN/WpxLf5Q/Nb+v+rWQw+5V2YXpeBPlfz6lPMcGpFISYsL6+Kh8nt0y+N6609cMQT7xs5jnwTbwz18Vn/xIBXdgKsMssfEC1lu1dKQ259ibzRDKsI5IZuJDlPXUyU8A1xdBZvXNNSz6gcKFjqbLjiDDdWt/rM3m3fY361GoPVd06xMMh8TrXEgagfknl8FtHoAHlFwZ1HQAk9YavuVDGlj2xxL+7CMLcyq2DpXZfNHnG+ypBDQspfh5BcOw7WWkO2Vmxm3fWSQUyWd9QWl1RHkscoUgHTBYAV/MkHfR5Nsgq13cgKWnFeQgQsWizyAo9Ow1QCaO5BJTgyddAHxwacYGkLcjh/LeTc315DC0UWmeFaFlknv8wyIydBWf9tjhnEbsUggn6ZmNILu4JCOWvp4xB6sJuJxyMXRYrKL22BvLwucpEntTD58Lk5mFCdDvx1EBthOFWShAX38KmTAKL70+O4+Ju0tcw7pwS/2ihcTqRh5hcidD0FVBqu18drqtjClNQgsMcrPpQfvIy8nPdTHMHNH8uctUM+B1W9B55seu3WxXN8EU95E74AOQhmommpqx5V4HaeWEOvPzey0qZAzcSMN3jlkesJMI5Of2ReLhbByrZBSfvIrYJeffPJNYQwgJ/ X-OriginatorOrg: bu.edu X-MS-Exchange-CrossTenant-Network-Message-Id: 0ac96244-b67d-4886-be06-08d939f4f277 X-MS-Exchange-CrossTenant-AuthSource: SN6PR03MB3871.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Jun 2021 05:24:05.3822 (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: /msPBI7/Hv9B8yzO40h5V/QjfVlE9lUQ/9sn2bhfJ45j/2MZt9nxUz65Xw9jFmq3 X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN6PR03MB4446 Received-SPF: pass client-ip=40.107.236.137; envelope-from=alxndr@bu.edu; helo=NAM11-BN8-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 cea7d4058e..71d36e8f6f 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 Mon Jun 28 05:23:48 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Bulekov X-Patchwork-Id: 12347241 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 3EA4BC2B9F4 for ; Mon, 28 Jun 2021 05:26: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 D380061A0F for ; Mon, 28 Jun 2021 05:26:32 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D380061A0F 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]:46526 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lxjmx-0002Mp-RK for qemu-devel@archiver.kernel.org; Mon, 28 Jun 2021 01:26:31 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33588) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lxjlC-0007By-MK for qemu-devel@nongnu.org; Mon, 28 Jun 2021 01:24:42 -0400 Received: from mail-bn8nam11on2137.outbound.protection.outlook.com ([40.107.236.137]:14944 helo=NAM11-BN8-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 1lxjlA-0004bu-W9 for qemu-devel@nongnu.org; Mon, 28 Jun 2021 01:24:42 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=guZBDRmu7h7Xg3nb875BLg8jeqTNzeg5+6YVV18uzm80JQ7V+TsFzmt7x2mIzU9BeRnGsrA0MifX8Olu2h9L/nV9igvQOr6FpJEc5E0iAVN31iMkczwo6faJS8Cc+m2ryHMlqXUr0wgtQYZSFARmbq9ZTVyiutwq6/E7w84tXvXuVAHW4XDsx+gxxLzHB0+m51SjzBKMvHi18alkIeC1tTocdn90NOJ0L7DrBHuB+fCrv2usrYJGI5CahfdF1gk90BcCta8bwCWVA/vTSr0sH+1dL05TmP5YtVNSwVeYwI1dBkRl8b1yFO4Q6gQcDYC7fVzl+2NwMUfVpNRdclyaDg== 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=9jvUid/wftaT46wmRZr7h9STkApK602QqaQbXcz0fFM=; b=UuLl1WTGNBza1XiflZAY4YcYaT/X6qjWKbgTNmrelBp0DP6CEbWMCjI4lW3TGZ0vUNDl0Nd27B51SVI6WXC6EComWmtPzB7Gc2KnpYl0z5IDkwHvcgx2jeyGngXEy14tLwpwAkA8RlXzecae1SqHCPrljZzzMO7VIyA71t7PCKh+ZgujicLE4oBVDoJUzX3YcAfBJ3bc9XkH+Sm4lmbdSN8d2bFFzjNOOHsOX+I5suDXLFKXSnRGjve0DUS2iYeiNh2+EIGHXxHGZfSxNZmAODfKsryOu+joq/itPl0GNYfAe8zzQnkUfwHUfiqx5QhmGXVTEb7n2XWUvqYJTYyNdw== 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=9jvUid/wftaT46wmRZr7h9STkApK602QqaQbXcz0fFM=; b=GvSFV01wuQ57DwjQ39ZlImPH2cdlSIoMViRXJotmR5xdnQkH/QGBXblmOAGtGBRQoeRgMYVCws+PCP5nvQ0JIwzZZ6GJpHvg183UUqRQPtHumOzPfDNqBwoYk7mFjVLfhK6IS68hBfkOH0Z6VRueTqWwZeTBjqlnXuY+QmqGW8s= 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 SN6PR03MB4446.namprd03.prod.outlook.com (2603:10b6:805:f6::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4264.20; Mon, 28 Jun 2021 05:24:06 +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.026; Mon, 28 Jun 2021 05:24:06 +0000 From: Alexander Bulekov To: qemu-devel@nongnu.org Subject: [PATCH v4 2/3] fuzz: add an instrumentation filter Date: Mon, 28 Jun 2021 01:23:48 -0400 Message-Id: <20210628052349.113262-3-alxndr@bu.edu> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20210628052349.113262-1-alxndr@bu.edu> References: <20210628052349.113262-1-alxndr@bu.edu> X-Originating-IP: [72.74.210.193] X-ClientProxiedBy: BL0PR05CA0013.namprd05.prod.outlook.com (2603:10b6:208:91::23) 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 BL0PR05CA0013.namprd05.prod.outlook.com (2603:10b6:208:91::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4287.12 via Frontend Transport; Mon, 28 Jun 2021 05:24:05 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 986f67f6-bfe3-46ec-31b0-08d939f4f30d X-MS-TrafficTypeDiagnostic: SN6PR03MB4446: 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: JHpMRp6wy2V6+rXtm73/blaQkeXB2lf2aw9i1uShVKnc8HNE0tDyXlvlVy7e9Vm/vN2qmyKnixI2dVu9QZCU/5oMPRCPPJORnObraegF/plsMR/KfsEqvD7hubSmVBlxB+ukAg3C5zFXl7Gkzo6PSBZENRJH6jwBZb+8v3x9pbQ8/Iv9Jz4c4ITOVTpDtPmHiRVAk90MHvc+V6evtOLPEdfAFa2PJOyYF/E7Wh2n8HwI6GxCMkq0eWQ14ylWRxhKIW0t5Z2VmU0Cb0WrlLmTvYTUEJzseTYAkkr7j7lwUAf+b9vMMeyBUNWd4fvDU4PmBBHKVB0nP+jqmnLwolISX6uAqM1rvIscYaI8Rzt+cUfLGdSP+k7HDpX15uEb0e8r7IUqMD+aCqMVrhKDP9NhOOGyfBXVqG886fyYbxnxtyKEWzsVctjoTBebTK5NUAPmafARjjSDVw3J734/ahZ+3unBW6ynz44hh4r8kQ31kZKRbQ5S7E+BtRFgrk+zcv/nQTL0mxBjsJHwaLlVj1RUc8hizTLpljAiY/691Asov6RVbInPg/8od3mmWZX3OtnkqH8gtg2RUnR/F80hItRVXCf5X/nuOAEfmzMQErGrAMyBZbXfXgQolAU0WPj+t/DfH9LpAaOWFZoIOLRdoWQWQYOgn+vLI5Oxh1SfcipKQ8h/SpIvrlC01Utrh37q0Ecgcrkd0YOBDY+NlnrLIRGHnYebAjVGpRAH21Sm7aGAacJUFsd1MQALRlqkeINg+ZDG6/1BFCalGCtl+uKp4nusmLsv+MviVZY1lqFSwWQrm4c= 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)(346002)(366004)(396003)(376002)(136003)(39860400002)(86362001)(16526019)(26005)(6916009)(52116002)(8676002)(786003)(2906002)(186003)(6512007)(4326008)(2616005)(36756003)(966005)(38100700002)(1076003)(956004)(316002)(6666004)(478600001)(8936002)(6506007)(38350700002)(6486002)(66556008)(66476007)(5660300002)(75432002)(66946007)(54906003)(21314003); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: H9AsJrcoKp1I4PGiICXm+vVeIpW0Oq4GeggOEGF2ryGtTVd4deehY9lTR9B23+nJaUU0oOWnOS5FMbH/lyGwKAdnd0sMlMFt/U9Y9GFdA5pZB8ssDWkAC+xf3jjgldxTQxMPn1bkGX/4wPiCAb8m2WXodPOneW3BdL1+c0WpXhicOzGPmt+w981ELwvTC0csbjXAZ6pa/VjFcZVJ5hB+sOoPU0K8YWYCuwcJvTtNuSMLNeKk5AjjsvmVEqsUcOZZn7wyhNqNK5sX2oDbKgo8She8FnkHPrQegBg4smWNCrh85EU2qAhbSPj/is5RHKgU/juPsDQ5UzUbM1LE9YrT4kLwcrifcXgkTMpM6Jcrf4195qgbEGYHZ1dwjKjqdAxhrFZhq+llhCPOQNcIIFr7L7ZDRdiWYL3BlgOK+ve1RlehXSbDtObgctmw4S1mu94vjKkEgO4O+L6C5197RIYSCbo8GEqPzYcEI0boxcWTzVHjpg4CTU3gwrdbQEEvWbSGkTxyUE5kFMh9hDEA/+VdyO5bttoptj+mEkO2ETGBM6aXqZUp6l2ShMJFObWtqHPCfKPpVv3j2GqEvwPcdbJ+dWq6ifqaJurVpG0fpwHH0yTgW3PF/DDvoRTolW7XoKJBYtMF5ilkLexdhXhCV94dB7U9i9QSxh4jYo1kqjI5c4ZLmAa6kCT/1fQpzthUg94rROIqCB/AZv1W8b5/qRKo3sHO77QffxXW+iB4WcU9Cj2B5a34b07pNVXWdAgacaehIXktvHhXcUf3z0Y88mWc1UYhSn2IvAQfomBbl7eEm8cnWJZvYn2n3PYx+tdoO4hpjFWKdjLBOps2BWU6xXJK2jorE8HbKYleEeZ7DZQS6baJ5SUcwjeZrK+UUR6tLV4z1EnvGwzILcvG+9eAKw4eIWqRhaW6obGRsx9rkjPbxStQE/2RTeENbf76vVjPnsdHFSFybUUWNBDgva+FzLEWnFJSuKbqDmwSZbwCKDR2OsYjWrUWYlv5y697u6FhM43OhsQughuUk0BO5amnh2hMIOxXCJEOn8ROq06SbsP+JltCTFJKSDXYLrGTYTt18U9HhqOqowdOvPI5lmwbgUD9BOSxJMGgc+XX1lhMPbsc5V4ygWJDqpWCcwIY3Cxh7PwudlxygSFbnQchNgrO5pGDC4FpcoxZzOBUFGsrBuXz/SMqVAg0f/vRrpmFv041rX7V7w4WtGVrmdGjTv4gvCCctdZeM0Qo5yHSM9VzFXN2EBAIiV5OC+gyM1ptHR/5YCR/JpCgxQQCn5boW2c7nxxNPYtlnt4zdv1o6RbFCDtJF9Z0XaJJ8gJLHF9RdoVV/ily X-OriginatorOrg: bu.edu X-MS-Exchange-CrossTenant-Network-Message-Id: 986f67f6-bfe3-46ec-31b0-08d939f4f30d X-MS-Exchange-CrossTenant-AuthSource: SN6PR03MB3871.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Jun 2021 05:24:06.3626 (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: vY+WMcW6/AnGteGaeWh5iPTS6cUZJapedc+0BJ5pgq+N5OwHK5tuMl/lcX2mMkGA X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN6PR03MB4446 Received-SPF: pass client-ip=40.107.236.137; envelope-from=alxndr@bu.edu; helo=NAM11-BN8-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 --- 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 debd50c085..c755f8f29e 100755 --- a/configure +++ b/configure @@ -5176,6 +5176,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; @@ -6101,6 +6106,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 Mon Jun 28 05:23:49 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Bulekov X-Patchwork-Id: 12347239 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 06C35C2B9F4 for ; Mon, 28 Jun 2021 05:26: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 83179614A7 for ; Mon, 28 Jun 2021 05:26:04 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 83179614A7 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]:44486 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lxjmV-00010O-Lz for qemu-devel@archiver.kernel.org; Mon, 28 Jun 2021 01:26:03 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33604) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lxjlE-0007Gz-Bz for qemu-devel@nongnu.org; Mon, 28 Jun 2021 01:24:44 -0400 Received: from mail-bn8nam11on2137.outbound.protection.outlook.com ([40.107.236.137]:14944 helo=NAM11-BN8-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 1lxjlC-0004bu-Ri for qemu-devel@nongnu.org; Mon, 28 Jun 2021 01:24:44 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kQ/zjp3vSfHwF0ipu3HNKpXJMvpJxsQ8HlpmlHYYuM5Rm7l9PxlbG1eehYn8I+Fa8d8ZHRZDRVqSqSrqfCEDapkCOgsqIOz+YmSAtVu9uzx6nHvd2eJi7gQVwTxvf9V1TrKwiZOjheuzeUZQvY9mDfIyZb8SXRPMBSTYBUPQThOmSyXuoLwwI2hI568+QBELOVX9wgyUosf8O21qFRSPh0spiclwpm/7uSVoiWUudrOUAdojlFcClC1C4NgG8VYVd4nDc5vLIhg3RmaQX7b/x4ga9bfjuG+QblcO31cgs2THkisVwuZHHc/xLpigx7g15k8yjt/2/eom1j+zswc73w== 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=TiOOzLqrPAsxZ2ttjbAtHFmmNtZovpYHiTwYJlp3SZA=; b=HC+e7q05t1ZVtyc4AGMAcYu90yYibRBHUMaPia9SOUXRmmicPyisz41eEjINFEI8ggxcZDTrYceD3WgvfIa5jgGrM9waEhOZh5YOsvtd9XB1Q5ePl7g+ljhLUgZv1Hb/K5uBd4/S1ElE2oAarYQi7tQIkXdNcAloRAB4JdwGDa9n4OylE9k7ors4o3RyDsNSjfPuqI9/0y8/GUbBprKsueff1l1+5ep3AFC1gZ7X7NJNk/cIkhmfBWT9K62Vrue2PkqCuF1IhLbRUxfYYblb+yT8+acU/wwHYVYFn23cPRyDK1DcKOKP+N1Z7NKAXDZ0YTe/L2q6LjDn2NPzGDoTzQ== 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=TiOOzLqrPAsxZ2ttjbAtHFmmNtZovpYHiTwYJlp3SZA=; b=I/iFrVwBQc85o/kTzfsIn4tWEXPHDrZHxg6nQYVfx0lleCL+nnd89kY2YKNlPu/Z20tm/0fNQTiLKmCOeXcOINy6K69PueQdSTRlBo4ohyIfCHJWINr5FqO2vu3qsRhvVjNUKKibITSuYtPpvEEfbSZWBCGqOhz+2cgGgKN1gqo= 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 SN6PR03MB4446.namprd03.prod.outlook.com (2603:10b6:805:f6::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4264.20; Mon, 28 Jun 2021 05:24:07 +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.026; Mon, 28 Jun 2021 05:24:07 +0000 From: Alexander Bulekov To: qemu-devel@nongnu.org Subject: [PATCH v4 3/3] fuzz: make object-name matching case-insensitive Date: Mon, 28 Jun 2021 01:23:49 -0400 Message-Id: <20210628052349.113262-4-alxndr@bu.edu> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20210628052349.113262-1-alxndr@bu.edu> References: <20210628052349.113262-1-alxndr@bu.edu> X-Originating-IP: [72.74.210.193] X-ClientProxiedBy: BL0PR05CA0013.namprd05.prod.outlook.com (2603:10b6:208:91::23) 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 BL0PR05CA0013.namprd05.prod.outlook.com (2603:10b6:208:91::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4287.12 via Frontend Transport; Mon, 28 Jun 2021 05:24:06 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 63a2265d-4c7f-4f28-9bc4-08d939f4f3af X-MS-TrafficTypeDiagnostic: SN6PR03MB4446: 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: 4M7Rp2WfIpWdbrWoqHSE/QIM7F6pfxZqgZAHQq3E1Thp6r9I/3ZKVBKxOxqARNO/+9Ct+CU6Qlv+BkaUtlZYB9r0Un0BRqVJSaHSjGv8RJJPxJ1BC5RBHj4AVuEr1jznlkFXkMPLQfFehHNXcALYtC2ilzyfHYBa0exCETqcKm0b7sWLUWgvL7ZmweAkYBRcti5Q7SxPdoABkt44fW3Z3OxMps7a5m7nTX7bMnERIixkTzcfkKq6yB9IwuO9uD3NN1qL2uETug4Fofhp+TDVug1qbLNHWfUb+Qgg3CH/o/o7s+rFBsLYhSKXbnpcLSfIgF6t1aF55OK0oUTsu8PFUdVNIUL3LMp2p8p7SljSYFJtt+ukITv6riqwuVZ5N7Wk99hMox/GEa5cEHg8u2CWMCIwSygDDbZTsfOFkV5ZqW6NMX6pVOjz/nPC7+zBRhsejmXssRDpT6styirzkC88D0q0MSndL4Lgvrfk0fTlFAINW2PfeGmzUYraPIC3WYnFT+3gyvQgTfBcfPbR8yBOhb5tumQQTNSKOUwloFo/b3KERxHDZzm7K3yJbF8Xj7fol0/tZr7HjXRE1nLwrb+OjidPpqkJcDR68nbtWp0nM1wjk+vNGWNVWLtR7XHraqvjRBYa/IvmJ5r4lZ7jSBW76w== 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)(346002)(366004)(396003)(376002)(136003)(39860400002)(86362001)(16526019)(26005)(6916009)(52116002)(8676002)(786003)(2906002)(186003)(6512007)(4326008)(2616005)(36756003)(83380400001)(38100700002)(1076003)(956004)(316002)(6666004)(478600001)(8936002)(6506007)(38350700002)(6486002)(66556008)(66476007)(5660300002)(75432002)(66946007)(54906003); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 7eNX7R+l3GrSLwyavJDM97QRqEa0Y4K8k7I0muwzBuiliNeZ+CZWSDD29rMRwkoQwzetsdK/7KsrZcb+MZEMomo2T63r19QMwlzc7uSqgQnw/XZGC8SfapruxrHk+fB6PiiJyXX1sO7z1KkpvCIsCXm3SZXZifbZHuHll1ftjeBTLadLP5r50jaK5gSdUFkZDkFkjLHtCWTeuHaKaxPENqaq9VPrSiaJKB8x4zVsXnKWXQ6n8aGAjmpGLFkkctnSIteHGYEopVA8z9SodOD2IPz+67TtYH5WvZZbhEvRUSu6irrc5D311SoNQLnBcXGwk4OMtVtaWrTAWn7Fr5+Krhaa9JujK91fG6QELXX0GI8HfyCNmjBcuUVIyYkge+OMxpi9EhDUUcSRFrJsVsGX/Kiw4VqBJj8Yuxl9mSZSd/9H91j3uDY19YfpKtREM1hJTbulDcnsHZb4G/D/Agl8UrThoJuXP4cyr/By0PvOuJjYwysTP5lbc7lfmCF+pnSbfUFjkhLFCL75RwON96yZv3grXCfWiH3l6K2CZoD2lN2eWPdoX+bTnqgBdJV5gu2Sogke55j3hjrmjl2CnEP7vCBpxTWAgjUmhAmPrGL7N+cnR2Z7cL3l0MySzthFd63HC+mKKW1XG9Gvd8+cu5VLpJV337xXXqNziJQR1N+EtFE9SkXHQfqDaVOPslxyTrgFV0V9ohdJQJk29CfO1SpGlFRFGJ6X3khGY8HJkTG51cbI6nlQkoBMeORRJhjA735VbQqWbWBv26E9rTj+Iaizy1Ew5ZT3SwQiImg2aLZEnijxBN9XsA2A/DPQ0Vh+MhnEu7ed/EYseNRnXn7yOghbCXO4ctolIfG445yJ12ntglB254H9dgQLihjtYQ0djphXxX+jVVb+DYTRo3fc6so547a5KwU2AcMIUwWKIDbFBvk9FUnIaqd0WSkrfjfRjc3gMW5NmwfxLls9k5G+YlLHwV4Pq6QTyjFBqszGR3P0tJEcieFB6ZfW08POFW1j6K7tPIdjBgq0eoTodWLAlSSyN+6Y/A8ywBGWO7fmchS4sM6EzVrC0F1+6BdbWsPlDUAwm0ak0v7a6nL7av9tc/EJNg3Js90tdw2+PAQWPdUXBhgCk5Lu5KAGYBznPiHRdn2Hx3QwIBEgIh2h5mPVDdVZiBwlSP1N04yB/kItk0armSd9jDHPsyE5tizLlaxGlehe4xlgnvTigzvzY/NRwZADb+UlcEl+pw0BdIcPLEIXz/QnhFuA0kuBip2OELO/C0rpatnUX+5S26nyl3YwttIbGXcRZhYomtIdIvg/2HlwIVF5CtI1J+8fylv4l1l3OOFl X-OriginatorOrg: bu.edu X-MS-Exchange-CrossTenant-Network-Message-Id: 63a2265d-4c7f-4f28-9bc4-08d939f4f3af X-MS-Exchange-CrossTenant-AuthSource: SN6PR03MB3871.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Jun 2021 05:24:07.4340 (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: ZlyReebLG/kc7ZAvWC/fkJ/CIe9xsZ7DOndSjfYsidj6cTQpRGbEJyK9tvPffpze X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN6PR03MB4446 Received-SPF: pass client-ip=40.107.236.137; envelope-from=alxndr@bu.edu; helo=NAM11-BN8-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 Signed-off-by: Alexander Bulekov Reviewed-by: Darren Kenny --- 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 71d36e8f6f..0695a349b2 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 *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++) { + 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(pattern); printf("Matching objects by name %s\n", result[i]); object_child_foreach_recursive(qdev_get_machine(), locate_fuzz_objects, - result[i]); + pattern->str); + g_string_free(pattern, true); } g_strfreev(result); printf("This process will try to fuzz the following MemoryRegions:\n");