[RHEL7,COMMIT] ploop: Fix the check that nobody writes to ZERO_PAGE()

Submitted by Konstantin Khorenko on Aug. 27, 2019, 9:40 a.m.

Details

Message ID 201908270940.x7R9e6Ru015685@finist-ce7.sw.ru
State New
Series "ploop: Fix the check that nobody writes to ZERO_PAGE()"
Headers show

Commit Message

Konstantin Khorenko Aug. 27, 2019, 9:40 a.m.
The commit is pushed to "branch-rh7-3.10.0-957.27.2.vz7.107.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-957.27.2.vz7.107.6
------>
commit aab49006c94789d6a629478a4d7092bdf85dc7a5
Author: Konstantin Khorenko <khorenko@virtuozzo.com>
Date:   Tue Aug 27 12:30:16 2019 +0300

    ploop: Fix the check that nobody writes to ZERO_PAGE()
    
    The check must verify the destination page, not the source one.
    
    Fixes: 3a44b99ce15e ("ploop: Check that nobody writes to ZERO_PAGE()")
    https://jira.sw.ru/browse/PSBM-97043
    
    Signed-off-by: Konstantin Khorenko <khorenko@virtuozzo.com>
    
    --
    v2: move the check in bcopy_from_blist() out of the cycle
---
 drivers/block/ploop/dev.c       | 2 +-
 drivers/block/ploop/io_direct.c | 3 ++-
 2 files changed, 3 insertions(+), 2 deletions(-)

Patch hide | download patch | download mbox

diff --git a/drivers/block/ploop/dev.c b/drivers/block/ploop/dev.c
index 6fb95f0fadb6..b6cb408347d2 100644
--- a/drivers/block/ploop/dev.c
+++ b/drivers/block/ploop/dev.c
@@ -1583,7 +1583,7 @@  static void bio_bcopy(struct bio *dst, struct bio *src, struct ploop_device *plo
 		if (copy > PAGE_SIZE - poff)
 			copy = PAGE_SIZE - poff;
 
-		WARN_ON_ONCE(bv->bv_page == ZERO_PAGE(0));
+		WARN_ON_ONCE(dst->bi_io_vec[didx].bv_page == ZERO_PAGE(0));
 		ksrc = kmap_atomic(bv->bv_page);
 		memcpy(page_address(dst->bi_io_vec[didx].bv_page) + poff,
 		       ksrc + bv->bv_offset + bv_off,
diff --git a/drivers/block/ploop/io_direct.c b/drivers/block/ploop/io_direct.c
index 6b4fd667ff71..1beb4f3292a2 100644
--- a/drivers/block/ploop/io_direct.c
+++ b/drivers/block/ploop/io_direct.c
@@ -344,11 +344,12 @@  static void bcopy_from_blist(struct page *page, int dst_off, /* dst */
 {
 	u8 *kdst = kmap_atomic(page);
 
+	WARN_ON_ONCE(page == ZERO_PAGE(0));
+
 	while (copy_len > 0) {
 		u8 *ksrc;
 		int copy = MIN(copy_len, biter->bv->bv_len - biter->off);
 
-		WARN_ON_ONCE(biter->bv->bv_page == ZERO_PAGE(0));
 		ksrc = kmap_atomic(biter->bv->bv_page);
 		memcpy(kdst + dst_off,
 		       ksrc + biter->bv->bv_offset + biter->off,