You've already forked linux-apfs
mirror of
https://github.com/linux-apfs/linux-apfs.git
synced 2026-05-01 15:00:59 -07:00
new helper: readlink_copy()
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
This commit is contained in:
+4
-10
@@ -146,7 +146,7 @@ static int proc_ns_readlink(struct dentry *dentry, char __user *buffer, int bufl
|
||||
struct task_struct *task;
|
||||
void *ns;
|
||||
char name[50];
|
||||
int len = -EACCES;
|
||||
int res = -EACCES;
|
||||
|
||||
task = get_proc_task(inode);
|
||||
if (!task)
|
||||
@@ -155,24 +155,18 @@ static int proc_ns_readlink(struct dentry *dentry, char __user *buffer, int bufl
|
||||
if (!ptrace_may_access(task, PTRACE_MODE_READ))
|
||||
goto out_put_task;
|
||||
|
||||
len = -ENOENT;
|
||||
res = -ENOENT;
|
||||
ns = ns_ops->get(task);
|
||||
if (!ns)
|
||||
goto out_put_task;
|
||||
|
||||
snprintf(name, sizeof(name), "%s:[%u]", ns_ops->name, ns_ops->inum(ns));
|
||||
len = strlen(name);
|
||||
|
||||
if (len > buflen)
|
||||
len = buflen;
|
||||
if (copy_to_user(buffer, name, len))
|
||||
len = -EFAULT;
|
||||
|
||||
res = readlink_copy(buffer, buflen, name);
|
||||
ns_ops->put(ns);
|
||||
out_put_task:
|
||||
put_task_struct(task);
|
||||
out:
|
||||
return len;
|
||||
return res;
|
||||
}
|
||||
|
||||
static const struct inode_operations proc_ns_link_inode_operations = {
|
||||
|
||||
+1
-1
@@ -16,7 +16,7 @@ static int proc_self_readlink(struct dentry *dentry, char __user *buffer,
|
||||
if (!tgid)
|
||||
return -ENOENT;
|
||||
sprintf(tmp, "%d", tgid);
|
||||
return vfs_readlink(dentry,buffer,buflen,tmp);
|
||||
return readlink_copy(buffer, buflen, tmp);
|
||||
}
|
||||
|
||||
static void *proc_self_follow_link(struct dentry *dentry, struct nameidata *nd)
|
||||
|
||||
Reference in New Issue
Block a user