On 11/3/21 11:10 PM, Coly Li wrote:
This reverts commit 2fd3e5efe791946be0957c8e1eed9560b541fe46.
The above commit replaces page_address(bv->bv_page) by bvec_virt(bv) to avoid directly access to bv->bv_page, but in situation bv->bv_offset is not zero and page_address(bv->bv_page) is not equal to bvec_virt(bv). In such case a memory corruption may happen because memory in next page is tainted by following line in do_btree_node_write(), memcpy(bvec_virt(bv), addr, PAGE_SIZE);
This patch reverts the mentioned commit to avoid the memory corruption.
Fixes: 2fd3e5efe791 ("bcache: use bvec_virt") Signed-off-by: Coly Li colyli@suse.de Cc: Christoph Hellwig hch@lst.de Cc: stable@vger.kernel.org # 5.15
drivers/md/bcache/btree.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/md/bcache/btree.c b/drivers/md/bcache/btree.c index 93b67b8d31c3..88c573eeb598 100644 --- a/drivers/md/bcache/btree.c +++ b/drivers/md/bcache/btree.c @@ -378,7 +378,7 @@ static void do_btree_node_write(struct btree *b) struct bvec_iter_all iter_all; bio_for_each_segment_all(bv, b->bio, iter_all) {
memcpy(bvec_virt(bv), addr, PAGE_SIZE);
}memcpy(page_address(bv->bv_page), addr, PAGE_SIZE); addr += PAGE_SIZE;
Hi Jens,
Since now we don't have a better alternative patch yet, and this issue should be fixed ASAP. Could you please take it firstly. And I will work with Christoph for a better change (maybe large and not trivial) later for next merge window?
Thanks.
Coly Li