Skip to content

Commit 430af82

Browse files
oleg-nesterovPeter Zijlstra
authored andcommitted
uprobes: kill the unnecessary put_uprobe/xol_free_insn_slot in uprobe_free_utask()
If pre_ssout() succeeds and sets utask->active_uprobe and utask->xol_vaddr the task must not exit until it calls handle_singlestep() which does the necessary put_uprobe() and xol_free_insn_slot(). Remove put_uprobe() and xol_free_insn_slot() from uprobe_free_utask(). With this change xol_free_insn_slot() can't hit xol_area/utask/xol_vaddr == NULL, we can kill the unnecessary checks checks and simplify this function more. Signed-off-by: Oleg Nesterov <[email protected]> Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent c7b4133 commit 430af82

File tree

1 file changed

+5
-19
lines changed

1 file changed

+5
-19
lines changed

kernel/events/uprobes.c

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1673,28 +1673,16 @@ static unsigned long xol_get_insn_slot(struct uprobe *uprobe)
16731673
}
16741674

16751675
/*
1676-
* xol_free_insn_slot - If slot was earlier allocated by
1677-
* @xol_get_insn_slot(), make the slot available for
1678-
* subsequent requests.
1676+
* xol_free_insn_slot - free the slot allocated by xol_get_insn_slot()
16791677
*/
16801678
static void xol_free_insn_slot(struct task_struct *tsk)
16811679
{
1682-
struct xol_area *area;
1683-
unsigned long slot_addr;
1684-
unsigned long offset;
1685-
1686-
if (!tsk->mm || !tsk->mm->uprobes_state.xol_area || !tsk->utask)
1687-
return;
1688-
1689-
slot_addr = tsk->utask->xol_vaddr;
1690-
if (unlikely(!slot_addr))
1691-
return;
1680+
struct xol_area *area = tsk->mm->uprobes_state.xol_area;
1681+
unsigned long offset = tsk->utask->xol_vaddr - area->vaddr;
16921682

16931683
tsk->utask->xol_vaddr = 0;
1694-
area = tsk->mm->uprobes_state.xol_area;
1695-
offset = slot_addr - area->vaddr;
16961684
/*
1697-
* slot_addr must fit into [area->vaddr, area->vaddr + PAGE_SIZE).
1685+
* xol_vaddr must fit into [area->vaddr, area->vaddr + PAGE_SIZE).
16981686
* This check can only fail if the "[uprobes]" vma was mremap'ed.
16991687
*/
17001688
if (offset < PAGE_SIZE) {
@@ -1764,14 +1752,12 @@ void uprobe_free_utask(struct task_struct *t)
17641752
if (!utask)
17651753
return;
17661754

1767-
if (utask->active_uprobe)
1768-
put_uprobe(utask->active_uprobe);
1755+
WARN_ON_ONCE(utask->active_uprobe || utask->xol_vaddr);
17691756

17701757
ri = utask->return_instances;
17711758
while (ri)
17721759
ri = free_ret_instance(ri);
17731760

1774-
xol_free_insn_slot(t);
17751761
kfree(utask);
17761762
t->utask = NULL;
17771763
}

0 commit comments

Comments
 (0)