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: <20201124060755.1405602-18-ira.weiny@intel.com>
Date:   Mon, 23 Nov 2020 22:07:55 -0800
From:   ira.weiny@...el.com
To:     Andrew Morton <akpm@...ux-foundation.org>
Cc:     Ira Weiny <ira.weiny@...el.com>,
        Kirti Wankhede <kwankhede@...dia.com>,
        Thomas Gleixner <tglx@...utronix.de>,
        Dave Hansen <dave.hansen@...el.com>,
        Matthew Wilcox <willy@...radead.org>,
        Christoph Hellwig <hch@...radead.org>,
        Dan Williams <dan.j.williams@...el.com>,
        Al Viro <viro@...iv.linux.org.uk>,
        Eric Biggers <ebiggers@...nel.org>,
        Luis Chamberlain <mcgrof@...nel.org>,
        Patrik Jakobsson <patrik.r.jakobsson@...il.com>,
        Jani Nikula <jani.nikula@...ux.intel.com>,
        Joonas Lahtinen <joonas.lahtinen@...ux.intel.com>,
        Rodrigo Vivi <rodrigo.vivi@...el.com>,
        David Howells <dhowells@...hat.com>, Chris Mason <clm@...com>,
        Josef Bacik <josef@...icpanda.com>,
        David Sterba <dsterba@...e.com>,
        Steve French <sfrench@...ba.org>,
        Jaegeuk Kim <jaegeuk@...nel.org>, Chao Yu <yuchao0@...wei.com>,
        Nicolas Pitre <nico@...xnic.net>,
        "Martin K. Petersen" <martin.petersen@...cle.com>,
        Brian King <brking@...ibm.com>,
        Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
        Alexei Starovoitov <ast@...nel.org>,
        Daniel Borkmann <daniel@...earbox.net>,
        Jérôme Glisse <jglisse@...hat.com>,
        linux-kernel@...r.kernel.org, linux-fsdevel@...r.kernel.org
Subject: [PATCH 17/17] samples: Use memcpy_to/from_page()

From: Ira Weiny <ira.weiny@...el.com>

Remove kmap/mem*()/kunmap pattern and use memcpy_to/from_page()

Cc: Kirti Wankhede <kwankhede@...dia.com>
Signed-off-by: Ira Weiny <ira.weiny@...el.com>
---
 samples/vfio-mdev/mbochs.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/samples/vfio-mdev/mbochs.c b/samples/vfio-mdev/mbochs.c
index e03068917273..54fe04f63c66 100644
--- a/samples/vfio-mdev/mbochs.c
+++ b/samples/vfio-mdev/mbochs.c
@@ -30,6 +30,7 @@
 #include <linux/iommu.h>
 #include <linux/sysfs.h>
 #include <linux/mdev.h>
+#include <linux/pagemap.h>
 #include <linux/pci.h>
 #include <linux/dma-buf.h>
 #include <linux/highmem.h>
@@ -442,7 +443,6 @@ static ssize_t mdev_access(struct mdev_device *mdev, char *buf, size_t count,
 	struct device *dev = mdev_dev(mdev);
 	struct page *pg;
 	loff_t poff;
-	char *map;
 	int ret = 0;
 
 	mutex_lock(&mdev_state->ops_lock);
@@ -479,12 +479,10 @@ static ssize_t mdev_access(struct mdev_device *mdev, char *buf, size_t count,
 		pos -= MBOCHS_MMIO_BAR_OFFSET;
 		poff = pos & ~PAGE_MASK;
 		pg = __mbochs_get_page(mdev_state, pos >> PAGE_SHIFT);
-		map = kmap(pg);
 		if (is_write)
-			memcpy(map + poff, buf, count);
+			memcpy_to_page(pg, poff, buf, count);
 		else
-			memcpy(buf, map + poff, count);
-		kunmap(pg);
+			memcpy_from_page(buf, pg, poff, count);
 		put_page(pg);
 
 	} else {
-- 
2.28.0.rc0.12.gb6a658bd00c9

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ