lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Thu, 26 Sep 2019 16:44:50 +0200
From:   Peter Zijlstra <peterz@...radead.org>
To:     Alexander Shishkin <alexander.shishkin@...ux.intel.com>
Cc:     Ingo Molnar <mingo@...hat.com>,
        Arnaldo Carvalho de Melo <acme@...hat.com>,
        linux-kernel@...r.kernel.org, jolsa@...hat.com
Subject: Re: [PATCH v1 4/6] perf: Allow using AUX data in perf samples

On Fri, Aug 09, 2019 at 03:32:39PM +0300, Alexander Shishkin wrote:
> The other problem is sampling SW events, that would require a ctx->lock
> to prevent racing with event_function_call()s from other cpus, resulting
> in somewhat cringy "if (!in_nmi()) raw_spin_lock(...)", but I don't have
> better idea as to how to handle that.

> +int perf_pmu_aux_sample_output(struct perf_event *event,
> +			       struct perf_output_handle *handle,
> +			       unsigned long size)
> +{
> +	unsigned long flags;
> +	int ret;
> +
> +	/*
> +	 * NMI vs IRQ
> +	 *
> +	 * Normal ->start()/->stop() callbacks run in IRQ mode in scheduler
> +	 * paths. If we start calling them in NMI context, they may race with
> +	 * the IRQ ones, that is, for example, re-starting an event that's just
> +	 * been stopped.
> +	 */
> +	if (!in_nmi())
> +		raw_spin_lock_irqsave(&event->ctx->lock, flags);
> +
> +	ret = event->pmu->snapshot_aux(event, handle, size);
> +
> +	if (!in_nmi())
> +		raw_spin_unlock_irqrestore(&event->ctx->lock, flags);
> +
> +	return ret;
> +}

I'm confused... would not something like:

	unsigned long flags;

	local_irq_save(flags);
	ret = event->pmu->snapshot_aux(...);
	local_irq_restore(flags);

	return ret;

Be sufficient? By disabling IRQs we already hold off remote
event_function_call()s.

Or am I misunderstanding the race here?

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ