On 09/09, Andrii Nakryiko wrote: > > Currently put_uprobe() might trigger mutex_lock()/mutex_unlock(), which > makes it unsuitable to be called from more restricted context like softirq. > > Let's make put_uprobe() agnostic to the context in which it is called, > and use work queue to defer the mutex-protected clean up steps. ... > +static void uprobe_free_deferred(struct work_struct *work) > +{ > + struct uprobe *uprobe = container_of(work, struct uprobe, work); > + > + /* > + * If application munmap(exec_vma) before uprobe_unregister() > + * gets called, we don't get a chance to remove uprobe from > + * delayed_uprobe_list from remove_breakpoint(). Do it here. > + */ > + mutex_lock(&delayed_uprobe_lock); > + delayed_uprobe_remove(uprobe, NULL); > + mutex_unlock(&delayed_uprobe_lock); > + > + kfree(uprobe); > +} > + > static void uprobe_free_rcu(struct rcu_head *rcu) > { > struct uprobe *uprobe = container_of(rcu, struct uprobe, rcu); > > - kfree(uprobe); > + INIT_WORK(&uprobe->work, uprobe_free_deferred); > + schedule_work(&uprobe->work); > } This is still wrong afaics... If put_uprobe() can be called from softirq (after the next patch), then put_uprobe() and all other users of uprobes_treelock should use write_lock_bh/read_lock_bh to avoid the deadlock. To be honest... I simply can't force myself to even try to read 2/3 ;) I'll try to do this later, but I am sure I will never like it, sorry. Oleg.