Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 75241
b: refs/heads/master
c: 831830b
h: refs/heads/master
i:
  75239: 44197e7
v: v3
  • Loading branch information
Al Viro authored and Linus Torvalds committed Jan 2, 2008
1 parent 76d2a78 commit 97af43d
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 8 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: ac40532ef0b8649e6f7f83859ea0de1c4ed08a19
refs/heads/master: 831830b5a2b5d413407adf380ef62fe17d6fcbf2
20 changes: 20 additions & 0 deletions trunk/fs/proc/base.c
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,26 @@ static int proc_root_link(struct inode *inode, struct dentry **dentry, struct vf
(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);
if (!mm)
return NULL;
down_read(&mm->mmap_sem);
task_lock(task);
if (task->mm != mm)
goto out;
if (task->mm != current->mm && __ptrace_may_attach(task) < 0)
goto out;
task_unlock(task);
return mm;
out:
task_unlock(task);
up_read(&mm->mmap_sem);
mmput(mm);
return NULL;
}

static int proc_pid_cmdline(struct task_struct *task, char * buffer)
{
int res = 0;
Expand Down
2 changes: 2 additions & 0 deletions trunk/fs/proc/internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ struct vmalloc_info {
unsigned long largest_chunk;
};

extern struct mm_struct *mm_for_maps(struct task_struct *);

#ifdef CONFIG_MMU
#define VMALLOC_TOTAL (VMALLOC_END - VMALLOC_START)
extern void get_vmalloc_info(struct vmalloc_info *vmi);
Expand Down
3 changes: 1 addition & 2 deletions trunk/fs/proc/task_mmu.c
Original file line number Diff line number Diff line change
Expand Up @@ -397,12 +397,11 @@ static void *m_start(struct seq_file *m, loff_t *pos)
if (!priv->task)
return NULL;

mm = get_task_mm(priv->task);
mm = mm_for_maps(priv->task);
if (!mm)
return NULL;

priv->tail_vma = tail_vma = get_gate_vma(priv->task);
down_read(&mm->mmap_sem);

/* Start with last addr hint */
if (last_addr && (vma = find_vma(mm, last_addr))) {
Expand Down
4 changes: 1 addition & 3 deletions trunk/fs/proc/task_nommu.c
Original file line number Diff line number Diff line change
Expand Up @@ -165,15 +165,13 @@ static void *m_start(struct seq_file *m, loff_t *pos)
if (!priv->task)
return NULL;

mm = get_task_mm(priv->task);
mm = mm_for_maps(priv->task);
if (!mm) {
put_task_struct(priv->task);
priv->task = NULL;
return NULL;
}

down_read(&mm->mmap_sem);

/* start from the Nth VMA */
for (vml = mm->context.vmlist; vml; vml = vml->next)
if (n-- == 0)
Expand Down
1 change: 1 addition & 0 deletions trunk/include/linux/ptrace.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ extern void __ptrace_link(struct task_struct *child,
extern void __ptrace_unlink(struct task_struct *child);
extern void ptrace_untrace(struct task_struct *child);
extern int ptrace_may_attach(struct task_struct *task);
extern int __ptrace_may_attach(struct task_struct *task);

static inline void ptrace_link(struct task_struct *child,
struct task_struct *new_parent)
Expand Down
4 changes: 2 additions & 2 deletions trunk/kernel/ptrace.c
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ int ptrace_check_attach(struct task_struct *child, int kill)
return ret;
}

static int may_attach(struct task_struct *task)
int __ptrace_may_attach(struct task_struct *task)
{
/* May we inspect the given task?
* This check is used both for attaching with ptrace
Expand Down Expand Up @@ -154,7 +154,7 @@ int ptrace_may_attach(struct task_struct *task)
{
int err;
task_lock(task);
err = may_attach(task);
err = __ptrace_may_attach(task);
task_unlock(task);
return !err;
}
Expand Down

0 comments on commit 97af43d

Please sign in to comment.