Skip to content

Commit

Permalink
uprobes: Change the callsite of uprobe_copy_process()
Browse files Browse the repository at this point in the history
Preparation for the next patches.

Move the callsite of uprobe_copy_process() in copy_process() down
to the succesfull return. We do not care if copy_process() fails,
uprobe_free_utask() won't be called in this case so the wrong
->utask != NULL doesn't matter.

OTOH, with this change we know that copy_process() can't fail when
uprobe_copy_process() is called, the new task should either return
to user-mode or call do_exit(). This way uprobe_copy_process() can:

	1. setup p->utask != NULL if necessary

	2. setup uprobes_state.xol_area

	3. use task_work_add(p)

Also, move the definition of uprobe_copy_process() down so that it
can see get_utask().

Signed-off-by: Oleg Nesterov <oleg@redhat.com>
Acked-by: Srikar Dronamraju <srikar@linux.vnet.ibm.com>
  • Loading branch information
Oleg Nesterov committed Oct 29, 2013
1 parent c2d3f25 commit b68e074
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
16 changes: 8 additions & 8 deletions kernel/events/uprobes.c
Original file line number Diff line number Diff line change
Expand Up @@ -1344,14 +1344,6 @@ void uprobe_free_utask(struct task_struct *t)
t->utask = NULL;
}

/*
* Called in context of a new clone/fork from copy_process.
*/
void uprobe_copy_process(struct task_struct *t)
{
t->utask = NULL;
}

/*
* Allocate a uprobe_task object for the task if if necessary.
* Called when the thread hits a breakpoint.
Expand All @@ -1367,6 +1359,14 @@ static struct uprobe_task *get_utask(void)
return current->utask;
}

/*
* Called in context of a new clone/fork from copy_process.
*/
void uprobe_copy_process(struct task_struct *t)
{
t->utask = NULL;
}

/*
* Current area->vaddr notion assume the trampoline address is always
* equal area->vaddr.
Expand Down
2 changes: 1 addition & 1 deletion kernel/fork.c
Original file line number Diff line number Diff line change
Expand Up @@ -1373,7 +1373,6 @@ static struct task_struct *copy_process(unsigned long clone_flags,
INIT_LIST_HEAD(&p->pi_state_list);
p->pi_state_cache = NULL;
#endif
uprobe_copy_process(p);
/*
* sigaltstack should be cleared when sharing the same VM
*/
Expand Down Expand Up @@ -1490,6 +1489,7 @@ static struct task_struct *copy_process(unsigned long clone_flags,
perf_event_fork(p);

trace_task_newtask(p, clone_flags);
uprobe_copy_process(p);

return p;

Expand Down

0 comments on commit b68e074

Please sign in to comment.