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: <1293022927-27141-1-git-send-email-mohan@in.ibm.com>
Date:	Wed, 22 Dec 2010 18:32:07 +0530
From:	"M. Mohan Kumar" <mohan@...ibm.com>
To:	v9fs-developer@...ts.sourceforge.net,
	linux-fsdevel@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: [PATCH] fs/9p: TREADLINK fix

Use copy_to_user function to copy symlink information to the userspace
address. As part of this change v9fs_vfs_followlink_dotl also changed.

Signed-off-by: M. Mohan Kumar <mohan@...ibm.com>
---
 fs/9p/vfs_inode.c |   43 +++++++++++++++++++++----------------------
 1 files changed, 21 insertions(+), 22 deletions(-)

diff --git a/fs/9p/vfs_inode.c b/fs/9p/vfs_inode.c
index 2ce3668..9d3b910 100644
--- a/fs/9p/vfs_inode.c
+++ b/fs/9p/vfs_inode.c
@@ -1995,26 +1995,26 @@ error:
 }
 
 static int
-v9fs_vfs_readlink_dotl(struct dentry *dentry, char *buffer, int buflen)
+v9fs_vfs_readlink_dotl(struct dentry *dentry, char __user *buffer, int buflen)
 {
-	int retval;
+	int retval = -EPERM;
 	struct p9_fid *fid;
 	char *target = NULL;
 
 	P9_DPRINTK(P9_DEBUG_VFS, " %s\n", dentry->d_name.name);
-	retval = -EPERM;
 	fid = v9fs_fid_lookup(dentry);
 	if (IS_ERR(fid))
 		return PTR_ERR(fid);
-
 	retval = p9_client_readlink(fid, &target);
 	if (retval < 0)
-		return retval;
-
-	strncpy(buffer, target, buflen);
-	P9_DPRINTK(P9_DEBUG_VFS, "%s -> %s\n", dentry->d_name.name, buffer);
-
-	retval = strnlen(buffer, buflen);
+		goto error;
+	retval = copy_to_user(buffer, target, buflen);
+	if (retval < 0)
+		goto error;
+	P9_DPRINTK(P9_DEBUG_VFS, "%s -> %s\n", dentry->d_name.name, target);
+	retval = strnlen(target, buflen);
+error:
+	kfree(target);
 	return retval;
 }
 
@@ -2028,23 +2028,22 @@ v9fs_vfs_readlink_dotl(struct dentry *dentry, char *buffer, int buflen)
 static void *
 v9fs_vfs_follow_link_dotl(struct dentry *dentry, struct nameidata *nd)
 {
-	int len = 0;
-	char *link = __getname();
+	int retval;
+	struct p9_fid *fid;
+	char *link = NULL;
 
 	P9_DPRINTK(P9_DEBUG_VFS, "%s n", dentry->d_name.name);
 
-	if (!link)
-		link = ERR_PTR(-ENOMEM);
-	else {
-		len = v9fs_vfs_readlink_dotl(dentry, link, PATH_MAX);
-		if (len < 0) {
-			__putname(link);
-			link = ERR_PTR(len);
-		} else
-			link[min(len, PATH_MAX-1)] = 0;
+	fid = v9fs_fid_lookup(dentry);
+	if (IS_ERR(fid))
+		return fid;
+	retval = p9_client_readlink(fid, &link);
+	if (retval < 0) {
+		kfree(link);
+		link = ERR_PTR(retval);
 	}
-	nd_set_link(nd, link);
 
+	nd_set_link(nd, link);
 	return NULL;
 }
 
-- 
1.7.0.4

--
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