Re: [PATCH perf/core] uprobes: remove too strict lockdep_assert() condition in hprobe_expire()

From: Oleg Nesterov
Date: Wed Feb 26 2025 - 06:31:22 EST


On 02/25, Andrii Nakryiko wrote:
>
> --- a/kernel/events/uprobes.c
> +++ b/kernel/events/uprobes.c
> @@ -762,10 +762,14 @@ static struct uprobe *hprobe_expire(struct hprobe *hprobe, bool get)
> enum hprobe_state hstate;
>
> /*
> - * return_instance's hprobe is protected by RCU.
> - * Underlying uprobe is itself protected from reuse by SRCU.
> + * Caller should guarantee that return_instance is not going to be
> + * freed from under us. This can be achieved either through holding
> + * rcu_read_lock() or by owning return_instance in the first place.
> + *
> + * Underlying uprobe is itself protected from reuse by SRCU, so ensure
> + * SRCU lock is held properly.
> */
> - lockdep_assert(rcu_read_lock_held() && srcu_read_lock_held(&uretprobes_srcu));
> + lockdep_assert(srcu_read_lock_held(&uretprobes_srcu));

Reviewed-by: Oleg Nesterov <oleg@xxxxxxxxxx>