From patchwork Sun Jan 10 13:19:31 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qiuhao Li X-Patchwork-Id: 12009115 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, 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 6F201C433DB for ; Sun, 10 Jan 2021 13:24:29 +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 B60AE2247F for ; Sun, 10 Jan 2021 13:24:28 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B60AE2247F 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]:58514 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kyahn-0007Do-JS for qemu-devel@archiver.kernel.org; Sun, 10 Jan 2021 08:24:27 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:57110) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kyae4-0005Ik-60 for qemu-devel@nongnu.org; Sun, 10 Jan 2021 08:20:36 -0500 Received: from mail-hk2apc01olkn0815.outbound.protection.outlook.com ([2a01:111:f400:febc::815]:19200 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 1kyads-0003yV-5A for qemu-devel@nongnu.org; Sun, 10 Jan 2021 08:20:35 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=bMP9UnB54XBpQRxxbAnxDB3/fIjSmXNNjm736ULT3yn+kPIfiTPPquJAtzGpEUrW/XgWV0QrqUBmXqbQeRz25bM3A2FKLy729kJQMDnS0274N7W08bg7tW+pAy805SVbadxcA2P1pnWgbuK0RtnBDX7MoUa36Nk2PRWykYWdxulkyJa33Bodmnn73FhujuGth2TBeA3mVnvVHzKfmdoyRNZBsQx77S/BLFDJvU8QRvoZF9/8N9CAktvZv3pqUN79bmOUTR3b/j5GoAtwuiU84Jk2iQY+lX3zxc1N5CGWLL7gIjVAM8fJvWIfW9DqrJXAw97RwxE8cDZu12dg3VU/ng== 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=KmWPhbr2A9dl2tv4GeP7FLGqD6awY6aDQw3lPLYbZQ4=; b=LNgolhePPzUzwODIw1QKNenMSURbdkW5fgaGSTQpNr32rTmWg/jotG2B8cQ5xYFfM/sFTayH816rDNAGf1PY5y332leEhcEM+5wLTe5nxa9vwsHykdlZpk+RR6WlNHaHIP4mvLMisHfv95CkhpBeEP0O7gIxqpubhd0KCru5Fm3HJxqaqIXV/CkUJ7INNmqy0OoGSTwAsMwF/tKm70p80cUktDfaNFvnn4zvE+CRq6tUjWaavCCFLR1LwFlJ3y2FpQQ6oD14kQa7yUXMYEZD2tCKAYDOuAlt3mKN/WwwSl8nUIAYbOxKkmrODpZ/oPmvQxUnN+JAnWditrJTDBc9IQ== 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=KmWPhbr2A9dl2tv4GeP7FLGqD6awY6aDQw3lPLYbZQ4=; b=mTT6Nz6O+wcKcFYu6m9WpMnmmzjWgerjJz62zuzY/JIJbEtSONo7iKqKU4fD4EKoNnyQ2DgHOaquM5wS6Xzx/j2pTZgLCrnV10hcazIVP2T04Skr2FztkzpeCr3kaTcHBijU2tobOpMKcZ08KTSlsfbfB6hrV7k5/ACe0PJ3skeB8VrOBxNmqAoVZPNH/pQHux+3ek6H3XYc5T2U0LT+ej7iHAjNOOXg+yV7g8vvJJ38CsBdvDcIEn35rrQIILhtCGhvXRjBqGN4aBBmFpNz6uYfXsWSEkdtWVyjdz3FfNHmCe+P62kHbbhVbTVXShX+6JaKAwcLkE9OP6BGTB5mhA== Received: from HK2APC01FT060.eop-APC01.prod.protection.outlook.com (2a01:111:e400:7ebc::4b) by HK2APC01HT169.eop-APC01.prod.protection.outlook.com (2a01:111:e400:7ebc::236) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3742.6; Sun, 10 Jan 2021 13:20:05 +0000 Received: from SYCPR01MB3502.ausprd01.prod.outlook.com (2a01:111:e400:7ebc::52) by HK2APC01FT060.mail.protection.outlook.com (2a01:111:e400:7ebc::416) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3742.6 via Frontend Transport; Sun, 10 Jan 2021 13:20:05 +0000 X-IncomingTopHeaderMarker: OriginalChecksum:99FB900A1C812FB8579F4230941B2D298C7708A999C9C8CD06A8247DC8A263AD; UpperCasedChecksum:9ADB6431074DEE33C95054EBBFB2512C2F811359CED5633F27E476DD21438A18; SizeAsReceived:7547; 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.011; Sun, 10 Jan 2021 13:20:04 +0000 From: Qiuhao Li To: alxndr@bu.edu, qemu-devel@nongnu.org Subject: [PATCH v7 1/7] fuzz: accelerate non-crash detection Date: Sun, 10 Jan 2021 21:19:31 +0800 Message-ID: X-Mailer: git-send-email 2.25.1 In-Reply-To: References: X-TMN: [76+PZH3vo3KYpSfeX/yVHSbQiOQ/QaWY] X-ClientProxiedBy: HK2PR0302CA0021.apcprd03.prod.outlook.com (2603:1096:202::31) To SYCPR01MB3502.ausprd01.prod.outlook.com (2603:10c6:10:3e::12) X-Microsoft-Original-Message-ID: <20210110131937.98351-1-Qiuhao.Li@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from XPS-13-9360 (111.176.239.56) by HK2PR0302CA0021.apcprd03.prod.outlook.com (2603:1096:202::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3763.6 via Frontend Transport; Sun, 10 Jan 2021 13:20:03 +0000 X-MS-PublicTrafficType: Email X-IncomingHeaderCount: 47 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-Correlation-Id: d598e955-4d0e-43ff-8863-08d8b56a7131 X-MS-Exchange-SLBlob-MailProps: pt8ZUcDWjMUUvYT8pgQ1QLOhg7myynsEZETeCxjQbBxAWUTyac2rXdL4bbwnboEjSeIFbHUZREvgqZT75ILjQiHoVwZZdrcOj5SGbKnB1Ddk8WQRN1vAc4gEx3noBN4DM3VSvJ9tin14PsfWXF2AdsJdOJNYFrGLUfCxjLUvohWs8UK/W+TgWCaOSND5DhyXU5cLEExUHz9BzA2PqVu82iwblzDBS2CYkuhcX+iS7nlsK4ny4Ss/bEyQA8jvwJtU2TMBaFNfc4RLberMyeIZgQsyoN8tsHVVdYG/IgkWjyBdYeWqv8/JcPG4EyQLdFnALLS8MiUAiN6rU9asgGoJfB8gE6z7pFSYsJjLMvqCgwkqF9LUNq2Gp4RCK2rytJTTokEs/oN3Y2kDSkRU06SIQQk7hTudkDjGgKfcb0p+7ykWGLJXxeNS0pTE5oBihycU+Qz/BeNGQI00WFYN6PVhiblWvIGRgk5afTcj9Ayv4T3jI2ghWTlsyKbwsXl5LqAg0VTzJQQmNRNtliu5WDWu+Lmub8na6JAH3LELgQZNLJQsEtyIJjDswmtSNZH/PyfzKMtV1YivosiNn0pcol8MvbnvsJAbnGRdyPwh4QMjiNOfOAaQt7Hwj/bKMoQxocIIoOQWrWMoIo0ErY7wVJn891JYVgliv4rdFuybqZGlKfs4EoqCey6QAChKeOchiN+h/dv3ivxNb14qkMaCntDOk8+bgFXn3xDNlnKOHvrQEFz5vA5/7lGALqoHXd+aNSH+7TIsz4LRvbOZKg8AJ08/mwiLBAfzmgCGAQrAmSwhZ25/RbfnWV7jdlf3maWmo5mi9tA3C3rtwe2VT0Tu4STqpehpQWCzkoDRr4+fLqPTqgZVzrhlZ/BT+X5p4teOsw9NrDbJUDOVQAJBQ7XO/ETfxi9Pp6OmRy5D/4HvZpL/H5zKgCf3nzd4ZPclPhziydBq X-MS-TrafficTypeDiagnostic: HK2APC01HT169: X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: W/BqvPoYsSKhnJCAYQ6OOMrmFf43h9a70q7i2+EL3Org+lDK8hxQNGKd6KNeLY7Lov8cORyrD0RCFCmSW6+oJCpRNTpFgAkW5nXrPuOoB2Mim9VZtmU2/lGJ42INOhMFPT4Ck47kr6OpAOHH3a7OfUwugxPFfCOl2fj7Pe710rjHlHJHPHQL1VD6bQyDXTusYmRsKrKbhcFKrye+lqCs9hm+IHlXaW+luIPokaDAF1Zk8ZmUuS5ckZRDgY4zhFk+OBlqzUwI2rX98bazbfit7PC/fe8XDa0e3D5joNfL5nQ= X-MS-Exchange-AntiSpam-MessageData: qdvQRUFphQiJ4aNuTgctTr0Ob+jVmNQAliEJ7vp5Qc6oLH/HLDwJbi187NG9SWREtubbzeALsTLddXBEruBPfFYoS3adEohI/zxt4dP9m9ahw4dzdYIiji8IlCh0dpBpcGHoQC7pFNRZG3ZPGu7RDg== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Jan 2021 13:20:04.1948 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-Network-Message-Id: d598e955-4d0e-43ff-8863-08d8b56a7131 X-MS-Exchange-CrossTenant-AuthSource: HK2APC01FT060.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: HK2APC01HT169 Received-SPF: pass client-ip=2a01:111:f400:febc::815; 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, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: thuth@redhat.com, Qiuhao Li , darren.kenny@oracle.com, bsd@redhat.com, stefanha@redhat.com, pbonzini@redhat.com Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" 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 --- scripts/oss-fuzz/minimize_qtest_trace.py | 43 +++++++++++++++++------- 1 file changed, 31 insertions(+), 12 deletions(-) diff --git a/scripts/oss-fuzz/minimize_qtest_trace.py b/scripts/oss-fuzz/minimize_qtest_trace.py index 5e405a0d5f..97f1201747 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,32 @@ 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, b''): + if "CLOSED" in line: + return False + if CRASH_TOKEN in line: + return True + # We reach the end of stdout and there is no "CLOSED" or CRASH_TOKEN + # Usually this is caused by a different type of crash + if line == "": + return False + + return False def minimize_trace(inpath, outpath): @@ -66,7 +86,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 Sun Jan 10 13:19:32 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qiuhao Li X-Patchwork-Id: 12009117 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, 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 19F5FC433E6 for ; Sun, 10 Jan 2021 13:24:30 +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 A14B72247F for ; Sun, 10 Jan 2021 13:24:29 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A14B72247F 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]:58568 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kyaho-0007Ey-Gz for qemu-devel@archiver.kernel.org; Sun, 10 Jan 2021 08:24:28 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:57102) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kyae4-0005If-63 for qemu-devel@nongnu.org; Sun, 10 Jan 2021 08:20:36 -0500 Received: from mail-oln040092255108.outbound.protection.outlook.com ([40.92.255.108]:6040 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 1kyads-0003z0-7r for qemu-devel@nongnu.org; Sun, 10 Jan 2021 08:20:30 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=BEghSTVX3UCLcv1z6YdfPSxng8nkRMqbyzwrwKD8y5C6ofvcPRJUqc4ebBr+RKCBzCY02V/I/kgxFrkwajLq9czeBsq/ZkXf9pXMkWZRKlTkZhavdbnOxqbwqoFP2dZvRxpI6LV7fbLN1yUEbkrKlDO9gShaK4Qk5AMmdVu4V0FZBkVyI8xihbQxkLKAA4cHBC7+3sCWDdTRG6bJB8Ws6ZmmaUrB0Cb7bfzrm/+U2ElI7PlWPSriruh6rpb4jjKeHmBlpbIwN1AxWMVHe/bTqRjJMda4Z18Cf9N7LPVE7ji06LJe8BSJm5lynQF6J/34crqRbJ0k9lX0XbGcrwpYhA== 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=WWCQvrwHfs4UukNcMgmmi3IVA4aqGwZRoCNmGbLm05s=; b=I5yYlCiXgN9/ii/aPtmqBqwncJS2PeI51n3P7vfIxUGl08dPWR4Dj2wcYeBHbpcKUyrrHeoiqOeb/HuddWUOu8UZWCoOKaYEzv2+ZTyofp0oeVuuNMYk1aiBjZV8FZ7cZzq38M8Mye8CBaDpa4XKYRcYGe91UbbzWFIq/LFTlDzEUz4ERDZs+kOd3NLJN3GAL6AcfcERrbW9C8mQ42o1WZQdEcSchRQEc73YKDgHLhoqK0pTpvd4KRdJNpn9q3hOeHa+LoMMQg0xDqPjSJFqbqE9KC3o/WVUUHrspbWkDGjYZqeumXNCzu8HHjKGWIjMAQs/FSGuwWc1gidwY0GAjQ== 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=WWCQvrwHfs4UukNcMgmmi3IVA4aqGwZRoCNmGbLm05s=; b=o3ISO97CuIv2MxhK0V9t+rYtkCxr3FRZYf5maFe7AEHzr5OkBMFBue3o/XWhb/d0MnoWokBZM7bk/LE1hzinhRo0zBIwPvpOlTLbdxQGCcwq7vLumocmv9mBAql3w/JvxRVZBi2E19tLYk35nBN4n8IwWikAKo8E5D2L0Ehss8yDKGB0GKV8oTbRj7kt5d3udwML461++rAx4UwSMZd1jqjx070G8wQESZePV2zAAXEOKFsLriHyh2ex7gUczM8DoJfZ/HkPgkwbIEg8ZSziPAk+1poj8+q4kn16GvVcbfnkTX2I+1UBrIkn3T8T+3wU829EhNgSqKOQPGc7ELv56Q== Received: from HK2APC01FT060.eop-APC01.prod.protection.outlook.com (2a01:111:e400:7ebc::51) by HK2APC01HT219.eop-APC01.prod.protection.outlook.com (2a01:111:e400:7ebc::411) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3742.6; Sun, 10 Jan 2021 13:20:13 +0000 Received: from SYCPR01MB3502.ausprd01.prod.outlook.com (2a01:111:e400:7ebc::52) by HK2APC01FT060.mail.protection.outlook.com (2a01:111:e400:7ebc::416) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3742.6 via Frontend Transport; Sun, 10 Jan 2021 13:20:13 +0000 X-IncomingTopHeaderMarker: OriginalChecksum:C86F4672FA4C2C8B59CF6ED2E9D7E3B1742A114474E048D42D89749EAD9AF374; UpperCasedChecksum:7F52FC36AD75B3F7F5ED8AAFBC062CD0ECEE36C4EF78C13B8DC738251B2C457D; SizeAsReceived:7561; 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.011; Sun, 10 Jan 2021 13:20:12 +0000 From: Qiuhao Li To: alxndr@bu.edu, qemu-devel@nongnu.org Subject: [PATCH v7 2/7] fuzz: double the IOs to remove for every loop Date: Sun, 10 Jan 2021 21:19:32 +0800 Message-ID: X-Mailer: git-send-email 2.25.1 In-Reply-To: References: X-TMN: [ZNfcQsGweh7wxFQibmTtP8yLuKVsafu+] X-ClientProxiedBy: HK2P15301CA0017.APCP153.PROD.OUTLOOK.COM (2603:1096:202:1::27) To SYCPR01MB3502.ausprd01.prod.outlook.com (2603:10c6:10:3e::12) X-Microsoft-Original-Message-ID: <20210110131937.98351-2-Qiuhao.Li@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from XPS-13-9360 (111.176.239.56) by HK2P15301CA0017.APCP153.PROD.OUTLOOK.COM (2603:1096:202:1::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3784.0 via Frontend Transport; Sun, 10 Jan 2021 13:20:12 +0000 X-MS-PublicTrafficType: Email X-IncomingHeaderCount: 47 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-Correlation-Id: 3b1b3d7a-fd13-407a-3ece-08d8b56a765d X-MS-Exchange-SLBlob-MailProps: KE5ywuOaN5idtt69Y1RXkPvCFgonS6VzPC0kkpEdaJ7Q5TY8I4NGmRongek21SDp/LMIEhbLh1MuI8tHwIVGqItjLUb4gbebUIQCektAefYlIrvyFL2Xr7YKUTtdRkIlYw1b6x2lv4JhLXXsIEu4vS9wdbZy0dPTIhKr4C07bcKkGSqBwuPDei1BxLq/ff+01XCFa1Vm8QxTFQX6sLZGgflGjnLhxLx/moVkKEs4Atgl7axG7uBlwc4Y5PF43WQcPhlAxedqZoimHU6OjDHbBa0vewK99A5yPqunvNFIldXOYCDrswQjwDQKlfvOx7cvTyTA7DX78YeqlLRG4X4+s4CDNZrrrSe39V3YAWNYbuYxyHjQoOoV9R6yL9GXer9voVbPUODkq12xgkgV2ufpv9Nkdro+fnQPbKYb+KNjFF6lD0WLDppNk86+e7EMcX1lbgkYpcTjipSKKTmJHL9/dbIu57i41jxY18dUbUJklTLq/SIuyFgFjFIBPN1ycrpL+mGVzjANEOKkA88/Of8i81BvXTaoqs2RCjFO6R8pMZ0UHOCSaAfJlXl3ovQttEa8v+8Ow9jM7gjRlZHGJe3Q3jUmwO+h9gB7tiEFtQdvumE342dRJ3Jnj5XcRqsfGpaluwCOhPnfDNs4+yUm4ZzPGUFL/zKXYM4Rad6XVYqIkpwglAHA4URlM6BLuQ93ndfy87SqVt4hftB0hpalmqIEpdrdXYpyjJnvXhvpwqnDSLzSfWKkYfVOBkLHmUvwj33HfH9QyBdP3hhb7Rkpp830rl4GdcOnw6J1OnZdf4hjR/bcBnpdTXq5NcK+8tRvqOn1m2s7j7HcoLwY+Iw4xmuVR4afNFvQ5Xj1MScxxf02v7cfwS0y6S8euwgu8/0iiAzS8AutqyrTTlffeHJXT9hCwvgWo1YnCB4NBETxLKpw1hOwn0hvVsqd0SnzNZdBkq5KhfkU1qPkri4WV0v0S7baIozuCHD79LMt X-MS-TrafficTypeDiagnostic: HK2APC01HT219: X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: VWy5J1ranwWOeZnAI39FGsedg0DZzb7DyF3/IbGf0MxCjZtFwEDeIekDDFv3MZaX5DEdCUJpAuSWnn+CgU+iuzlWoCwRKKCj0ubBJc1vPi6JvEGBXhb7D468zZu1aTReF/FLmpsTYOOsp/KzwajUeT3wOu4E6XFByCdLMm+9FNqedcJxt4s1laUz7Z7HASC+xHMH1o8Wzt/8V3BvvMsgim3SFKyk6jocN/DXpiH8XUmDKtkSlQ4c6qcwMSw05VMqZ9FHqVjLvXAXTB84IMCiROYV1svsUHqtwIQ19s+V6CI= X-MS-Exchange-AntiSpam-MessageData: /lDsbbySKQJ3yZZqGfCKHlZeoGX6f2+yAUtsyasydGeEbFP+gOOuKYhASXdUuL/IsY5sdDSOc+ZIn4jrIPIdIjX/BRFMWqJtHTGvXgK8ETRwtQUgntFTAyJM0NqwgRBh6pxujBxhkr+KvyhK9EWiog== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Jan 2021 13:20:12.9198 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-Network-Message-Id: 3b1b3d7a-fd13-407a-3ece-08d8b56a765d X-MS-Exchange-CrossTenant-AuthSource: HK2APC01FT060.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: HK2APC01HT219 Received-SPF: pass client-ip=40.92.255.108; envelope-from=Qiuhao.Li@outlook.com; helo=APC01-HK2-obe.outbound.protection.outlook.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: thuth@redhat.com, Qiuhao Li , darren.kenny@oracle.com, bsd@redhat.com, stefanha@redhat.com, pbonzini@redhat.com Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" 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 97f1201747..3c11db4b8a 100755 --- a/scripts/oss-fuzz/minimize_qtest_trace.py +++ b/scripts/oss-fuzz/minimize_qtest_trace.py @@ -89,19 +89,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) @@ -122,7 +131,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 @@ -155,7 +164,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 Sun Jan 10 13:19:33 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qiuhao Li X-Patchwork-Id: 12009125 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, 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 6E528C433DB for ; Sun, 10 Jan 2021 13:33:09 +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 B86A4206E9 for ; Sun, 10 Jan 2021 13:33:08 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B86A4206E9 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]:44170 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kyaqB-0005Kv-R9 for qemu-devel@archiver.kernel.org; Sun, 10 Jan 2021 08:33:07 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:57156) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kyae7-0005JM-KL for qemu-devel@nongnu.org; Sun, 10 Jan 2021 08:20:39 -0500 Received: from mail-hk2apc01olkn0815.outbound.protection.outlook.com ([2a01:111:f400:febc::815]:19200 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 1kyae5-0003yV-BZ for qemu-devel@nongnu.org; Sun, 10 Jan 2021 08:20:39 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=n9KrEkgkhWQFy+WQoRdvWtCpJVare/oR43BVDq3HusdZ/6gvbtnhYGV8nA6rIL6V//xOSRatfFUaRxvxrChTWe00VEWG82NYoLXPIhCG//whiuCJUxU1Z1kyYzcizosyWnqcg2TRoevsUGIR/9IkkT/rX1ulI3CurFYGFs1WWkszu3h2GfW4A0U0fUY0nFyIz7XhjH85tJVS1Gz1r1lFvAKGRl+QmE43zJ5Xo1k5IkDv0Bh/wtY+zNFV+JJ0z3gHEpQAybb3qt6UUaFVBa45HXE4Y+7i4BPU4FyBWmrQSfQD2hG4CA4UECOFX60NObyKuMgf2qFqa1UUeKFU2cPQuw== 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=ARgnu0gW2qtYaEL0fn7nj0CwiHsnY/V7KV5fmDEbdb8=; b=YL0ec9wtlUWi312BKF1BoyKhAcziv0vByhUcqVuHF+gHhFNgFb74gJRYrgVniZMe4VcWm+BpaaZCuY5FiKJOkXQScO2Z+YG3DndiHgBG6GBdsWpwA0KUPZhVP4rhn/EKM2nW5CSfSWWa25XrnLvo2wPrMWa2XnZohvhk0ADrRnk+xyIf3QCnBK5m6LATCmOT2cJLsPJW2AAws4fmiIpdPK8S45b6zAz89xzMGeGvFDypGWr8jvRbRfSyTQsz8F+RR9DsOwzOzSQojLT/xeMDanfYOr1MLyBhp6W+QLvMISyF50sVfWEzjkMRKzGpH6pEegc8VWuwX0jMscVumMIsCw== 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=ARgnu0gW2qtYaEL0fn7nj0CwiHsnY/V7KV5fmDEbdb8=; b=mUh5AXN55j5M4mcQ+c10nFWNPq6fR/r3Y5migmmAmanMYO/j7mM3EYAFMdEIEmBZHsx56DUpNZAw+n5+O/x4kuBYeqcGwXDV8mRpNyzg0WqjtbHtSQzmvLqWUE/UavR0SWf4NwE/MrozRmvytyS7haXxsdgEsgcp9La6CN9U8/H2kSNwQhcl7A1GD1vyq9ojT5QNP4qR6UeYn8mf0nLGyiDDZ36lD+pgNqyNhRJP5Axz/R8HWSBsw3tsZX1pSDvK98cRLAIfYskxe6udBQilXj72p8pA4+mXWmuRbE6N2V8OZmfB7oZsn2iSA7FPFfTFrjRgUCA55W9WBZor8FBHaQ== Received: from HK2APC01FT060.eop-APC01.prod.protection.outlook.com (2a01:111:e400:7ebc::4b) by HK2APC01HT169.eop-APC01.prod.protection.outlook.com (2a01:111:e400:7ebc::236) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3742.6; Sun, 10 Jan 2021 13:20:18 +0000 Received: from SYCPR01MB3502.ausprd01.prod.outlook.com (2a01:111:e400:7ebc::52) by HK2APC01FT060.mail.protection.outlook.com (2a01:111:e400:7ebc::416) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3742.6 via Frontend Transport; Sun, 10 Jan 2021 13:20:17 +0000 X-IncomingTopHeaderMarker: OriginalChecksum:2DECC59FFBFA58AF5B7546919E066092F38921EAB7CDC2FB0E6B974685087C51; UpperCasedChecksum:7A981745749DE3118E33A991E5F40E8F18BA05CFF2348EA560FD34545B650A4A; SizeAsReceived:7584; 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.011; Sun, 10 Jan 2021 13:20:17 +0000 From: Qiuhao Li To: alxndr@bu.edu, qemu-devel@nongnu.org Subject: [PATCH v7 3/7] fuzz: split write operand using binary approach Date: Sun, 10 Jan 2021 21:19:33 +0800 Message-ID: X-Mailer: git-send-email 2.25.1 In-Reply-To: References: X-TMN: [BMKMREuUyEsTwTS70U2W/iqFuur2s7Bd] X-ClientProxiedBy: HK2PR04CA0061.apcprd04.prod.outlook.com (2603:1096:202:14::29) To SYCPR01MB3502.ausprd01.prod.outlook.com (2603:10c6:10:3e::12) X-Microsoft-Original-Message-ID: <20210110131937.98351-3-Qiuhao.Li@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from XPS-13-9360 (111.176.239.56) by HK2PR04CA0061.apcprd04.prod.outlook.com (2603:1096:202:14::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3742.6 via Frontend Transport; Sun, 10 Jan 2021 13:20:17 +0000 X-MS-PublicTrafficType: Email X-IncomingHeaderCount: 47 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-Correlation-Id: bd4a8bc7-2dd7-4048-cadd-08d8b56a7941 X-MS-Exchange-SLBlob-MailProps: gjx25WM8ZNWt8qMG3IjM1nlahHjQ+yeyZi0K9+WSlJp1Kmxz/ypV8F5I3pAbvBgO3bcOQMaN1VjHNdD8OWD8supT+3iOD+PouKBaY9kcxUcGa/ZmCBOATTsA5NjErpYLkCRTxG8WVV2Cm7ENzoGD239FJ0tsSQmvkeH792eDFiPfBjnkeZErNAQ9YPFjtmwt9UTZqMR5SwMAXK7HFqh+pB4mBRWOTqB3pvZoxBRBbXEGZ5/+MrpZzEPAqFw0B0voWe8I6UYcgYLLMz5n3JBCaertWHcNTqt5EFmvxIdgtOXtsXhrcAyoJUBREwkmMM2PYDRe0YVaYJP3z3B+xGOzby7JwiHOn5oezP+cKVBi6OS0+oMKh6aQSdH5Sd9GzCF9S/woZjvq4EmYg3bQWClYs5Lyf4REkSCqMFBj6MWTh0B/eoLt1khgCC73kroe09jPQByQ6tVZemBOn5N9LHI5Ue08zglyjfO2VwmXM19Npc87sx0R2Lp+0228C20iJHMCfgJxBuPPxCLxgRDcNCq1rxtJaQU2Ojp8Rn/VWzWAB2cm/Bh4qZlmRS/suJThjYg2wXEIOXl95jMkHJSakXUiuhsKtiY01aNOVu2ekiC9NazTDSIHQBaij1zJ1szH/EneI6+xxYFjb7rKPYTtkwCo87NTWzFJtC8aOTVfPJxwb6K0Rv1XntP7BCdmFW46EKIyBc/zt1EZ+s8dYh9zYyfPoI94l2oj21tOFgW7Chry8QE= X-MS-TrafficTypeDiagnostic: HK2APC01HT169: X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: F4LdL1k38wyGTyMT4a2fX4Xi3RNlOu2f/w5FS2m73mTFyqpgaWSfoMz9N504o6l/MEbGE2fLJJuIkREYuwYzKcHxxEqcWoVMot+EkX/TA/wZBMng8qLUH0hhmrv2qb0VGCM1yVdG33d9CU68xXF7UrFBY6NYoCCtIyQm38snoz2KXtD3Bhj7j+GzXcpmUo05/8stMiZqqcR7JVYjFKACnynwNdVbQK1SyWW3q6RgibhgYqGdavz3ORz63+rDHOqP X-MS-Exchange-AntiSpam-MessageData: Te+OdJL4R2W2T8k2D8ZTux73OHvhkVpInyimKLS4FhM3ZGbl27Rv9Tc+mXYcKQDTI9LhHOBfR+s96k4cB/nIrYHwtbUJX61UQKQCcTanYPWn/7HA1jdgQrWa+59FZU/2IhEY6WJfnwGuyV2dT0KWQA== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Jan 2021 13:20:17.7711 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-Network-Message-Id: bd4a8bc7-2dd7-4048-cadd-08d8b56a7941 X-MS-Exchange-CrossTenant-AuthSource: HK2APC01FT060.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: HK2APC01HT169 Received-SPF: pass client-ip=2a01:111:f400:febc::815; 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, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: thuth@redhat.com, Qiuhao Li , darren.kenny@oracle.com, bsd@redhat.com, stefanha@redhat.com, pbonzini@redhat.com Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" 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 3c11db4b8a..319f4c02d0 100755 --- a/scripts/oss-fuzz/minimize_qtest_trace.py +++ b/scripts/oss-fuzz/minimize_qtest_trace.py @@ -98,7 +98,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 @@ -111,9 +111,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] @@ -134,11 +136,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) @@ -147,6 +153,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), @@ -158,9 +165,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 Sun Jan 10 13:19:34 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qiuhao Li X-Patchwork-Id: 12009123 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, 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 3B511C433E0 for ; Sun, 10 Jan 2021 13:28:41 +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 A5284224D3 for ; Sun, 10 Jan 2021 13:28:40 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A5284224D3 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]:38276 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kyalj-0002TJ-8u for qemu-devel@archiver.kernel.org; Sun, 10 Jan 2021 08:28:36 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:57142) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kyae5-0005JA-RR for qemu-devel@nongnu.org; Sun, 10 Jan 2021 08:20:37 -0500 Received: from mail-oln040092254093.outbound.protection.outlook.com ([40.92.254.93]:25836 helo=APC01-PU1-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 1kyady-00045L-Mo for qemu-devel@nongnu.org; Sun, 10 Jan 2021 08:20:37 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=HZK2hEr1ffldQaXWLYtIuPExbg4wHD9edggGJp9TAN7RXz72tgD7Pg+64KFT+C4ZxLtJHrC6qDF1fAdznDFLM8Nf6WdkxfH1ASXjMkmzC8zKng75bcZOP27W4wUW956StBZA1bjlpkkKsd/XMyezVPehknkGjcvboQhaU7VDXRLbFPkaKRv/serNXuzG8SuxrvyEUlmmJfxw6F053+F644aOg4aCmTcfs1N/9tCCQgyfBFiA1JfHpvG20ijHnwyzHtVN8yUzGnnP3Z8S0RSM4nwmJBJ7aEksyv91eQxScMyNgZPqpArbbqU+VvKZxwIH7kzsuVk6PVi/917wx0oIAA== 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=a/fmEzl5MRJz69Oqt8xtIeAA6debynlRzRD4wWQ7EvQ=; b=TZ3hMLDq99R+MoU0NCrQgqPhtnXWMepoEcbqqdADKuB24R45F+Br2z4LM5kD3kdZyEuw9/bsfFp61iu7FjSWn9Bsbgmbd4Q20hxd09hesPKeSPxeEr8yAZ1fAxjG/OMLvBju2zA0qaTWeptJTO0y9ddQrS0za9PPWKf7attExdqdM05hvCLOLz/eHOsNDImuECnktVtNXeA/UPiM9ftuQoNLmfZMYuvn0kX8wEdxGsiVoEQ8pXJchOWVsoOHHATFDT0loBXObZ5PPT2AyR+uPba1iBPCCqh0wOQcUcrudkkPQUavhp2wgb9mAScUg7zduMEf7/CbzKrvW0MayyMJBA== 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=a/fmEzl5MRJz69Oqt8xtIeAA6debynlRzRD4wWQ7EvQ=; b=gf34aCZ32eiA5wD4x+cWvGZconaNvdRMFlr7RvtolkfhqJWIVCoFX3ls+HUkrSqr7/vAgGo/0cYNHDHZXadll2saLset8+Ir9sEeIeyv1IvvI+Kb47GiQfKvQzEnrDA4uWyuBC1+ci3nvvdASgQ+1vl/ehXM6dB8Fpujuu5dDsQ2wPPn14T54mObJpXZi4dtC/38JEMej/0LDKNmEY+UlBq1+r9nAzZhD2zVVYkh66K88tiVz25qgKgt5jeuKW6CN9NfRyY4jQJzlypVGcJxFgqltkYlpbklZNgMX76lBbUyWwU7aEztxCJkI1bK08kYMoftMJ5ICtz6jpQ4SXe2sw== Received: from HK2APC01FT060.eop-APC01.prod.protection.outlook.com (2a01:111:e400:7ebc::46) by HK2APC01HT092.eop-APC01.prod.protection.outlook.com (2a01:111:e400:7ebc::382) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3742.6; Sun, 10 Jan 2021 13:20:24 +0000 Received: from SYCPR01MB3502.ausprd01.prod.outlook.com (2a01:111:e400:7ebc::52) by HK2APC01FT060.mail.protection.outlook.com (2a01:111:e400:7ebc::416) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3742.6 via Frontend Transport; Sun, 10 Jan 2021 13:20:23 +0000 X-IncomingTopHeaderMarker: OriginalChecksum:8F759C8646C72B952F79E2FE54ED85748038C2CA12C1BF1489C493BCEAC6368F; UpperCasedChecksum:09F57D5EE6BF2456CCC66EF778F1B847F048689A171689FF59A29D1FBFE27139; SizeAsReceived:7573; 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.011; Sun, 10 Jan 2021 13:20:23 +0000 From: Qiuhao Li To: alxndr@bu.edu, qemu-devel@nongnu.org Subject: [PATCH v7 4/7] fuzz: remove IO commands iteratively Date: Sun, 10 Jan 2021 21:19:34 +0800 Message-ID: X-Mailer: git-send-email 2.25.1 In-Reply-To: References: X-TMN: [qNcAFgIP5ep646nhT5IUF/wW9pMVZ3cs] X-ClientProxiedBy: HK2PR04CA0064.apcprd04.prod.outlook.com (2603:1096:202:14::32) To SYCPR01MB3502.ausprd01.prod.outlook.com (2603:10c6:10:3e::12) X-Microsoft-Original-Message-ID: <20210110131937.98351-4-Qiuhao.Li@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from XPS-13-9360 (111.176.239.56) by HK2PR04CA0064.apcprd04.prod.outlook.com (2603:1096:202:14::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3742.6 via Frontend Transport; Sun, 10 Jan 2021 13:20:23 +0000 X-MS-PublicTrafficType: Email X-IncomingHeaderCount: 47 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-Correlation-Id: c2781ace-3b52-4479-16b2-08d8b56a7cd7 X-MS-Exchange-SLBlob-MailProps: S/btQ8cKWiSygBPrM25OmO0bBkd81GAbWJADUOi50NfKRvBQZEallobRy7DwHVxRY4CzH+0EetlqsQ0griGApdJnj1vpLTz4Zp15bNNZkp9h81RHAYS38+Azd7autjNQTlPGExUndt4ocqnw6Tvpl9mjmR+XUUJS+0EMgmTjr37i8qWJfYnP1Aq7geWN4sZCl7vgS9jwYjftllsDffHJbfxA5SDc6n/4YZHMyQhpKaxv3aGCRU/8p550haWgNXINdZI2yZlkVCMpxSM/Dd4GbUS5QcXvwV0b3y83qMsdJhb+xTB3SKz0uPbSlLjqeymh87WpjD5AMZxg0CWQ+/1ftnMkGC2LPqqNszJmdN0f79Pc1C1JPwc5m9ywyRSbYZpoEBartczgYay/IsvVH38kn8tpifo3AuIpPPiFxf0NUvNE9qu+Y6NWONeQZNLv5/d+KHeZee9UD92BaqrFalgIuxxn52o8kFHrKxBhp9hDEQO/u4XZZNGszTOxLoemkOg+BNWseFbWXJrG/Ike7nvGU2SUPkmCY/U8+xGfe5QvhGAD1Mcin0M+Vvg8iSuS/f07oLdg2Xf0Ps1NM9XPfOdGyOoseabQgAr9lDodxbq3x9C78uVea+nT/2ELRgrNcr6yOmK0f1/kpLUKB3W+aNRJySO3tuyY+9RWHWa0Gi/oFzfc0i8z5q02ueAMFbh/TZ0S5udSeJgpFoToY2bTDgtBj0udvwj0bmQy0ILpDTMaH4BEStSt4vAC5fhFiYMtflvxn5W7YBloef8= X-MS-TrafficTypeDiagnostic: HK2APC01HT092: X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: wJl8KBxRq9687F1GWWRuIyCIP5wPGtPKgj0t8XHpenlpxhUnJrXJcl3ULoxJLOKqDWlyd2E/OlHLNjkXrmxPcn8ZDhGc7qaIGZ2VmOycnAV9difTTjMxYFTDylzEPlL+f4aNFVHEw6/kUBihByDxKH+TC0gsi5U3DiXhtr2nNP+WQeqbyEB5rVxc5PobDVBfDLqzUdu1xhJAlx+1/0B9O8hSPcVyJZne6hTsqN0hcwzUb6gFTI9AHhMYJqsiX+U2 X-MS-Exchange-AntiSpam-MessageData: QcNmziquf6yL2HEDe/Mn1CEieucIXLgMTpQqaM+on502/d8ouRlc7xFBV2NXZfq3+Bd/0IkzLndYOIxV3o+ANgQXz8+h/FMCC6x4T8TAVKuhsXCAy5Wm/2GUNcqkWN+CNejxsy4r7U0RUtv+/m/0iw== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Jan 2021 13:20:23.8137 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-Network-Message-Id: c2781ace-3b52-4479-16b2-08d8b56a7cd7 X-MS-Exchange-CrossTenant-AuthSource: HK2APC01FT060.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: HK2APC01HT092 Received-SPF: pass client-ip=40.92.254.93; envelope-from=Qiuhao.Li@outlook.com; helo=APC01-PU1-obe.outbound.protection.outlook.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: thuth@redhat.com, Qiuhao Li , darren.kenny@oracle.com, bsd@redhat.com, stefanha@redhat.com, pbonzini@redhat.com Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Now we use a one-time scan and remove strategy in the 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 319f4c02d0..287266fe39 100755 --- a/scripts/oss-fuzz/minimize_qtest_trace.py +++ b/scripts/oss-fuzz/minimize_qtest_trace.py @@ -75,21 +75,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. @@ -178,7 +166,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 Sun Jan 10 13:19:35 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qiuhao Li X-Patchwork-Id: 12009119 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, 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 BA745C433E0 for ; Sun, 10 Jan 2021 13:24:40 +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 566B52247F for ; Sun, 10 Jan 2021 13:24:40 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 566B52247F 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]:59778 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kyahz-0007kz-GC for qemu-devel@archiver.kernel.org; Sun, 10 Jan 2021 08:24:39 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:57172) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kyae9-0005Ky-Rs for qemu-devel@nongnu.org; Sun, 10 Jan 2021 08:20:41 -0500 Received: from mail-hk2apc01olkn0815.outbound.protection.outlook.com ([2a01:111:f400:febc::815]:19200 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 1kyae8-0003yV-4F for qemu-devel@nongnu.org; Sun, 10 Jan 2021 08:20:41 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=cAMKkGGE6ucX8fTsu+B+TlPOSdpdhBSqBd4GKRMVr3My87tcofBdvdD+tLIkmxRT06I7A8XIteos2dA4p5YmVxZKup7pQOebx3ZuZrz2MMEg+CEUCBEIZ+jPU1t6NuwU6W5mXVE+ALWAio9ext1OLpz7bsFD6EH+Dx/Fvkj1RgJuRvM8F1BPhZlYsvi5qHK8ttrZ5TBu3hnPz5So+rSDPkezYmy6g1vlItFRB0L6ScU6iyb8SZZebfPWgRsfug/KbWHqAlMRr0ZaGoooKGIEJPZ66fF1ZU15qAp3eqtwJ5yI2WtsjKs2xMVDk/DdP/eeNMqsB4U0xfFJMlPDQ2pmPg== 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=QZjkbaPLeqhK0KeAaMyIA5RNpZ7SNgRCGiZKM5L69KA=; b=Ui9+AR5L9f9Jk4aRlZMad2tBjcISqJSTyv7xryxY+XpgIyYVu72SJzFFZ+taCSLbrICVsuMFxQaCCy+n42QX368FjONu/dCqQZL+u2YCCpU1JN4XrYZDI1y/j0ggRH7s+uM4ZuwVTOxHK6cYNvnh+xQdfYS/kV0mxqnNoSTCHxPUHGdClSEqkDDNN+URJ5emH3RUIPNPN0U4r+L5BTxn9lD7H/UzkrWhhuK+Z9/2XDnftXgRoCfx3Xbkwc3p0KlP5jnCS4mcpk8CLrShir2AHIFGod8z3XUITaetvA5Y6tR+t1Ypwj1IPhS3XraZGQIfB6YzT71HzydXNPKRjxi1+Q== 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=QZjkbaPLeqhK0KeAaMyIA5RNpZ7SNgRCGiZKM5L69KA=; b=qGtsqC+ZBWw8zDz2EQhVl+m3xZVDsPgEFsvVWXgdP63p5PbakhxBUkKaz+RMxKAKunf3V5botMENblHbuq7aVK4+R6JY6k5lkZRmEEoGF75TK6XlsV8n32046MJtlZ4BQQz4ptpjmSuWXZCk3rSStZaJ35+k7PyPZneE2C1y3p83nov/Vjc3AhfQSzUZSRI+nt+Q8trgtKu0bhzOt9LQeuuNVaKL/Kh2+aCgG9XlsGi5UHNqIhbM+zHvua/s/UMajKTpn3kmdueUFov7bxAldqcXVX+eWX4IsLnrGxY+nCSV9UrDAa4gEwpPa05wzZOMSMDOrS4YkmW3kj+wAYkWHA== Received: from HK2APC01FT060.eop-APC01.prod.protection.outlook.com (2a01:111:e400:7ebc::4b) by HK2APC01HT169.eop-APC01.prod.protection.outlook.com (2a01:111:e400:7ebc::236) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3742.6; Sun, 10 Jan 2021 13:20:30 +0000 Received: from SYCPR01MB3502.ausprd01.prod.outlook.com (2a01:111:e400:7ebc::52) by HK2APC01FT060.mail.protection.outlook.com (2a01:111:e400:7ebc::416) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3742.6 via Frontend Transport; Sun, 10 Jan 2021 13:20:30 +0000 X-IncomingTopHeaderMarker: OriginalChecksum:5CC3F1DB4FB88A2A736CFBF856BE4191D9892B4BB6275673C716F4D2B00A25E2; UpperCasedChecksum:6CDEBA692185F7F4D1197D2386E7223A62EFE448488FB6C7C26EA1F01D208DD0; SizeAsReceived:7574; 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.011; Sun, 10 Jan 2021 13:20:30 +0000 From: Qiuhao Li To: alxndr@bu.edu, qemu-devel@nongnu.org Subject: [PATCH v7 5/7] fuzz: set bits in operand of write/out to zero Date: Sun, 10 Jan 2021 21:19:35 +0800 Message-ID: X-Mailer: git-send-email 2.25.1 In-Reply-To: References: X-TMN: [RQu6Jco7q1FcKAEz6aELuj3j0K8KA+kV] X-ClientProxiedBy: HK2PR04CA0062.apcprd04.prod.outlook.com (2603:1096:202:14::30) To SYCPR01MB3502.ausprd01.prod.outlook.com (2603:10c6:10:3e::12) X-Microsoft-Original-Message-ID: <20210110131937.98351-5-Qiuhao.Li@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from XPS-13-9360 (111.176.239.56) by HK2PR04CA0062.apcprd04.prod.outlook.com (2603:1096:202:14::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3742.6 via Frontend Transport; Sun, 10 Jan 2021 13:20:29 +0000 X-MS-PublicTrafficType: Email X-IncomingHeaderCount: 47 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-Correlation-Id: b083c2ca-c127-44ba-567f-08d8b56a809d X-MS-Exchange-SLBlob-MailProps: S/btQ8cKWiSygBPrM25OmO0bBkd81GAbshGJbSqDQOIc7u8er8zgSR3G5AbKuSBeFmt5Y/G7gwFEKOv5SJbq+IHWZCL7N7QLXouBzqN9s1g6eyjfXfH7jPiQNjr22+HEzcIFJS2Bb5/hoK8uRhS1l2b3YrV+g7M4OUXk3GpDy7rP5h+6SCvtCLJli43wLcLJO9T58u9kbHTA1mR4O5po4Gx7nImMrCEwGMUHDvl8bdF4SRZcr/EFsRwQWR0s3Kf1vwVINnC4te4nx2VYbYMxJF/kv4h0Io9kLdCMvtrtFqBg7hszGmZ6iJBZfrVs93xq53zzTEOiFtg9POEVNF95OqiRNeNx0+EbUo9zE8+IVluN86AI8SA3eCMV+t77/ArmtDziUDIQUduirMkdcSsRTH4i5e1UVKt0U0O+zVTIUuarFC4rONC+J7v0sVSwreCM+hKyQTSbbCO2QS5aW/gSk63OlVIS0UF46jJkVkgP+yN48t0095a2QHhgplNTYF8+tuQ4vQZBTwYuGqQRsMLobmPzDSbq+0emdWHEvFE57binezW35yr/3qlok3jT+jdmzX/5w5f3HanY1cTMlBQzQDswAAtgEO4O7rTBY4yPn3VkrB3u/SGWF0OqdB07pglu2uf2fUPDlvncWVBzXqSOAhW7PncrCE9IYKCHmqJTKcZ5++gpC2xTCA+jl6A7czD3/y4M/2JXSjPyYpfwpk7JBXpuMKH0Wv9rjRVXbtJs6glKnqV+J/pKS8E296h0FqIVHz/9FFGluXw= X-MS-TrafficTypeDiagnostic: HK2APC01HT169: X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: MdiV6Jkeky8fxPSXB13HrTyNokFLSezlneHF7FidRLYTxgblLAJH0WBSJGU5Y4nhq20usXesx5lebVGLenZ6u2vNfOJJ6xDEcjE4eovs9o4yONzIaB7zaG+KBP232HFrfa6PZ4l/Q04axhwWiuyphzr6rkIkim1B5y8rW4ipOsZVSQ1O/k0r5ZoGi8yAzk7EiC+eTI/LQK5rJhlgJRFQDz6m3xwFB+0NYajt3O9WCi/XKVR9I7qXDXCbokOY+VWb X-MS-Exchange-AntiSpam-MessageData: neDKhctVbmqM6vYj87pyZVjQQsqV2fzbn6uGEj3rlE1f9cilGXLlSaQqx/3l3L+bq6FGWMuyVl6FzrwqJbYfycovJApEPbfhTycq4Sv7USl7+Da8igauQKFufl7d0voRFCpQcojhj1MqH9Z6ff3Ppw== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Jan 2021 13:20:30.1561 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-Network-Message-Id: b083c2ca-c127-44ba-567f-08d8b56a809d X-MS-Exchange-CrossTenant-AuthSource: HK2APC01FT060.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: HK2APC01HT169 Received-SPF: pass client-ip=2a01:111:f400:febc::815; 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, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: thuth@redhat.com, Qiuhao Li , darren.kenny@oracle.com, bsd@redhat.com, stefanha@redhat.com, pbonzini@redhat.com Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" 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 287266fe39..f86bbcf6b3 100755 --- a/scripts/oss-fuzz/minimize_qtest_trace.py +++ b/scripts/oss-fuzz/minimize_qtest_trace.py @@ -168,6 +168,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: @@ -188,7 +224,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 Sun Jan 10 13:19:36 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qiuhao Li X-Patchwork-Id: 12009121 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, 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 1B173C433DB for ; Sun, 10 Jan 2021 13:28:27 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id AA360224D3 for ; Sun, 10 Jan 2021 13:28:26 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org AA360224D3 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]:37952 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kyald-0002LR-LS for qemu-devel@archiver.kernel.org; Sun, 10 Jan 2021 08:28:25 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:57222) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kyaeS-0005PA-KA for qemu-devel@nongnu.org; Sun, 10 Jan 2021 08:21:04 -0500 Received: from mail-oln040092254093.outbound.protection.outlook.com ([40.92.254.93]:6160 helo=APC01-PU1-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 1kyaeG-00047l-0N for qemu-devel@nongnu.org; Sun, 10 Jan 2021 08:20:55 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=NR6V3RVLlVd0AwZ5mT4K0jQvbXFi6iyCALA9AuFOmQ2CJw1ijCziTgndNhJWGdMZTNMtdLZk22sQgbr4xTR9tzjGr0bYw8l/GoGdGCD9+SKRnalvA5kP60WpW1XE6Fzz4lCi+DqmnQWhkv5JzHrpMNhsD6sFfMISvPI+otc08zpV7FB3Nk+gVcAxRZJSqYXc6oqjDSB3y7CLken0pdQP3uHadlQ30kH1j6+Q6hk0tRqS6WxFBMbIOE8pBx9Tp6g6sfvL1wZnYpjvY1MF5TknuvHfLQGZJ8MUSFWoNGUd10tKMJMii9YniRBypX+izgAbK7xF6CtizzgDaUrv6+xw0w== 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=XptUlGrlbQq6fLKY5LrXciHjbkk4pDTTuT5hg8euBcg=; b=URsy0hCvc/EQdmduH6OjFbyY7aks2nWHWfNRO1Nt4DubmpLFlBXrmUZji1DmRCblrB7M05HI8TK7HPbK4paJMhMk5z00jfZer2fx3mBj40jCuAaiCSvLlopH3jq/bJZHsIXLNQdteOUjNw1Hbfw2jlqMV8ucty8ONjCH/fTSe1mscQVzNlKYiGBdTDwOzAChYQB6fb5CGGII6acVn8fhEt78f5Yb27Y5MGgfa6GTUaar4zU4hArKXbUVx5XQlqGCQwzSomKum7IChl9MsQLU057yQmEpAkJhlK78CmyE9wl/E5myIWPZ72kNzNnsFRkmJ+WNbldzYr90+WMXOJZSew== 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=XptUlGrlbQq6fLKY5LrXciHjbkk4pDTTuT5hg8euBcg=; b=qg0v5Uy58CsOxHF6GkBvnYtLeCXR8zvr31GoPkWYV8EMFPPskFzUaPr/qEz6ZyHljars8zDDz3/AsZPTi6MJlrja1w9ZU9BJrjVSy5N3mYVKXhkkz2up3ggacG35e/lfMxtbVMrX+J2q/tXUFwRUtOuUKpHe0OaWzK8ryyXDoHT40cNiio3iphkACKzwx+tg+WuizbZq8QbIidLkbnHDYmuR3vT1wjETj5JQ7RfHv0z1TVu4xmHEagOBrmn11W7KtEAragj6vKV9JD8f0Ya8M2XEReN70j6Ske9FBAkKeBszvnEyweJYs/wwCYW0KfO4+QxWlI4m9+5roqhokjNPbQ== Received: from HK2APC01FT060.eop-APC01.prod.protection.outlook.com (2a01:111:e400:7ebc::48) by HK2APC01HT159.eop-APC01.prod.protection.outlook.com (2a01:111:e400:7ebc::316) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3742.6; Sun, 10 Jan 2021 13:20:35 +0000 Received: from SYCPR01MB3502.ausprd01.prod.outlook.com (2a01:111:e400:7ebc::52) by HK2APC01FT060.mail.protection.outlook.com (2a01:111:e400:7ebc::416) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3742.6 via Frontend Transport; Sun, 10 Jan 2021 13:20:34 +0000 X-IncomingTopHeaderMarker: OriginalChecksum:E87BD653A0F9E4EDA1E37BBC4BA51B50C8686D196E5DF582C406666B6AD5E7E5; UpperCasedChecksum:4A5B9426CDEDDF914891C6840ECB9BDDC92BE05152F8491B28E05060F3AB9E9F; SizeAsReceived:7548; 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.011; Sun, 10 Jan 2021 13:20:34 +0000 From: Qiuhao Li To: alxndr@bu.edu, qemu-devel@nongnu.org Subject: [PATCH v7 6/7] fuzz: add minimization options Date: Sun, 10 Jan 2021 21:19:36 +0800 Message-ID: X-Mailer: git-send-email 2.25.1 In-Reply-To: References: X-TMN: [YdHCCOdvVQBdDvD7zGgkzViHvhWzefwB] X-ClientProxiedBy: HK2PR04CA0046.apcprd04.prod.outlook.com (2603:1096:202:14::14) To SYCPR01MB3502.ausprd01.prod.outlook.com (2603:10c6:10:3e::12) X-Microsoft-Original-Message-ID: <20210110131937.98351-6-Qiuhao.Li@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from XPS-13-9360 (111.176.239.56) by HK2PR04CA0046.apcprd04.prod.outlook.com (2603:1096:202:14::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; Sun, 10 Jan 2021 13:20:34 +0000 X-MS-PublicTrafficType: Email X-IncomingHeaderCount: 47 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-Correlation-Id: 03d621d5-3a08-4561-c64c-08d8b56a8362 X-MS-Exchange-SLBlob-MailProps: S/btQ8cKWiSygBPrM25OmO0bBkd81GAbWssNP9Loc5WrvkweIsbXvxQtSWQkHhOyiNsnA5IZhwCCd/tMmNZdtjL8bYVJP/PPSt1+rdCQoljKqAcOHWgRTjLEKGgB69l6/SiG/5k8VV/EEwljwHXv6h5D5AXdeJYY5L0pyPv6l01IgJNmlcBF9cAm/XKu3AqVoy9FvicQKBsnLS4hUmYkTDr0BHcy3W71NGaxu82t3l3GwcT2O6UuRadnCjMLUlRT+++3ftYIBm4BH5JNxjrD2/rAMrPSNjJC7DUek/OKVM0Z1L9HL1X9SB0lIsjOsi5cJ46ryzihqm1XrwGXPTSGyCtSotuH7yaeYBtVnyUh3hYmUWgnNh0JYQfv6vgzXlgGys/FXp69Zan9CQFCck0xMB7zRrprGTbNYuG2KVCjSwq5e8cFet/1m2Q6BFIzAUHF+/jGk7eZBRalF4OnaxQ2gyq6VFCPy/wYzWxHuH88bcWgX9A20VgeS28nMz3Q4G86TX83JmWnP1RmzcJVy2H8bixR5YkwggdHGND9WHN4ZHkewBw3lQiQIxooJM8xkkrQ2yB0DTxpIDWB6vY92t5FCnXuJApBQHBf8RJIKAk/YxZlkc87fjQCTN8kG7ElJ2UzQy8U7aU+48OjsBF+vNT6OyD/MxaRlPOrGqq8VEsarVFXelKczZaBaST7HYQo2Xl4mr2tyBWdI/kB+625PgfVl52aQVCWujQ9+NiXk6IUYMi+rg8744/6DcMbHb0K00M4V9+4RWTVRoI= X-MS-TrafficTypeDiagnostic: HK2APC01HT159: X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 94rEvasbaDs+xIGp7EIkK0Y3Y20i1PzIFj556Quk7c8kBeimZlJ0gsVvnCuBvzcgEX/PAFvNmyuQuWcL/cEjZmsnp8KJlcF51k1iuvi61eot1xhGqwNS5EVTDMKkzXuFRBVpnd7EIzDU8+MwlZunSmV7fow4gxhUKJr9wdrOyH/EMBY7tjNTWfr7aJ801DHHPzq5C2isAtTA2OIDjPJKv6FS8fUFg26r2rudaITbf2ISCD+2XAPJZlYvkZ9VfxeT X-MS-Exchange-AntiSpam-MessageData: kBt5rnC+ignrlHLSDsbTvJDmY0It7Dj0vuEpnx4RxdKNUVRwZuhnOugbgax1vUFMbx/9m4Gj87ItHmqiZJyOI15OBfZViPSWzDW/venh1OGBLDcxGnz4SZoucsmuqaExUTjL9Rlw8R0f0afrGImzgw== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Jan 2021 13:20:34.7595 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-Network-Message-Id: 03d621d5-3a08-4561-c64c-08d8b56a8362 X-MS-Exchange-CrossTenant-AuthSource: HK2APC01FT060.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: HK2APC01HT159 Received-SPF: pass client-ip=40.92.254.93; envelope-from=Qiuhao.Li@outlook.com; helo=APC01-PU1-obe.outbound.protection.outlook.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: thuth@redhat.com, Qiuhao Li , darren.kenny@oracle.com, bsd@redhat.com, stefanha@redhat.com, pbonzini@redhat.com Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" -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 f86bbcf6b3..d2e3f67b66 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\ @@ -217,24 +231,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: @@ -243,4 +265,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 Sun Jan 10 13:19:37 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qiuhao Li X-Patchwork-Id: 12009127 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, 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 51447C433E0 for ; Sun, 10 Jan 2021 13:34:48 +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 B04E7224DE for ; Sun, 10 Jan 2021 13:34:47 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B04E7224DE 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]:46516 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kyarm-0006Jq-Bl for qemu-devel@archiver.kernel.org; Sun, 10 Jan 2021 08:34:46 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:57200) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kyaeJ-0005O8-PV for qemu-devel@nongnu.org; Sun, 10 Jan 2021 08:21:02 -0500 Received: from mail-oln040092253049.outbound.protection.outlook.com ([40.92.253.49]:15814 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 1kyaeF-00048B-Td for qemu-devel@nongnu.org; Sun, 10 Jan 2021 08:20:50 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=F8kfrg4Mlc5DvhaqepHNFZ8iG8cMF22LhuNCsdQBYDwOcT/ieaa/faBbp2xwtliu5RHEtlns/UGvDlPI1XtsUmQ7FbnU42RAuNx9ASoI861MSYK2IFOlrH7V/0ze/Di+6zL+RqJRLBKsYiQAjk2uJV/OvlSA9oz5wc36vjMhAWmcm8VxfP+5JW1hOuroJSRa8VGrNJY13KaeU+W+e4w7x1kViQuE1w7KwiUdp4Wyquu9VfAxwDWbqvEojsTsmh2ynpiB27wBX8/lmJXJ7nWmYhRpp+8J7gV4K2X2wnB7apakj6GB9YBT4e8MDEsjj+ikm4Dwe96mu5OAJQImM+2pBw== 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=ko3OOYXdR0q1ez34lhmiN3jtJwrvThhf5rdtEw2BaOU=; b=IRKcoF/hsqENwVLz4PmF0Y+rFXhWLTkbn2tV2v4lFs5FRAea7AHKrpBoZFybhm9ikn256wkr1sZ1dNu/5pkIK5ka1lEL5jUVkWUYvcndWzQesDiR8V80C3bfyhX446Wqwrs+jOXM15dDX1ywP0bDuGkODp5dFD8znxpfMeVWOL+BG6NGz/MiRb6ZFa+c8ImRp1mtPbgSW91dkxIXnhB06vMqmlK5sQ8Tuux4squFc1aVWNbjDFjA1TP9TQ1Re9cYFY+5gNkU3DowJT5TCHEnRO9aC9eUzJMsB/FbsmWuRJ3CcR/H2K3O+XSiPl2yG0pQK/jOFdnvVddEm7ZxKXKnwA== 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=ko3OOYXdR0q1ez34lhmiN3jtJwrvThhf5rdtEw2BaOU=; b=UxGVn+0hLgINEjHAi1/jBOt8sO8OBRWz0F86ODkl5H3wWozz1rXkrQ8m3znmkNlF9jhFKSr1aUgW+9NxPlCcurMgndwkQqgRe5XVANuYFfHsTpsJjX0DqC50Tn81/zXN3rkrOjTwfYvw95j5KN8fXEqdxlDoQbo46Vmjid05JXs8am1Th2pUYE2byNiM4I6otQHoOQKOJlE4iqwzv4Z03Ki2YKHRhLu162DCuxQl1W+vOogYJTg3B/y0txUgYsURKpPjhkUPZczbvkh94NRCJpxIFRGLqXCT8eVPiIZgyZyob7zOmPJ9OqY94Oy2cdMUeQo1RYhoelPatP7rC1tCYQ== Received: from HK2APC01FT060.eop-APC01.prod.protection.outlook.com (2a01:111:e400:7ebc::46) by HK2APC01HT092.eop-APC01.prod.protection.outlook.com (2a01:111:e400:7ebc::382) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3742.6; Sun, 10 Jan 2021 13:20:39 +0000 Received: from SYCPR01MB3502.ausprd01.prod.outlook.com (2a01:111:e400:7ebc::52) by HK2APC01FT060.mail.protection.outlook.com (2a01:111:e400:7ebc::416) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3742.6 via Frontend Transport; Sun, 10 Jan 2021 13:20:39 +0000 X-IncomingTopHeaderMarker: OriginalChecksum:75BEB53D676062A04F1E72F7DB04FD822A07D465DFE1046D90ED17E7ABB60C4C; UpperCasedChecksum:F48CC350ACC4228C593DD1E7527303172A5DA1BD635BE59CD668E42AF3975A03; SizeAsReceived:7554; 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.011; Sun, 10 Jan 2021 13:20:39 +0000 From: Qiuhao Li To: alxndr@bu.edu, qemu-devel@nongnu.org Subject: [PATCH v7 7/7] fuzz: heuristic split write based on past IOs Date: Sun, 10 Jan 2021 21:19:37 +0800 Message-ID: X-Mailer: git-send-email 2.25.1 In-Reply-To: References: X-TMN: [QsgUByfeEz9J0za6ez7JDfZFHBkeLQ45] X-ClientProxiedBy: HK2PR04CA0055.apcprd04.prod.outlook.com (2603:1096:202:14::23) To SYCPR01MB3502.ausprd01.prod.outlook.com (2603:10c6:10:3e::12) X-Microsoft-Original-Message-ID: <20210110131937.98351-7-Qiuhao.Li@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from XPS-13-9360 (111.176.239.56) by HK2PR04CA0055.apcprd04.prod.outlook.com (2603:1096:202:14::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3742.6 via Frontend Transport; Sun, 10 Jan 2021 13:20:38 +0000 X-MS-PublicTrafficType: Email X-IncomingHeaderCount: 47 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-Correlation-Id: 8d8d44df-e17f-4e38-1e56-08d8b56a8607 X-MS-Exchange-SLBlob-MailProps: S/btQ8cKWiSygBPrM25OmO0bBkd81GAbiDFWcOT4TYWp6QkpEOC3DhVK6t1rLMOLsJIAc8HyCBE7irpBY17c00Pn3WTOwVqs1/1Ivem6XBGOUuY/mrnyqdsdw1XVRFMia1Q4khfKhhFZ2F2/GBYdaoSGEmXZ2G1pKqEKPS0hhBf897MX613THhwZq0Wy1ufdJTy3iS7Y/woeXwXtB6THhA3gmvfzO3b1v5GEPKqBBkLV325zwpcNiAm6p5K/F8mZHgSG96M8vbqmmkZ7RsFOMRt+rxX1pH6GkKBrdRtsUui2IWFAvJAms4fbExGHBhFHqCyI2AYODX+cyKOIxZOkXjUCKftevOnlSepPdFGLLtGXVUHHO2HpmHFzc3cIP0+/ffF1bRDxMa0ZnXfpU/ie0LX7SWy8u23PEzjNMx2SROo0C3MUPp/PPc+c3+6S8KRTGO2+qC7l4xFVHncYLuMsSr8fkDNjfMk4hqVXF0y8kCsgdB5pAgvGS7yzNlceeN382fUAPKBhM90imsqnFqqQUWtlWQkoRpWxncSWJ8BA52rr91HWgtSmZhfkwaBfkA87g/AShrRZ1TKt/hEH3iitwwfCPu80vW5jtrFQLZ9ETpilu1IR6GMoCbTm1Zhr7V0Tjij/7AJIT5kzZ/5IG3XnEgkRDHihQC1p4z+9rN2GUaaKB0i8WuF5152WSKBTt2bzUhF7PRMMjccGxX0Bc8t/B+pu8kZ5C/U2ttU75GlYpCHVNFYJBXZwY7jGSXEBbcFr4pEO7FmPTd4= X-MS-TrafficTypeDiagnostic: HK2APC01HT092: X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: vGA9QlpjwAhmlGHL/BJh7CNkiJjjN2wgiMCjxyf6uKCNCbG4bQ8M6+PzaCTQsXn7nTdeN4BjgwJt0CZe/k8Ymqwm7iGnT2ZWv/XWU2Jk70vXMWngO2yK0Y71Ui+NL2wUao6P0thL73b0tdBYp2Ny6qDL1dFmKAQFk5fHgDsQz4fBCVvHRXGEgC1T7J1BU7ol4ndWLHnh0yH8Ud627V2820Zb0mu+bRd+JIGsVsV1lOtAJJf/lcGlI99Ypp8S9cZG X-MS-Exchange-AntiSpam-MessageData: 5ulqqtJqYDrnh9B+T46L8aNE4qv+yHkkohC21QtsVk8ROyN4Ig+FCrGQNEyNFga2eC1Av4mP4p4PlC93AqMqOVxzgKJwACuOg4QscXD2YrrdlOspcu8rfHyPVBTcVHEoowCZmu56VPm82pgfnQ/wsw== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Jan 2021 13:20:39.2359 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-Network-Message-Id: 8d8d44df-e17f-4e38-1e56-08d8b56a8607 X-MS-Exchange-CrossTenant-AuthSource: HK2APC01FT060.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: HK2APC01HT092 Received-SPF: pass client-ip=40.92.253.49; 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, Qiuhao Li , darren.kenny@oracle.com, bsd@redhat.com, stefanha@redhat.com, pbonzini@redhat.com Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" 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 d2e3f67b66..831e1f107f 100755 --- a/scripts/oss-fuzz/minimize_qtest_trace.py +++ b/scripts/oss-fuzz/minimize_qtest_trace.py @@ -89,6 +89,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 @@ -152,6 +189,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, "")