lkml.org 
[lkml]   [2010]   [Sep]   [2]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH v2 02/24] ptrace: cleanup ptrace_request()
Date
use new local variable to remove unnecesary casting, but it requires
put_user() to be changed to copy_to_user().

Signed-off-by: Namhyung Kim <namhyung@gmail.com>
---
kernel/ptrace.c | 13 +++++++------
1 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/kernel/ptrace.c b/kernel/ptrace.c
index f838afe..1084bef 100644
--- a/kernel/ptrace.c
+++ b/kernel/ptrace.c
@@ -563,6 +563,7 @@ int ptrace_request(struct task_struct *child, long request,
{
int ret = -EIO;
siginfo_t siginfo;
+ void __user *datap = (void __user *) data;

switch (request) {
case PTRACE_PEEKTEXT:
@@ -579,19 +580,19 @@ int ptrace_request(struct task_struct *child, long request,
ret = ptrace_setoptions(child, data);
break;
case PTRACE_GETEVENTMSG:
- ret = put_user(child->ptrace_message, (unsigned long __user *) data);
+ ret = copy_to_user(datap, &child->ptrace_message,
+ sizeof (child->ptrace_message)) ?
+ -EFAULT : 0;
break;

case PTRACE_GETSIGINFO:
ret = ptrace_getsiginfo(child, &siginfo);
if (!ret)
- ret = copy_siginfo_to_user((siginfo_t __user *) data,
- &siginfo);
+ ret = copy_siginfo_to_user(datap, &siginfo);
break;

case PTRACE_SETSIGINFO:
- if (copy_from_user(&siginfo, (siginfo_t __user *) data,
- sizeof siginfo))
+ if (copy_from_user(&siginfo, datap, sizeof siginfo))
ret = -EFAULT;
else
ret = ptrace_setsiginfo(child, &siginfo);
@@ -622,7 +623,7 @@ int ptrace_request(struct task_struct *child, long request,
}
mmput(mm);

- ret = put_user(tmp, (unsigned long __user *) data);
+ ret = copy_to_user(datap, &tmp, sizeof tmp) ? -EFAULT : 0;
break;
}
#endif
--
1.7.2.2


\
 
 \ /
  Last update: 2010-09-02 17:49    [W:0.176 / U:0.844 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site