From patchwork Fri Oct 12 02:30:06 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Damien Le Moal X-Patchwork-Id: 10637743 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 EBF9A157A for ; Fri, 12 Oct 2018 02:30:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DB7992C24A for ; Fri, 12 Oct 2018 02:30:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CFB7C2C258; Fri, 12 Oct 2018 02:30:22 +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.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=unavailable 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 8C9D42C252 for ; Fri, 12 Oct 2018 02:30:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727013AbeJLKA1 (ORCPT ); Fri, 12 Oct 2018 06:00:27 -0400 Received: from esa2.hgst.iphmx.com ([68.232.143.124]:6549 "EHLO esa2.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726183AbeJLKA1 (ORCPT ); Fri, 12 Oct 2018 06:00:27 -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=1539311433; x=1570847433; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=TO9/d2tST9vnaD05TIZjJa0QPE0wX3n1RaGQVyoHWb4=; b=mhfVGV7GuG2WUq3QKRCH+YzArsIiNvc9vuxN23rRUhEhwRQiwIENaMmz LeBeYf9XJMNompRRP7CWCkP7vkHsu6yG1zPrKqlnwLvXklKMnNKZCocbr p2I4H+c0tJmB2JcBHiS55Vp9MdNuzvoeZwC5wax3aFM6lm2j9M5cZfJhi Sm0S6W5N6PQC4v2kxX9O2JdukE/CdNMW4ZrtRJj+98hlODXfg1gIpp5p1 SLjZAGLqA4Prud553qvZwtTIP432FyNoFhYY+72aKyQKZz5j5xiRw4n3T xt0wvRkyFihSML/P6KcZOEiYgwS12v8l4pQK6ARbufXLQadi1M0rCHl9o Q==; X-IronPort-AV: E=Sophos;i="5.54,370,1534780800"; d="scan'208";a="189468216" Received: from h199-255-45-14.hgst.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 12 Oct 2018 10:30:33 +0800 Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep01.wdc.com with ESMTP; 11 Oct 2018 19:15:40 -0700 Received: from washi.fujisawa.hgst.com ([10.149.53.254]) by uls-op-cesaip02.wdc.com with ESMTP; 11 Oct 2018 19:30:20 -0700 From: Damien Le Moal To: linux-block@vger.kernel.org, Jens Axboe , linux-scsi@vger.kernel.org, "Martin K . Petersen" , dm-devel@redhat.com, Mike Snitzer Cc: Christoph Hellwig , Matias Bjorling Subject: [PATCH v3 05/11] block: Limit allocation of zone descriptors for report zones Date: Fri, 12 Oct 2018 11:30:06 +0900 Message-Id: <20181012023012.29923-6-damien.lemoal@wdc.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181012023012.29923-1-damien.lemoal@wdc.com> References: <20181012023012.29923-1-damien.lemoal@wdc.com> Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP There is no point in allocating more zone descriptors than the number of zones a block device has for doing a zone report. Avoid doing that in blkdev_report_zones_ioctl() by limiting the number of zone decriptors allocated internally to process the user request. Signed-off-by: Damien Le Moal Reviewed-by: Christoph Hellwig Reviewed-by: Hannes Reinecke --- block/blk-zoned.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/block/blk-zoned.c b/block/blk-zoned.c index 32e377f755d8..bb4ed69f917f 100644 --- a/block/blk-zoned.c +++ b/block/blk-zoned.c @@ -355,8 +355,7 @@ int blkdev_report_zones_ioctl(struct block_device *bdev, fmode_t mode, if (!rep.nr_zones) return -EINVAL; - if (rep.nr_zones > INT_MAX / sizeof(struct blk_zone)) - return -ERANGE; + rep.nr_zones = min(blkdev_nr_zones(bdev), rep.nr_zones); zones = kvmalloc_array(rep.nr_zones, sizeof(struct blk_zone), GFP_KERNEL | __GFP_ZERO);