lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1427012095-4095-2-git-send-email-ming.lei@canonical.com>
Date:	Sun, 22 Mar 2015 16:14:52 +0800
From:	Ming Lei <ming.lei@...onical.com>
To:	Jens Axboe <axboe@...com>, linux-kernel@...r.kernel.org
Cc:	Christoph Hellwig <hch@....de>, Al Viro <viro@...iv.linux.org.uk>,
	Maxim Patlasov <mpatlasov@...allels.com>,
	Ming Lei <ming.lei@...onical.com>
Subject: [PATCH 1/3] block: loop: use kmap(page) instead of page_address(page)

The raw page allocated in lo_send() can be a highmem page,
so kmap(page) should be used for read/write on the page.

Also the patch removes kmap()/kunmap() in lo_send() because
it isn't needed at all.

Signed-off-by: Ming Lei <ming.lei@...onical.com>
---
 drivers/block/loop.c |   11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/drivers/block/loop.c b/drivers/block/loop.c
index d1f168b..965f117 100644
--- a/drivers/block/loop.c
+++ b/drivers/block/loop.c
@@ -275,10 +275,13 @@ static int do_lo_send_write(struct loop_device *lo, struct bio_vec *bvec,
 {
 	int ret = lo_do_transfer(lo, WRITE, page, 0, bvec->bv_page,
 			bvec->bv_offset, bvec->bv_len, pos >> 9);
-	if (likely(!ret))
-		return __do_lo_send_write(lo->lo_backing_file,
-				page_address(page), bvec->bv_len,
+	if (likely(!ret)) {
+		ret =  __do_lo_send_write(lo->lo_backing_file,
+				kmap(page), bvec->bv_len,
 				pos);
+		kunmap(page);
+		return ret;
+	}
 	printk_ratelimited(KERN_ERR "loop: Transfer error at byte offset %llu, "
 			"length %i.\n", (unsigned long long)pos, bvec->bv_len);
 	if (ret > 0)
@@ -299,7 +302,6 @@ static int lo_send(struct loop_device *lo, struct request *rq, loff_t pos)
 		page = alloc_page(GFP_NOIO | __GFP_HIGHMEM);
 		if (unlikely(!page))
 			goto fail;
-		kmap(page);
 		do_lo_send = do_lo_send_write;
 	} else {
 		do_lo_send = do_lo_send_direct_write;
@@ -312,7 +314,6 @@ static int lo_send(struct loop_device *lo, struct request *rq, loff_t pos)
 		pos += bvec.bv_len;
 	}
 	if (page) {
-		kunmap(page);
 		__free_page(page);
 	}
 out:
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ