From patchwork Mon Jan 7 21:13:16 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: 10751219 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 26EE491E for ; Mon, 7 Jan 2019 21:13:33 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1608628A3D for ; Mon, 7 Jan 2019 21:13:33 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 096E528A4E; Mon, 7 Jan 2019 21:13:33 +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 66BDD28A3D for ; Mon, 7 Jan 2019 21:13:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726392AbfAGVNc (ORCPT ); Mon, 7 Jan 2019 16:13:32 -0500 Received: from mail-eopbgr750123.outbound.protection.outlook.com ([40.107.75.123]:32634 "EHLO NAM02-BL2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726667AbfAGVNb (ORCPT ); Mon, 7 Jan 2019 16:13:31 -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=9jM1RotnqEtMw6HpdzD4RNBozgIDiHb81abw+7LSjdA=; b=HdgKPgTxiGJ6ruI9lSYDxtFcattp2qo6pe0K5cokLIHUqf0D70GeZVBQmPBakgC6nyRGWYEZezzdGw1p4iLUqtGLpT1ZHGCdewT2qbG/X/f8AiCG6DAbR7V8MPMlrOmGMSBLA+Rh1pUcFhRywlzGMbZrKpAxcgi30VE+vGCNrlc= Received: from BL0PR0102CA0021.prod.exchangelabs.com (2603:10b6:207:18::34) by BN6PR01MB2435.prod.exchangelabs.com (2603:10b6:404:51::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1495.10; Mon, 7 Jan 2019 21:13:26 +0000 Received: from DM3NAM03FT013.eop-NAM03.prod.protection.outlook.com (2a01:111:f400:7e49::209) by BL0PR0102CA0021.outlook.office365.com (2603:10b6:207:18::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.1495.7 via Frontend Transport; Mon, 7 Jan 2019 21:13:26 +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 DM3NAM03FT013.mail.protection.outlook.com (10.152.82.79) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.1471.13 via Frontend Transport; Mon, 7 Jan 2019 21:13:25 +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 x07LDOvA026019 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 7 Jan 2019 16:13:25 -0500 Received: by callcc.thunk.org (Postfix, from userid 15806) id 028A27A02E7; Mon, 7 Jan 2019 16:13:23 -0500 (EST) From: Theodore Ts'o To: CC: Theodore Ts'o Subject: [PATCH blktests] src/sg/syzkaller1.c: fix portability problem for syscall(__NR_mmap, ...) Date: Mon, 7 Jan 2019 16:13:16 -0500 Message-ID: <20190107211316.17578-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)(39860400002)(376002)(346002)(396003)(136003)(2980300002)(189003)(199004)(316002)(476003)(2616005)(86362001)(575784001)(786003)(126002)(6916009)(4326008)(246002)(336012)(1076003)(50226002)(52956003)(6266002)(26005)(51416003)(186003)(47776003)(2351001)(356004)(6666004)(103686004)(106466001)(8936002)(50466002)(48376002)(90966002)(305945005)(106002)(36756003)(5660300001)(2870700001)(486006)(75432002)(88552002)(36906005)(8676002)(42186006)(478600001)(2906002)(26826003)(42866002);DIR:OUT;SFP:1102;SCL:1;SRVR:BN6PR01MB2435;H:outgoing.mit.edu;FPR:;SPF:Pass;LANG:en;PTR:outgoing-auth-1.mit.edu;MX:1;A:1; X-Microsoft-Exchange-Diagnostics: 1;DM3NAM03FT013;1:w8shWEGgXHi6nonIIRBX5Md9t2Z9JEC9hobLHd4I1OBTxTKksHB4JNCqlxdPWYhFLeN0anBIkZlzJqqz5o/rJ202z0d8YLeo199Xjq/LnDcXNXyfu7r+2CWVRfV+/Dt+ X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 25e4008b-da6b-4339-ac82-08d674e4f6d5 X-Microsoft-Antispam: BCL:0;PCL:0;RULEID:(2390118)(7020095)(4652040)(8989299)(5600109)(711020)(4608076)(4709027)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7153060);SRVR:BN6PR01MB2435; X-Microsoft-Exchange-Diagnostics: 1;BN6PR01MB2435;3:wj6UTP0zLHemI9tPKMoLpFEsgkeOEeJKKhiVLwzzWE6e0KJhC3jDbaWVaQcysU71Mu+zeEYr1kyM5cbrA6goDeAgrxs5ZG6/TaW0zdMCUNwT3j4bwQpGh5PIsPMHPTionASSsRY0Dfh2fXpOCc9j+Dxm34+YtwEMbiHMU9/FyXnoEZISSTI+2Y6ZJlSuk2TNUz4Ekir2nMCcbigpiLIhhpdhpGnmHDBKfXR/TF7TB56+gSTStNVMwAZgwkEeD2au9LiFfxTebbdkwnLpAIqEUKcM+fHkiFO7JY5sMz1VE0S8SLUv0sK7bM/SwROj+v+lx5hmik1+vM0+KyiUvQZBWeN2KqwXe3rxqUR/2nvHewM8vv7poHu9FbgVu9bYcZ28;25:LEQvK7i2qpacKAn9BhV7mi5JygI3IvSYCCGKvVLTX0O6qnbs9brmNQpLXFuwicKiEtL9FVLJTrLhkV/lfopOm4sSErV14IKs4mAekVTezGoZefzBR6pBt0MV6Mwqiux7is4O1yh1Zt4I3HWex1QIJndle6Cfy53g3uD1WrMa9BwFWsDS3EfJ0Y60m42jEkddqsbDHg52ii1NOhRB2tnZ987safcM1++tHDW6JRHVxkaitJOsCYqRa87TQZjIHdtOCwnKS00iTpYVmG654OHWusm8S5g0UTO2OLHbiQUHGmaJM9exB+1ye8gUSiM0+2M/Lrnddi/Ts9QKzobvRsBD5A== X-MS-TrafficTypeDiagnostic: BN6PR01MB2435: X-LD-Processed: 64afd9ba-0ecf-4acf-bc36-935f6235ba8b,ExtAddr X-Microsoft-Exchange-Diagnostics: 1;BN6PR01MB2435;31:v8YtKjr4ki8i8NH+xIZ8ruYGF+tz7IkicD7AV6TnhLX9BW45OPOoCefru3aQseZ/LuBR3h5fgkjMGBWIymPMjsS7XKlmf8V6p2/L/1YLE78IUzqPxEG1UlZlKAi2qs0OC2QzSyHSFTO+9d/791Nw16XrZAmte6jlJ26dB9PbJYMCvXWoiycRRYmBbSBBSXNwOex9iFksYAOQWNvLxh14gSJvDh3iBDewq24j5r5FJWE=;20:S/MumAmxBZaN6+3wQiNLOwt27tGDN2y9WOMDJrQiQl5ZXr9myl31Djpr+MzEG3g0Ny7Ll7wg45F1IlkrtAelxyC8GP7XnV3WlHKMAhybK13JliiVyIBGd6zyznLzoOVK/gqQqeN+cazDU8GsxNTHcy7ioC50Ke3yqfqBdrP+YK5p8cS7LDk7WFndGVfWp0h/TnFpdknYJH5YBI4LHwshqiAMQ8yXoBzQM6b0NBymg0mo6Hsiyp81bMzj7LX9z3FUEfh6KpbD2OOcNUVvgA7IIfXK4/VjZfxuqIqwx6m+ftQSamVGlQaj7ij32qii7t7/ebu5fNJtJEfoDhsOUhGlfq6NOYYUCpCcBl134gX/Qq9J7SIeMOpxuue08/iPDAxCtKW1R7tFqXU/e1cFAKCC4aMdeHmSO/z11wRhgwLVM9WadyQw3ec/06v3CL90BVDj7HxpDQiPlKIc6rSzGNneSKM+16ijCOiL/HmIMlO4lFK35NTpSr27X/2VAZ7YKbuG X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(8211001083)(3230021)(908002)(999002)(5005026)(6040522)(8220060)(2401047)(8121501046)(3002001)(10201501046)(93006095)(93004095)(3231475)(944501520)(52105112)(6041310)(20161123564045)(20161123560045)(20161123562045)(201703131423095)(201702281528075)(201702281529075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(201708071742011)(7699051)(76991095);SRVR:BN6PR01MB2435;BCL:0;PCL:0;RULEID:;SRVR:BN6PR01MB2435; X-Microsoft-Exchange-Diagnostics: 1;BN6PR01MB2435;4:MWXdbe/BD1+10BBWh5OYKIndSNRynmVYVYmg10tNuYSodIb3O+PvzRd5TMEy18XN8IZ1ZDrg0q2JBt2jVQc9N3aJlUTwLRfW+unoJjhnTWTGmXmAD7hwob7u16gF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KOafZnj2vohyMLth//lEV12zAvfcdDU7BK25vOEzPT81FzOGPL365q4dqzOhlof/6z8MllKrokR7p6OwQi0xFbM+wQDY8+clFQPO4Tjg34OX374zxEwOTrZWOS/7A==;5:bzeAVuQ3BNZqU+tY5iI16WJBaKaNmrlop/MlrreIDVh5DouSqUcQurQRS1TyYP17reZywMYsbl7UBhPHfKaeEwyxml8djWQTyAAetZHv6+Cma1Xglt86U/dZv5mlLS+LDpmhtQkLWaCxBjoQPIDS2awnKKvVEkwuS1+ewiFg/eiH0F3Vz1o+4B2NqPrxYje/GT8HdId3+Y7vPhyxkKa1jw==;7:ax05H89KnxMQ/TtcYWCqmX5fbh9KOapeDATb+g7izcCzoeER26RM9Qfxz+Sl9mntSgzXhcYHhHStvUkSN/P7BBX2LeTByzGD2QkVBXspeJ7pQ9NwLiJirM9nfr8d3NGvYOME8m2cV6Lp1B7SAt4Dug== SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: mit.edu X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Jan 2019 21:13:25.9411 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 25e4008b-da6b-4339-ac82-08d674e4f6d5 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: BN6PR01MB2435 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 archiecture. 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(-) 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,