[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v3 01/16] perf: Ensure perf_guest_cbs aren't reloaded between !NULL check and deref
- To: Paolo Bonzini <pbonzini@xxxxxxxxxx>
- From: Sean Christopherson <seanjc@xxxxxxxxxx>
- Date: Thu, 11 Nov 2021 00:39:52 +0000
- Cc: Like Xu <like.xu.linux@xxxxxxxxx>, Peter Zijlstra <peterz@xxxxxxxxxxxxx>, Will Deacon <will@xxxxxxxxxx>, Alexander Shishkin <alexander.shishkin@xxxxxxxxxxxxxxx>, Jiri Olsa <jolsa@xxxxxxxxxx>, Namhyung Kim <namhyung@xxxxxxxxxx>, James Morse <james.morse@xxxxxxx>, Alexandru Elisei <alexandru.elisei@xxxxxxx>, Suzuki K Poulose <suzuki.poulose@xxxxxxx>, Vitaly Kuznetsov <vkuznets@xxxxxxxxxx>, Wanpeng Li <wanpengli@xxxxxxxxxxx>, Jim Mattson <jmattson@xxxxxxxxxx>, Joerg Roedel <joro@xxxxxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, linux-arm-kernel@xxxxxxxxxxxxxxxxxxx, linux-perf-users@xxxxxxxxxxxxxxx, linux-kernel@xxxxxxxxxxxxxxx, kvmarm@xxxxxxxxxxxxxxxxxxxxx, linux-csky@xxxxxxxxxxxxxxx, linux-riscv@xxxxxxxxxxxxxxxxxxx, kvm@xxxxxxxxxxxxxxx, xen-devel@xxxxxxxxxxxxxxxxxxxx, Artem Kashkanov <artem.kashkanov@xxxxxxxxx>, Zhu Lingshan <lingshan.zhu@xxxxxxxxx>, Juergen Gross <jgross@xxxxxxxx>, Ingo Molnar <mingo@xxxxxxxxxx>, Albert Ou <aou@xxxxxxxxxxxxxxxxx>, Palmer Dabbelt <palmer@xxxxxxxxxxx>, Vincent Chen <deanbo422@xxxxxxxxx>, Paul Walmsley <paul.walmsley@xxxxxxxxxx>, Greentime Hu <green.hu@xxxxxxxxx>, Boris Ostrovsky <boris.ostrovsky@xxxxxxxxxx>, Marc Zyngier <maz@xxxxxxxxxx>, Nick Hu <nickhu@xxxxxxxxxxxxx>, Guo Ren <guoren@xxxxxxxxxx>, Mark Rutland <mark.rutland@xxxxxxx>, Arnaldo Carvalho de Melo <acme@xxxxxxxxxx>
- Delivery-date: Thu, 11 Nov 2021 00:40:19 +0000
- List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
On Wed, Nov 10, 2021, Paolo Bonzini wrote:
> On 11/4/21 15:18, Sean Christopherson wrote:
> > If I'm interpeting Paolo's suggestion
> > correctly, he's pointing out that oustanding stores to the function
> > pointers in
> > @cbs need to complete before assigning a non-NULL pointer to perf_guest_cbs,
> > otherwise a perf event handler may see a valid pointer with half-baked
> > callbacks.
> >
> > I think smp_store_release() with a comment would be appropriate, assuming my
> > above interpretation is correct.
> >
>
> Yes, exactly. It should even be rcu_assign_pointer(), matching the
> synchronize_rcu()
And perf_guest_cbs should be tagged __rcu and accessed accordingly. Which is
effectively what this version (poorly) implemented with a homebrewed mix of
{READ,WRITE}_ONCE, lockdep(), and synchronize_rcu().
> in patch 1 (and the change can be done in patch 1, too).
Ya, the change needs to go into patch 1.
|