> On 6/30/20 2:49 PM, Lorenzo Bianconi wrote:
> [...]

[...]

> >     old_rcpu = xchg(&cmap->cpu_map[key_cpu], rcpu);
> >     if (old_rcpu) {
> > +           if (old_rcpu->prog)
> > +                   bpf_prog_put(old_rcpu->prog);
> >             call_rcu(&old_rcpu->rcu, __cpu_map_entry_free);
> >             INIT_WORK(&old_rcpu->kthread_stop_wq, cpu_map_kthread_stop);
> >             schedule_work(&old_rcpu->kthread_stop_wq);
> 
> Hm, not quite sure I follow the logic here. Why is the bpf_prog_put() not 
> placed inside
> __cpu_map_entry_free(), for example? Wouldn't this at least leave a potential 
> small race
> window of UAF given the rest is still live? If we already piggy-back from RCU 
> side on
> rcpu entry, why not having it in __cpu_map_entry_free()?

ack right, thanks for spotting this issue. I guess we can even move
"bpf_prog_put(rcpu->prog)" in put_cpu_map_entry() so the last consumer
of bpf_cpu_map_entry will free the attached program. Agree?

Regards,
Lorenzo

> 
> Thanks,
> Daniel

Attachment: signature.asc
Description: PGP signature

Reply via email to