Re: [PATCH] uprobes: avoid postponing return-probe SRCU lease expiration
From: Oleg Nesterov
Date: Mon Nov 16 2026 - 09:48:49 EST
On 11/15, Avi Weiss wrote:
>
> --- a/kernel/events/uprobes.c
> +++ b/kernel/events/uprobes.c
> @@ -2052,6 +2052,9 @@ static void ri_timer(struct timer_list *timer)
> */
> raw_write_seqcount_begin(&utask->ri_seqcount);
>
> + /* Pair with prepare_uretprobe() to avoid a missed rearm. */
> + smp_mb();
> +
> for_each_ret_instance_rcu(ri, utask->return_instances)
> hprobe_expire(&ri->hprobe, false);
>
> @@ -2304,7 +2307,9 @@ static void prepare_uretprobe(struct uprobe *uprobe, struct pt_regs *regs,
> ri->next = utask->return_instances;
> rcu_assign_pointer(utask->return_instances, ri);
>
> - mod_timer(&utask->ri_timer, jiffies + RI_TIMER_PERIOD);
> + /* Pair with ri_timer() after publishing the instance. */
> + smp_mb();
> + timer_reduce(&utask->ri_timer, jiffies + RI_TIMER_PERIOD);
Hmm... timer_reduce() looks a bit confusing to me, perhaps
if (!timer_pending(...))
add_timer(...);
make more sense?
Either way, I am not sure I fully understand the memory barriers... Looks
correct, but IMO the "Pair with ..." comments do not really help.
IIUC, prepare_uretprobe() needs mb() between STORE in rcu_assign_pointer()
and LOAD in timer_pending(); while ri_timer() needs mb() between STORE in
expire_timers()->detach_timer() and LOAD in for_each_ret_instance_rcu().
Right?
Oleg.