Skip to content

Commit b68e074

Browse files
committed
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>
1 parent c2d3f25 commit b68e074

2 files changed

Lines changed: 9 additions & 9 deletions

File tree

‎kernel/events/uprobes.c‎

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1344,14 +1344,6 @@ void uprobe_free_utask(struct task_struct *t)
13441344
t->utask = NULL;
13451345
}
13461346

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-
13551347
/*
13561348
* Allocate a uprobe_task object for the task if if necessary.
13571349
* Called when the thread hits a breakpoint.
@@ -1367,6 +1359,14 @@ static struct uprobe_task *get_utask(void)
13671359
return current->utask;
13681360
}
13691361

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+
13701370
/*
13711371
* Current area->vaddr notion assume the trampoline address is always
13721372
* equal area->vaddr.

‎kernel/fork.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1373,7 +1373,6 @@ static struct task_struct *copy_process(unsigned long clone_flags,
13731373
INIT_LIST_HEAD(&p->pi_state_list);
13741374
p->pi_state_cache = NULL;
13751375
#endif
1376-
uprobe_copy_process(p);
13771376
/*
13781377
* sigaltstack should be cleared when sharing the same VM
13791378
*/
@@ -1490,6 +1489,7 @@ static struct task_struct *copy_process(unsigned long clone_flags,
14901489
perf_event_fork(p);
14911490

14921491
trace_task_newtask(p, clone_flags);
1492+
uprobe_copy_process(p);
14931493

14941494
return p;
14951495

0 commit comments

Comments
 (0)