Messages in this thread - First message in thread
- "Levin, Alexander (Sasha Levin)"
- "Levin, Alexander (Sasha Levin)"
- "Levin, Alexander (Sasha Levin)"
- "Levin, Alexander (Sasha Levin)"
- "Levin, Alexander (Sasha Levin)"
- "Levin, Alexander (Sasha Levin)"
- "Levin, Alexander (Sasha Levin)"
- "Levin, Alexander (Sasha Levin)"
- "Levin, Alexander (Sasha Levin)"
- "Levin, Alexander (Sasha Levin)"
- "Levin, Alexander (Sasha Levin)"
- "Levin, Alexander (Sasha Levin)"
- "Levin, Alexander (Sasha Levin)"
- "Levin, Alexander (Sasha Levin)"
- "Levin, Alexander (Sasha Levin)"
- "Levin, Alexander (Sasha Levin)"
- "Levin, Alexander (Sasha Levin)"
- Greg KH
Patch in this message | | | From | "Levin, Alexander (Sasha Levin)" <> | Subject | [PATCH for 4.9 11/39] Btrfs: fix potential use-after-free for cloned bio | Date | Mon, 18 Sep 2017 00:19:39 +0000 |
| |
From: Liu Bo <bo.li.liu@oracle.com>
[ Upstream commit a967efb30b3afa3d858edd6a17f544f9e9e46eea ]
KASAN reports that there is a use-after-free case of bio in btrfs_map_bio.
If we need to submit IOs to several disks at a time, the original bio would get cloned and mapped to the destination disk, but we really should use the original bio instead of a cloned bio to do the sanity check because cloned bios are likely to be freed by its endio.
Reported-by: Diego <diegocg@gmail.com> Signed-off-by: Liu Bo <bo.li.liu@oracle.com> Reviewed-by: David Sterba <dsterba@suse.com> Signed-off-by: David Sterba <dsterba@suse.com> Signed-off-by: Sasha Levin <alexander.levin@verizon.com> --- fs/btrfs/volumes.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c index 71a60cc01451..06a77e47957d 100644 --- a/fs/btrfs/volumes.c +++ b/fs/btrfs/volumes.c @@ -6226,7 +6226,7 @@ int btrfs_map_bio(struct btrfs_root *root, struct bio *bio, for (dev_nr = 0; dev_nr < total_devs; dev_nr++) { dev = bbio->stripes[dev_nr].dev; if (!dev || !dev->bdev || - (bio_op(bio) == REQ_OP_WRITE && !dev->writeable)) { + (bio_op(first_bio) == REQ_OP_WRITE && !dev->writeable)) { bbio_error(bbio, first_bio, logical); continue; } -- 2.11.0
| |