lkml.org 
[lkml]   [2021]   [Sep]   [16]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v2 01/13] perf: Ensure perf_guest_cbs aren't reloaded between !NULL check and deref
On Sat, Aug 28, 2021, Peter Zijlstra wrote:
> On Fri, Aug 27, 2021 at 05:35:46PM -0700, Sean Christopherson wrote:
> > diff --git a/kernel/events/core.c b/kernel/events/core.c
> > index 464917096e73..2126f6327321 100644
> > --- a/kernel/events/core.c
> > +++ b/kernel/events/core.c
> > @@ -6491,14 +6491,19 @@ struct perf_guest_info_callbacks *perf_guest_cbs;
> >
> > int perf_register_guest_info_callbacks(struct perf_guest_info_callbacks *cbs)
> > {
> > - perf_guest_cbs = cbs;
> > + if (WARN_ON_ONCE(perf_guest_cbs))
> > + return -EBUSY;
> > +
> > + WRITE_ONCE(perf_guest_cbs, cbs);
> > + synchronize_rcu();
>
> You're waiting for all NULL users to go away? :-) IOW, we can do without
> this synchronize_rcu() call.

Doh, right. I was thinking KVM needed to wait for in-progress NMI to exit to
ensure guest PT interrupts are handled correctly, but obviously the NMI handler
needs to exit for that CPU to get into a guest...

> > return 0;
> > }
> > EXPORT_SYMBOL_GPL(perf_register_guest_info_callbacks);
> >
> > int perf_unregister_guest_info_callbacks(struct perf_guest_info_callbacks *cbs)
> > {
> > - perf_guest_cbs = NULL;
>
> if (WARN_ON_ONCE(perf_guest_cbs != cbs))
> return -EBUSY;
>
> ?

Works for me. I guess I'm more optimistic about people not being morons :-)

\
 
 \ /
  Last update: 2021-09-16 23:43    [W:0.054 / U:0.972 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site