From mboxrd@z Thu Jan 1 00:00:00 1970 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.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,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 DE78EC433E0 for ; Tue, 29 Dec 2020 04:44:26 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 6114D2079A for ; Tue, 29 Dec 2020 04:44:26 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6114D2079A Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=outlook.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:36184 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ku6rx-00089k-80 for qemu-devel@archiver.kernel.org; Mon, 28 Dec 2020 23:44:25 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:38570) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ku6p4-0004if-Hb for qemu-devel@nongnu.org; Mon, 28 Dec 2020 23:41:27 -0500 Received: from mail-oln040092255030.outbound.protection.outlook.com ([40.92.255.30]:6184 helo=APC01-HK2-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 1ku6p2-0004Tu-EL for qemu-devel@nongnu.org; Mon, 28 Dec 2020 23:41:26 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kDHgLxL3jMoqXG/fAodFxfRvPz7bCqbxdJAqUMdshjEPt+Yi3N/jtsaFRrPJCbIK0PF529Dwx+tr69HWFD4sge0pMK19Dgbv4VVdzM0+wHkj6ueJqh+IMfeh96x54g0crBToiS0MJ8Ca1RP3G+ON9p3fal3CRRijayYbDgaSj2R2e4OgPe4cpoQ8f/+QR316S4GEkpuH+fuex+JaI2QfUnTdGUrODhVamowaJCaUuA+m/0DLvafWIXjke3kpMx8rfNvld0UGqcZMi/9u3/OWHZn9DwLd+8+dW+aM3THPy1CHdv602/q/Y9IBxT/xQWynE2hgoluyYPk6Up108gv3Jw== 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=wK3n7Uk3ZhGJC8cCCDEWGObNFbGcVgU5QZ8HMxsoMdY=; b=AncWUKMVcKRmao77+CCfZK0QvqDxikJUyYpk08SYEfMT0MkVuUzSMl1RClCyiEa/D0Lf6PmojaROkHmwz6zeqo4z/n64CuiDRjwrPI0cDH/muk1F5rbpMeAlH5VKj0ikG8v6GL9oBuyz5+gIVg19ucmXp/IYGjj2JFTKhFimCZNuMrVxN4Tv79PvK+TWEq69U+Tq9gqwOrE/3TtxPZDxNJ55YcnTEA/Pcy5VMo4p8tckc0tTma79Qz0SpRN16qzJIu9f4Yhv9So4BU+tTA67BDPwpkr6ettwmYFefWprCaiL6XvOl82IKubXiFS0uvdr7qXF/4WIVGBj0wTS/PrMmA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=outlook.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=wK3n7Uk3ZhGJC8cCCDEWGObNFbGcVgU5QZ8HMxsoMdY=; b=GP0bi3IQQ5KveIEQcO5IRSpozYGmmXyyNWyEtPKRj0vlJfGUZ0tk8KcDOmJcts1t1MdB2SQoAvRPWiJkv3iebStJ431+seHVW9njOxV34cHIt3F2lZK5q7Glk4Pg4iL7nvU7KcQDx5ntkuvWgIV4iaUEjyf3ZXaxM22dVLyAf1/Z2Y757zF8A95Dst9mNO0gx2FieihRvSuDPfalzMCekaRySdarjRe0iRPKmu0cTYnoaQHh3+4RgID+FzS4XvAe4BqaZrFTAKqjngGpRZPsY+kYjU7EAH8v9v0H7+ZruA5VOBAQKP8+Ff4qOx06GozGbI4ag4Io2P7QTC3p9lcB0w== Received: from SG2APC01FT025.eop-APC01.prod.protection.outlook.com (2a01:111:e400:7ebd::4c) by SG2APC01HT192.eop-APC01.prod.protection.outlook.com (2a01:111:e400:7ebd::412) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3700.27; Tue, 29 Dec 2020 04:41:20 +0000 Received: from ME3P282MB1745.AUSP282.PROD.OUTLOOK.COM (2a01:111:e400:7ebd::44) by SG2APC01FT025.mail.protection.outlook.com (2a01:111:e400:7ebd::187) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3700.27 via Frontend Transport; Tue, 29 Dec 2020 04:41:20 +0000 X-IncomingTopHeaderMarker: OriginalChecksum:57CC17EF41B0F21F7D88F38DE07C8098DF364D95F9724379764449ED6832E544; UpperCasedChecksum:520FC871A88D032A8A8C56736FEF2E3ECDD3644C5FA795694364AFEC09CFB131; SizeAsReceived:7660; Count:47 Received: from ME3P282MB1745.AUSP282.PROD.OUTLOOK.COM ([fe80::88cb:2262:60f7:7d1e]) by ME3P282MB1745.AUSP282.PROD.OUTLOOK.COM ([fe80::88cb:2262:60f7:7d1e%8]) with mapi id 15.20.3700.031; Tue, 29 Dec 2020 04:41:19 +0000 From: Qiuhao Li To: alxndr@bu.edu, qemu-devel@nongnu.org Subject: [PATCH v4 4/7] fuzz: loop the remove minimizer and refactoring Date: Tue, 29 Dec 2020 12:40:41 +0800 Message-ID: X-Mailer: git-send-email 2.25.1 In-Reply-To: References: Content-Transfer-Encoding: 8bit Content-Type: text/plain X-TMN: [8Q6U9TTSscVdXx6KBmXED5orJf2Huuc5HHP08t5gr6bHnSUSYxdEVqo8bagF+iYR] X-ClientProxiedBy: TYAPR01CA0055.jpnprd01.prod.outlook.com (2603:1096:404:2b::19) To ME3P282MB1745.AUSP282.PROD.OUTLOOK.COM (2603:10c6:220:ac::12) X-Microsoft-Original-Message-ID: <20201229044044.3706227-4-Qiuhao.Li@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from pc (2001:250:fe01:130:6d26:2348:77a5:f7ed) by TYAPR01CA0055.jpnprd01.prod.outlook.com (2603:1096:404:2b::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3700.27 via Frontend Transport; Tue, 29 Dec 2020 04:41:19 +0000 X-MS-PublicTrafficType: Email X-IncomingHeaderCount: 47 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-Correlation-Id: bc5fe06d-83d0-493d-1a72-08d8abb3fcb2 X-MS-Exchange-SLBlob-MailProps: S/btQ8cKWiRaJ+ox6yOiFxhBa7ZFYMmiF1Yyh28+MKsrj98hRx6boQ9+6tvhCh+vkL+7D7u+8xSNToZcgEruP6l4r4EUBMeF0zZs12oeFhDJ4KLZ3ALeUapB0nNONbOnqNSBhm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GKqxOB8vzL5QY33zhP4AtdTrfWu2hCdJMsi3c/MlWXooSqKiAK/ngVsW7KzSv75YwTkWsTncENasVdOI4FQcW+9CE7O0HFHFemLgEuAr5Gz5A9+oHqc4GF8vxSTHF/MZXzx9sv4Q== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Dec 2020 04:41:19.9214 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-Network-Message-Id: bc5fe06d-83d0-493d-1a72-08d8abb3fcb2 X-MS-Exchange-CrossTenant-AuthSource: SG2APC01FT025.eop-APC01.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: Internet X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: SG2APC01HT192 Received-SPF: pass client-ip=40.92.255.30; envelope-from=Qiuhao.Li@outlook.com; helo=APC01-HK2-obe.outbound.protection.outlook.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, 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=ham 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, Qiuhao Li , darren.kenny@oracle.com, bsd@redhat.com, stefanha@redhat.com, pbonzini@redhat.com Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Now we use a one-time scan and remove strategy in the remval minimizer, which is not suitable for timing dependent instructions. For example, instruction A will indicate an address where the config chunk locates, and instruction B will make the configuration active. If we have the following instruction sequence: ... A1 B1 A2 B2 ... A2 and B2 are the actual instructions that trigger the bug. If we scan from top to bottom, after we remove A1, the behavior of B1 might be unknowable, including not to crash the program. But we will successfully remove B1 later cause A2 and B2 will crash the process anyway: ... A1 A2 B2 ... Now one more trimming will remove A1. In the perfect case, we would need to be able to remove A and B (or C!) at the same time. But for now, let's just add a loop around the minimizer. Since we only remove instructions, this iterative algorithm is converging. Tested with Bug 1908062. Signed-off-by: Qiuhao Li --- scripts/oss-fuzz/minimize_qtest_trace.py | 41 +++++++++++++++--------- 1 file changed, 26 insertions(+), 15 deletions(-) diff --git a/scripts/oss-fuzz/minimize_qtest_trace.py b/scripts/oss-fuzz/minimize_qtest_trace.py index 1a26bf5b93..378a7ccec6 100755 --- a/scripts/oss-fuzz/minimize_qtest_trace.py +++ b/scripts/oss-fuzz/minimize_qtest_trace.py @@ -71,21 +71,9 @@ def check_if_trace_crashes(trace, path): return False -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)) - - i = 0 - newtrace = trace[:] +def remove_minimizer(newtrace, outpath): remove_step = 1 + i = 0 while i < len(newtrace): # 1.) Try to remove lines completely and reproduce the crash. # If it works, we're done. @@ -174,7 +162,30 @@ def minimize_trace(inpath, outpath): newtrace[i] = prior[0] del newtrace[i+1] i += 1 - check_if_trace_crashes(newtrace, outpath) + + +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)) + + newtrace = trace[:] + + # remove minimizer + old_len = len(newtrace) + 1 + while(old_len > len(newtrace)): + old_len = len(newtrace) + remove_minimizer(newtrace, outpath) + newtrace = list(filter(lambda s: s != "", newtrace)) + + assert(check_if_trace_crashes(newtrace, outpath)) if __name__ == '__main__': -- 2.25.1