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>] [day] [month] [year] [list]
Message-Id: <20210824054651.58520-1-deng.changcheng@zte.com.cn>
Date:   Mon, 23 Aug 2021 22:46:51 -0700
From:   CGEL <cgel.zte@...il.com>
To:     Jan Harkes <jaharkes@...cmu.edu>
Cc:     coda@...cmu.edu, codalist@...a.cs.cmu.edu,
        linux-kernel@...r.kernel.org,
        Jing Yangyang <jing.yangyang@....com.cn>,
        Zeal Robot <zealci@....com.cn>
Subject: [PATCH linux-next] coda:psdev: Use vmemdup_user to replace the open code

From: Jing Yangyang <jing.yangyang@....com.cn>

vmemdup_user is better than duplicating its implementation,
So just replace the open code.

./fs/coda/psdev.c:125:10-18:WARNING:opportunity for vmemdup_user

The issue is detected with the help of Coccinelle.

Reported-by: Zeal Robot <zealci@....com.cn>
Signed-off-by: Jing Yangyang <jing.yangyang@....com.cn>
---
 fs/coda/psdev.c | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)

diff --git a/fs/coda/psdev.c b/fs/coda/psdev.c
index 240669f..7e23cb2 100644
--- a/fs/coda/psdev.c
+++ b/fs/coda/psdev.c
@@ -122,14 +122,10 @@ static ssize_t coda_psdev_write(struct file *file, const char __user *buf,
 				hdr.opcode, hdr.unique);
 		        nbytes = size;
 		}
-		dcbuf = kvmalloc(nbytes, GFP_KERNEL);
-		if (!dcbuf) {
-			retval = -ENOMEM;
-			goto out;
-		}
-		if (copy_from_user(dcbuf, buf, nbytes)) {
-			kvfree(dcbuf);
-			retval = -EFAULT;
+
+		dcbuf = vmemdup_user(buf, nbytes);
+		if (IS_ERR(dcbuf)) {
+			retval = PTR_ERR(dcbuf);
 			goto out;
 		}
 
-- 
1.8.3.1


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ