From nobody Mon Feb 9 13:30:36 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1dmarc=pass fromdomain=outlook.com); dmarc=pass(p=none dis=none) header.from=outlook.com ARC-Seal: i=2; a=rsa-sha256; t=1610345605; cv=pass; d=zohomail.com; s=zohoarc; b=TAZOKqYxARkNjG0z8VkkUuheHofYInOZ09ir9c1SA3l/MxldUe9UTQCdsrMIU7cP79EdJe7wcj35qF11qOAWwwASs+MMF8ir0fLCor0BOzf79gRkYGYvqxEXS81LAggFOXELDY48kDIHdv7pZq+0kVdP5cpi0HzqnGQdg7hYhas= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1610345605; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=fwJXB6/eqTwXMwRYiTY3utbq1jPv07QKC4mHI9Pi4dA=; b=OVM7Z7FQP0aDsBvv3msT4lUtsVNz/UAdZ/Kp+QY6gZ1eDloErrYnAbR48pOOps+38F+9QWCH/P2ZQBjUthz+i1FXj8ciAWM37q2IHBvLH7Dd1JTpcgcwBPg1ObSLI+O+PFZ2Xe3uICGRap8DdhtO+Ppe/84/hUYNXr/odUvpwh8= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1dmarc=pass fromdomain=outlook.com); dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1610345605425214.19195555612396; Sun, 10 Jan 2021 22:13:25 -0800 (PST) Received: from localhost ([::1]:58428 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kyqSC-0003wI-Am for importer@patchew.org; Mon, 11 Jan 2021 01:13:24 -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 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 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 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 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== X-IncomingTopHeaderMarker: OriginalChecksum:59C557EAC96F31594027613CB558D58C53350723A42E2B103AC8BAD714193386; UpperCasedChecksum:61BA08611D152365717D640C9ACFCEE00109DAF4D71223AEB8CEC49CF6A9D91B; SizeAsReceived:7569; Count:47 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: Content-Transfer-Encoding: quoted-printable 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 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 (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @outlook.com) Content-Type: text/plain; charset="utf-8" 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/mi= nimize_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 str= ing that idenitifes the crash by setting CRASH_TOKEN=3D """.format((sys.argv[0]))) =20 +deduplication_note =3D """\n\ +Note: While trimming the input, sometimes the mutated trace triggers a dif= ferent +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 m= ay +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)) =20 @@ -41,18 +47,31 @@ def check_if_trace_crashes(trace, path): trace_path=3Dpath), shell=3DTrue, stdin=3Dsubprocess.PIPE, - stdout=3Dsubprocess.PIPE) - stdo =3D rc.communicate()[0] - output =3D stdo.decode('unicode_escape') - if rc.returncode =3D=3D 137: # Timed Out - return False - if len(output.splitlines()) < 2: - return False - + stdout=3Dsubprocess.PIPE, + encoding=3D"utf-8") + global CRASH_TOKEN if CRASH_TOKEN is None: - CRASH_TOKEN =3D output.splitlines()[-2] + try: + outs, _ =3D rc.communicate(timeout=3D5) + CRASH_TOKEN =3D " ".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 =20 - 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 subproces= s.") + print(" Usually this indicates a different type of crash.\n") + return False =20 =20 def minimize_trace(inpath, outpath): @@ -66,7 +85,6 @@ def minimize_trace(inpath, outpath): print("Crashed in {} seconds".format(end-start)) TIMEOUT =3D (end-start)*5 print("Setting the timeout for {} seconds".format(TIMEOUT)) - print("Identifying Crashes by this string: {}".format(CRASH_TOKEN)) =20 i =3D 0 newtrace =3D trace[:] --=20 2.25.1 From nobody Mon Feb 9 13:30:36 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1dmarc=pass fromdomain=outlook.com); dmarc=pass(p=none dis=none) header.from=outlook.com ARC-Seal: i=2; a=rsa-sha256; t=1610345780; cv=pass; d=zohomail.com; s=zohoarc; b=Ztmd9XGHrIpnMOjtWkJg+HXPL5YtRhwHRrqTdliKDHjy82hDJ47ly2niEaNsbWwt0G+uYlv7Zaa/gdgOVEZsdkpXZeeBr5HwepTudDDnGFtHSDngXiq01dX7rN3RLFbujixztAcpRW/ZDoPl1GmJjLJ+F8R9jnJH3zLETqXwX4Q= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1610345780; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=6elFADColTZ1H4wdYADJXnK547NGaYfuNoPdnVaOgpA=; b=H32wxLpMwU3YR0PromgHMsgXp7O7jeVuBaEqpVAfNreFilImSvSP5Fx+Zrkz0yXN30AVfnTX8GwLbHin097xP84HpIo+Q9K2cjdQtn4K59WUMctwhyHNNY55y8UOY/W13qvkTz9+CNADSbCGivIR0d7SglDLUOZpECZZgLB1iEU= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1dmarc=pass fromdomain=outlook.com); dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1610345780387242.20946533940753; Sun, 10 Jan 2021 22:16:20 -0800 (PST) Received: from localhost ([::1]:33170 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kyqV0-0005FF-Qy for importer@patchew.org; Mon, 11 Jan 2021 01:16:18 -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 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 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 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 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== X-IncomingTopHeaderMarker: OriginalChecksum:CD8F0471EEFCC95F66B152751E5219F1D127793311A8687B4F293EC5DDA1FAA0; UpperCasedChecksum:43ED1CD95A49559A4ACE4FED8032C8779DB5B514DD7E72271CC399E6B9FD8FD0; SizeAsReceived:7564; Count:47 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: Content-Transfer-Encoding: quoted-printable 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 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: =?us-ascii?Q?KE5ywuOaN5idtt69Y1RXkPrSrL7zR5FKqmkiwKFeFiXr8PxXQqE8eobEgaLQ?= =?us-ascii?Q?/Z1GXjKo8aayz4a+a2NWA1gxrs2rAk02Tp2l9KdSZT/l0Bu5cjUU2CCR7kwS?= =?us-ascii?Q?xpdgZ18PtlRmOFad5/W7UHSxu1t2zrVR15eigXQGaa46ojtfIyZftmRm9wji?= =?us-ascii?Q?022aSQjeDub9ECymSu1tYFhxjT8BHcEO0eZMK1U57EL3WF5cpBacQO89CmTu?= =?us-ascii?Q?EgkqXyEZzWuiCnzVBqxXtYW1hjeArIgmBItu+F8BRPNgMn1WbxlsrVYnk/UZ?= =?us-ascii?Q?5zI0gJtXvZxVZz4V2M60J8MBaB21G/99dMkme11+c9y9/U47beDLRXZvQahx?= =?us-ascii?Q?5GUMPZKONcE/k+i8Bhwbr6H9g6F/N1vxss4V5XTelC/0o00WFHfHgCVYoe5t?= =?us-ascii?Q?TLrvPINenSOPzGW/pi+/YOYzs63FtNQ/6RxukLG4dMZbrHOH0L87dTNvLwng?= =?us-ascii?Q?fkwP9/ovBmUxey7ziz32D51Ok0ju/4H23rnTLy1TVbspyboSXkP7+JnacKv1?= =?us-ascii?Q?/xaGQ13UnDEg4A3Z0HpDBHILWA6JbNwj6xHYrC74A+yfiKz6XbdHoN2gcUtD?= =?us-ascii?Q?U2cysnC0MtGKTFOBRKZJrkRsy9GOV/xoCWt4AIxH+Ec/F6oooulsVRIUx9ew?= =?us-ascii?Q?WdkHCBYkqn5tuiRAoPRKMDhVag9xkJG6f6tLCtKdmIs/20f8FXx34L1V7zrF?= =?us-ascii?Q?2B0Fs6cNzBTZjRONC+UNCEsL704KZ4oTZjBS5ngd5KFhKejtPIDF3HQxGHwR?= =?us-ascii?Q?biGpQcdlNFzOLqwUbYvY/AJrircVzhfgPJ1OglyFXG5X5khpNqrRkcfqfAB6?= =?us-ascii?Q?vegR6XByQ4KFFw8W46pzM+f9HyiJSV+X5GN2F+soE4Zih9AbN0xwI/L9oYw5?= =?us-ascii?Q?LmsfsZlXkXdDXm8U2Ybj5dW9IkBI9itYDIiJ1knFZDkgRW4odJf1tJKA3TEk?= =?us-ascii?Q?rYhDvhgy28rlC5fZnN60yReDiCL6a89+?= 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 (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @outlook.com) Content-Type: text/plain; charset="utf-8" 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/mi= nimize_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): =20 i =3D 0 newtrace =3D trace[:] - # For each line + remove_step =3D 1 while i < len(newtrace): - # 1.) Try to remove it completely and reproduce the crash. If it w= orks, - # we're done. - prior =3D newtrace[i] - print("Trying to remove {}".format(newtrace[i])) - # Try to remove the line completely - newtrace[i] =3D "" + # 1.) Try to remove lines completely and reproduce the crash. + # If it works, we're done. + if (i+remove_step) >=3D len(newtrace): + remove_step =3D 1 + prior =3D newtrace[i:i+remove_step] + for j in range(i, i+remove_step): + newtrace[j] =3D "" + print("Removing {lines} ...".format(lines=3Dprior)) if check_if_trace_crashes(newtrace, outpath): - i +=3D 1 + i +=3D remove_step + # Double the number of lines to remove for next round + remove_step *=3D 2 continue - newtrace[i] =3D prior - + # Failed to remove multiple IOs, fast recovery + if remove_step > 1: + for j in range(i, i+remove_step): + newtrace[j] =3D prior[j-i] + remove_step =3D 1 + continue + newtrace[i] =3D prior[0] # remove_step =3D 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] =3D prior + newtrace[i] =3D prior[0] =20 # 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 -=3D 1 else: - newtrace[i] =3D prior + newtrace[i] =3D prior[0] del newtrace[i+1] i +=3D 1 check_if_trace_crashes(newtrace, outpath) --=20 2.25.1 From nobody Mon Feb 9 13:30:36 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1dmarc=pass fromdomain=outlook.com); dmarc=pass(p=none dis=none) header.from=outlook.com ARC-Seal: i=2; a=rsa-sha256; t=1610345889; cv=pass; d=zohomail.com; s=zohoarc; b=L+S1xq3gDsYKz37bxGVkNuq5Br7i4LxcVuQFbtPAtm8HBB/jqsgRAkxKiXe8baOj6cpku4yQXV/JYLGXVLbAbL5FDl8T6iVaBLuc7bOo+YGSG+1ixGQicNVUPHNptm4eP11l6cnmAJuakGiQVfmornqtnqB3XpLskgdxtdJM+Hk= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1610345889; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=69VvBKSI6Qqwnihmzlhyqr0ckajgMlwEgGgSwuzTTGQ=; b=fo3ghfzZaTU7DZ+tDsjfNnH6ovz8iyHXwKDnwyQdYKUF8CVwjhlWt7zXuUO42ojmih1PFHSMi91F9bLDGYsmFlo33JZ/yEZ5YTV2pMo23tuipruk6Rw22wxSSlC0uKYe60J+qyBfNty8Ss4UguGWvs2IddbFnRkBZmgjqUEF8X4= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1dmarc=pass fromdomain=outlook.com); dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1610345889706586.2225943164591; Sun, 10 Jan 2021 22:18:09 -0800 (PST) Received: from localhost ([::1]:35598 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kyqWm-0006MK-Gs for importer@patchew.org; Mon, 11 Jan 2021 01:18:08 -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 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 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 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 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== X-IncomingTopHeaderMarker: OriginalChecksum:C65FAD93FB17E6C7A63A55E2151FB6609623A29315651B40F3BA729B50D13269; UpperCasedChecksum:B1B5DB160F9F68979D7E4E40F8B3D7DB15D5B247F20FC6A5B3D4CAD01328D1DC; SizeAsReceived:7585; Count:47 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: Content-Transfer-Encoding: quoted-printable 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 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 (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @outlook.com) Content-Type: text/plain; charset="utf-8" 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=3D6 + | + xxx,xuu 6/2=3D3 fail + +--------------+-------------+ | | + + xx,xxuu 6/2^2=3D1 fail xxxxu,u 6-1=3D5 success + + +------------------+----+ | | | +-------------+ u removed + + xx,xxu 5/2=3D2 fail xxxx,u 6-2=3D4 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/mi= nimize_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 =3D newtrace[i:i+remove_step] for j in range(i, i+remove_step): newtrace[j] =3D "" - print("Removing {lines} ...".format(lines=3Dprior)) + print("Removing {lines} ...\n".format(lines=3Dprior)) if check_if_trace_crashes(newtrace, outpath): i +=3D remove_step # Double the number of lines to remove for next round @@ -110,9 +110,11 @@ def minimize_trace(inpath, outpath): remove_step =3D 1 continue newtrace[i] =3D prior[0] # remove_step =3D 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 =3D newtrace[i].split()[0][-1] @@ -133,11 +135,15 @@ def minimize_trace(inpath, outpath): newtrace[i] =3D prior[0] =20 # 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, un= til - # there is no space left. The idea is to prune unneccessary bytes = from - # long writes, while accommodating arbitrary MemoryRegion access s= izes - # and alignments. + # it into two separate write commands. If splitting the data opera= nd + # 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 =3D=3D 0.= The idea + # is to prune unneccessary bytes from long writes, while accommoda= ting + # 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 =3D int(newtrace[i].split()[1], 16) length =3D int(newtrace[i].split()[2], 16) @@ -146,6 +152,7 @@ def minimize_trace(inpath, outpath): leftlength =3D int(length/2) rightlength =3D length - leftlength newtrace.insert(i+1, "") + power =3D 1 while leftlength > 0: newtrace[i] =3D "write {addr} {size} 0x{data}\n".forma= t( addr=3Dhex(addr), @@ -157,9 +164,13 @@ def minimize_trace(inpath, outpath): data=3Ddata[leftlength*2:]) if check_if_trace_crashes(newtrace, outpath): break - else: - leftlength -=3D 1 - rightlength +=3D 1 + # move the pivot to right side + if leftlength < rightlength: + rightlength, leftlength =3D leftlength, rightlength + continue + power +=3D 1 + leftlength =3D int(length/pow(2, power)) + rightlength =3D length - leftlength if check_if_trace_crashes(newtrace, outpath): i -=3D 1 else: --=20 2.25.1 From nobody Mon Feb 9 13:30:36 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1dmarc=pass fromdomain=outlook.com); dmarc=pass(p=none dis=none) header.from=outlook.com ARC-Seal: i=2; a=rsa-sha256; t=1610345957; cv=pass; d=zohomail.com; s=zohoarc; b=L1yjv+mWfdzEHcdwAR2o/NiK9TGT2IPqVeY6v02ulGgsvdq8tAS3EREOCBC/SQgT6cQMZI+zt41q1El3eThQdv/XI7KM2sqThZr/EPk7wVhhdctqUYeMUgVSSPtxeOboDMnBTloLSIexyKdYZyEAGhkkALNrZBSFmPBJaa+pmW0= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1610345957; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=cU/DLQcN67fmdXItDkz2dQhakfELffXv+QxefRmq63o=; b=cyFLkKkHDj+lJd9Fl42xnhvflSgqNkr6V0J55deqkVamNpnGn0imkBMcbBWMFHT4T3/tMPH7HMlbPLzQw95xVsq0VwQWbNdWuqvI+/eMN8FAvBjVTApHMOfKmkKsHB9rx+Cljf87Fm/G6eqw6Jy3nwor9hlN3bo9lKuH7RyHhOg= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1dmarc=pass fromdomain=outlook.com); dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1610345957328377.1551261299485; Sun, 10 Jan 2021 22:19:17 -0800 (PST) Received: from localhost ([::1]:37042 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kyqXs-0006yu-2s for importer@patchew.org; Mon, 11 Jan 2021 01:19:16 -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 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 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 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 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== X-IncomingTopHeaderMarker: OriginalChecksum:7B6325708695386333C1D5156E22A9423AAEB9B8F8002C50108684C51B41F616; UpperCasedChecksum:91BC9BA6941C1CC6D963459A1C04ED688AB148500F53F56503CE60C701EB6995; SizeAsReceived:7575; Count:47 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: Content-Transfer-Encoding: quoted-printable 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 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 (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @outlook.com) Content-Type: text/plain; charset="utf-8" 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/mi= nimize_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 =20 =20 -def minimize_trace(inpath, outpath): - global TIMEOUT - with open(inpath) as f: - trace =3D f.readlines() - start =3D time.time() - if not check_if_trace_crashes(trace, outpath): - sys.exit("The input qtest trace didn't cause a crash...") - end =3D time.time() - print("Crashed in {} seconds".format(end-start)) - TIMEOUT =3D (end-start)*5 - print("Setting the timeout for {} seconds".format(TIMEOUT)) - - i =3D 0 - newtrace =3D trace[:] +def remove_lines(newtrace, outpath): remove_step =3D 1 + i =3D 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] =3D prior[0] del newtrace[i+1] i +=3D 1 - check_if_trace_crashes(newtrace, outpath) + + +def minimize_trace(inpath, outpath): + global TIMEOUT + with open(inpath) as f: + trace =3D f.readlines() + start =3D time.time() + if not check_if_trace_crashes(trace, outpath): + sys.exit("The input qtest trace didn't cause a crash...") + end =3D time.time() + print("Crashed in {} seconds".format(end-start)) + TIMEOUT =3D (end-start)*5 + print("Setting the timeout for {} seconds".format(TIMEOUT)) + + newtrace =3D trace[:] + + # remove lines + old_len =3D len(newtrace) + 1 + while(old_len > len(newtrace)): + old_len =3D len(newtrace) + remove_lines(newtrace, outpath) + newtrace =3D list(filter(lambda s: s !=3D "", newtrace)) + + assert(check_if_trace_crashes(newtrace, outpath)) =20 =20 if __name__ =3D=3D '__main__': --=20 2.25.1 From nobody Mon Feb 9 13:30:36 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1dmarc=pass fromdomain=outlook.com); dmarc=pass(p=none dis=none) header.from=outlook.com ARC-Seal: i=2; a=rsa-sha256; t=1610346046; cv=pass; d=zohomail.com; s=zohoarc; b=P70Ev+IIGoYXgAaBgW4bYM5DzUYnoWb07LNF++Fzj5Ikq56q4KHF7IEyVT465mJ9lVv0uv3OlyJsvpsy67vq+N0tszIyXFQvdX6s3meQni+5GagV3V/vPa3CpOqU0qBi7TEaBDGCl+7oAF1PQd6TbvSXi+9ttOrdveaTXfTluWI= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1610346046; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=+CqrkHd0eGJi/nkPBCL2hDvMALR7Y/Cl2ck11Bv+VI0=; b=l+oC63Ar1dSufRhpfnGf7cryRpTyZYo7lta3fpcxQsZ2DFGe1TiI2v+9PfhvnKMw4BQtSImG8qBR5hf8z+K0F/C33eDK7J4mC5bYpBMqJjFxiFwOq+RSCw3VvLwVP69sve3kYvRZ7dD8OSMtJ0VeV7Q2ETpHnFT90XEGoQXUFY4= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1dmarc=pass fromdomain=outlook.com); dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1610346046123356.19287826231334; Sun, 10 Jan 2021 22:20:46 -0800 (PST) Received: from localhost ([::1]:41404 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kyqZJ-0000OT-02 for importer@patchew.org; Mon, 11 Jan 2021 01:20:45 -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 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 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 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 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== X-IncomingTopHeaderMarker: OriginalChecksum:BE2E455D28BF8F94C9F00D8878581B83F4E3271B3F2D4CDDAABC00DF42174C43; UpperCasedChecksum:BA126988ECF333439BA57015C1B77A87080EDB6A7E347E1C586BF8F6300AD4BF; SizeAsReceived:7565; Count:47 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: Content-Transfer-Encoding: quoted-printable 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 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 (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @outlook.com) Content-Type: text/plain; charset="utf-8" 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/mi= nimize_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 +=3D 1 =20 =20 +def clear_bits(newtrace, outpath): + # try setting bits in operands of out/write to zero + i =3D 0 + while i < len(newtrace): + if (not newtrace[i].startswith("write ") and not + newtrace[i].startswith("out")): + i +=3D 1 + continue + # write ADDR SIZE DATA + # outx ADDR VALUE + print("\nzero setting bits: {}".format(newtrace[i])) + + prefix =3D " ".join(newtrace[i].split()[:-1]) + data =3D newtrace[i].split()[-1] + data_bin =3D bin(int(data, 16)) + data_bin_list =3D list(data_bin) + + for j in range(2, len(data_bin_list)): + prior =3D newtrace[i] + if (data_bin_list[j] =3D=3D '1'): + data_bin_list[j] =3D '0' + data_try =3D hex(int("".join(data_bin_list), 2)) + # It seems qtest only accepts padded hex-values. + if len(data_try) % 2 =3D=3D 1: + data_try =3D data_try[:2] + "0" + data_try[2:-1] + + newtrace[i] =3D "{prefix} {data_try}\n".format( + prefix=3Dprefix, + data_try=3Ddata_try) + + if not check_if_trace_crashes(newtrace, outpath): + data_bin_list[j] =3D '1' + newtrace[i] =3D prior + i +=3D 1 + + def minimize_trace(inpath, outpath): global TIMEOUT with open(inpath) as f: @@ -187,7 +223,10 @@ def minimize_trace(inpath, outpath): old_len =3D len(newtrace) remove_lines(newtrace, outpath) newtrace =3D list(filter(lambda s: s !=3D "", newtrace)) + assert(check_if_trace_crashes(newtrace, outpath)) =20 + # set bits to zero + clear_bits(newtrace, outpath) assert(check_if_trace_crashes(newtrace, outpath)) =20 =20 --=20 2.25.1 From nobody Mon Feb 9 13:30:36 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1dmarc=pass fromdomain=outlook.com); dmarc=pass(p=none dis=none) header.from=outlook.com ARC-Seal: i=2; a=rsa-sha256; t=1610346145; cv=pass; d=zohomail.com; s=zohoarc; b=dbeQKQmhezZZrwwWZZYb8VqiZjQlddrJrZXt3yaxjMu8oji6D35P1yWsP8r2q+1Lcz/2qYz9fc6eply1yGc999zqsCzMtt6NrdqSllOrlltGKNa7+wGhj2s1iDreqm3TXrUKatRT7tIZ/aTiGymL4lhRL9vFzBwVixPGsHtHfHY= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1610346145; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Gt4ZDE1o6MqlXqsPI7Z6ZyMUqy8CaNUyoKoTehZjR7U=; b=Semw7BLkPgTTwrHncKZprm6xEHV7HYTUWiu04OnbmfIAUF7+XTBZyx3luCe9qHgk/PCVoE0bUgkNS0pgWJtzQHNPraiiOyByx/oXtQQHIgkSm/N5U8Pq9CLPOwZPtXc6MCE4NTf7bPm2n5KwWTLkrjSXo+WVgRtu/G/XxhOrQGY= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1dmarc=pass fromdomain=outlook.com); dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1610346145606722.9689210014402; Sun, 10 Jan 2021 22:22:25 -0800 (PST) Received: from localhost ([::1]:44120 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kyqau-0001hZ-CP for importer@patchew.org; Mon, 11 Jan 2021 01:22:24 -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 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 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 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 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== X-IncomingTopHeaderMarker: OriginalChecksum:38E3E9DDECA07F4849FF7EB97D5AF746305AD67177BA1F7CA52394682C776265; UpperCasedChecksum:39F9B02A09D1451E0D20A02DED2978FCBE158C052906D2ADE445B9AEEBE011F5; SizeAsReceived:7568; Count:47 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: Content-Transfer-Encoding: quoted-printable 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 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 (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @outlook.com) Content-Type: text/plain; charset="utf-8" -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/mi= nimize_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 =3D None TIMEOUT =3D 5 CRASH_TOKEN =3D None =20 +# Minimization levels +M1 =3D False # try removing IO commands iteratively +M2 =3D False # try setting bits in operand of write/out to zero + write_suffix_lookup =3D {"b": (1, "B"), "w": (2, "H"), "l": (4, "L"), @@ -23,10 +27,20 @@ write_suffix_lookup =3D {"b": (1, "B"), =20 def usage(): sys.exit("""\ -Usage: QEMU_PATH=3D"/path/to/qemu" QEMU_ARGS=3D"args" {} input_trace outpu= t_trace +Usage: + +QEMU_PATH=3D"/path/to/qemu" QEMU_ARGS=3D"args" {} [Options] input_trace ou= tput_trace + By default, will try to use the second-to-last line in the output to ident= ify whether the crash occred. Optionally, manually set a string that idenitife= s the crash by setting CRASH_TOKEN=3D + +Options: + +-M1: enable a loop around the remove minimizer, which may help decrease so= me + timing dependant instructions. Off by default. +-M2: try setting bits in operand of write/out to zero. Off by default. + """.format((sys.argv[0]))) =20 deduplication_note =3D """\n\ @@ -216,24 +230,32 @@ def minimize_trace(inpath, outpath): print("Setting the timeout for {} seconds".format(TIMEOUT)) =20 newtrace =3D trace[:] + global M1, M2 =20 # remove lines old_len =3D len(newtrace) + 1 while(old_len > len(newtrace)): old_len =3D len(newtrace) + print("trace lenth =3D ", old_len) remove_lines(newtrace, outpath) + if not M1 and not M2: + break newtrace =3D list(filter(lambda s: s !=3D "", newtrace)) assert(check_if_trace_crashes(newtrace, outpath)) =20 # set bits to zero - clear_bits(newtrace, outpath) + if M2: + clear_bits(newtrace, outpath) assert(check_if_trace_crashes(newtrace, outpath)) =20 =20 if __name__ =3D=3D '__main__': if len(sys.argv) < 3: usage() - + if "-M1" in sys.argv: + M1 =3D True + if "-M2" in sys.argv: + M2 =3D True QEMU_PATH =3D os.getenv("QEMU_PATH") QEMU_ARGS =3D os.getenv("QEMU_ARGS") if QEMU_PATH is None or QEMU_ARGS is None: @@ -242,4 +264,4 @@ if __name__ =3D=3D '__main__': # QEMU_ARGS +=3D " -accel qtest" CRASH_TOKEN =3D os.getenv("CRASH_TOKEN") QEMU_ARGS +=3D " -qtest stdio -monitor none -serial none " - minimize_trace(sys.argv[1], sys.argv[2]) + minimize_trace(sys.argv[-2], sys.argv[-1]) --=20 2.25.1 From nobody Mon Feb 9 13:30:36 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1dmarc=pass fromdomain=outlook.com); dmarc=pass(p=none dis=none) header.from=outlook.com ARC-Seal: i=2; a=rsa-sha256; t=1610346299; cv=pass; d=zohomail.com; s=zohoarc; b=SovLrSECOQwhq3pFH5Foks5kYvZz6fiOH2vSw1a2tDqqT4s6k83BBj8MVZMo+lRpuJWUk7Z4S1NxeLTT4/z1JEWc2HiYaHTlaLygLgNBkJ1TtDoZVVBR0QCEwaP2yyoZ/UZVQachFQt5Q1oSBlyOp7lehIY249qMhak1UYGdzXk= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1610346299; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=fS0+t4hYQWLGjfoiqhvDFCY7YsB/eIXiuIW9ZbNHtdE=; b=g28CIpzi0/xXlE7zTJWyzuYNyoKpqbzTDaEo41DUi6zGPP9Jvx1A24aRCa+PIPFXcDl6DDTnmJ4no+6aqkR30jqCwATB0tcG+TZy6DSC84LR1AfmwaCSdun/9fukVVtKkMCQKMxPG0Vgi1tT6NPSkQWpXuOnxwqssK735IFy1uU= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1dmarc=pass fromdomain=outlook.com); dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1610346299787981.9574044630325; Sun, 10 Jan 2021 22:24:59 -0800 (PST) Received: from localhost ([::1]:46408 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kyqdO-0002pe-KK for importer@patchew.org; Mon, 11 Jan 2021 01:24:58 -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 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 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 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 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== X-IncomingTopHeaderMarker: OriginalChecksum:746784368A5719B3842499C7715DD86DDE6996F6E4667123CCCED8223A03AD1D; UpperCasedChecksum:A161244E2BA9FFE8E21EE5992DA389125444895D82C4010C7649D6A3C1400378; SizeAsReceived:7555; Count:47 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: Content-Transfer-Encoding: quoted-printable 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 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 (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @outlook.com) Content-Type: text/plain; charset="utf-8" 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/mi= nimize_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 =20 =20 +# 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 =3D 3 # > 2 + if i <=3D(HINT_LEN-1): + return None + + #find previous continuous write traces + k =3D 0 + l =3D i-1 + writes =3D [] + while (k !=3D HINT_LEN and l >=3D 0): + if newtrace[l].startswith("write "): + writes.append(newtrace[l]) + k +=3D 1 + l -=3D 1 + elif newtrace[l] =3D=3D "": + l -=3D 1 + else: + return None + if k !=3D HINT_LEN: + return None + + length =3D int(writes[0].split()[2], 16) + for j in range(1, HINT_LEN): + if length !=3D int(writes[j].split()[2], 16): + return None + + step =3D int(writes[0].split()[1], 16) - int(writes[1].split()[1], 16) + for j in range(1, HINT_LEN-1): + if step !=3D 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 =3D 1 i =3D 0 @@ -151,6 +188,25 @@ def remove_lines(newtrace, outpath): length =3D int(newtrace[i].split()[2], 16) data =3D newtrace[i].split()[3][2:] if length > 1: + + # Can we get a hint from previous writes? + hint =3D split_write_hint(newtrace, i) + if hint is not None: + hint_addr =3D hint[0] + hint_len =3D hint[1] + if hint_addr >=3D addr and hint_addr+hint_len <=3D add= r+length: + newtrace[i] =3D "write {addr} {size} 0x{data}\n".f= ormat( + addr=3Dhex(hint_addr), + size=3Dhex(hint_len), + data=3Ddata[(hint_addr-addr)*2:\ + (hint_addr-addr)*2+hint_len*2]) + if check_if_trace_crashes(newtrace, outpath): + # next round + i +=3D 1 + continue + newtrace[i] =3D prior[0] + + # Try splitting it using a binary approach leftlength =3D int(length/2) rightlength =3D length - leftlength newtrace.insert(i+1, "") --=20 2.25.1