Skip to content

Commit a967efb

Browse files
Liu Bokdave
authored andcommitted
Btrfs: fix potential use-after-free for cloned bio
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 <[email protected]> Signed-off-by: Liu Bo <[email protected]> Reviewed-by: David Sterba <[email protected]> Signed-off-by: David Sterba <[email protected]>
1 parent 97bf5a5 commit a967efb

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

fs/btrfs/volumes.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6213,7 +6213,7 @@ int btrfs_map_bio(struct btrfs_fs_info *fs_info, struct bio *bio,
62136213
for (dev_nr = 0; dev_nr < total_devs; dev_nr++) {
62146214
dev = bbio->stripes[dev_nr].dev;
62156215
if (!dev || !dev->bdev ||
6216-
(bio_op(bio) == REQ_OP_WRITE && !dev->writeable)) {
6216+
(bio_op(first_bio) == REQ_OP_WRITE && !dev->writeable)) {
62176217
bbio_error(bbio, first_bio, logical);
62186218
continue;
62196219
}

0 commit comments

Comments
 (0)