aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatias Bjørling <m@bjorling.me>2016-05-06 14:03:10 -0400
committerJens Axboe <axboe@fb.com>2016-05-06 14:51:10 -0400
commit293a6e8e270f19f676ac4cbe6c653aaf27146ca6 (patch)
tree997fc5890a47675065b345fd87adcab455fd451a
parent00ee6cc3b74bdb4dfb71838046517beb6839647c (diff)
lightnvm: fix out of bound ppa lun id on bb tbl
The ppa configured for retrieving the bad block table uses the internal lun id to setup the get bad block ppa. This increases monotonically with the number luns available. When configuring a ppa, the channel and lun must be specified separately, leading to an out of bound memory access in gennvm_block_bb when lun id goes beyond the luns available within a channel. Additional, remove out of bound check in gennvm_block_bb(), as it was a buggy to begin with. Signed-off-by: Matias Bjørling <m@bjorling.me> Signed-off-by: Jens Axboe <axboe@fb.com>
-rw-r--r--drivers/lightnvm/gennvm.c7
1 files changed, 1 insertions, 6 deletions
diff --git a/drivers/lightnvm/gennvm.c b/drivers/lightnvm/gennvm.c
index 89b880a25cc6..61790aebb8da 100644
--- a/drivers/lightnvm/gennvm.c
+++ b/drivers/lightnvm/gennvm.c
@@ -148,11 +148,6 @@ static int gennvm_block_bb(struct gen_nvm *gn, struct ppa_addr ppa,
148 continue; 148 continue;
149 149
150 blk = &lun->vlun.blocks[i]; 150 blk = &lun->vlun.blocks[i];
151 if (!blk) {
152 pr_err("gennvm: BB data is out of bounds.\n");
153 return -EINVAL;
154 }
155
156 list_move_tail(&blk->list, &lun->bb_list); 151 list_move_tail(&blk->list, &lun->bb_list);
157 lun->vlun.nr_bad_blocks++; 152 lun->vlun.nr_bad_blocks++;
158 lun->vlun.nr_free_blocks--; 153 lun->vlun.nr_free_blocks--;
@@ -257,7 +252,7 @@ static int gennvm_blocks_init(struct nvm_dev *dev, struct gen_nvm *gn)
257 252
258 ppa.ppa = 0; 253 ppa.ppa = 0;
259 ppa.g.ch = lun->vlun.chnl_id; 254 ppa.g.ch = lun->vlun.chnl_id;
260 ppa.g.lun = lun->vlun.id; 255 ppa.g.lun = lun->vlun.lun_id;
261 256
262 ret = nvm_get_bb_tbl(dev, ppa, blks); 257 ret = nvm_get_bb_tbl(dev, ppa, blks);
263 if (ret) 258 if (ret)