Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1298994 > unrolled thread

[PATCH] lightnvm: wrong offset in bad blk lun calculation

Started byMatias Bjørling <m@bjorling.me>
First post2015-12-29 14:40 +0100
Last post2015-12-29 16:30 +0100
Articles 2 — 2 participants

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  [PATCH] lightnvm: wrong offset in bad blk lun calculation Matias Bjørling <m@bjorling.me> - 2015-12-29 14:40 +0100
    Re: [PATCH] lightnvm: wrong offset in bad blk lun calculation Jens Axboe <axboe@kernel.dk> - 2015-12-29 16:30 +0100

#1298994 — [PATCH] lightnvm: wrong offset in bad blk lun calculation

FromMatias Bjørling <m@bjorling.me>
Date2015-12-29 14:40 +0100
Subject[PATCH] lightnvm: wrong offset in bad blk lun calculation
Message-ID<qL2Fl-17h-17@gated-at.bofh.it>
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 <m@bjorling.me>
---
 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)
-- 
2.1.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [next] | [standalone]


#1299038

FromJens Axboe <axboe@kernel.dk>
Date2015-12-29 16:30 +0100
Message-ID<qL4nM-2iM-5@gated-at.bofh.it>
In reply to#1298994
On 12/29/2015 06:37 AM, Matias Bjørling wrote:
> 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.

Added for 4.4, thanks.

-- 
Jens Axboe

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web