From patchwork Tue Dec 29 13:37:56 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Matias_Bj=C3=B8rling?= X-Patchwork-Id: 7930031 X-Patchwork-Delegate: axboe@kernel.dk Return-Path: X-Original-To: patchwork-linux-block@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 1192ABEEE5 for ; Tue, 29 Dec 2015 13:38:13 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 4C98E2013D for ; Tue, 29 Dec 2015 13:38:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 0521020225 for ; Tue, 29 Dec 2015 13:38:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753377AbbL2NiK (ORCPT ); Tue, 29 Dec 2015 08:38:10 -0500 Received: from mail-wm0-f51.google.com ([74.125.82.51]:34607 "EHLO mail-wm0-f51.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753073AbbL2NiI (ORCPT ); Tue, 29 Dec 2015 08:38:08 -0500 Received: by mail-wm0-f51.google.com with SMTP id u188so10986564wmu.1 for ; Tue, 29 Dec 2015 05:38:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bjorling.me; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-type:content-transfer-encoding; bh=W3qPAECJk1KIpdJEDajpMnuDkDSuUX6FqK48JQHhaus=; b=UKtYT6Dz31mf4UxqCU8AukczQbDpXgz32pXII2Z9AuCr9w9CUXhxUGIDEKfEDUBMa0 4SGME/hEFmDUYeplggdCrt1w8WrABCuC442pshDHhdkBNw2D1nCchBGhJSZZX9ZrJn9g pUPMI7qEkib6WjryMPu5Td1fCe/bl5kOvTbwQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-type:content-transfer-encoding; bh=W3qPAECJk1KIpdJEDajpMnuDkDSuUX6FqK48JQHhaus=; b=NnLsCAtwFOPFTytaOLtMh2Xe7oTG6FmftML8XGrJnabXUT+npKaxFp+7MRR2s2hXEl GzY77UdBk10mMzihtfhi7fI2l5aSz//Cyg7JeD4V0avgPC+fVgewsbFJzfKZ4GWQO2+l 00jbEBjLMNQ+MQSloMXLuKqILfp5tCSefzAdli4QcF6EATyNcb79ntW4XVpOOAbZ/wvz B3LKW0P85xdLQ8oyN4tVZuYPsZ7WzuQ8Vs/XA52OHOt0hPJMiZxVkv4hA76qB3lxe1Yb K3PQk+MhnTlJQeNpfK2ZBrp6OvjibUhE7dTpHpv1iQaQM9zu/f7Y8RlFfy55KY5e/TWu 1lRw== X-Gm-Message-State: ALoCoQnJflLr8UNs0JVsiqU8GGfH5Mf3jLnPh4beT9fB2s8F3/xldmZsDOWt3NCKbXtzMcppxuRa1akFyXWet4ojVlvSBi8bug== X-Received: by 10.194.205.134 with SMTP id lg6mr61774147wjc.156.1451396287836; Tue, 29 Dec 2015 05:38:07 -0800 (PST) Received: from localhost.localdomain (6164198-cl69.boa.fiberby.dk. [193.106.164.198]) by smtp.gmail.com with ESMTPSA id gl10sm61118855wjb.30.2015.12.29.05.38.06 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 29 Dec 2015 05:38:07 -0800 (PST) From: =?UTF-8?q?Matias=20Bj=C3=B8rling?= To: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, axboe@fb.com Cc: =?UTF-8?q?Matias=20Bj=C3=B8rling?= Subject: [PATCH] lightnvm: wrong offset in bad blk lun calculation Date: Tue, 29 Dec 2015 14:37:56 +0100 Message-Id: <1451396276-2589-2-git-send-email-m@bjorling.me> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1451396276-2589-1-git-send-email-m@bjorling.me> References: <1451396276-2589-1-git-send-email-m@bjorling.me> MIME-Version: 1.0 Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=ham 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 dev->nr_luns reports the total number of luns available in a device while dev->luns_per_chnl is the number of luns per channel. When multiple channels are available, the offset is calculated from a channel and lun id into a linear array. As it multiplies with the total number of luns, we go out of bound when channel id > 0 and causes the kernel to panic when we read a protected kernel memory area. Signed-off-by: Matias Bjørling --- drivers/lightnvm/gennvm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/lightnvm/gennvm.c b/drivers/lightnvm/gennvm.c index 04aead4..12ddcaa 100644 --- a/drivers/lightnvm/gennvm.c +++ b/drivers/lightnvm/gennvm.c @@ -75,7 +75,7 @@ static int gennvm_block_bb(struct ppa_addr ppa, int nr_blocks, u8 *blks, struct nvm_block *blk; int i; - lun = &gn->luns[(dev->nr_luns * ppa.g.ch) + ppa.g.lun]; + lun = &gn->luns[(dev->luns_per_chnl * ppa.g.ch) + ppa.g.lun]; for (i = 0; i < nr_blocks; i++) { if (blks[i] == 0)