Revision 321027c1fe77f892f4ea07846aeae08cefbbb290 authored by Peter Zijlstra on 11 January 2017, 20:09:50 UTC, committed by Ingo Molnar on 14 January 2017, 09:56:11 UTC
Di Shen reported a race between two concurrent sys_perf_event_open()
calls where both try and move the same pre-existing software group
into a hardware context.

The problem is exactly that described in commit:

  f63a8daa5812 ("perf: Fix event->ctx locking")

... where, while we wait for a ctx->mutex acquisition, the event->ctx
relation can have changed under us.

That very same commit failed to recognise sys_perf_event_context() as an
external access vector to the events and thereby didn't apply the
established locking rules correctly.

So while one sys_perf_event_open() call is stuck waiting on
mutex_lock_double(), the other (which owns said locks) moves the group
about. So by the time the former sys_perf_event_open() acquires the
locks, the context we've acquired is stale (and possibly dead).

Apply the established locking rules as per perf_event_ctx_lock_nested()
to the mutex_lock_double() for the 'move_group' case. This obviously means
we need to validate state after we acquire the locks.

Reported-by: Di Shen (Keen Lab)
Tested-by: John Dias <joaodias@google.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Arnaldo Carvalho de Melo <acme@kernel.org>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Kees Cook <keescook@chromium.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Min Chong <mchong@google.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Vince Weaver <vincent.weaver@maine.edu>
Fixes: f63a8daa5812 ("perf: Fix event->ctx locking")
Link: http://lkml.kernel.org/r/20170106131444.GZ3174@twins.programming.kicks-ass.net
Signed-off-by: Ingo Molnar <mingo@kernel.org>
1 parent 63cae12
History
File Mode Size
bridge
i2c
ttm
ati_pcigart.h -rw-r--r-- 692 bytes
drmP.h -rw-r--r-- 25.2 KB
drm_agpsupport.h -rw-r--r-- 3.8 KB
drm_atomic.h -rw-r--r-- 14.1 KB
drm_atomic_helper.h -rw-r--r-- 10.4 KB
drm_auth.h -rw-r--r-- 2.2 KB
drm_blend.h -rw-r--r-- 2.6 KB
drm_bridge.h -rw-r--r-- 7.8 KB
drm_cache.h -rw-r--r-- 1.7 KB
drm_color_mgmt.h -rw-r--r-- 2.1 KB
drm_connector.h -rw-r--r-- 27.9 KB
drm_crtc.h -rw-r--r-- 28.3 KB
drm_crtc_helper.h -rw-r--r-- 3.2 KB
drm_debugfs_crc.h -rw-r--r-- 2.6 KB
drm_displayid.h -rw-r--r-- 2.8 KB
drm_dp_dual_mode_helper.h -rw-r--r-- 4.4 KB
drm_dp_helper.h -rw-r--r-- 29.9 KB
drm_dp_mst_helper.h -rw-r--r-- 15.9 KB
drm_drv.h -rw-r--r-- 14.5 KB
drm_edid.h -rw-r--r-- 14.0 KB
drm_encoder.h -rw-r--r-- 8.0 KB
drm_encoder_slave.h -rw-r--r-- 6.4 KB
drm_fb_cma_helper.h -rw-r--r-- 1.9 KB
drm_fb_helper.h -rw-r--r-- 14.8 KB
drm_fixed.h -rw-r--r-- 4.7 KB
drm_flip_work.h -rw-r--r-- 3.0 KB
drm_fourcc.h -rw-r--r-- 2.7 KB
drm_framebuffer.h -rw-r--r-- 9.4 KB
drm_gem.h -rw-r--r-- 7.9 KB
drm_gem_cma_helper.h -rw-r--r-- 2.2 KB
drm_global.h -rw-r--r-- 2.0 KB
drm_hashtab.h -rw-r--r-- 3.1 KB
drm_irq.h -rw-r--r-- 6.2 KB
drm_legacy.h -rw-r--r-- 6.8 KB
drm_mem_util.h -rw-r--r-- 2.4 KB
drm_mipi_dsi.h -rw-r--r-- 10.1 KB
drm_mm.h -rw-r--r-- 11.2 KB
drm_mode_config.h -rw-r--r-- 23.2 KB
drm_mode_object.h -rw-r--r-- 4.8 KB
drm_modes.h -rw-r--r-- 16.7 KB
drm_modeset_helper.h -rw-r--r-- 1.5 KB
drm_modeset_helper_vtables.h -rw-r--r-- 40.2 KB
drm_modeset_lock.h -rw-r--r-- 4.1 KB
drm_of.h -rw-r--r-- 2.0 KB
drm_os_linux.h -rw-r--r-- 2.2 KB
drm_panel.h -rw-r--r-- 6.9 KB
drm_pciids.h -rw-r--r-- 66.4 KB
drm_plane.h -rw-r--r-- 19.0 KB
drm_plane_helper.h -rw-r--r-- 3.1 KB
drm_print.h -rw-r--r-- 3.2 KB
drm_property.h -rw-r--r-- 11.2 KB
drm_rect.h -rw-r--r-- 5.0 KB
drm_simple_kms_helper.h -rw-r--r-- 4.0 KB
drm_sysfs.h -rw-r--r-- 300 bytes
drm_vma_manager.h -rw-r--r-- 7.7 KB
gma_drm.h -rw-r--r-- 1.0 KB
i915_component.h -rw-r--r-- 4.1 KB
i915_drm.h -rw-r--r-- 3.5 KB
i915_pciids.h -rw-r--r-- 12.3 KB
intel-gtt.h -rw-r--r-- 941 bytes

back to top