X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=fs%2Fproc%2Fbase.c;h=d491006a2b65325a158777e1e55e4ed1c6f3f6ef;hb=567f20a20be06ad546b5962340c4be268462055b;hp=0e732865f44e2b1ffd533cdab68cbe668ce2bae0;hpb=653a9213ae6f303790975dd836d95778aab070de;p=linux-2.6.git diff --git a/fs/proc/base.c b/fs/proc/base.c index 0e732865f..d491006a2 100644 --- a/fs/proc/base.c +++ b/fs/proc/base.c @@ -67,7 +67,6 @@ #include #include #include -#include #include #include #include @@ -415,6 +414,13 @@ static int proc_root_link(struct inode *inode, struct dentry **dentry, struct vf return result; } +#define MAY_PTRACE(task) \ + (task == current || \ + (task->parent == current && \ + (task->ptrace & PT_PTRACED) && \ + (task->state == TASK_STOPPED || task->state == TASK_TRACED) && \ + security_ptrace(current,task) == 0)) + struct mm_struct *mm_for_maps(struct task_struct *task) { struct mm_struct *mm = get_task_mm(task); @@ -759,8 +765,7 @@ static ssize_t mem_read(struct file * file, char __user * buf, if (!task) goto out_no_task; - if (!tracehook_allow_access_process_vm(task) - || !ptrace_may_attach(task)) + if (!MAY_PTRACE(task) || !ptrace_may_attach(task)) goto out; ret = -ENOMEM; @@ -786,8 +791,7 @@ static ssize_t mem_read(struct file * file, char __user * buf, this_len = (count > PAGE_SIZE) ? PAGE_SIZE : count; retval = access_process_vm(task, src, page, this_len, 0); - if (!retval || !tracehook_allow_access_process_vm(task) - || !ptrace_may_attach(task)) { + if (!retval || !MAY_PTRACE(task) || !ptrace_may_attach(task)) { if (!ret) ret = -EIO; break; @@ -831,8 +835,7 @@ static ssize_t mem_write(struct file * file, const char * buf, if (!task) goto out_no_task; - if (!tracehook_allow_access_process_vm(task) - || !ptrace_may_attach(task)) + if (!MAY_PTRACE(task) || !ptrace_may_attach(task)) goto out; copied = -ENOMEM;