mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
synced 2025-01-15 11:37:47 +00:00
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 <oleg@redhat.com> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Link: https://lore.kernel.org/r/20240929144239.GA9475@redhat.com
This commit is contained in:
parent
c7b4133c48
commit
430af825ba
@ -1673,28 +1673,16 @@ static unsigned long xol_get_insn_slot(struct uprobe *uprobe)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* xol_free_insn_slot - If slot was earlier allocated by
|
* xol_free_insn_slot - free the slot allocated by xol_get_insn_slot()
|
||||||
* @xol_get_insn_slot(), make the slot available for
|
|
||||||
* subsequent requests.
|
|
||||||
*/
|
*/
|
||||||
static void xol_free_insn_slot(struct task_struct *tsk)
|
static void xol_free_insn_slot(struct task_struct *tsk)
|
||||||
{
|
{
|
||||||
struct xol_area *area;
|
struct xol_area *area = tsk->mm->uprobes_state.xol_area;
|
||||||
unsigned long slot_addr;
|
unsigned long offset = tsk->utask->xol_vaddr - area->vaddr;
|
||||||
unsigned long offset;
|
|
||||||
|
|
||||||
if (!tsk->mm || !tsk->mm->uprobes_state.xol_area || !tsk->utask)
|
|
||||||
return;
|
|
||||||
|
|
||||||
slot_addr = tsk->utask->xol_vaddr;
|
|
||||||
if (unlikely(!slot_addr))
|
|
||||||
return;
|
|
||||||
|
|
||||||
tsk->utask->xol_vaddr = 0;
|
tsk->utask->xol_vaddr = 0;
|
||||||
area = tsk->mm->uprobes_state.xol_area;
|
|
||||||
offset = slot_addr - area->vaddr;
|
|
||||||
/*
|
/*
|
||||||
* slot_addr must fit into [area->vaddr, area->vaddr + PAGE_SIZE).
|
* xol_vaddr must fit into [area->vaddr, area->vaddr + PAGE_SIZE).
|
||||||
* This check can only fail if the "[uprobes]" vma was mremap'ed.
|
* This check can only fail if the "[uprobes]" vma was mremap'ed.
|
||||||
*/
|
*/
|
||||||
if (offset < PAGE_SIZE) {
|
if (offset < PAGE_SIZE) {
|
||||||
@ -1764,14 +1752,12 @@ void uprobe_free_utask(struct task_struct *t)
|
|||||||
if (!utask)
|
if (!utask)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (utask->active_uprobe)
|
WARN_ON_ONCE(utask->active_uprobe || utask->xol_vaddr);
|
||||||
put_uprobe(utask->active_uprobe);
|
|
||||||
|
|
||||||
ri = utask->return_instances;
|
ri = utask->return_instances;
|
||||||
while (ri)
|
while (ri)
|
||||||
ri = free_ret_instance(ri);
|
ri = free_ret_instance(ri);
|
||||||
|
|
||||||
xol_free_insn_slot(t);
|
|
||||||
kfree(utask);
|
kfree(utask);
|
||||||
t->utask = NULL;
|
t->utask = NULL;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user