Skip to contentSkip to conversation

lightnvm: pblk: fix use-after-free bug

PATCH Matias Bjørling 3 participants 3 messages Dec 22, 2018 1 message not in the archive Block layer

lore
Share & tools
lore
#1 lore raw
In reply to a message not in the archive
Quoted 19 lines · Gustavo A. R. Silva

Remove one of the calls to function bio_put(), so *bio* is only freed once.

Notice that bio is being dereferenced in bio_put(), hence leading to a use-after-free bug once *bio* has already been freed.

Addresses-Coverity-ID: 1475952 ("Use after free")

Fixes 55d8ec35398e ("lightnvm: pblk: support packed metadata")
---
  drivers/lightnvm/pblk-recovery.c | 1 -
  1 file changed, 1 deletion(-)
drivers/lightnvm/pblk-recovery.c +0 -0
index 3fcf062d752c..5ee20da7bdb3 100644

drivers/lightnvm/pblk-recovery.c static int pblk_recov_scan_oob(struct pblk *pblk, struct pblk_line *line, · line 423

Quoted 7 lines
drivers/lightnvm/pblk-recovery.c +0 -1
@@ -418,7 +418,6 @@ static int pblk_recov_scan_oob(struct pblk *pblk, struct pblk_line *line,
  	if (ret) {
  		pblk_err(pblk, "I/O submission failed: %d\n", ret);
  		bio_put(bio);
-		bio_put(bio);
  		return ret;
  	}
 

Thanks Gustavo. I missed that one.

Jens, if possible could you please pick this up?

Happy holidays!

#2 lore raw
Quoted 30 lines · Matias Bjørling
Quoted 19 lines · Gustavo A. R. Silva

Remove one of the calls to function bio_put(), so *bio* is only freed once.

Notice that bio is being dereferenced in bio_put(), hence leading to a use-after-free bug once *bio* has already been freed.

Addresses-Coverity-ID: 1475952 ("Use after free")

Fixes 55d8ec35398e ("lightnvm: pblk: support packed metadata")

---
  drivers/lightnvm/pblk-recovery.c | 1 -

  1 file changed, 1 deletion(-)
drivers/lightnvm/pblk-recovery.c +0 -0
index 3fcf062d752c..5ee20da7bdb3 100644

drivers/lightnvm/pblk-recovery.c static int pblk_recov_scan_oob(struct pblk *pblk, · line 423

Quoted 7 lines
drivers/lightnvm/pblk-recovery.c +0 -1
@@ -418,7 +418,6 @@ static int pblk_recov_scan_oob(struct pblk *pblk, 
 struct pblk_line *line,
       if (ret) {
           pblk_err(pblk, "I/O submission failed: %d\n", ret);
           bio_put(bio);
-        bio_put(bio);
           return ret;
       }

Thanks Gustavo. I missed that one.

Quoted 4 lines

Jens, if possible could you please pick this up?

Happy holidays!

Glad to help. :)

Happy holidays everybody.

--
Gustavo

maintainer
#3 lore raw
In reply to Matias Bjørling
Quoted 30 lines · Matias Bjørling
Quoted 19 lines · Gustavo A. R. Silva

Remove one of the calls to function bio_put(), so *bio* is only freed once.

Notice that bio is being dereferenced in bio_put(), hence leading to a use-after-free bug once *bio* has already been freed.

Addresses-Coverity-ID: 1475952 ("Use after free")

Fixes 55d8ec35398e ("lightnvm: pblk: support packed metadata")
---
  drivers/lightnvm/pblk-recovery.c | 1 -
  1 file changed, 1 deletion(-)
drivers/lightnvm/pblk-recovery.c +0 -0
index 3fcf062d752c..5ee20da7bdb3 100644

drivers/lightnvm/pblk-recovery.c static int pblk_recov_scan_oob(struct pblk *pblk, struct pblk_line *line, · line 423

Quoted 7 lines
drivers/lightnvm/pblk-recovery.c +0 -1
@@ -418,7 +418,6 @@ static int pblk_recov_scan_oob(struct pblk *pblk, struct pblk_line *line,
  	if (ret) {
  		pblk_err(pblk, "I/O submission failed: %d\n", ret);
  		bio_put(bio);
-		bio_put(bio);
  		return ret;
  	}
 

Thanks Gustavo. I missed that one.

Quoted 1 line

Jens, if possible could you please pick this up?

Yep, added for the later pull.

Signature · 1 line
Jens Axboe