From patchwork Fri Aug 25 16:43:32 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: George Dunlap X-Patchwork-Id: 9922493 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 098E46022E for ; Fri, 25 Aug 2017 16:46:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EE5E2281D2 for ; Fri, 25 Aug 2017 16:46:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E3526283CF; Fri, 25 Aug 2017 16:46:20 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 9F466281D2 for ; Fri, 25 Aug 2017 16:46:20 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dlHiD-00050B-OB; Fri, 25 Aug 2017 16:44:01 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dlHiD-0004zg-9f for xen-devel@lists.xenproject.org; Fri, 25 Aug 2017 16:44:01 +0000 Received: from [85.158.139.211] by server-11.bemta-5.messagelabs.com id ED/EA-01729-0D350A95; Fri, 25 Aug 2017 16:44:00 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFmpgkeJIrShJLcpLzFFi42JxWrrBXvdC8IJ IgyfHWCy+b5nM5MDocfjDFZYAxijWzLyk/IoE1oxHa/8wFUzirbixuaCB8TlXFyMnh4SAv0TD us2sIDabgJ7EvONfWboYOThEBFQkbu816GLk4mAW2M8o0fv1BxtIjbCAi8Tmid3sIDaLgKrEv lO/wep5BWwl/nxihhgpL3HuwW1mkDCngJ3ErpNcIKYQUMWLM3ogFUJAjYsfHAUbwisgKHFy5h MWEJtZQELi4IsXzBMYeWchSc1CklrAyLSKUb04tagstUjXRC+pKDM9oyQ3MTNH19DAVC83tbg 4MT01JzGpWC85P3cTIzBkGIBgB+OtPudDjJIcTEqivNYv50cK8SXlp1RmJBZnxBeV5qQWH2KU 4eBQkuCVC1oQKSRYlJqeWpGWmQMMXpi0BAePkggvF0iat7ggMbc4Mx0idYpRUUqc908gUEIAJ JFRmgfXBouYS4yyUsK8jECHCPEUpBblZpagyr9iFOdgVBLmtQUZz5OZVwI3/RXQYiagxZNOzA FZXJKIkJJqYJTpLV5/3Gj7z94XNx98El54s4iZc8sJlUCxjA+b+64evM5zMrbhj9vu+w5bM30 nVPJOO7X5TZmQfvCdgr/TsotYg9vXGhm765vZun+9qrhpycLeM5tnNLZKKS6JFeidUPybL8tA 9Ymer23zqdPli1/qbatVdXkpzJ/yZ1/e08t2r+6/492s9FGJpTgj0VCLuag4EQDJ91emkwIAA A== X-Env-Sender: prvs=4030414b0=George.Dunlap@citrix.com X-Msg-Ref: server-11.tower-206.messagelabs.com!1503679437!87780548!2 X-Originating-IP: [66.165.176.63] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogNjYuMTY1LjE3Ni42MyA9PiAzMDYwNDg=\n, received_headers: No Received headers X-StarScan-Received: X-StarScan-Version: 9.4.45; banners=-,-,- X-VirusChecked: Checked Received: (qmail 36773 invoked from network); 25 Aug 2017 16:43:59 -0000 Received: from smtp02.citrix.com (HELO SMTP02.CITRIX.COM) (66.165.176.63) by server-11.tower-206.messagelabs.com with RC4-SHA encrypted SMTP; 25 Aug 2017 16:43:59 -0000 X-IronPort-AV: E=Sophos;i="5.41,426,1498521600"; d="scan'208";a="445163892" From: George Dunlap To: Date: Fri, 25 Aug 2017 17:43:32 +0100 Message-ID: <20170825164343.29015-3-george.dunlap@citrix.com> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20170825164343.29015-1-george.dunlap@citrix.com> References: <20170825164343.29015-1-george.dunlap@citrix.com> MIME-Version: 1.0 Cc: Ian Jackson , Wei Liu , George Dunlap , Jan Beulich , Andrew Cooper Subject: [Xen-devel] [PATCH 03/14] fuzz/x86_emulate: Actually use cpu_regs input X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP Commit c07574b reorganized the way fuzzing was done, explicitly creating a structure that the input data would be copied into. Unfortunately, the cpu register state used by the emulator is on the stack; it's cleared, but data is never copied into it. If we're explicitly setting an entirely new cpu_regs struct for each new input anyway, there's no need to have two copies around anymore; just point to the one in the data structure. Signed-off-by: George Dunlap --- This is a candidate for backporting to 4.9. To test that this has an effect, revert the previous patch ("x86emul/fuzz: add rudimentary limit checking"): with this patch it hits an ASSERT(). CC: Ian Jackson CC: Wei Liu CC: Andrew Cooper CC: Jan Beulich --- tools/fuzz/x86_instruction_emulator/fuzz-emul.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tools/fuzz/x86_instruction_emulator/fuzz-emul.c b/tools/fuzz/x86_instruction_emulator/fuzz-emul.c index 105145e9f9..48a879cc88 100644 --- a/tools/fuzz/x86_instruction_emulator/fuzz-emul.c +++ b/tools/fuzz/x86_instruction_emulator/fuzz-emul.c @@ -785,13 +785,12 @@ int LLVMFuzzerInitialize(int *argc, char ***argv) int LLVMFuzzerTestOneInput(const uint8_t *data_p, size_t size) { - struct cpu_user_regs regs = {}; struct fuzz_state state = { .ops = all_fuzzer_ops, }; struct x86_emulate_ctxt ctxt = { .data = &state, - .regs = ®s, + .regs = &input.regs, .addr_size = 8 * sizeof(void *), .sp_size = 8 * sizeof(void *), };