From patchwork Wed Jun 13 15:36:42 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 10462597 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 AE2D060348 for ; Wed, 13 Jun 2018 15:36:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 75EB028C70 for ; Wed, 13 Jun 2018 15:36:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6885E28C74; Wed, 13 Jun 2018 15:36:48 +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=-7.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, 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 437F328C70 for ; Wed, 13 Jun 2018 15:36:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935842AbeFMPgq (ORCPT ); Wed, 13 Jun 2018 11:36:46 -0400 Received: from esa6.hgst.iphmx.com ([216.71.154.45]:61433 "EHLO esa6.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935781AbeFMPgo (ORCPT ); Wed, 13 Jun 2018 11:36:44 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1528904206; x=1560440206; h=from:to:cc:subject:date:message-id:content-id: content-transfer-encoding:mime-version; bh=4FYi8ELC2y4+J+n+o8HSXAugT5kcQY2+GwwIKf+3i70=; b=l5jG9G2Dq6dxLJ+j7pRZhhdgKu/2mczMKjxp/7xwNPvIsCygtdRYjhlf 3OEFnsNqjw46opdIpjfwxmnEJMytU9ksTdZ6fWtgJUMfWn4KZJb7gpyK4 NdC88pdc6/FOaBEPDoAgUEz/vrTRFMGvLA1TlOsgbVIlR/cwL+4POt2RG n73IvZLsbn8VMFQHq33Oq6HQYJtzBQYn4BtLudYDulaYC3W452FLjlA79 nIA+S+YrnZ2iADW8ecQMcz9o+R0Ngfjkpo+0dhpHk2oapEbnPbM47ZPsK M5opuwX9wflCwitoDL2Ev4u1Q6t9tyPPSZmBq3fE8e9X9AaajDAZBHPF1 Q==; X-IronPort-AV: E=Sophos;i="5.51,219,1526313600"; d="scan'208";a="81377403" Received: from mail-sn1nam02lp0023.outbound.protection.outlook.com (HELO NAM02-SN1-obe.outbound.protection.outlook.com) ([216.32.180.23]) by ob1.hgst.iphmx.com with ESMTP; 13 Jun 2018 23:36:45 +0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sharedspace.onmicrosoft.com; s=selector1-wdc-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=4FYi8ELC2y4+J+n+o8HSXAugT5kcQY2+GwwIKf+3i70=; b=UveQ5tTjQjoommVhyUtXD84Ujy6e/ctlJtalwxERzfMrV287xzWQ4B7SHqenpCKSZwHa/0UU1TSl6NAEOQFUAE0FlbfBSejvn+9Qzsoz/OzNVHkFM97JohX3b+/aINg7fQyDnhUiybsEjmh3I6Pzd/wOdARbkwo4xKpfWtCKHdQ= Received: from MWHPR04MB1198.namprd04.prod.outlook.com (10.173.48.151) by MWHPR04MB0190.namprd04.prod.outlook.com (10.169.201.139) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.841.18; Wed, 13 Jun 2018 15:36:42 +0000 Received: from MWHPR04MB1198.namprd04.prod.outlook.com ([fe80::9de4:3c8d:39af:e4c5]) by MWHPR04MB1198.namprd04.prod.outlook.com ([fe80::9de4:3c8d:39af:e4c5%8]) with mapi id 15.20.0841.019; Wed, 13 Jun 2018 15:36:42 +0000 From: Bart Van Assche To: "stable@vger.kernel.org" CC: "linux-block@vger.kernel.org" , Damien Le Moal Subject: [Backport request] blkdev_report_zones_ioctl(): Use vmalloc() to allocate large buffers Thread-Topic: [Backport request] blkdev_report_zones_ioctl(): Use vmalloc() to allocate large buffers Thread-Index: AQHUAyxTUsyHnArcGUq36g21FIsHUw== Date: Wed, 13 Jun 2018 15:36:42 +0000 Message-ID: <021c1029a42253c749a182a38d9709c2cd8db0df.camel@wdc.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: spf=none (sender IP is ) smtp.mailfrom=Bart.VanAssche@wdc.com; x-originating-ip: [199.255.44.174] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; MWHPR04MB0190; 7:sCX38HTAhe3mSTV/VTUXWiJkKjtRtiHIVQubIFQ14/Sh/XAYl7VjhDyoKPOphkdVfZf8m6HGAjGmsTSZm7pDsJypdq2vsLlrYqqNtRV/3N7s1g0JMzyai3SqR9MYEHj4nKA7wugD13UDVs5aL1fMKpAhvO6ibGjPPE1DeJutRn+//xfTUVEOuZH3AAdWRpvyjILKwXUuwTgjpUK/CzbUTft+Mo6evdRkYOoqjNCoV4/AbxqkKoo2wj44F+sDj1BI; 20:Wqa8vBZ/aYwMiw+j3tnWAg64Iews7h3wp0ArCN4Dco1kvEodf2VtLM2in7XIZAA9F9jmtJStJbaQiSwzkIMavrWe8sUiEI6ebEekmckFnIZcqV2hHzsweGD8BLcqP/pKqhdrJELDPVX1UnytB044xySLUeMjV2lT2qa48oI5wZI= x-ms-exchange-antispam-srfa-diagnostics: SOS;SOR; x-ms-office365-filtering-ht: Tenant X-MS-Office365-Filtering-Correlation-Id: 2222a7b5-2b2a-4c71-673b-08d5d14376a9 x-microsoft-antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(48565401081)(5600026)(711020)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603328)(7153060)(7193020); SRVR:MWHPR04MB0190; x-ms-traffictypediagnostic: MWHPR04MB0190: wdcipoutbound: EOP-TRUE x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(79135771888625)(9452136761055)(146099531331640); x-ms-exchange-senderadcheck: 1 x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(6040522)(2401047)(8121501046)(5005006)(3002001)(3231254)(944501410)(52105095)(93006095)(93001095)(10201501046)(6055026)(149027)(150027)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123562045)(20161123560045)(20161123558120)(20161123564045)(6072148)(201708071742011)(7699016); SRVR:MWHPR04MB0190; BCL:0; PCL:0; RULEID:; SRVR:MWHPR04MB0190; x-forefront-prvs: 07025866F6 x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(376002)(396003)(39380400002)(346002)(366004)(39860400002)(189003)(199004)(5660300001)(6916009)(2900100001)(99286004)(8936002)(316002)(118296001)(6506007)(102836004)(59450400001)(105586002)(106356001)(3660700001)(2906002)(86362001)(36756003)(3280700002)(3846002)(575784001)(6116002)(305945005)(68736007)(8676002)(1730700003)(81166006)(81156014)(54906003)(7736002)(476003)(2616005)(2351001)(478600001)(6486002)(72206003)(6512007)(53936002)(486006)(25786009)(186003)(450100002)(26005)(97736004)(4326008)(5250100002)(5640700003)(6436002)(14454004)(2501003)(66066001); DIR:OUT; SFP:1102; SCL:1; SRVR:MWHPR04MB0190; H:MWHPR04MB1198.namprd04.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; x-microsoft-antispam-message-info: 3EIWsd8Y9KU2PPgxMHHGjfcKUK3e3GsDZLCT4pf//i34oE6R9vMkO9bv7DiKoPvnozOF8NGO1rKDNvPf+dbrSgdYzgZMlg595rJ7No4zKegW9SMlXqpYJHglZggAjGDF/WMmI96/RG4AKH/OTmvp3YgDL2c4wl7Az/46RYwzz0b2dAvdZKGpYa16WBbuLUCb spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-ID: MIME-Version: 1.0 X-OriginatorOrg: wdc.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2222a7b5-2b2a-4c71-673b-08d5d14376a9 X-MS-Exchange-CrossTenant-originalarrivaltime: 13 Jun 2018 15:36:42.5850 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: b61c8803-16f3-4c35-9b17-6f65f441df86 X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR04MB0190 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 Hello stable kernel maintainers, Please backport patch 327ea4adcfa3 ("blkdev_report_zones_ioctl(): Use vmalloc() to allocate large buffers") to at least the v4.17.x and v4.14.y stable kernel series. That patch fixes a bug introduced in kernel v4.10. The entire patch is shown below. Thanks, Bart. commit cf0110698846fc5a93df89eb20ac7cc70a860c17 Author: Bart Van Assche Date: Tue May 22 08:27:22 2018 -0700 blkdev_report_zones_ioctl(): Use vmalloc() to allocate large buffers Avoid that complaints similar to the following appear in the kernel log if the number of zones is sufficiently large: fio: page allocation failure: order:9, mode:0x140c0c0(GFP_KERNEL|__GFP_COMP|__GFP_ZERO), nodemask=(null) Call Trace: dump_stack+0x63/0x88 warn_alloc+0xf5/0x190 __alloc_pages_slowpath+0x8f0/0xb0d __alloc_pages_nodemask+0x242/0x260 alloc_pages_current+0x6a/0xb0 kmalloc_order+0x18/0x50 kmalloc_order_trace+0x26/0xb0 __kmalloc+0x20e/0x220 blkdev_report_zones_ioctl+0xa5/0x1a0 blkdev_ioctl+0x1ba/0x930 block_ioctl+0x41/0x50 do_vfs_ioctl+0xaa/0x610 SyS_ioctl+0x79/0x90 do_syscall_64+0x79/0x1b0 entry_SYSCALL_64_after_hwframe+0x3d/0xa2 Fixes: 3ed05a987e0f ("blk-zoned: implement ioctls") Signed-off-by: Bart Van Assche Cc: Shaun Tancheff Cc: Damien Le Moal Cc: Christoph Hellwig Cc: Martin K. Petersen Cc: Hannes Reinecke Cc: Signed-off-by: Jens Axboe diff --git a/block/blk-zoned.c b/block/blk-zoned.c index 08e84ef2bc05..3d08dc84db16 100644 --- a/block/blk-zoned.c +++ b/block/blk-zoned.c @@ -328,7 +328,11 @@ int blkdev_report_zones_ioctl(struct block_device *bdev, fmode_t mode, if (!rep.nr_zones) return -EINVAL; - zones = kcalloc(rep.nr_zones, sizeof(struct blk_zone), GFP_KERNEL); + if (rep.nr_zones > INT_MAX / sizeof(struct blk_zone)) + return -ERANGE; + + zones = kvmalloc(rep.nr_zones * sizeof(struct blk_zone), + GFP_KERNEL | __GFP_ZERO); if (!zones) return -ENOMEM; @@ -350,7 +354,7 @@ int blkdev_report_zones_ioctl(struct block_device *bdev, fmode_t mode, } out: - kfree(zones); + kvfree(zones); return ret; }