From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 605A7C433F5 for ; Tue, 16 Nov 2021 00:41:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 374FD619FA for ; Tue, 16 Nov 2021 00:41:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1356097AbhKPAmc (ORCPT ); Mon, 15 Nov 2021 19:42:32 -0500 Received: from mail.kernel.org ([198.145.29.99]:45394 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345083AbhKOT0N (ORCPT ); Mon, 15 Nov 2021 14:26:13 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 212CB6109E; Mon, 15 Nov 2021 19:09:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1637003391; bh=QQ/EFiM1Q3qH70HEMMkXoE5EpmYyYlh00KibiceVI/4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rboIeZJevYqPEZvO/4cHgl1soD3QfPj/4Kxr02vJLrbNswgcvl3eSDjV9bYtbosSR ZocBy1p8Itb6CbrM/sCQ3WQn5G83aewalvcWUAzGfjHc3vgqyI4tkOMTpFCfzJlEB4 4K1EJJx097aOK0eg7PlVj3dXcClSyjYkLPZwGLjg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Coly Li , Christoph Hellwig , Jens Axboe Subject: [PATCH 5.15 885/917] bcache: Revert "bcache: use bvec_virt" Date: Mon, 15 Nov 2021 18:06:20 +0100 Message-Id: <20211115165459.060259009@linuxfoundation.org> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211115165428.722074685@linuxfoundation.org> References: <20211115165428.722074685@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Coly Li commit 2878feaed543c35f9dbbe6d8ce36fb67ac803eef upstream. 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 Cc: Christoph Hellwig Cc: stable@vger.kernel.org # 5.15 Signed-off-by: Christoph Hellwig Link: https://lore.kernel.org/r/20211103151041.70516-1-colyli@suse.de Signed-off-by: Jens Axboe Signed-off-by: Greg Kroah-Hartman --- drivers/md/bcache/btree.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/drivers/md/bcache/btree.c +++ b/drivers/md/bcache/btree.c @@ -378,7 +378,7 @@ static void do_btree_node_write(struct 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; }