From patchwork Wed Jan 9 03:11:53 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Theodore Ts'o X-Patchwork-Id: 10753389 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 00E2A17E1 for ; Wed, 9 Jan 2019 03:12:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E066F28905 for ; Wed, 9 Jan 2019 03:12:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D16B328965; Wed, 9 Jan 2019 03:12:02 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 261C028905 for ; Wed, 9 Jan 2019 03:12:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728398AbfAIDMB (ORCPT ); Tue, 8 Jan 2019 22:12:01 -0500 Received: from mail-eopbgr770134.outbound.protection.outlook.com ([40.107.77.134]:49120 "EHLO NAM02-SN1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727857AbfAIDMB (ORCPT ); Tue, 8 Jan 2019 22:12:01 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mit.edu; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Ex2Lg4sAvx5EebjEzmocfx+YX6283YnCEFqiVEH0ijM=; b=BiMhXrBGgKapr0IywpnIsvyxgt592S2i777ORYCdnSsoaHtlezEOyB1XE6CYKvCF9K+XrEhcFaL+GTn26kAxN/hYTozqFQ00zO/0vBy0G2axojIa639sbrAX2SB2Wf4Fobh3Dl0i4nJ65C5gKnhXLZ9/5zD4BzPitYokV+irxdI= Received: from BYAPR01CA0031.prod.exchangelabs.com (2603:10b6:a02:80::44) by DM6PR01MB4026.prod.exchangelabs.com (2603:10b6:5:2e::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1516.14; Wed, 9 Jan 2019 03:11:58 +0000 Received: from CO1NAM03FT050.eop-NAM03.prod.protection.outlook.com (2a01:111:f400:7e48::205) by BYAPR01CA0031.outlook.office365.com (2603:10b6:a02:80::44) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.1495.7 via Frontend Transport; Wed, 9 Jan 2019 03:11:57 +0000 Authentication-Results: spf=pass (sender IP is 18.9.28.11) smtp.mailfrom=mit.edu; vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=bestguesspass action=none header.from=mit.edu; Received-SPF: Pass (protection.outlook.com: domain of mit.edu designates 18.9.28.11 as permitted sender) receiver=protection.outlook.com; client-ip=18.9.28.11; helo=outgoing.mit.edu; Received: from outgoing.mit.edu (18.9.28.11) by CO1NAM03FT050.mail.protection.outlook.com (10.152.81.76) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.1471.13 via Frontend Transport; Wed, 9 Jan 2019 03:11:57 +0000 Received: from callcc.thunk.org (guestnat-104-133-0-100.corp.google.com [104.133.0.100] (may be forged)) (authenticated bits=0) (User authenticated as tytso@ATHENA.MIT.EDU) by outgoing.mit.edu (8.14.7/8.12.4) with ESMTP id x093BtfO005100 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 8 Jan 2019 22:11:56 -0500 Received: by callcc.thunk.org (Postfix, from userid 15806) id E9D717A02E7; Tue, 8 Jan 2019 22:11:54 -0500 (EST) From: Theodore Ts'o To: CC: "Bart Van Assche --in-reply-to=5423ce34-1d3c-2363-da4e-fe35b02c988b @ acm . org" , Theodore Ts'o Subject: [PATCH blktests v2] src/sg/syzkaller1.c: fix portability problem for syscall(__NR_mmap, ...) Date: Tue, 8 Jan 2019 22:11:53 -0500 Message-ID: <20190109031153.27604-1-tytso@mit.edu> X-Mailer: git-send-email 2.19.1 MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-Forefront-Antispam-Report: CIP:18.9.28.11;IPV:CAL;SCL:-1;CTRY:US;EFV:NLI;SFV:NSPM;SFS:(10019020)(396003)(346002)(136003)(376002)(39860400002)(2980300002)(199004)(189003)(2616005)(50466002)(47776003)(6916009)(476003)(126002)(305945005)(48376002)(8936002)(8676002)(246002)(50226002)(90966002)(52956003)(42186006)(2906002)(36756003)(88552002)(2870700001)(36906005)(478600001)(26826003)(316002)(486006)(26005)(786003)(5660300001)(14444005)(75432002)(186003)(86362001)(575784001)(106466001)(1076003)(356004)(2351001)(51416003)(106002)(6266002)(4326008)(54906003)(336012)(103686004)(42866002);DIR:OUT;SFP:1102;SCL:1;SRVR:DM6PR01MB4026;H:outgoing.mit.edu;FPR:;SPF:Pass;LANG:en;PTR:outgoing-auth-1.mit.edu;A:1;MX:1; X-Microsoft-Exchange-Diagnostics: 1;CO1NAM03FT050;1:aVT69HBkTUbAFhgvXz4MfGRUvy1b3LRhCclM8zQu8X8+NjsnlRmabXsuF1xc/KmZvaGo5X3qbH7esnfujtcAaZdvfLdO75Vv4dnjrE1qRt+Fme5FM/3TVpiUrLd/m+mU X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 828134f0-e376-4170-30cd-08d675e03724 X-Microsoft-Antispam: BCL:0;PCL:0;RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600109)(711020)(4608076)(4709027)(2017052603328)(7153060);SRVR:DM6PR01MB4026; X-Microsoft-Exchange-Diagnostics: 1;DM6PR01MB4026;3:KguMJmpjVLUw2tLPS3vdFzsr/oRBn44Li61FEH6p1zWb5mNw3ghTpKNCdHywSIrG5a5F7S9ZBo8NCAmQyT2GYbjbFzW9wixBv9mlYTbtMu4espHDRGLeiijos6OSNJhFS1S+Z54p2D/KIsIJz7vCi1HIHDlAEzwIYCzG2YidPN6WNWvKzUr5mOOy/ev7i3jBUCGCtvgdSZmeKtzP9Vs/ZYO6UU5VxKBGr1je6jaueEo8765ZpcPIU2T//K297QiTB4A9JiQ4hjU1xeKB4fgUZClfoWC4oiPajJNhxlJgMuxwOrsRpu+htDpGh/lSfJFWe1sHAn73JRTYUV7/hLlc+9DWY9CN/mI+mzqbGbFnSGg88iHFMqmePtMtKrz48gEi;25:f3MuRpe0DspzAYT2S3vrUq+jXwoehir+a27nn0g910AENfecE7OG0I/zjQ/vdb/JmXYxnIveyUgeJq5n6ZjexHhbJ8BZflTStu3SGauHdYt1NrXiTlbzeo6JvxjhPyKxsQXJg3VOQnSYTgFKoXwfuBW4vK5Q3TWdtnUB4xEB8M0RIryTHLshZ9e0ZHkMK3/aBFpC/paVb3Xo1nJcB5lDVecZXfcHGR6gnRPrUQh9UbA6GzuIky7x4mv7e/Fogr/wl7z5KsoNUmlDi5Wj+HGcVywrxpBlQ7jDaYb5l4oMAq/yhAjgMmnzTn0iKar0W+V6JW8Itc8+JgjrReMY+VcdbA== X-MS-TrafficTypeDiagnostic: DM6PR01MB4026: X-LD-Processed: 64afd9ba-0ecf-4acf-bc36-935f6235ba8b,ExtAddr X-Microsoft-Exchange-Diagnostics: 1;DM6PR01MB4026;31:uXCLE+3poxegR3BmVl/+olVzLk6aemWdeSDeTPB+Uo6I3ZWkncH75+BsMEK1PgUsHP52MLPkr6bp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YVBns7KAAfGKwkbB/0v0xSFyiO4+5GqvMAkFZyIiYgQm0adnH3ky7wgqRNxDMdlz1w5uEpfDPQNH2u78QBegIvhcXlvVFPnyqWUAgQK/Ou3lPnFBKjci626lSL0cie6vQLvLJ7AQ==;7:Zn3AZE/XkNI/i2ynoP7S/lxcMUfR/kliydbYxpj/DC/aP9Px+4/hmBRSVM15YhFD12JSNICKwgdJ3S+zzUEHtGXEgM2GvYXzwph+c8sDtGpcDJTqljKXs/zkgUL/ISG/mMmaIbQp7THA/JvrA5iMoQ== SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: mit.edu X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Jan 2019 03:11:57.4465 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 828134f0-e376-4170-30cd-08d675e03724 X-MS-Exchange-CrossTenant-Id: 64afd9ba-0ecf-4acf-bc36-935f6235ba8b X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=64afd9ba-0ecf-4acf-bc36-935f6235ba8b;Ip=[18.9.28.11];Helo=[outgoing.mit.edu] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR01MB4026 Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP How mmap is mapped to a raw system call varies across different architectures. On some architectures (such as 32-bit ARM), __NR_mmap may not exist at all; glibc will use __NR_mmap2 to implement mmap(2). Syzkaller is using mmap() as a non-portable version of malloc(3), so it should be safe to use the glibc's mmap wrapper instead of trying to directly call the system call. Signed-off-by: Theodore Ts'o Reviewed-by: Bart Van Assche --- src/sg/syzkaller1.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) [ I found this issue when trying to build blktests as part of the kvm-xfstests test appliance, which I currently do for the x86_64, i386, arm64, and armhf platforms. The PULL request I sent is this -v2 version, which has the spelling correction pointed out by Bart plus his Reviewed-by. I thought about rewriting the full Syzkaller test in idiomatic C instead of the cr*p assembly-language like mess that it generates, but that would risk changing the test case. So for this change I opted to keep it as close as possible to the original machine-generated test. ] diff --git a/src/sg/syzkaller1.c b/src/sg/syzkaller1.c index 743859a..e254d4a 100644 --- a/src/sg/syzkaller1.c +++ b/src/sg/syzkaller1.c @@ -401,8 +401,10 @@ long r[15]; void test() { memset(r, -1, sizeof(r)); - r[0] = execute_syscall(__NR_mmap, 0x20000000ul, 0x5000ul, 0x3ul, - 0x32ul, (uintptr_t)(-1ul), 0x0ul, 0, 0, 0); +//r[0] = execute_syscall(__NR_mmap, 0x20000000ul, 0x5000ul, 0x3ul, +// 0x32ul, (uintptr_t)(-1ul), 0x0ul, 0, 0, 0); + r[0] = (long) mmap((void *) 0x20000000, (size_t) 0x5000, + PROT_READ | PROT_WRITE, MAP_FIXED | MAP_ANONYMOUS, -1, 0); NONFAILING(memcpy((void*)0x20000000, dev_sg, strlen(dev_sg))); r[2] = execute_syscall(__NR_syz_open_dev, 0x20000000ul, 0x0ul, 0x2ul,