diff options
| author | Oleg Nesterov <oleg@redhat.com> | 2013-10-13 15:18:31 -0400 |
|---|---|---|
| committer | Oleg Nesterov <oleg@redhat.com> | 2013-10-29 13:02:48 -0400 |
| commit | b68e0749100e1b901bf11330f149b321c082178e (patch) | |
| tree | e6950bc5bafbb845ce1f7650e738e6aac7e12b12 /kernel | |
| parent | c2d3f25dda016d9697c5416810d4528770f0a281 (diff) | |
uprobes: Change the callsite of uprobe_copy_process()
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>
Diffstat (limited to 'kernel')
| -rw-r--r-- | kernel/events/uprobes.c | 16 | ||||
| -rw-r--r-- | kernel/fork.c | 2 |
2 files changed, 9 insertions, 9 deletions
diff --git a/kernel/events/uprobes.c b/kernel/events/uprobes.c index ad8e1bdca70e..db7a1dcb3dd6 100644 --- a/kernel/events/uprobes.c +++ b/kernel/events/uprobes.c | |||
| @@ -1345,14 +1345,6 @@ void uprobe_free_utask(struct task_struct *t) | |||
| 1345 | } | 1345 | } |
| 1346 | 1346 | ||
| 1347 | /* | 1347 | /* |
| 1348 | * Called in context of a new clone/fork from copy_process. | ||
| 1349 | */ | ||
| 1350 | void uprobe_copy_process(struct task_struct *t) | ||
| 1351 | { | ||
| 1352 | t->utask = NULL; | ||
| 1353 | } | ||
| 1354 | |||
| 1355 | /* | ||
| 1356 | * Allocate a uprobe_task object for the task if if necessary. | 1348 | * Allocate a uprobe_task object for the task if if necessary. |
| 1357 | * Called when the thread hits a breakpoint. | 1349 | * Called when the thread hits a breakpoint. |
| 1358 | * | 1350 | * |
| @@ -1368,6 +1360,14 @@ static struct uprobe_task *get_utask(void) | |||
| 1368 | } | 1360 | } |
| 1369 | 1361 | ||
| 1370 | /* | 1362 | /* |
| 1363 | * Called in context of a new clone/fork from copy_process. | ||
| 1364 | */ | ||
| 1365 | void uprobe_copy_process(struct task_struct *t) | ||
| 1366 | { | ||
| 1367 | t->utask = NULL; | ||
| 1368 | } | ||
| 1369 | |||
| 1370 | /* | ||
| 1371 | * Current area->vaddr notion assume the trampoline address is always | 1371 | * Current area->vaddr notion assume the trampoline address is always |
| 1372 | * equal area->vaddr. | 1372 | * equal area->vaddr. |
| 1373 | * | 1373 | * |
diff --git a/kernel/fork.c b/kernel/fork.c index 086fe73ad6bd..d3603b81246b 100644 --- a/kernel/fork.c +++ b/kernel/fork.c | |||
| @@ -1373,7 +1373,6 @@ static struct task_struct *copy_process(unsigned long clone_flags, | |||
| 1373 | INIT_LIST_HEAD(&p->pi_state_list); | 1373 | INIT_LIST_HEAD(&p->pi_state_list); |
| 1374 | p->pi_state_cache = NULL; | 1374 | p->pi_state_cache = NULL; |
| 1375 | #endif | 1375 | #endif |
| 1376 | uprobe_copy_process(p); | ||
| 1377 | /* | 1376 | /* |
| 1378 | * sigaltstack should be cleared when sharing the same VM | 1377 | * sigaltstack should be cleared when sharing the same VM |
| 1379 | */ | 1378 | */ |
| @@ -1490,6 +1489,7 @@ static struct task_struct *copy_process(unsigned long clone_flags, | |||
| 1490 | perf_event_fork(p); | 1489 | perf_event_fork(p); |
| 1491 | 1490 | ||
| 1492 | trace_task_newtask(p, clone_flags); | 1491 | trace_task_newtask(p, clone_flags); |
| 1492 | uprobe_copy_process(p); | ||
| 1493 | 1493 | ||
| 1494 | return p; | 1494 | return p; |
| 1495 | 1495 | ||
