Skip to contentSkip to conversation

Patch "Btrfs: fix potential use-after-free for cloned bio" has been added to the 4.9-stable tree

PATCH [email protected] 1 participant 1 message Oct 5, 2017

Subsystems (2)
lore
Share & tools
lore

[email protected]

author maintainer Applied
#0 lore raw

This is a note to let you know that I've just added the patch titled

Btrfs: fix potential use-after-free for cloned bio

to the 4.9-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
btrfs-fix-potential-use-after-free-for-cloned-bio.patch
and it can be found in the queue-4.9 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree, please let <[email protected]> know about it.

Quoted 1 line

From foo@baz Thu Oct 5 10:28:31 CEST 2017

From: Liu Bo <[email protected]>
Date: Mon, 10 Apr 2017 12:36:26 -0700
Subject: Btrfs: fix potential use-after-free for cloned bio

From: Liu Bo <[email protected]>

[ 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.

---
 fs/btrfs/volumes.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/btrfs/volumes.c +1 -1
@@ -6226,7 +6226,7 @@ int btrfs_map_bio(struct btrfs_root *roo
 	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;
 		}

Patches currently in stable-queue which might be from [email protected] are

queue-4.9/btrfs-fix-potential-use-after-free-for-cloned-bio.patch queue-4.9/btrfs-fix-segmentation-fault-when-doing-dio-read.patch