From patchwork Mon Jan 11 06:11:46 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qiuhao Li X-Patchwork-Id: 12009837 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 0E5EAC433E0 for ; Mon, 11 Jan 2021 06:13: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 A67E122581 for ; Mon, 11 Jan 2021 06:13:22 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A67E122581 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]:58428 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kyqS9-0003wI-PN for qemu-devel@archiver.kernel.org; Mon, 11 Jan 2021 01:13:21 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:40640) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kyqRO-0003VX-L6 for qemu-devel@nongnu.org; Mon, 11 Jan 2021 01:12:34 -0500 Received: from mail-oln040092255103.outbound.protection.outlook.com ([40.92.255.103]:17825 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 1kyqRL-00033P-1i for qemu-devel@nongnu.org; Mon, 11 Jan 2021 01:12:34 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Gd7VcXdA9EHSkmrYtRIXoC3I95pp/0eMDthoGevM5NDob9jfeLzihpNrmzkxXjx9YNrYQNcTVADIdU1opB2R3M/BTy+TsnTRColL5rZwKFCpCbXTRYdmpTK/IpkY/WZxTB0b/2+L9Zu0NNwjOJkW5CrUgBWPjMWROCE6mAiGkRsWmJ1XeiCBrmXsDiBpMwg5PBNBwAg5qdTH22oYpARSZqyMpYG8kZCY0UBhvcY7hM9ez1xEjYTbrx5S6ZGZT8zEn//CAFR50ji+7EVnkbaDPaG+APV0y3SIUU+tBNKI3lNutbVkuO+nHRuAxHleRbhcScOVSF8Gzj61zy5orJVIbA== 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=fwJXB6/eqTwXMwRYiTY3utbq1jPv07QKC4mHI9Pi4dA=; b=Jaa9mMq5aVbJBBILWVBt75UtnodKH4BzWfoInCREJm2eiKws9PBhlU6qgyViNu/cDSd9yJkQG+G0pjCbzPFVbhzJZsEm1H0l7q2SupaQepufIf5HdugI/PWn1CfzdvFwSppGxiCn1BgBjDW4/i3Qfxggd8vqLCYKtyq53uU8/t2dDOP9EObeUluyQJjZvq/RIN1UCdSDpL9cZwKezet94phVXD35+jcoQnKNzBcBxWKZk6IPvpwJKuLLFl7YmJIBF3JdP+whCAs/DnO64rgmpdI6v9Kllu7+2yiCstSKf45vg9zPLBqmt3UPFkXup7n//ZxBEyez5PSsKAhB75MTSQ== 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=fwJXB6/eqTwXMwRYiTY3utbq1jPv07QKC4mHI9Pi4dA=; b=frqJnMKfS9+UU4Y7gp0fXZ3YzLPaIgxUZBjwIn9wOabdlKv4TjyfOuYT5sCJ/5RsXMtpvggrdcSAekg3WHrPA3dN52pUP/jA2Q4VYQ1hYnBjs/MEM5Oxb/iNYDPIxSoZf7PXAl8DHikYEuAIkTr7RKc5AmuQRID/RMD790gnXRsKZ/degsNGp8oSZLCsqm4m+fyHUrJyfdCpRiO3FQIUU5vG/5oaOe+3z4GXlAMP68OuEie0XyDDltyubhyB6oaKuXsHaoc6ZKp+0Fzlao5giH0M0rbkMcQGgD1/TxbRcwhMlspHkfZn3TEO3QHJvzZn6Gl9YOQMy+bVo1fHLu7UPw== Received: from HK2APC01FT046.eop-APC01.prod.protection.outlook.com (2a01:111:e400:7ebc::42) by HK2APC01HT187.eop-APC01.prod.protection.outlook.com (2a01:111:e400:7ebc::317) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3742.6; Mon, 11 Jan 2021 06:12:22 +0000 Received: from SYCPR01MB3502.ausprd01.prod.outlook.com (10.152.248.51) by HK2APC01FT046.mail.protection.outlook.com (10.152.249.180) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3742.6 via Frontend Transport; Mon, 11 Jan 2021 06:12:22 +0000 X-IncomingTopHeaderMarker: OriginalChecksum:59C557EAC96F31594027613CB558D58C53350723A42E2B103AC8BAD714193386; UpperCasedChecksum:61BA08611D152365717D640C9ACFCEE00109DAF4D71223AEB8CEC49CF6A9D91B; SizeAsReceived:7569; Count:47 Received: from SYCPR01MB3502.ausprd01.prod.outlook.com ([fe80::b5dd:6210:81a:7780]) by SYCPR01MB3502.ausprd01.prod.outlook.com ([fe80::b5dd:6210:81a:7780%5]) with mapi id 15.20.3742.012; Mon, 11 Jan 2021 06:12:22 +0000 From: Qiuhao Li To: qemu-devel@nongnu.org Subject: [PATCH v8 1/7] fuzz: accelerate non-crash detection Date: Mon, 11 Jan 2021 14:11:46 +0800 Message-ID: X-Mailer: git-send-email 2.25.1 In-Reply-To: References: X-TMN: [OoGnRoo7KNwjp87rIRc39VhIBlGHa4c+] X-ClientProxiedBy: HK2PR02CA0178.apcprd02.prod.outlook.com (2603:1096:201:21::14) To SYCPR01MB3502.ausprd01.prod.outlook.com (2603:10c6:10:3e::12) X-Microsoft-Original-Message-ID: <20210111061152.176206-1-Qiuhao.Li@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from XPS-13-9360 (111.176.239.56) by HK2PR02CA0178.apcprd02.prod.outlook.com (2603:1096:201:21::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3742.6 via Frontend Transport; Mon, 11 Jan 2021 06:12:21 +0000 X-MS-PublicTrafficType: Email X-IncomingHeaderCount: 47 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-Correlation-Id: 0c42a82a-b1ed-46bf-b5d8-08d8b5f7dbda X-MS-Exchange-SLBlob-MailProps: /mB5ds43bCFukvp7s0pXhQHGyaaJwPQxJG3eApK9Bggt0F7U2IMASA4va0Pojtwsz8IVJMTHz8eeBbZsmSbSZOXjLf6vmchk5S465pH0coAmZnW/utubVFa0hMniQL3RRRYX3aWYcHEUTAbVkyVzmkAcorcFYDBSxJBXjm2Rjp4lxzlbg5tziAsvlJGH8cOA0nkpXuzOonUCM96Y0s4FwttrdCU6YL3NBvtpKXCdYu78lsLBNRPmYxLHqln+/UWgDWhuBIhhW/Hc/aNCJ0jaF7mkawV/3WG589M+NnIwZya6jPrE0yjcK+SU6XJwt7ALJYgr9S8puLcKpZ2ZV44F2fhUFn0wOAofRRH1Feflrf5VHJgIHuHog+WZBnYeX4SbjavFT8pW1q2k/De7VyhAK/pub5J0Dm2tBBI3CKytNejkgOOB83gbW0M1PVLzQaRMu5/bp2/TXt5eluzdebPSdzUR8yugry5eqlKeiIUmBAvioirXVlduSnJzLJCwB8jha/mqVYMMGOopWufRJonpfkPy8lyutx0IQxbRW+mm3Q+RR/q56lJ9UBprcXjmL2SFV9j9ZtakMVoQpD7WTqQOy256e1TDlsgEh4NF5Bm8IUBYTteOXScQGQSfHVwcmbP8dXxcPkeIVBYcFbJE+TaUC74zaH1aYO/prCUXOSFH3/mHZV/ugLEJ96wrFV8UIwI+1MUCD4pBi5oYmJPXMUPY1uxNCrzv2hXQ06RnVepphU736LvlIvEYNO0v/37ILUNZyn4LfL9aWs8ITMVD+GlxB7oGv9P0sO1ID7W3bwpnirYHeg8BUxGunsvTbO8hZiS59HrvVnruXzBCXx2x51KCPTghkuWhfECKxDlHcsqpfDloE/AD7G2+c6ktwysvZi6myZzbT2cTmsuFAG0weXKliryYPJU7PdbJf6JgOkyKkZ8= X-MS-TrafficTypeDiagnostic: HK2APC01HT187: X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 1+Av7J7fPDvtQIp0VzCZ6ibvSXO0Z/x7Pv1Hrz1aYoWq9bma3SVM5EHZvBDe0tTHBBLIbK9iZQF4W0XTdCYQDtHCJWisxm9TEyXZiGXsvElAMcyX3U4iHjaOdYeB1q9XsVYK/hnsMzkTu5Uh39b+pQE/nH5DZKvIq+mdx7z57mQHi13kq/9ehEyXb0xcZNxYZ9PdInmXykBM/snypp2aVNaxLUnP/FfTCoGTG4XDy3X4HPfYrtXeCC6k6RxFcx5Wp7L2zXCmrqVnPU1vCsKpoRObTTHzh6z3u8kjRkD2ous= X-MS-Exchange-AntiSpam-MessageData: tEF7w5gMZxkuOMOFisNkRv0mL8AcxWbhZxbVI9AmnsgZI+aFerpnXl5QnO6nCo2VOwBEHl48cTevPASujk80GbGiMRvRy7Jm/ju9a7CUHpCAkjT6W0vupoEvZhcb+P0lySeZI+j2e2qAIhqZfGI28w== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Jan 2021 06:12:22.2298 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-Network-Message-Id: 0c42a82a-b1ed-46bf-b5d8-08d8b5f7dbda X-MS-Exchange-CrossTenant-AuthSource: HK2APC01FT046.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: HK2APC01HT187 Received-SPF: pass client-ip=40.92.255.103; 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, darren.kenny@oracle.com, Qiuhao Li , alxndr@bu.edu, bsd@redhat.com, stefanha@redhat.com, pbonzini@redhat.com Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" We spend much time waiting for the timeout program during the minimization process until it passes a time limit. This patch hacks the CLOSED (indicates the redirection file closed) notification in QTest's output if it doesn't crash. Test with quadrupled trace input at: https://bugs.launchpad.net/qemu/+bug/1890333/comments/1 Original version: real 1m37.246s user 0m13.069s sys 0m8.399s Refined version: real 0m45.904s user 0m16.874s sys 0m10.042s Note: Sometimes the mutated or the same trace may trigger a different crash summary (second-to-last line) but indicates the same bug. For example, Bug 1910826 [1], which will trigger a stack overflow, may output summaries like: SUMMARY: AddressSanitizer: stack-overflow /home/qiuhao/hack/qemu/build/../softmmu/physmem.c:488 in flatview_do_translate or SUMMARY: AddressSanitizer: stack-overflow (/home/qiuhao/hack/qemu/build/qemu-system-i386+0x27ca049) in __asan_memcpy Etc. If we use the whole summary line as the token, we may be prevented from further minimization. So in this patch, we only use the first three words which indicate the type of crash: SUMMARY: AddressSanitizer: stack-overflow [1] https://bugs.launchpad.net/qemu/+bug/1910826 Signed-off-by: Qiuhao Li Reviewed-by: Alexander Bulekov Tested-by: Alexander Bulekov --- scripts/oss-fuzz/minimize_qtest_trace.py | 42 +++++++++++++++++------- 1 file changed, 30 insertions(+), 12 deletions(-) diff --git a/scripts/oss-fuzz/minimize_qtest_trace.py b/scripts/oss-fuzz/minimize_qtest_trace.py index 5e405a0d5f..a28913a2a7 100755 --- a/scripts/oss-fuzz/minimize_qtest_trace.py +++ b/scripts/oss-fuzz/minimize_qtest_trace.py @@ -29,8 +29,14 @@ whether the crash occred. Optionally, manually set a string that idenitifes the crash by setting CRASH_TOKEN= """.format((sys.argv[0]))) +deduplication_note = """\n\ +Note: While trimming the input, sometimes the mutated trace triggers a different +type crash but indicates the same bug. Under this situation, our minimizer is +incapable of recognizing and stopped from removing it. In the future, we may +use a more sophisticated crash case deduplication method. +\n""" + def check_if_trace_crashes(trace, path): - global CRASH_TOKEN with open(path, "w") as tracefile: tracefile.write("".join(trace)) @@ -41,18 +47,31 @@ def check_if_trace_crashes(trace, path): 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 - + stdout=subprocess.PIPE, + encoding="utf-8") + global CRASH_TOKEN if CRASH_TOKEN is None: - CRASH_TOKEN = output.splitlines()[-2] + try: + outs, _ = rc.communicate(timeout=5) + CRASH_TOKEN = " ".join(outs.splitlines()[-2].split()[0:3]) + except subprocess.TimeoutExpired: + print("subprocess.TimeoutExpired") + return False + print("Identifying Crashes by this string: {}".format(CRASH_TOKEN)) + global deduplication_note + print(deduplication_note) + return True - return CRASH_TOKEN in output + for line in iter(rc.stdout.readline, ""): + if "CLOSED" in line: + return False + if CRASH_TOKEN in line: + return True + + print("\nWarning:") + print(" There is no 'CLOSED'or CRASH_TOKEN in the stdout of subprocess.") + print(" Usually this indicates a different type of crash.\n") + return False def minimize_trace(inpath, outpath): @@ -66,7 +85,6 @@ def minimize_trace(inpath, outpath): 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[:] From patchwork Mon Jan 11 06:11:47 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qiuhao Li X-Patchwork-Id: 12009839 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 4AB2FC433DB for ; Mon, 11 Jan 2021 06:16:17 +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 9FFBC22581 for ; Mon, 11 Jan 2021 06:16:16 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9FFBC22581 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]:33170 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kyqUx-0005FF-DW for qemu-devel@archiver.kernel.org; Mon, 11 Jan 2021 01:16:15 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:40806) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kyqSl-0004ei-Di for qemu-devel@nongnu.org; Mon, 11 Jan 2021 01:13:59 -0500 Received: from mail-oln040092255092.outbound.protection.outlook.com ([40.92.255.92]:43472 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 1kyqSj-0003iF-H7 for qemu-devel@nongnu.org; Mon, 11 Jan 2021 01:13:59 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=JavuOaIFY2NR+nhPFjwKTgVg8wQ95DSpqU8vyg5ErwQ/82slYWpm6yjXgR1YDnV43pGMPOMpkPSTn80ieuOSu/T6Fk13u6wvgy080TJX55Qf4bwFKoGawgizKR8DH5I8TdZR9iyk5uMNC+ig6ucjtezuqStp9LO26h4AjD5fuAOfzB41omYXd4NmBDXW2VNG3GrLosSvkM6XjjEKoDnMgebJtJZOVMH92mB5/KcKeunM5Jl6lco5b1+3HIK1N5m5N6VaCX1h/si6b02yz/H85ndxtipXAmFCuIoraYiOYd51RlpepsBHclCZ07PqKrgxd+bvrJOEiE+YAriKvV8aaQ== 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=6elFADColTZ1H4wdYADJXnK547NGaYfuNoPdnVaOgpA=; b=a2TE/4TKyO0J1b6SOo9SXOmHlpGYJfGXseRNjT6K7/QPhH0LC6ruEmfkknS9paqBFLrJ+S+huF92Mw5QKP6Ak12WOD/FF6bJvhwgkDfxPRgVDFxh8vYtMXyoVuoNko7k5NFjPkdGRe5DeVvjg7EYlbMMKfmQwBn/kqivq8wADPUii594kkw+3NSuGF7uKmVXsBTaU4ZrRxDW7G/iGi82NScCbp5HdRnQtMpZVgNCpG5D2eljoQz2xiuCg8pWx1Zq+lEYcmRjypnuaB+h1k7+e/Ygc2Wu/dkDZ2C+R0DGAZUx2R50YP940Elb2oDo+vWaW3lLI3ypzFspbs8p8PHqEQ== 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=6elFADColTZ1H4wdYADJXnK547NGaYfuNoPdnVaOgpA=; b=aHEfiWfQUH0Yj+Og9myOWGJoLw5DMAm/bi3etP1ai83rjpPQRgibJEFs8UZlMwwdTzm604+HaEYK2qIZO1C+O+fQqkQu/eCA18tt2WYm71rEwlhUigJwlHbUqCYunyjBSMEYxO+PRq2isBcDfGcCrNngruMOYJiVe4bVOJNjPCau1MCrHGJcJHjRyzvPwMyiV3HkUQCb4fLhTqt2HPqUywxIeOZzH3r56q9pIydWNr4ig7Qm5bzG5BEMdoFPeNI2ks9rCuQYtJRzVbEx/CBP2xKtG5/ZPdmv5lmSbLbEOHn9ecw0HCpB0tCB515l7axaP0wvyZTM6FSsijFML6N2rA== Received: from HK2APC01FT054.eop-APC01.prod.protection.outlook.com (2a01:111:e400:7ebc::48) by HK2APC01HT180.eop-APC01.prod.protection.outlook.com (2a01:111:e400:7ebc::467) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3742.6; Mon, 11 Jan 2021 06:13:47 +0000 Received: from SYCPR01MB3502.ausprd01.prod.outlook.com (10.152.248.59) by HK2APC01FT054.mail.protection.outlook.com (10.152.249.28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3742.6 via Frontend Transport; Mon, 11 Jan 2021 06:13:47 +0000 X-IncomingTopHeaderMarker: OriginalChecksum:CD8F0471EEFCC95F66B152751E5219F1D127793311A8687B4F293EC5DDA1FAA0; UpperCasedChecksum:43ED1CD95A49559A4ACE4FED8032C8779DB5B514DD7E72271CC399E6B9FD8FD0; SizeAsReceived:7564; Count:47 Received: from SYCPR01MB3502.ausprd01.prod.outlook.com ([fe80::b5dd:6210:81a:7780]) by SYCPR01MB3502.ausprd01.prod.outlook.com ([fe80::b5dd:6210:81a:7780%5]) with mapi id 15.20.3742.012; Mon, 11 Jan 2021 06:13:46 +0000 From: Qiuhao Li To: qemu-devel@nongnu.org Subject: [PATCH v8 2/7] fuzz: double the IOs to remove for every loop Date: Mon, 11 Jan 2021 14:11:47 +0800 Message-ID: X-Mailer: git-send-email 2.25.1 In-Reply-To: References: X-TMN: [Mt1T9bO+g1U4yzmNBVsB3pkkgKjzonh4] X-ClientProxiedBy: HK2PR02CA0143.apcprd02.prod.outlook.com (2603:1096:202:16::27) To SYCPR01MB3502.ausprd01.prod.outlook.com (2603:10c6:10:3e::12) X-Microsoft-Original-Message-ID: <20210111061152.176206-2-Qiuhao.Li@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from XPS-13-9360 (111.176.239.56) by HK2PR02CA0143.apcprd02.prod.outlook.com (2603:1096:202:16::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3742.6 via Frontend Transport; Mon, 11 Jan 2021 06:13:46 +0000 X-MS-PublicTrafficType: Email X-IncomingHeaderCount: 47 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-Correlation-Id: e60637fa-1437-47b2-95ff-08d8b5f80e4f X-MS-Exchange-SLBlob-MailProps: KE5ywuOaN5idtt69Y1RXkPrSrL7zR5FKqmkiwKFeFiXr8PxXQqE8eobEgaLQ/Z1GXjKo8aayz4a+a2NWA1gxrs2rAk02Tp2l9KdSZT/l0Bu5cjUU2CCR7kwSxpdgZ18PtlRmOFad5/W7UHSxu1t2zrVR15eigXQGaa46ojtfIyZftmRm9wji022aSQjeDub9ECymSu1tYFhxjT8BHcEO0eZMK1U57EL3WF5cpBacQO89CmTuEgkqXyEZzWuiCnzVBqxXtYW1hjeArIgmBItu+F8BRPNgMn1WbxlsrVYnk/UZ5zI0gJtXvZxVZz4V2M60J8MBaB21G/99dMkme11+c9y9/U47beDLRXZvQahx5GUMPZKONcE/k+i8Bhwbr6H9g6F/N1vxss4V5XTelC/0o00WFHfHgCVYoe5tTLrvPINenSOPzGW/pi+/YOYzs63FtNQ/6RxukLG4dMZbrHOH0L87dTNvLwngfkwP9/ovBmUxey7ziz32D51Ok0ju/4H23rnTLy1TVbspyboSXkP7+JnacKv1/xaGQ13UnDEg4A3Z0HpDBHILWA6JbNwj6xHYrC74A+yfiKz6XbdHoN2gcUtDU2cysnC0MtGKTFOBRKZJrkRsy9GOV/xoCWt4AIxH+Ec/F6oooulsVRIUx9ewWdkHCBYkqn5tuiRAoPRKMDhVag9xkJG6f6tLCtKdmIs/20f8FXx34L1V7zrF2B0Fs6cNzBTZjRONC+UNCEsL704KZ4oTZjBS5ngd5KFhKejtPIDF3HQxGHwRbiGpQcdlNFzOLqwUbYvY/AJrircVzhfgPJ1OglyFXG5X5khpNqrRkcfqfAB6vegR6XByQ4KFFw8W46pzM+f9HyiJSV+X5GN2F+soE4Zih9AbN0xwI/L9oYw5LmsfsZlXkXdDXm8U2Ybj5dW9IkBI9itYDIiJ1knFZDkgRW4odJf1tJKA3TEkrYhDvhgy28rlC5fZnN60yReDiCL6a89+ X-MS-TrafficTypeDiagnostic: HK2APC01HT180: X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ss2t0sqSw/Nr1viq9Wxxj0oAnVmdGB4nxLt7ZCVlcfgwl399PH/zJm+xhYuxUvHchZOVifEXlPkYyS+15Os4DG5Q7slpO9srf8PPCRLbRpqNoONoaXH78vVJGt7t1i5co0nqgt4A8+J8qo4K9uGOQCPNbG9AIPjW1It0/aNjMsribqDliXZnrxQSUKpdAX/yHP0s2jaD+bAIolPyvnNDi1vXaffcXGw1SqcSYgc6mGu2NLkZCC+hPXdZjmjeaJXy3HKST7FAoxXxHwQ0nQ73bHONAFUaLnrhYZGq32OcAg8= X-MS-Exchange-AntiSpam-MessageData: RKm/D4N9Nbg5qfVX4FSORgX5rQoUl/k62NsBzC+iUwnUd+vXBBpZTs41ed7POJBGPN/EOvCgq3OHXCQDaRQpI0UCuUnOc/E1PdwvgcfivdJPqeG9kpioVjspLPK/M7VWdDIf5Q0+TRInw/a4o1r/hw== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Jan 2021 06:13:46.8519 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-Network-Message-Id: e60637fa-1437-47b2-95ff-08d8b5f80e4f X-MS-Exchange-CrossTenant-AuthSource: HK2APC01FT054.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: HK2APC01HT180 Received-SPF: pass client-ip=40.92.255.92; 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, darren.kenny@oracle.com, Qiuhao Li , alxndr@bu.edu, bsd@redhat.com, stefanha@redhat.com, pbonzini@redhat.com Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Instead of removing IO instructions one by one, we can try deleting multiple instructions at once. According to the locality of reference, we double the number of instructions to remove for the next round and recover it to one once we fail. This patch is usually significant for large input. Test with quadrupled trace input at: https://bugs.launchpad.net/qemu/+bug/1890333/comments/1 Patched 1/6 version: real 0m45.904s user 0m16.874s sys 0m10.042s Refined version: real 0m11.412s user 0m6.888s sys 0m3.325s Signed-off-by: Qiuhao Li Reviewed-by: Alexander Bulekov Tested-by: Alexander Bulekov --- scripts/oss-fuzz/minimize_qtest_trace.py | 33 +++++++++++++++--------- 1 file changed, 21 insertions(+), 12 deletions(-) diff --git a/scripts/oss-fuzz/minimize_qtest_trace.py b/scripts/oss-fuzz/minimize_qtest_trace.py index a28913a2a7..cacabf2638 100755 --- a/scripts/oss-fuzz/minimize_qtest_trace.py +++ b/scripts/oss-fuzz/minimize_qtest_trace.py @@ -88,19 +88,28 @@ def minimize_trace(inpath, outpath): i = 0 newtrace = trace[:] - # For each line + remove_step = 1 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] = "" + # 1.) Try to remove lines completely and reproduce the crash. + # If it works, we're done. + if (i+remove_step) >= len(newtrace): + remove_step = 1 + prior = newtrace[i:i+remove_step] + for j in range(i, i+remove_step): + newtrace[j] = "" + print("Removing {lines} ...".format(lines=prior)) if check_if_trace_crashes(newtrace, outpath): - i += 1 + i += remove_step + # Double the number of lines to remove for next round + remove_step *= 2 continue - newtrace[i] = prior - + # Failed to remove multiple IOs, fast recovery + if remove_step > 1: + for j in range(i, i+remove_step): + newtrace[j] = prior[j-i] + remove_step = 1 + continue + newtrace[i] = prior[0] # remove_step = 1 # 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) @@ -121,7 +130,7 @@ def minimize_trace(inpath, outpath): if(check_if_trace_crashes(newtrace, outpath)): break else: - newtrace[i] = prior + newtrace[i] = prior[0] # 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 @@ -154,7 +163,7 @@ def minimize_trace(inpath, outpath): if check_if_trace_crashes(newtrace, outpath): i -= 1 else: - newtrace[i] = prior + newtrace[i] = prior[0] del newtrace[i+1] i += 1 check_if_trace_crashes(newtrace, outpath) From patchwork Mon Jan 11 06:11:48 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qiuhao Li X-Patchwork-Id: 12009841 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 05F6CC433DB for ; Mon, 11 Jan 2021 06:17:59 +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 56EC222581 for ; Mon, 11 Jan 2021 06:17:58 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 56EC222581 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]:35598 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kyqWb-0006MK-GG for qemu-devel@archiver.kernel.org; Mon, 11 Jan 2021 01:17:57 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:41062) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kyqU7-0005Dv-TT for qemu-devel@nongnu.org; Mon, 11 Jan 2021 01:15:28 -0500 Received: from mail-oln040092255055.outbound.protection.outlook.com ([40.92.255.55]:20704 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 1kyqU4-0004Fx-Hm for qemu-devel@nongnu.org; Mon, 11 Jan 2021 01:15:23 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=DvAGfU5Bgp8OG+5Uzor/hCm4dEazo777qtYoZRae4zewEVEfQ1Xde5Orz4FnDMWS1oSYBokYqYl+17B1tfJ1PsEA5XqsGaFOIe/TzyiCmXI+xfaEHKd7lZRQlD5OncZWfDB5TqlcEymLR1q0ciqYZ0GXDo/kyrSSH8wzRvtboG6bol2fBF6ZRsHqBymhrntMzTaKqVi/6OMPUCU578cqjZx3rbZk7B8ebJ5QiKeJu4MANrvTUh1k6c3+E3/U3nVvVDf0+1bf2dFNgAyEu4P5vuER3s+sO01G78aOqKVz77xe0P5Zs7xYXVUeKPIurbr9Ph+Pm+sHLDRc9MYYcnMxVQ== 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=69VvBKSI6Qqwnihmzlhyqr0ckajgMlwEgGgSwuzTTGQ=; b=fSqQybAKzyzCjSP2fJJA+Iei2Nw0YQw4Rh0sw7AuojNVPviyneAoh36OgybV/ikXF0RGoOMzxvPVrmJDM9J6w0gY7kc3z/g5TcCp8fE6Xiud0C4E+J+uwy5dTMIk5j0zMNB4RFG67E0cuJopIeJ2vSwxna+FOvCivF/veMCpZZCebVRBVzkKbyxrpVWwjwSlFSDJweLdyaIQBOlgwnhg3TKnhZfUH9wSJroGrHAXGGyGzFZFwmw0+Xc4CgRVEyvU5ETl79+A+kSZn2pGqAnefYw5I/WQjidWSuX1q9iKlo97eECZwGIHXZ9bjDcXQA9rW4wbsBrz9iQVhyTAij+Y8g== 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=69VvBKSI6Qqwnihmzlhyqr0ckajgMlwEgGgSwuzTTGQ=; b=sG0G6KJGMy9/6LCv4ffQYW1XtPsskH2kVfYaRkOAcUn6WGUXudhRg2mqkwdZCeJpEOdjdjnsIpRzIbe59gRykV6BasCCXb/b5YYzSml9LR7WaIPNPN7LTUzCq5V9xA94UDcWmiNj7khxbkX93ZdwkLJdpRo+qHxhBTHG9CCgh3sMn5I7jtEZNkMFbLW7tccdeUlTT4fGPMLWJxGQUkSnHYVSV567V8OLJPcKOwl5Sm2vvw9tPAYTDyL4wBRDHNDti3IG7EiScsUZbQx0gqKtBUYrMoNkkq9wqce/KB154OJTejD9weXmF618YRZ29hOu56txDDSdhCjsmj/mccSvUw== Received: from HK2APC01FT054.eop-APC01.prod.protection.outlook.com (2a01:111:e400:7ebc::48) by HK2APC01HT180.eop-APC01.prod.protection.outlook.com (2a01:111:e400:7ebc::467) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3742.6; Mon, 11 Jan 2021 06:15:12 +0000 Received: from SYCPR01MB3502.ausprd01.prod.outlook.com (10.152.248.59) by HK2APC01FT054.mail.protection.outlook.com (10.152.249.28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3742.6 via Frontend Transport; Mon, 11 Jan 2021 06:15:11 +0000 X-IncomingTopHeaderMarker: OriginalChecksum:C65FAD93FB17E6C7A63A55E2151FB6609623A29315651B40F3BA729B50D13269; UpperCasedChecksum:B1B5DB160F9F68979D7E4E40F8B3D7DB15D5B247F20FC6A5B3D4CAD01328D1DC; SizeAsReceived:7585; Count:47 Received: from SYCPR01MB3502.ausprd01.prod.outlook.com ([fe80::b5dd:6210:81a:7780]) by SYCPR01MB3502.ausprd01.prod.outlook.com ([fe80::b5dd:6210:81a:7780%5]) with mapi id 15.20.3742.012; Mon, 11 Jan 2021 06:15:11 +0000 From: Qiuhao Li To: qemu-devel@nongnu.org Subject: [PATCH v8 3/7] fuzz: split write operand using binary approach Date: Mon, 11 Jan 2021 14:11:48 +0800 Message-ID: X-Mailer: git-send-email 2.25.1 In-Reply-To: References: X-TMN: [vgaaAggLYURjz8phGbTt6jqBFEQCzoQ3] X-ClientProxiedBy: HK2PR02CA0143.apcprd02.prod.outlook.com (2603:1096:202:16::27) To SYCPR01MB3502.ausprd01.prod.outlook.com (2603:10c6:10:3e::12) X-Microsoft-Original-Message-ID: <20210111061152.176206-3-Qiuhao.Li@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from XPS-13-9360 (111.176.239.56) by HK2PR02CA0143.apcprd02.prod.outlook.com (2603:1096:202:16::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3742.6 via Frontend Transport; Mon, 11 Jan 2021 06:15:10 +0000 X-MS-PublicTrafficType: Email X-IncomingHeaderCount: 47 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-Correlation-Id: e940858c-3e0e-4b7d-a626-08d8b5f840c0 X-MS-Exchange-SLBlob-MailProps: q+fD6XS3/ULYlaWyz2NXCmXZW2G0IxobxkE1bq7b2w8xQJoMNIFGLfAF1pL1PUdz91g3o+6CvoJ/8B55b1Wts5HOhOA2jMxlH6zrzGekkURn0amdvhctuWNY16z8RfUqI3heQsxsBtCmP9d9S2l1PQgSzG1JBEvlxbQoZ0AQTUINN/SO9zW20SVu65LXn2p4Qi6bSj4eEPx40JiaDXSsyLlpSJmqIKmgS2uUrfh6UJdm0LOU5EOSUPm8OYlw6WD+Cc3qQIV5CSokLj8K+c4qYupa4mm66NzCoJihZ6rAx5rRsyWF0BXwkOC3rnhLy2WlkTN/y0IyGUxxsAf/T9nYKSQtnb4gIFwZn6qjIe3TkXf4nNIIr2IFHqBnKdBIkFT7aCquTkaPFwkoE0MX0wqZ5as8G6HpjA0zCbIEMCOFncpy0W2j3EHlKFxrevH2mA5AkZZfIwgGBT+B2iLWwTLXAoyV5/dcg6Hc4Xzl6sHyRgMhBCerVr/okYGZL/XLb/KIuTHT+X2RUm1WkPQYcjrez4UHfLTlQQOkdW97rQqdRFeZePZ/JGJx88o/72QYmJ983k/7xO2hZ77bDVcWmHQ3Tn+LvJ89UGhM25jJzIuMyKZj7rO0cL23y6B1pLokpbrDA58cKZ43shAdwCTYRXU01apARDyk5w47BJDxDPkwmNRP1MmFERb6XXJUZyGcOr6PMRtEqosizDUnAlZ+eSdkHQ== X-MS-TrafficTypeDiagnostic: HK2APC01HT180: X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: WzqZyfm7FaVfqGFsnE4T3vrrBDHtoE7mitwoIplopN5Y3puTf0HjY2Mgl7kfS1CXlsTQrGZcUqOg2KK4pLAY2egkwEL3EXj7IRus+c63DQYXw9RDb20mletALIyRjj8avpr2IUHtAhx7fA8ySz8qW9neNWTgD80dfentKjpcqSu2WbIzNh9Rtmme9PwcI8F1uwNdZVojsIX82Xgeshc8gopplwldGcXaIiS7YZ1dGWK2UcCQf44HP2vlTPSAtppq X-MS-Exchange-AntiSpam-MessageData: pGNfeiBa7KCtznHFd8J27pomZKY0WhEMs9LUMRerVUmYG4/4mvBaWNGlvyv+4L5kXUJvWLmod9f1xlNlLb92Ym+VR3mqE2ZNoru+sv6KrUz/GFPI86MT6OqLMDruUkzVNgsutgXGcwKzghml1RCUSQ== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Jan 2021 06:15:11.5329 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-Network-Message-Id: e940858c-3e0e-4b7d-a626-08d8b5f840c0 X-MS-Exchange-CrossTenant-AuthSource: HK2APC01FT054.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: HK2APC01HT180 Received-SPF: pass client-ip=40.92.255.55; 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, darren.kenny@oracle.com, Qiuhao Li , alxndr@bu.edu, bsd@redhat.com, stefanha@redhat.com, pbonzini@redhat.com Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Currently, we split the write commands' data from the middle. If it does not work, try to move the pivot left by one byte and retry until there is no space. But, this method has two flaws: 1. It may fail to trim all unnecessary bytes on the right side. For example, there is an IO write command: write addr uuxxxxuu u is the unnecessary byte for the crash. Unlike ram write commands, in most case, a split IO write won't trigger the same crash, So if we split from the middle, we will get: write addr uu (will be removed in next round) write addr xxxxuu For xxxxuu, since split it from the middle and retry to the leftmost byte won't get the same crash, we will be stopped from removing the last two bytes. 2. The algorithm complexity is O(n) since we move the pivot byte by byte. To solve the first issue, we can try a symmetrical position on the right if we fail on the left. As for the second issue, instead moving by one byte, we can approach the boundary exponentially, achieving O(log(n)). Give an example: xxxxuu len=6 + | + xxx,xuu 6/2=3 fail + +--------------+-------------+ | | + + xx,xxuu 6/2^2=1 fail xxxxu,u 6-1=5 success + + +------------------+----+ | | | +-------------+ u removed + + xx,xxu 5/2=2 fail xxxx,u 6-2=4 success + | +-----------+ u removed In some rare cases, this algorithm will fail to trim all unnecessary bytes: xxxxxxxxxuxxxxxx xxxxxxxx-xuxxxxxx Fail xxxx-xxxxxuxxxxxx Fail xxxxxxxxxuxx-xxxx Fail ... I think the trade-off is worth it. Signed-off-by: Qiuhao Li Reviewed-by: Alexander Bulekov Tested-by: Alexander Bulekov --- scripts/oss-fuzz/minimize_qtest_trace.py | 29 ++++++++++++++++-------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/scripts/oss-fuzz/minimize_qtest_trace.py b/scripts/oss-fuzz/minimize_qtest_trace.py index cacabf2638..af9767f7e4 100755 --- a/scripts/oss-fuzz/minimize_qtest_trace.py +++ b/scripts/oss-fuzz/minimize_qtest_trace.py @@ -97,7 +97,7 @@ def minimize_trace(inpath, outpath): prior = newtrace[i:i+remove_step] for j in range(i, i+remove_step): newtrace[j] = "" - print("Removing {lines} ...".format(lines=prior)) + print("Removing {lines} ...\n".format(lines=prior)) if check_if_trace_crashes(newtrace, outpath): i += remove_step # Double the number of lines to remove for next round @@ -110,9 +110,11 @@ def minimize_trace(inpath, outpath): remove_step = 1 continue newtrace[i] = prior[0] # remove_step = 1 + # 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] @@ -133,11 +135,15 @@ def minimize_trace(inpath, outpath): newtrace[i] = prior[0] # 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. + # it into two separate write commands. If splitting the data operand + # from length/2^n bytes to the left does not work, try to move the pivot + # to the right side, then add one to n, until length/2^n == 0. The idea + # is to prune unneccessary bytes from long writes, while accommodating + # arbitrary MemoryRegion access sizes and alignments. + + # This algorithm will fail under some rare situations. + # e.g., xxxxxxxxxuxxxxxx (u is the unnecessary byte) + if newtrace[i].startswith("write "): addr = int(newtrace[i].split()[1], 16) length = int(newtrace[i].split()[2], 16) @@ -146,6 +152,7 @@ def minimize_trace(inpath, outpath): leftlength = int(length/2) rightlength = length - leftlength newtrace.insert(i+1, "") + power = 1 while leftlength > 0: newtrace[i] = "write {addr} {size} 0x{data}\n".format( addr=hex(addr), @@ -157,9 +164,13 @@ def minimize_trace(inpath, outpath): data=data[leftlength*2:]) if check_if_trace_crashes(newtrace, outpath): break - else: - leftlength -= 1 - rightlength += 1 + # move the pivot to right side + if leftlength < rightlength: + rightlength, leftlength = leftlength, rightlength + continue + power += 1 + leftlength = int(length/pow(2, power)) + rightlength = length - leftlength if check_if_trace_crashes(newtrace, outpath): i -= 1 else: From patchwork Mon Jan 11 06:11:49 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qiuhao Li X-Patchwork-Id: 12009843 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 B1C5FC433E0 for ; Mon, 11 Jan 2021 06:19:13 +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 48C2E22581 for ; Mon, 11 Jan 2021 06:19:13 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 48C2E22581 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]:37042 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kyqXo-0006yu-AB for qemu-devel@archiver.kernel.org; Mon, 11 Jan 2021 01:19:12 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:41238) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kyqVQ-0005qB-Mq for qemu-devel@nongnu.org; Mon, 11 Jan 2021 01:16:45 -0500 Received: from mail-oln040092253090.outbound.protection.outlook.com ([40.92.253.90]:11042 helo=APC01-SG2-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 1kyqVO-0004qc-II for qemu-devel@nongnu.org; Mon, 11 Jan 2021 01:16:44 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=WuftetXYpD+YMcXi8gLA4DDMgoS7WsBTZvm2KoWw2hbbomeclN9RTrYjlRxhf05QlAIcb2CTdomcSPdsWmNqBX0yNRBMEQjGmb0TmDASAZFBqr50ImgrFYHKu4t51ogwOhUdgcT2CUQ85hvEgaUgQXXdpQZphCE+zd1nKkOBOJCs+NwcDOLKpjF1mqOh/qYJ+sX9j55yff0UbI8/P2NBUrOImLJmoAXRj2uUyngl73AObM7hEHvQPwhFbJw1HlqDKS9rMigFjG+N9TTBKjg9Bl11c0jzKGk4/myC7FGI4Hr478zpC4DoH+NfFBTZS3WpAlfmxnumcTdMX/WWJxpTnw== 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=cU/DLQcN67fmdXItDkz2dQhakfELffXv+QxefRmq63o=; b=HH/CzkXbOL+WYW90waqtzrLRK5bTRYC2edZyU6lKkZR5Cuh22u2wLCaFaFeLGvdvVLnQYdV6uVAFZthWRbCntaH6O3BR5ZMtsRxcqbTp0U54ohTc5o5ujve5nRvBS4e+R62uY/LZ6OSVfPmiXC+1eKpqJ7bYANV35hAFmR1y4dGXqHTkFz1xhqndqHUnnx7qRlqQIHjNPS7f3cgqPKxrMySTpYtM08JAKiXppwspsuUS3hoR9QR5D9Ag7U4EcYEKXXKhTH5DY9vTQ0084kEdV39Y7u/CesvGmhKkoZ6iHUoL4vah764XbOaITCKKXIqUGq6MAqidyYBie2RE2FKgHQ== 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=cU/DLQcN67fmdXItDkz2dQhakfELffXv+QxefRmq63o=; b=AFre9B5gMJKzHaJLX/UjS52Jro0un3w8MIw9v2Q9IBzen4VFGx9+Gj5I1EgLEu2iCH+t7Rn5OSSkF9i0b04qCuskYZbhF3AUNyowMFkD8k7y1q5pHbbw7u2KORrrt6N23p/3yzDf1Mj7Q2SUoh8X6mA7r2lVW6zj2munc+D1UqksqxO5F2h4g7Rg+MoGzTPoyHv4Az2HdRyNS2eGCme4Nz10H8oFvNwMVDkRcSxpSmNZh64v0ppMUd/bAU+KvS/jaRmEt8pM7A/S8wb7V20ZGWwS+dOKI1cQ6ApXaAVoQaDv3VlcFNjxDo9AFSQBRyUg+gFT2RXNrMbrCrEh1Dp/fg== Received: from HK2APC01FT054.eop-APC01.prod.protection.outlook.com (2a01:111:e400:7ebc::44) by HK2APC01HT221.eop-APC01.prod.protection.outlook.com (2a01:111:e400:7ebc::444) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3742.6; Mon, 11 Jan 2021 06:16:31 +0000 Received: from SYCPR01MB3502.ausprd01.prod.outlook.com (10.152.248.59) by HK2APC01FT054.mail.protection.outlook.com (10.152.249.28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3742.6 via Frontend Transport; Mon, 11 Jan 2021 06:16:31 +0000 X-IncomingTopHeaderMarker: OriginalChecksum:7B6325708695386333C1D5156E22A9423AAEB9B8F8002C50108684C51B41F616; UpperCasedChecksum:91BC9BA6941C1CC6D963459A1C04ED688AB148500F53F56503CE60C701EB6995; SizeAsReceived:7575; Count:47 Received: from SYCPR01MB3502.ausprd01.prod.outlook.com ([fe80::b5dd:6210:81a:7780]) by SYCPR01MB3502.ausprd01.prod.outlook.com ([fe80::b5dd:6210:81a:7780%5]) with mapi id 15.20.3742.012; Mon, 11 Jan 2021 06:16:31 +0000 From: Qiuhao Li To: qemu-devel@nongnu.org Subject: [PATCH v8 4/7] fuzz: remove IO commands iteratively Date: Mon, 11 Jan 2021 14:11:49 +0800 Message-ID: X-Mailer: git-send-email 2.25.1 In-Reply-To: References: X-TMN: [fPSy4t6JJCLRBWGhOpDVbj8IzmG9YZCb] X-ClientProxiedBy: HK2PR02CA0141.apcprd02.prod.outlook.com (2603:1096:202:16::25) To SYCPR01MB3502.ausprd01.prod.outlook.com (2603:10c6:10:3e::12) X-Microsoft-Original-Message-ID: <20210111061152.176206-4-Qiuhao.Li@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from XPS-13-9360 (111.176.239.56) by HK2PR02CA0141.apcprd02.prod.outlook.com (2603:1096:202:16::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3742.6 via Frontend Transport; Mon, 11 Jan 2021 06:16:30 +0000 X-MS-PublicTrafficType: Email X-IncomingHeaderCount: 47 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-Correlation-Id: f7e97fcc-f9fe-483e-dae5-08d8b5f8705e X-MS-Exchange-SLBlob-MailProps: S/btQ8cKWiSygBPrM25OmKOGXZqaBnYp0dqYPQpcI3jY0uoIuoXaFtErUpR6B/j0KaKO43jS9+wDxTjlTUGU+EfkEtK5vMJFkBVEoaco1qXAh99lMsDBVqk4urkcJ8f56m6b+REfPeBLX442ZZQQiPRAse6eJhm/ybVyEJ37lXlGrOQ2RRniabUqx1aFZXFLbjnwgQTxzbRf8NSRHzQVt32bsyR75ds0AkEVhzN5Z3cUKbuWkpO9ooQwVV21CGa1tbxTjoNoGSq3E248dgF9lMqONx/4OwE4/YW09CCfyPGuprfCE9X3k7Q4c0K1pL9qDetgu0jufhqMCneXDSNdQibqwRgK/VU8+91myWSrdKywLCCmDWx+xlZjTeWDqW2XL9UIwUnqrC4IBvlhcs/74E9lYPkJ0/0hBC7zDjTiekj65UV/yEjeCZEUMLBOP80jxdS973hPhgVPbuSRrURCK+gOwGBoP0Eg924L9J0d3VaGPBcpBMyFjDINpTD+v03PUCDyEdy8rnwJu7JEK6aFsT3h8wFmV11GDY/ncCH+gtLlG3/Ci7S1fsDci0/ZL3EL2gktV4hMxwaT/hQEfxxhGgOQWZZCAuhj/3s2F4oh0swN+b+qS7mXWaT5SYqfRfi5sx6FDTKaEqCoZbvquaDeHTs4o+jQsazncbbV8TcOYGLe0v+5hLwHNPoxQ6ye13nXyn+WwGtfC4dOnYoxbyV2U+gj5cfJin7SY7X38xJyqvjpfgk9EnKQJntqPzeKoifxtuuN/aRNglI= X-MS-TrafficTypeDiagnostic: HK2APC01HT221: X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: b25Y8iP60Gpf1uu8nfstxyxGPzBX2dOpuaGVSI2Of9Id9CVCtJfPJ7mC6k1gErh9b+WmOD4ftpbWMYPojmMCistEe1FI1RmqoexBQk+OwFt6aEJgaSvdlLx9QAC5LrDJ5zkiCtlI3CiNH1dXr5+X+LRoHLP11FHy8YUISLPGAIwW28zi0PRI7ULmqL9U24jr7xPwI96MOAb/yH0h3ReiNPUzOHXUGaMjoSz9e1iuUOFqQNUsW5hM9w2/SESwE7rQ X-MS-Exchange-AntiSpam-MessageData: tyZ6d4DbMHOYmjQ9FhRz3VFCpCR6slPaNwjPUEcfoFYpDl6aCBUUIp5WEYo5RoYHmHcUhwIktCmPN+Uv9jZ0lNUDK4HSa/L5cY28MhTgrJPmluRbQiBMLnACByyUIC7rPTa2do3O+XfTfJkvuOGzRQ== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Jan 2021 06:16:31.4266 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-Network-Message-Id: f7e97fcc-f9fe-483e-dae5-08d8b5f8705e X-MS-Exchange-CrossTenant-AuthSource: HK2APC01FT054.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: HK2APC01HT221 Received-SPF: pass client-ip=40.92.253.90; envelope-from=Qiuhao.Li@outlook.com; helo=APC01-SG2-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, darren.kenny@oracle.com, Qiuhao Li , alxndr@bu.edu, 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 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 Reviewed-by: Alexander Bulekov Tested-by: Alexander Bulekov --- 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 af9767f7e4..59e91de7e2 100755 --- a/scripts/oss-fuzz/minimize_qtest_trace.py +++ b/scripts/oss-fuzz/minimize_qtest_trace.py @@ -74,21 +74,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_lines(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. @@ -177,7 +165,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 lines + old_len = len(newtrace) + 1 + while(old_len > len(newtrace)): + old_len = len(newtrace) + remove_lines(newtrace, outpath) + newtrace = list(filter(lambda s: s != "", newtrace)) + + assert(check_if_trace_crashes(newtrace, outpath)) if __name__ == '__main__': From patchwork Mon Jan 11 06:11:50 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qiuhao Li X-Patchwork-Id: 12009845 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 659EDC433E0 for ; Mon, 11 Jan 2021 06:20:43 +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 1681622581 for ; Mon, 11 Jan 2021 06:20:42 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1681622581 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]:41404 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kyqZF-0000OT-Tl for qemu-devel@archiver.kernel.org; Mon, 11 Jan 2021 01:20:41 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:41506) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kyqX3-0006tm-To for qemu-devel@nongnu.org; Mon, 11 Jan 2021 01:18:29 -0500 Received: from mail-oln040092255071.outbound.protection.outlook.com ([40.92.255.71]:64339 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 1kyqWx-0005WG-Ii for qemu-devel@nongnu.org; Mon, 11 Jan 2021 01:18:25 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Fd601N+QLtzvIExLfpxD9uxD2tye642uDuhnc4zy9HLB2wx5UTi4yBzK+MbwcCUCil6pLVGaePYJNMOXAYg8CDodXqHIuYjNQE4RQ8FlEWVToGGbLtwdmvWZNQGj1UTdqqhlo6u5a45Bd/Ye2mfySh5LKOBBa9oi8SonhrPlL5hIGc7zB/KkdZ5DyjJAGFxwq7cpaTFupjXObJX408ZekyAQZl6W1IPSTWEPa87CFF4PGKWWQYkogKZx5CsCBCBElOjcNO+ohemmzn8R5YCDEckaPWizZ1NREwJZP77ZlBrIzeov6YNbmIpzVDe9iXxiZRceWDXSpnRrxa1lPQZXmA== 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=+CqrkHd0eGJi/nkPBCL2hDvMALR7Y/Cl2ck11Bv+VI0=; b=Ad7DD/muG6WTyNYHdCtrvGnoPlzLioKkCBSLdqt86OuTCbjGEHsNEi6KkKmE06EL/PArKDi07KxZdQVu8dh23hhEVUX3nCq7yatJEhNjQO5cpbQT1pZKktnj1/cVXIwxpzTtVxse2WhzkSD6zQ60oXYNEtQAGIxRjqU7SDNS+mySaNb56uRvOqOsyAfgTiOG0VKCNUUV41/MFp2MEf2U4IC0Q8rvQqas1XwG4ld4FCqhNLQ7G/QMjGEdn6WZEC0vm710XYbVIfmaLpi5fD6mxx3BflIpp61uLaeRxysqOFoxPK+0Vh0bNB2fWzJFdPZGMMtHPGknBJHbcSvBxZNCxQ== 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=+CqrkHd0eGJi/nkPBCL2hDvMALR7Y/Cl2ck11Bv+VI0=; b=o/+xJrdDR98O6eWM4IccUj0h1lzU5fy854wOCbvMGx/TTlfNx17elqSO83/C3xPyrdaviVRWC0nSJg7iVA+valGk+971JqynnJeJ6DFlGrqwudIlqzmpkNIcECAhs4MNwFjvLHkPV4Fy5uE3R6Gc8yetNPsqgakGWBRWu93RiMk7BVZAP7nXB9nke5EmLft0CeG4Z2xGMf6GXtkxemeKbSFT+Y5nm8x8gh05/cBjEWAINVHfk32gKmZ0ctORJS9XvhuYaQA1k9X+2PKEz4Vunre8x9AeL/UXoBG5P1ZFUeUwHS21KRu0JRjXI9yL54krwFCuauMbU8lMLen3RqG1XQ== Received: from HK2APC01FT054.eop-APC01.prod.protection.outlook.com (2a01:111:e400:7ebc::52) by HK2APC01HT223.eop-APC01.prod.protection.outlook.com (2a01:111:e400:7ebc::427) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3742.6; Mon, 11 Jan 2021 06:18:08 +0000 Received: from SYCPR01MB3502.ausprd01.prod.outlook.com (10.152.248.59) by HK2APC01FT054.mail.protection.outlook.com (10.152.249.28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3742.6 via Frontend Transport; Mon, 11 Jan 2021 06:18:08 +0000 X-IncomingTopHeaderMarker: OriginalChecksum:BE2E455D28BF8F94C9F00D8878581B83F4E3271B3F2D4CDDAABC00DF42174C43; UpperCasedChecksum:BA126988ECF333439BA57015C1B77A87080EDB6A7E347E1C586BF8F6300AD4BF; SizeAsReceived:7565; Count:47 Received: from SYCPR01MB3502.ausprd01.prod.outlook.com ([fe80::b5dd:6210:81a:7780]) by SYCPR01MB3502.ausprd01.prod.outlook.com ([fe80::b5dd:6210:81a:7780%5]) with mapi id 15.20.3742.012; Mon, 11 Jan 2021 06:18:08 +0000 From: Qiuhao Li To: qemu-devel@nongnu.org Subject: [PATCH v8 5/7] fuzz: set bits in operand of write/out to zero Date: Mon, 11 Jan 2021 14:11:50 +0800 Message-ID: X-Mailer: git-send-email 2.25.1 In-Reply-To: References: X-TMN: [dzGac2B9Q3Wa/xd7CZ43t6L56tgbUBB9] X-ClientProxiedBy: HK2PR02CA0130.apcprd02.prod.outlook.com (2603:1096:202:16::14) To SYCPR01MB3502.ausprd01.prod.outlook.com (2603:10c6:10:3e::12) X-Microsoft-Original-Message-ID: <20210111061152.176206-5-Qiuhao.Li@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from XPS-13-9360 (111.176.239.56) by HK2PR02CA0130.apcprd02.prod.outlook.com (2603:1096:202:16::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3742.6 via Frontend Transport; Mon, 11 Jan 2021 06:18:07 +0000 X-MS-PublicTrafficType: Email X-IncomingHeaderCount: 47 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-Correlation-Id: 6b36d934-266f-4796-bb22-08d8b5f8a9fb X-MS-Exchange-SLBlob-MailProps: S/btQ8cKWiSygBPrM25OmKOGXZqaBnYpENrsmetjiDeaKCJ9y8q4OXZMpEP2LUnAKnE8ZcgunSfmaxOOZb/XinlTKXv+0RvtwkAleryuIkpznu3RlUwC/OKttI8b5lSm2IaKPYAUUHyTGNVfeRdFp7iUsFXfmQKJcrkj85aNrG057XvK6ex4Hq+nt82xjY9duqCdWy5e4GbNoVASTVzM5fTcaRdrWReRIi61cbOkbrimpgZgEG/qOoz7opElib/hKVK6c+HeJwMRO431CPfhZ9PRyrMTGuvU2HvQ7Olln3XAAFptNwoQ+GBDSSmXlWa6UDsTLpVJH5n/mrQZLamjNroIx5C0+rKruAoA1sgLPwW/rOndWYoUygTAgXvqFI8pDteAilnPVOBv7GTFwFtdzfv2B03y0tzoApY/C7uWF3cc2kGSfk22836WaXZ4vaL7AfBrBG47fm+97IzRfyXdq/OFzUa5QjdqAhyaw8HzooaC9bsd+kS/3NyNsyDS6vVla/MxqtXIGIjHUQXee62m1MDpbIq3qHglmd/nKR6cPOTZY3fhnLgbqz/plo6HbyCgr8T6bxVvTE/6f3wlNrOJIjijp51IzFyGsHtHFJv7sY+mU22A7HtyEZF/+iFubMIk0jynjpJ7klROwHfY/Ga55pG38xwIM1OSMzxlQTFcEKWh8+scGmjO3RmNap0Dgg+H6SKsmDUhc05oMiLtBB1N/P0wUwUlLCjGiOSFXzbC8Qi7Tx68JRws69oQADmrrvDeH6KW2ABRid4= X-MS-TrafficTypeDiagnostic: HK2APC01HT223: X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 8+Ddcn/Uj7NC1DJCUbBDWVhgdYkztad9It6DmeJvHEQM4NS2YE86cY0g+IDeZJ0rv2d0YSXwDYKUS5vDQIdQoZ1RJpiy01ngp18WKkyXjL/RzmDY5Uq/eAFBlPsHvOvMGxLC+/lnGkCv82scInIohmL5kCdl5AuqICUY3GdZCkfAHBw/S3JE0AHrMo5e8Eely7k+rHu7AmK+z6psxSRp+WsxwpEuLNI5bQzhyUJ2Pq+Pm1QUBdWJbrWjLefFCyZq X-MS-Exchange-AntiSpam-MessageData: RNwkUZhsFYeIUfKrgN+unia+aG40ySY4mghFduJbggVaNCZsV7FqiMUf+JcM8uhlaC6kNUvtqyoDuzuBpB3RC+LueEg9/Au2nHL/nqeolKzZ+WH05cTMFoSvDnySow2wSraF9WFaNr+qx2cGDOP2VQ== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Jan 2021 06:18:08.0249 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-Network-Message-Id: 6b36d934-266f-4796-bb22-08d8b5f8a9fb X-MS-Exchange-CrossTenant-AuthSource: HK2APC01FT054.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: HK2APC01HT223 Received-SPF: pass client-ip=40.92.255.71; 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, darren.kenny@oracle.com, Qiuhao Li , alxndr@bu.edu, bsd@redhat.com, stefanha@redhat.com, pbonzini@redhat.com Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Simplifying the crash cases by opportunistically setting bits in operands of out/write to zero may help to debug, since usually bit one means turn on or trigger a function while zero is the default turn-off setting. Tested Bug 1908062. Signed-off-by: Qiuhao Li Reviewed-by: Alexander Bulekov Tested-by: Alexander Bulekov --- scripts/oss-fuzz/minimize_qtest_trace.py | 39 ++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/scripts/oss-fuzz/minimize_qtest_trace.py b/scripts/oss-fuzz/minimize_qtest_trace.py index 59e91de7e2..219858a9e3 100755 --- a/scripts/oss-fuzz/minimize_qtest_trace.py +++ b/scripts/oss-fuzz/minimize_qtest_trace.py @@ -167,6 +167,42 @@ def remove_lines(newtrace, outpath): i += 1 +def clear_bits(newtrace, outpath): + # try setting bits in operands of out/write to zero + i = 0 + while i < len(newtrace): + if (not newtrace[i].startswith("write ") and not + newtrace[i].startswith("out")): + i += 1 + continue + # write ADDR SIZE DATA + # outx ADDR VALUE + print("\nzero setting bits: {}".format(newtrace[i])) + + prefix = " ".join(newtrace[i].split()[:-1]) + data = newtrace[i].split()[-1] + data_bin = bin(int(data, 16)) + data_bin_list = list(data_bin) + + for j in range(2, len(data_bin_list)): + prior = newtrace[i] + if (data_bin_list[j] == '1'): + data_bin_list[j] = '0' + data_try = hex(int("".join(data_bin_list), 2)) + # It seems qtest only accepts padded hex-values. + if len(data_try) % 2 == 1: + data_try = data_try[:2] + "0" + data_try[2:-1] + + newtrace[i] = "{prefix} {data_try}\n".format( + prefix=prefix, + data_try=data_try) + + if not check_if_trace_crashes(newtrace, outpath): + data_bin_list[j] = '1' + newtrace[i] = prior + i += 1 + + def minimize_trace(inpath, outpath): global TIMEOUT with open(inpath) as f: @@ -187,7 +223,10 @@ def minimize_trace(inpath, outpath): old_len = len(newtrace) remove_lines(newtrace, outpath) newtrace = list(filter(lambda s: s != "", newtrace)) + assert(check_if_trace_crashes(newtrace, outpath)) + # set bits to zero + clear_bits(newtrace, outpath) assert(check_if_trace_crashes(newtrace, outpath)) From patchwork Mon Jan 11 06:11:51 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qiuhao Li X-Patchwork-Id: 12009847 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 E8138C433DB for ; Mon, 11 Jan 2021 06:22:22 +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 9A3DF22581 for ; Mon, 11 Jan 2021 06:22:22 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9A3DF22581 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]:44120 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kyqar-0001hZ-GP for qemu-devel@archiver.kernel.org; Mon, 11 Jan 2021 01:22:21 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:41982) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kyqZp-0000w8-3D for qemu-devel@nongnu.org; Mon, 11 Jan 2021 01:21:17 -0500 Received: from mail-oln040092255087.outbound.protection.outlook.com ([40.92.255.87]:59712 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 1kyqZl-0006up-ND for qemu-devel@nongnu.org; Mon, 11 Jan 2021 01:21:16 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=n9BClFyQR1nX46ci9AMj3DJPU4kGwnRt3AxIC0iD+cSA6r1ewVHDjvV8Bs0rgirW0WjaSxMi63ZDf9WBPMsFnZ16yMyRBNySgo96Nrche3O9Q97B0y0XgJyMEb86lKHo0KEO590/SKN4X0QwmHXAytk808j+yvxSZpM2dHRX/MZQ4moynIzd1ykPZ2gzPJunhhrX17DHexlWERiG+Xs4U7zsv8rANKDwO1DI5r4c8c+9s/oFoxWpy7WMLfi6ZRT/aM49n4q7psG0Tqx1RdBPC6LfE+i+p7UWFOxgt+4GwkuXQtAmKkb2HSoa6QSlN5zUU6vNtlLn7TglI+Vgtvoszw== 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=Gt4ZDE1o6MqlXqsPI7Z6ZyMUqy8CaNUyoKoTehZjR7U=; b=AkFDUmVtgZ9evWn1jE7b7syagqij1HVPV6uDno+W/7RRNcRddEQVV9H+u8YjsOs/Lj+p9lqSOe1mMublaw5vus7YRBbdXEPChsOp7wX6bWTiuOR7tpe0A4amCvBSzl6m9CUL+YQGDNJncEhl+pNsJlvAlQexXgNRJMW6aVdCT6CHkVHEIkt6jbFiNsWlesHguhsPEWuvN6uAUGAnZWZBCkVLV25d/bxnUfDs2GYNChmjC6m0Gct/09hvdjWB2Qrb86fSTOeKAOAiUfzdTGKtzAziQE8X4SuNwPAh2X4w95+xjzfR2iEGqYHjvq2UISndgnBdjjcvY8fmTyYOnVy7kg== 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=Gt4ZDE1o6MqlXqsPI7Z6ZyMUqy8CaNUyoKoTehZjR7U=; b=dTSq2Sf7UrILi4hywjO15zcXL6i7EZjq7/NvmGS7Qf0I9H4wf23ibJ2mjkTnFr29Lhh/7Z2Bva2nd/8W+Qp1qtWlRCFPEnhMIWBPRIBzLxO16lYfr5ZmKx81e8rF5WGKkpniE58UNi8n06XFHpc3hA+iiNTvW70JkUCDTVvJphBy+X0NOnnUcNolN7ucdZ952CANLG1wqXL4dPi/9dgt9N2lvNm1SPyulbhtrXTGaWPgwsLR4eMsUqnoEdFEpM4kekh4mEAoXGU0lShxUu3tUDkhTgE3AztghltGdcwxRtZUNqAciupLMteXxMDXelR11LBwOWtR9WxlizX1dL4QIg== Received: from HK2APC01FT115.eop-APC01.prod.protection.outlook.com (2a01:111:e400:7ebc::46) by HK2APC01HT013.eop-APC01.prod.protection.outlook.com (2a01:111:e400:7ebc::158) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3742.6; Mon, 11 Jan 2021 06:21:06 +0000 Received: from SYCPR01MB3502.ausprd01.prod.outlook.com (2a01:111:e400:7ebc::52) by HK2APC01FT115.mail.protection.outlook.com (2a01:111:e400:7ebc::194) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3742.6 via Frontend Transport; Mon, 11 Jan 2021 06:21:06 +0000 X-IncomingTopHeaderMarker: OriginalChecksum:38E3E9DDECA07F4849FF7EB97D5AF746305AD67177BA1F7CA52394682C776265; UpperCasedChecksum:39F9B02A09D1451E0D20A02DED2978FCBE158C052906D2ADE445B9AEEBE011F5; SizeAsReceived:7568; Count:47 Received: from SYCPR01MB3502.ausprd01.prod.outlook.com ([fe80::b5dd:6210:81a:7780]) by SYCPR01MB3502.ausprd01.prod.outlook.com ([fe80::b5dd:6210:81a:7780%5]) with mapi id 15.20.3742.012; Mon, 11 Jan 2021 06:21:05 +0000 From: Qiuhao Li To: qemu-devel@nongnu.org Subject: [PATCH v8 6/7] fuzz: add minimization options Date: Mon, 11 Jan 2021 14:11:51 +0800 Message-ID: X-Mailer: git-send-email 2.25.1 In-Reply-To: References: X-TMN: [JBjYg9jE4pd5LGZAaqtfUUhdpT97awTG] X-ClientProxiedBy: HK2PR02CA0141.apcprd02.prod.outlook.com (2603:1096:202:16::25) To SYCPR01MB3502.ausprd01.prod.outlook.com (2603:10c6:10:3e::12) X-Microsoft-Original-Message-ID: <20210111061152.176206-6-Qiuhao.Li@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from XPS-13-9360 (111.176.239.56) by HK2PR02CA0141.apcprd02.prod.outlook.com (2603:1096:202:16::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3742.6 via Frontend Transport; Mon, 11 Jan 2021 06:21:04 +0000 X-MS-PublicTrafficType: Email X-IncomingHeaderCount: 47 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-Correlation-Id: f0131898-9cd5-4604-2bd2-08d8b5f9136e X-MS-Exchange-SLBlob-MailProps: gjx25WM8ZNWt8qMG3IjM1tewnTO4qKhayaN+CsK5UlmUTZIGraRzzEmUxzNQJ10wn9aGyjdgOLw2w+T2bIv3EAbziqhoRnVxnZUz6GZkZQtfsvhZ5Y5ygyB3bDezhkh0KR0L4bn2ph/DlnbtR1tY/lYydPfhvpO2XaBSbL6oo05tD7x1eqFyiTOjO2se46t2OipKSk1H05AI+kmBB/5+T4MqtdR2VbUmnW9FRaO61ainCn+tQI2ocRNPfnK+KhomFkpi7c2HosqqX4CyQafXTfVglfHL+3Jr1f7guhMto8Jp82nnQeBxR7E3b8V4FfFUhK2HncKDP5FTuQ7CvNLYLeliyAyFjabwHNs+2FnslkRTpNdNCaZYWWif6OrRKUPCVSC10cm2jZs7q+rcXl4YgmYaijlWXjB7xba6I6gU2RDPa+1JApdFPKVSmjtTUxB3eiCtSALee66/qt/5SXQBMcFh64+0/AUH020jNgCxo3URTkL3HVpiie+x/7y7oCDlqS7yIC9QAMU+GZkjDHwd7rP++7V8sjm6PNewGRzKkTi4ofvGYAglDlab6jsuNHyzhph8pjihg2EQqCVR3fZ+MUgsU4B23zQunHlQc0eCd7socQ0h6/MlCK5AFJAK+bhNZ7LMmLc6ALgUSAU1OwetatgEhDpIW7An2ZJj7kXEpZ0gmy3Wnf2i0D4Lc0EFbz1XlGYd6nu1egVPPgdzzMae4gAWAfTnv6+VytvcykDCi/4= X-MS-TrafficTypeDiagnostic: HK2APC01HT013: X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 6ORWWo7LLATRyox9rW6DSvUbg+S+xZbAOGEH5siDUqm0N4ivIkMjJGgdcXUAipIQaxUW55RN+dX0LnB0kCzXhav3hlKdFmpBif58h5/r50iFGSzzNPiZIrlu/Q663yJrYYwNbdIFk0GJCpkFV/LdM4gEDNkwsm8yaIXlqd2SrspEVAcZhgehHRHSZ7wTlrMVuZuYAW3M173h5z5QL3+QiltCCbJNwiNmhiDWEcPTuJA0aiYaJ9IJ/ywhu3hb7AzG X-MS-Exchange-AntiSpam-MessageData: b2KJw1vsXR0DVAK+tRyhFFIha9nsvWa4kI9i/a0e72cNQEPOuNftQsVAqu731TRZ2ME0qTc3em5mP9q+giq+Dk3EY87hqMnW8Ynsoi79Krv4rd5W6RYD2PhIc5xjMT8JPIxBHZqI72cHh2nXMBIitw== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Jan 2021 06:21:04.9457 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-Network-Message-Id: f0131898-9cd5-4604-2bd2-08d8b5f9136e X-MS-Exchange-CrossTenant-AuthSource: HK2APC01FT115.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: HK2APC01HT013 Received-SPF: pass client-ip=40.92.255.87; 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, darren.kenny@oracle.com, Qiuhao Li , alxndr@bu.edu, bsd@redhat.com, stefanha@redhat.com, pbonzini@redhat.com Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" -M1: remove IO commands iteratively -M2: try setting bits in operand of write/out to zero Signed-off-by: Qiuhao Li Reviewed-by: Alexander Bulekov Tested-by: Alexander Bulekov --- scripts/oss-fuzz/minimize_qtest_trace.py | 30 ++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/scripts/oss-fuzz/minimize_qtest_trace.py b/scripts/oss-fuzz/minimize_qtest_trace.py index 219858a9e3..0e59bdbb01 100755 --- a/scripts/oss-fuzz/minimize_qtest_trace.py +++ b/scripts/oss-fuzz/minimize_qtest_trace.py @@ -16,6 +16,10 @@ QEMU_PATH = None TIMEOUT = 5 CRASH_TOKEN = None +# Minimization levels +M1 = False # try removing IO commands iteratively +M2 = False # try setting bits in operand of write/out to zero + write_suffix_lookup = {"b": (1, "B"), "w": (2, "H"), "l": (4, "L"), @@ -23,10 +27,20 @@ write_suffix_lookup = {"b": (1, "B"), def usage(): sys.exit("""\ -Usage: QEMU_PATH="/path/to/qemu" QEMU_ARGS="args" {} input_trace output_trace +Usage: + +QEMU_PATH="/path/to/qemu" QEMU_ARGS="args" {} [Options] 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= + +Options: + +-M1: enable a loop around the remove minimizer, which may help decrease some + timing dependant instructions. Off by default. +-M2: try setting bits in operand of write/out to zero. Off by default. + """.format((sys.argv[0]))) deduplication_note = """\n\ @@ -216,24 +230,32 @@ def minimize_trace(inpath, outpath): print("Setting the timeout for {} seconds".format(TIMEOUT)) newtrace = trace[:] + global M1, M2 # remove lines old_len = len(newtrace) + 1 while(old_len > len(newtrace)): old_len = len(newtrace) + print("trace lenth = ", old_len) remove_lines(newtrace, outpath) + if not M1 and not M2: + break newtrace = list(filter(lambda s: s != "", newtrace)) assert(check_if_trace_crashes(newtrace, outpath)) # set bits to zero - clear_bits(newtrace, outpath) + if M2: + clear_bits(newtrace, outpath) assert(check_if_trace_crashes(newtrace, outpath)) if __name__ == '__main__': if len(sys.argv) < 3: usage() - + if "-M1" in sys.argv: + M1 = True + if "-M2" in sys.argv: + M2 = True QEMU_PATH = os.getenv("QEMU_PATH") QEMU_ARGS = os.getenv("QEMU_ARGS") if QEMU_PATH is None or QEMU_ARGS is None: @@ -242,4 +264,4 @@ if __name__ == '__main__': # 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]) + minimize_trace(sys.argv[-2], sys.argv[-1]) From patchwork Mon Jan 11 06:11:52 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qiuhao Li X-Patchwork-Id: 12009849 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 1B00BC433DB for ; Mon, 11 Jan 2021 06:24: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 6271522581 for ; Mon, 11 Jan 2021 06:24:57 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6271522581 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]:46408 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kyqdM-0002pe-29 for qemu-devel@archiver.kernel.org; Mon, 11 Jan 2021 01:24:56 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:42342) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kyqbg-0002C7-QX for qemu-devel@nongnu.org; Mon, 11 Jan 2021 01:23:12 -0500 Received: from mail-oln040092253044.outbound.protection.outlook.com ([40.92.253.44]:23680 helo=APC01-SG2-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 1kyqbe-0007o6-Vv for qemu-devel@nongnu.org; Mon, 11 Jan 2021 01:23:12 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=d5B0SeMM1QEsvaKdHF8HRlAPEs7BEaodI6jLb9wcKqI44DMaA3w7dWh+iyhXDn69T5X4uS/O9S3f8El7tyY5PWBatxE67tW7Sqb9hqYDvxQd7iaps+QZO0b2c7GRbD5tEB8D27o+g3dus9/Vsss3n439FRlVOgr5UF+gq0NBDCe4yR5VhqIketMLpvljStDnXqk2V03kEdE3Vwl2OJtAdOtq6OtDsM1uzJO7qo5tFNeIism2dY7z+9x6vN3MIQNdjR2faYDid6IyRabXqcZyTlWT/GOoLNT2tOakmxX/S/RNPU4MrcUGZ0T5QSSfisyAAFqgg+KKxigbw2gdM/Nvcg== 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=fS0+t4hYQWLGjfoiqhvDFCY7YsB/eIXiuIW9ZbNHtdE=; b=MjQsSY1GmwxbGXnNo8+I40ifaEWlgIHip06fhr1OWWXscxRFGotdGCBbmrHRqFuK4/pl5h9eyLKnhmmhlk5sUgmH96aI3jUGSgMm6Ugrhu7342PeFiSt5GLdKz8P/WqhaY5tVWopTlbLakI3DZl8EjMdJXel2yVfE5qSI66Rvos4tAT9XYyHHC3g3dVdUjSmaxJBMuTNtUB27bN6SWVK3SiEt6vkPvKVDU9PpYuGL9tRmbwxLgj7fD7fTeHqmuPpvhcO+L1JeueKsvBEuNJZeSvkiEcw23JsaXoci3ueRng96e58M1L0bL0F6Ig6S7PK9o452kt9XjE8TPBur/dy0A== 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=fS0+t4hYQWLGjfoiqhvDFCY7YsB/eIXiuIW9ZbNHtdE=; b=nHwurNiljt2MwDkx0SKsHpbPZWmlWh1WNMuiL9I64q8jgewAh3PDiMtoFYy7Cw+lTNpX84dKKiRf62KCyc5TKuwss9+ZLfwlBXgxHRO8sJq+VIHsPdYPcHMDKiWtf2lMdh1jFiEw/3StV5MOWlg+b4yVXICJVU3jucNbv+k6zLjrPCocZMzB89zpj69136m4P7zimFww5Nj+fP21jhgZkUklzX8oOvzWpPkYaBICkUPMrz7yIGSQ2OLANbFz5E87K0KS+/l0FctWX0ZSq3ENFdkDtwe96+fa3BGUA8H/y4Zj6iO31Eu2w40/iUCE5zbk9rAMvF8JgflCoq8CscuCKQ== Received: from HK2APC01FT115.eop-APC01.prod.protection.outlook.com (2a01:111:e400:7ebc::50) by HK2APC01HT157.eop-APC01.prod.protection.outlook.com (2a01:111:e400:7ebc::275) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3742.6; Mon, 11 Jan 2021 06:23:02 +0000 Received: from SYCPR01MB3502.ausprd01.prod.outlook.com (2a01:111:e400:7ebc::52) by HK2APC01FT115.mail.protection.outlook.com (2a01:111:e400:7ebc::194) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3742.6 via Frontend Transport; Mon, 11 Jan 2021 06:23:02 +0000 X-IncomingTopHeaderMarker: OriginalChecksum:746784368A5719B3842499C7715DD86DDE6996F6E4667123CCCED8223A03AD1D; UpperCasedChecksum:A161244E2BA9FFE8E21EE5992DA389125444895D82C4010C7649D6A3C1400378; SizeAsReceived:7555; Count:47 Received: from SYCPR01MB3502.ausprd01.prod.outlook.com ([fe80::b5dd:6210:81a:7780]) by SYCPR01MB3502.ausprd01.prod.outlook.com ([fe80::b5dd:6210:81a:7780%5]) with mapi id 15.20.3742.012; Mon, 11 Jan 2021 06:23:02 +0000 From: Qiuhao Li To: qemu-devel@nongnu.org Subject: [PATCH v8 7/7] fuzz: heuristic split write based on past IOs Date: Mon, 11 Jan 2021 14:11:52 +0800 Message-ID: X-Mailer: git-send-email 2.25.1 In-Reply-To: References: X-TMN: [1dyxjmlIfW/5AuPD0ayFHc3jSCxCzDEB] X-ClientProxiedBy: HK2PR02CA0137.apcprd02.prod.outlook.com (2603:1096:202:16::21) To SYCPR01MB3502.ausprd01.prod.outlook.com (2603:10c6:10:3e::12) X-Microsoft-Original-Message-ID: <20210111061152.176206-7-Qiuhao.Li@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from XPS-13-9360 (111.176.239.56) by HK2PR02CA0137.apcprd02.prod.outlook.com (2603:1096:202:16::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3742.6 via Frontend Transport; Mon, 11 Jan 2021 06:23:01 +0000 X-MS-PublicTrafficType: Email X-IncomingHeaderCount: 47 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-Correlation-Id: fe8980d1-f77a-4799-d007-08d8b5f95958 X-MS-Exchange-SLBlob-MailProps: S/btQ8cKWiSygBPrM25OmKOGXZqaBnYpnMrFc+MNpCWxi0YKz8r682bVXN/OzS13PtpRzGvjQ3zYd0jwpK2z3DAI2zfVr+sYeVwPnYN7W8YcL9uwR36IXq/2CNQegByvGYQ0VzGu6utCPj24aoOjcaKqxt3z7Ja1oV0Z14OHM2mnnzSt2Wjor/xJWhIp2uGNp1N3Fsoq55kyVH4+83E5Y3Q1brfzwNTSAPBWMYDvpBQdl/dlydpBOlz/qhFfKxB4AlWGWKnHE7N+fqszw7AOfMtMvcACxkk2scn2t6c+A46F2d6uLAwghoI5u//ZD6lzx4Z+v2q3HPuQaTjZ8MzSNLc9ghHLnf1UTBi5YuZOVt/AjMChzHDHrSkv8fN21UdhaDmDFd/h+yOMrvgZlPqzO1DeLmeAMzpDilvmLnckpBqA0+8SToSnfLLVfmhvD0JSn1SyucgZGrNIzfksViORuMbP1uPJ+uLiV91ZGw1fQcaXvo/qH0s9899AgoMKtCZvEyzpnpDZArMgSgoTT5/WiAqRxJWe6I/eETMz8zSqeClgs8pd/dBXvPW9B+4hOBNzEXAUPGjFDPb+RIIdlVxeSQ4wS/QusDVt0HyrEgMEHvlpCI+fXxiCTQLurB+B3qRAGnjEbrn65OC5vZIKztdHHrtewtIvLH9r8yreOCGiSnmyoPeNSE4zZY25h2GLntD8iDAkCXehtf9sPNx8QpJsw9CHvrs1ZS758sQuqrfjpMAhVLby8GGkeY2fOXuGcwWbBXgqcyx7XNg= X-MS-TrafficTypeDiagnostic: HK2APC01HT157: X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ZaLEkawtrfJZY2CgkF5EuSMLa/pIaQIEagW3Mfh5KZVKUSit8j5CSkyTyWHxQp/yaRqzma6dYEswf3gzW1JKi1ywoaGZm5SzkllLwaOVbA+2ZqnXF16attn4+O4H+DSTPaRM0DV6E1i6XIJIxvrX1OmUcOMvrk2uhmVvfjZQuyi9JLyHoHjhR09OGb60xbVTrGH0wIAEp0hzzb+Hf139wBcpKeqMrcvbYik1MBMzbaqcnYuYshf3YT1efeDkUr5I X-MS-Exchange-AntiSpam-MessageData: 8yF2DiQmsVOMuDMZDExNeBH6GtCn4mMopxMt/kbsH1Y5CFczJ+cYtxWloAirdng+YL4Fz92bdACbS7ufYCiaCquUFybbp8ZLC2S0WwArQgigjNU9lwaPouYIMiLDl1uVrj8YBzlZXtspj84e9icKQg== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Jan 2021 06:23:02.3012 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-Network-Message-Id: fe8980d1-f77a-4799-d007-08d8b5f95958 X-MS-Exchange-CrossTenant-AuthSource: HK2APC01FT115.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: HK2APC01HT157 Received-SPF: pass client-ip=40.92.253.44; envelope-from=Qiuhao.Li@outlook.com; helo=APC01-SG2-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, darren.kenny@oracle.com, Qiuhao Li , alxndr@bu.edu, bsd@redhat.com, stefanha@redhat.com, pbonzini@redhat.com Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" If previous write commands write the same length of data with the same step, we view it as a hint. Signed-off-by: Qiuhao Li Reviewed-by: Alexander Bulekov Tested-by: Alexander Bulekov --- scripts/oss-fuzz/minimize_qtest_trace.py | 56 ++++++++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/scripts/oss-fuzz/minimize_qtest_trace.py b/scripts/oss-fuzz/minimize_qtest_trace.py index 0e59bdbb01..4cba96dee2 100755 --- a/scripts/oss-fuzz/minimize_qtest_trace.py +++ b/scripts/oss-fuzz/minimize_qtest_trace.py @@ -88,6 +88,43 @@ def check_if_trace_crashes(trace, path): return False +# If previous write commands write the same length of data at the same +# interval, we view it as a hint. +def split_write_hint(newtrace, i): + HINT_LEN = 3 # > 2 + if i <=(HINT_LEN-1): + return None + + #find previous continuous write traces + k = 0 + l = i-1 + writes = [] + while (k != HINT_LEN and l >= 0): + if newtrace[l].startswith("write "): + writes.append(newtrace[l]) + k += 1 + l -= 1 + elif newtrace[l] == "": + l -= 1 + else: + return None + if k != HINT_LEN: + return None + + length = int(writes[0].split()[2], 16) + for j in range(1, HINT_LEN): + if length != int(writes[j].split()[2], 16): + return None + + step = int(writes[0].split()[1], 16) - int(writes[1].split()[1], 16) + for j in range(1, HINT_LEN-1): + if step != int(writes[j].split()[1], 16) - \ + int(writes[j+1].split()[1], 16): + return None + + return (int(writes[0].split()[1], 16)+step, length) + + def remove_lines(newtrace, outpath): remove_step = 1 i = 0 @@ -151,6 +188,25 @@ def remove_lines(newtrace, outpath): length = int(newtrace[i].split()[2], 16) data = newtrace[i].split()[3][2:] if length > 1: + + # Can we get a hint from previous writes? + hint = split_write_hint(newtrace, i) + if hint is not None: + hint_addr = hint[0] + hint_len = hint[1] + if hint_addr >= addr and hint_addr+hint_len <= addr+length: + newtrace[i] = "write {addr} {size} 0x{data}\n".format( + addr=hex(hint_addr), + size=hex(hint_len), + data=data[(hint_addr-addr)*2:\ + (hint_addr-addr)*2+hint_len*2]) + if check_if_trace_crashes(newtrace, outpath): + # next round + i += 1 + continue + newtrace[i] = prior[0] + + # Try splitting it using a binary approach leftlength = int(length/2) rightlength = length - leftlength newtrace.insert(i+1, "")