From patchwork Wed Aug 23 17:10:29 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 9917925 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 86FAC603FF for ; Wed, 23 Aug 2017 17:11:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7026C286D1 for ; Wed, 23 Aug 2017 17:11:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 65201287B1; Wed, 23 Aug 2017 17:11:35 +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=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID 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 B3AD0286D1 for ; Wed, 23 Aug 2017 17:11:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932411AbdHWRKv (ORCPT ); Wed, 23 Aug 2017 13:10:51 -0400 Received: from bombadil.infradead.org ([65.50.211.133]:57524 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932356AbdHWRKr (ORCPT ); Wed, 23 Aug 2017 13:10:47 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=References:In-Reply-To:Message-Id: Date:Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=9xotCvlurT5QHfNnEMSR8bauI/rjg+GuAu0E2hPhK10=; b=M1gg5XOREhsyso3ZWgMPhOTMK lbOSuO0nAl6dHj7RImyIRtaCXs5fmi0h0reobuyNOHXdoijqukJRZk48rnDH3OvwHhLx2gs2V8tjK ligy7trnZuoKHkpMSaTzbVZt9FYBP2NZzzBMNC8nTc2pcr0uv29EhjLvSI9dU4gPCGPnrHQseMLnF BYNQ5jiJkQlfM5xejbqc66ojo8/comVCHfYJSRTt+wazkeGFqcq5U0l16IsglEwTpFHbN1ecBrsbq lQpYOUvQGuqPWPyG9LyMCiWqSH8/p+ROU8UsLNeO7R5qUHiVxECRCVleVAXJmp+rBhwLb9JgW1TnY Pv/pRT9AQ==; Received: from clnet-p099-196.ikbnet.co.at ([83.175.99.196] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.87 #1 (Red Hat Linux)) id 1dkZB0-0007YQ-4d; Wed, 23 Aug 2017 17:10:46 +0000 From: Christoph Hellwig To: Jens Axboe Cc: linux-block@vger.kernel.org, linux-raid@vger.kernel.org, linux-btrfs@vger.kernel.org Subject: [PATCH 3/6] block: reject attempts to allocate more than DISK_MAX_PARTS partitions Date: Wed, 23 Aug 2017 19:10:29 +0200 Message-Id: <20170823171032.30529-4-hch@lst.de> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170823171032.30529-1-hch@lst.de> References: <20170823171032.30529-1-hch@lst.de> X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Christoph Hellwig --- block/genhd.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/block/genhd.c b/block/genhd.c index 2367087cdb7c..3380a1e73ea0 100644 --- a/block/genhd.c +++ b/block/genhd.c @@ -1357,6 +1357,13 @@ struct gendisk *alloc_disk_node(int minors, int node_id) struct gendisk *disk; struct disk_part_tbl *ptbl; + if (minors > DISK_MAX_PARTS) { + printk(KERN_ERR + "block: can't allocated more than %d partitions\n", + DISK_MAX_PARTS); + minors = DISK_MAX_PARTS; + } + disk = kzalloc_node(sizeof(struct gendisk), GFP_KERNEL, node_id); if (disk) { if (!init_part_stats(&disk->part0)) {