From patchwork Wed Mar 11 17:02:33 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ross Zwisler X-Patchwork-Id: 5987331 Return-Path: X-Original-To: patchwork-linux-nvdimm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id F16F4BF90F for ; Wed, 11 Mar 2015 17:03:11 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 2D4B42035E for ; Wed, 11 Mar 2015 17:03:11 +0000 (UTC) Received: from ml01.01.org (ml01.01.org [198.145.21.10]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 155992028D for ; Wed, 11 Mar 2015 17:03:10 +0000 (UTC) Received: from ml01.vlan14.01.org (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id D586480F07; Wed, 11 Mar 2015 10:03:09 -0700 (PDT) X-Original-To: linux-nvdimm@lists.01.org Delivered-To: linux-nvdimm@lists.01.org Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by ml01.01.org (Postfix) with ESMTP id 34B3280F07 for ; Wed, 11 Mar 2015 10:03:09 -0700 (PDT) Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga103.fm.intel.com with ESMTP; 11 Mar 2015 09:57:38 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.11,382,1422950400"; d="scan'208";a="539465088" Received: from theros.lm.intel.com ([10.232.112.52]) by orsmga003.jf.intel.com with ESMTP; 11 Mar 2015 10:02:30 -0700 From: Ross Zwisler To: linux-kernel@vger.kernel.org Date: Wed, 11 Mar 2015 11:02:33 -0600 Message-Id: <1426093353-23709-1-git-send-email-ross.zwisler@linux.intel.com> X-Mailer: git-send-email 1.9.3 Cc: Nick Piggin , linux-nvdimm@lists.01.org Subject: [Linux-nvdimm] [PATCH] brd: Ensure that bio_vecs have size <= PAGE_SIZE X-BeenThere: linux-nvdimm@lists.01.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Linux-nvdimm developer list." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: linux-nvdimm-bounces@lists.01.org Sender: "Linux-nvdimm" X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The functions copy_from_brd() and copy_to_brd() are written with an assumption that the bio_vec they are given has size <= PAGE_SIZE. This assumption is not enforced in any way, and if the bio_vec has size larger than PAGE_SIZE data will just be lost. Such a situation can occur with I/Os generated from in-kernel sources, or with coalesced bio_vecs. This bug was originally reported against the pmem driver, where it was found using the Enmotus tiering engine. Instead we should have brd explicitly tell the block layer that it can handle data segments of at most PAGE_SIZE. Signed-off-by: Ross Zwisler Reported-by: Hugh Daschbach Cc: Roger C. Pao (Enmotus) Cc: Boaz Harrosh Cc: linux-nvdimm@lists.01.org Cc: Nick Piggin --- drivers/block/brd.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/block/brd.c b/drivers/block/brd.c index 898b4f256782..7e4873361b64 100644 --- a/drivers/block/brd.c +++ b/drivers/block/brd.c @@ -490,6 +490,7 @@ static struct brd_device *brd_alloc(int i) blk_queue_make_request(brd->brd_queue, brd_make_request); blk_queue_max_hw_sectors(brd->brd_queue, 1024); blk_queue_bounce_limit(brd->brd_queue, BLK_BOUNCE_ANY); + blk_queue_max_segment_size(brd->brd_queue, PAGE_SIZE); brd->brd_queue->limits.discard_granularity = PAGE_SIZE; brd->brd_queue->limits.max_discard_sectors = UINT_MAX;