Commit fc3d8767 authored by Jovi Zhang's avatar Jovi Zhang Committed by Linus Torvalds

procfs: fix some wrong error code usage

[root@wei 1]# cat /proc/1/mem
cat: /proc/1/mem: No such process

error code -ESRCH is wrong in this situation.  Return -EPERM instead.
Signed-off-by: default avatarJovi Zhang <bookjovi@gmail.com>
Reviewed-by: default avatarKOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
Cc: Alexey Dobriyan <adobriyan@gmail.com>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 0db0c01b
...@@ -775,7 +775,8 @@ static ssize_t mem_read(struct file * file, char __user * buf, ...@@ -775,7 +775,8 @@ static ssize_t mem_read(struct file * file, char __user * buf,
if (!task) if (!task)
goto out_no_task; goto out_no_task;
if (check_mem_permission(task)) ret = check_mem_permission(task);
if (ret)
goto out; goto out;
ret = -ENOMEM; ret = -ENOMEM;
...@@ -845,7 +846,8 @@ static ssize_t mem_write(struct file * file, const char __user *buf, ...@@ -845,7 +846,8 @@ static ssize_t mem_write(struct file * file, const char __user *buf,
if (!task) if (!task)
goto out_no_task; goto out_no_task;
if (check_mem_permission(task)) copied = check_mem_permission(task);
if (copied)
goto out; goto out;
copied = -ENOMEM; copied = -ENOMEM;
...@@ -917,6 +919,7 @@ static ssize_t environ_read(struct file *file, char __user *buf, ...@@ -917,6 +919,7 @@ static ssize_t environ_read(struct file *file, char __user *buf,
if (!task) if (!task)
goto out_no_task; goto out_no_task;
ret = -EPERM;
if (!ptrace_may_access(task, PTRACE_MODE_READ)) if (!ptrace_may_access(task, PTRACE_MODE_READ))
goto out; goto out;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment