FAILED: patch "[PATCH] block: fix use-after-free in disk_part_iter_next" failed to apply to 5.10-stable tree
Subsystems (2)
[email protected]
maintainerThe patch below does not apply to the 5.10-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From aebf5db917055b38f4945ed6d621d9f07a44ff30 Mon Sep 17 00:00:00 2001
From: Ming Lei <[email protected]>
Date: Mon, 21 Dec 2020 12:33:35 +0800
Subject: [PATCH] block: fix use-after-free in disk_part_iter_next
Make sure that bdgrab() is done on the 'block_device' instance before referring to it for avoiding use-after-free.
Cc <[email protected]>
Reported-by [email protected]
Signed-off-by Ming Lei <[email protected]>
Reviewed-by Christoph Hellwig <[email protected]>
Signed-off-by Jens Axboe <[email protected]>
block/genhd.c +7 -4
@@ -246,15 +246,18 @@ struct block_device *disk_part_iter_next(struct disk_part_iter *piter) part =rcu_dereference (ptbl->part[piter->idx]);if (!part)continue ; + piter->part =bdgrab (part); +if (!piter->part) +continue ;if (!bdev_nr_sectors (part) && !(piter->flags &DISK_PITER_INCL_EMPTY ) && !(piter->flags &DISK_PITER_INCL_EMPTY_PART0 && - piter->idx ==0 )) + piter->idx ==0 )) { +bdput (piter->part); + piter->part =NULL ;continue ; + } - piter->part =bdgrab (part); -if (!piter->part) -continue ; piter->idx += inc;break ; }