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: <20200925071831.8025-5-sherry.sun@nxp.com>
Date:   Fri, 25 Sep 2020 15:18:31 +0800
From:   Sherry Sun <sherry.sun@....com>
To:     sudeep.dutt@...el.com, ashutosh.dixit@...el.com, arnd@...db.de,
        gregkh@...uxfoundation.org, rikard.falkeborn@...il.com,
        lee.jones@...aro.org, mst@...hat.com
Cc:     linux-kernel@...r.kernel.org, linux-imx@....com
Subject: [PATCH 4/4] mic: vop: copy data to kernel space then write to io memory

Read and write io memory should address align on ARCH ARM. Change to use
memcpy_toio to avoid kernel panic caused by the address un-align issue.

Signed-off-by: Sherry Sun <sherry.sun@....com>
Signed-off-by: Joakim Zhang <qiangqing.zhang@....com>
---
 drivers/misc/mic/vop/vop_vringh.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/misc/mic/vop/vop_vringh.c b/drivers/misc/mic/vop/vop_vringh.c
index 45fdb394de11..f344209ac386 100644
--- a/drivers/misc/mic/vop/vop_vringh.c
+++ b/drivers/misc/mic/vop/vop_vringh.c
@@ -602,6 +602,7 @@ static int vop_virtio_copy_from_user(struct vop_vdev *vdev, void __user *ubuf,
 	size_t partlen;
 	bool dma = VOP_USE_DMA && vi->dma_ch;
 	int err = 0;
+	void *temp = NULL;
 
 	if (dma) {
 		dma_alignment = 1 << vi->dma_ch->device->copy_align;
@@ -655,12 +656,15 @@ static int vop_virtio_copy_from_user(struct vop_vdev *vdev, void __user *ubuf,
 	 * We are copying to IO below and should ideally use something
 	 * like copy_from_user_toio(..) if it existed.
 	 */
-	if (copy_from_user((void __force *)dbuf, ubuf, len)) {
+	temp = kmalloc(len, GFP_KERNEL);
+	if (copy_from_user(temp, ubuf, len)) {
 		err = -EFAULT;
 		dev_err(vop_dev(vdev), "%s %d err %d\n",
 			__func__, __LINE__, err);
 		goto err;
 	}
+	memcpy_toio((void __force *)dbuf, temp, len);
+	kfree(temp);
 	vdev->out_bytes += len;
 	err = 0;
 err:
-- 
2.17.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ