On 09/13, Jiri Olsa wrote:
>
> On Fri, Sep 13, 2024 at 12:57:51PM +0200, Oleg Nesterov wrote:
>
> > static void handler_chain(struct uprobe *uprobe, struct pt_regs *regs)
> > {
> >     ...
> >     struct return_instance *ri = NULL;
> >     int push_idx = 0;
> >
> >     list_for_each_entry_rcu(uc, &uprobe->consumers, cons_node, 
> > rcu_read_lock_trace_held()) {
> >             __u64 cookie = 0;
> >             int rc = 0;
> >
> >             if (uc->handler)
> >                     rc = uc->handler(uc, regs, &cookie);
> >
> >             remove &= rc;
> >             has_consumers = true;
> >
> >             if (!uc->ret_handler || rc == UPROBE_HANDLER_REMOVE || rc == 2)
> >                     continue;
> >
> >             if (!ri)
> >                     ri = alloc_return_instance();
> >
> >             // or, better if (rc = UPROBE_HANDLER_I_WANT_MY_COOKIE)
> >             if (uc->handler))
> >                     ri = push_id_cookie(ri, push_idx++, uc->id, cookie);
> >     }
> >
> >     if (!ZERO_OR_NULL_PTR(ri)) {
>
> should we rather bail out right after we fail to allocate ri above?

I think handler_chain() should call all the ->handler's even if
kzalloc/krealloc fails.

This is close to what the current code does, all the ->handler's are
called even if then later prepare_uretprobe()->kmalloc() fails.

Oleg.


Reply via email to