This repository was archived by the owner on Oct 3, 2024. It is now read-only.
Commit d972fd8
perf/core: Only copy-to-user after completely unlocking all locks, v3.
We inadvertently create a dependency on mmap_sem with a whole chain.
This breaks any user who wants to take a lock and call rcu_barrier(),
while also taking that lock inside mmap_sem:
<4> [604.892532] ======================================================
<4> [604.892534] WARNING: possible circular locking dependency detected
<4> [604.892536] 5.6.0-rc7-CI-Patchwork_17096+ #1 Tainted: G U
<4> [604.892537] ------------------------------------------------------
<4> [604.892538] kms_frontbuffer/2595 is trying to acquire lock:
<4> [604.892540] ffffffff8264a558 (rcu_state.barrier_mutex){+.+.}, at: rcu_barrier+0x23/0x190
<4> [604.892547]
but task is already holding lock:
<4> [604.892547] ffff888484716050 (reservation_ww_class_mutex){+.+.}, at: i915_gem_object_pin_to_display_plane+0x89/0x270 [i915]
<4> [604.892592]
which lock already depends on the new lock.
<4> [604.892593]
the existing dependency chain (in reverse order) is:
<4> [604.892594]
-> #6 (reservation_ww_class_mutex){+.+.}:
<4> [604.892597] __ww_mutex_lock.constprop.15+0xc3/0x1090
<4> [604.892598] ww_mutex_lock+0x39/0x70
<4> [604.892600] dma_resv_lockdep+0x10e/0x1f5
<4> [604.892602] do_one_initcall+0x58/0x300
<4> [604.892604] kernel_init_freeable+0x17b/0x1dc
<4> [604.892605] kernel_init+0x5/0x100
<4> [604.892606] ret_from_fork+0x24/0x50
<4> [604.892607]
-> #5 (reservation_ww_class_acquire){+.+.}:
<4> [604.892609] dma_resv_lockdep+0xec/0x1f5
<4> [604.892610] do_one_initcall+0x58/0x300
<4> [604.892610] kernel_init_freeable+0x17b/0x1dc
<4> [604.892611] kernel_init+0x5/0x100
<4> [604.892612] ret_from_fork+0x24/0x50
<4> [604.892613]
-> #4 (&mm->mmap_sem#2){++++}:
<4> [604.892615] __might_fault+0x63/0x90
<4> [604.892617] _copy_to_user+0x1e/0x80
<4> [604.892619] perf_read+0x200/0x2b0
<4> [604.892621] vfs_read+0x96/0x160
<4> [604.892622] ksys_read+0x9f/0xe0
<4> [604.892623] do_syscall_64+0x4f/0x220
<4> [604.892624] entry_SYSCALL_64_after_hwframe+0x49/0xbe
<4> [604.892625]
-> #3 (&cpuctx_mutex){+.+.}:
<4> [604.892626] __mutex_lock+0x9a/0x9c0
<4> [604.892627] perf_event_init_cpu+0xa4/0x140
<4> [604.892629] perf_event_init+0x19d/0x1cd
<4> [604.892630] start_kernel+0x362/0x4e4
<4> [604.892631] secondary_startup_64+0xa4/0xb0
<4> [604.892631]
-> #2 (pmus_lock){+.+.}:
<4> [604.892633] __mutex_lock+0x9a/0x9c0
<4> [604.892633] perf_event_init_cpu+0x6b/0x140
<4> [604.892635] cpuhp_invoke_callback+0x9b/0x9d0
<4> [604.892636] _cpu_up+0xa2/0x140
<4> [604.892637] do_cpu_up+0x61/0xa0
<4> [604.892639] smp_init+0x57/0x96
<4> [604.892639] kernel_init_freeable+0x87/0x1dc
<4> [604.892640] kernel_init+0x5/0x100
<4> [604.892642] ret_from_fork+0x24/0x50
<4> [604.892642]
-> #1 (cpu_hotplug_lock.rw_sem){++++}:
<4> [604.892643] cpus_read_lock+0x34/0xd0
<4> [604.892644] rcu_barrier+0xaa/0x190
<4> [604.892645] kernel_init+0x21/0x100
<4> [604.892647] ret_from_fork+0x24/0x50
<4> [604.892647]
-> #0 (rcu_state.barrier_mutex){+.+.}:
<4> [604.892649] __lock_acquire+0x1328/0x15d0
<4> [604.892650] lock_acquire+0xa7/0x1c0
<4> [604.892651] __mutex_lock+0x9a/0x9c0
<4> [604.892652] rcu_barrier+0x23/0x190
<4> [604.892680] i915_gem_object_unbind+0x29d/0x3f0 [i915]
<4> [604.892707] i915_gem_object_pin_to_display_plane+0x141/0x270 [i915]
<4> [604.892737] intel_pin_and_fence_fb_obj+0xec/0x1f0 [i915]
<4> [604.892767] intel_plane_pin_fb+0x3f/0xd0 [i915]
<4> [604.892797] intel_prepare_plane_fb+0x13b/0x5c0 [i915]
<4> [604.892798] drm_atomic_helper_prepare_planes+0x85/0x110
<4> [604.892827] intel_atomic_commit+0xda/0x390 [i915]
<4> [604.892828] drm_atomic_helper_set_config+0x57/0xa0
<4> [604.892830] drm_mode_setcrtc+0x1c4/0x720
<4> [604.892830] drm_ioctl_kernel+0xb0/0xf0
<4> [604.892831] drm_ioctl+0x2e1/0x390
<4> [604.892833] ksys_ioctl+0x7b/0x90
<4> [604.892835] __x64_sys_ioctl+0x11/0x20
<4> [604.892835] do_syscall_64+0x4f/0x220
<4> [604.892836] entry_SYSCALL_64_after_hwframe+0x49/0xbe
<4> [604.892837]
Changes since v1:
- Use (*values)[n++] in perf_read_one().
Changes since v2:
- Centrally allocate values.
Signed-off-by: Maarten Lankhorst <[email protected]>
Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
Signed-off-by: Rodrigo Vivi <[email protected]>1 parent ee5bc23 commit d972fd8
1 file changed
+25
-24
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5500 | 5500 | | |
5501 | 5501 | | |
5502 | 5502 | | |
5503 | | - | |
| 5503 | + | |
| 5504 | + | |
5504 | 5505 | | |
5505 | 5506 | | |
5506 | 5507 | | |
5507 | 5508 | | |
5508 | | - | |
5509 | 5509 | | |
5510 | 5510 | | |
5511 | 5511 | | |
5512 | | - | |
5513 | | - | |
5514 | | - | |
5515 | | - | |
5516 | | - | |
| 5512 | + | |
5517 | 5513 | | |
5518 | 5514 | | |
5519 | 5515 | | |
| |||
5531 | 5527 | | |
5532 | 5528 | | |
5533 | 5529 | | |
5534 | | - | |
5535 | | - | |
5536 | 5530 | | |
5537 | | - | |
5538 | | - | |
5539 | | - | |
5540 | | - | |
5541 | 5531 | | |
5542 | 5532 | | |
5543 | | - | |
5544 | | - | |
5545 | 5533 | | |
5546 | 5534 | | |
5547 | 5535 | | |
5548 | 5536 | | |
5549 | | - | |
| 5537 | + | |
| 5538 | + | |
5550 | 5539 | | |
5551 | 5540 | | |
5552 | | - | |
5553 | 5541 | | |
5554 | 5542 | | |
5555 | 5543 | | |
| |||
5562 | 5550 | | |
5563 | 5551 | | |
5564 | 5552 | | |
5565 | | - | |
5566 | | - | |
5567 | | - | |
5568 | 5553 | | |
5569 | 5554 | | |
5570 | 5555 | | |
| |||
5585 | 5570 | | |
5586 | 5571 | | |
5587 | 5572 | | |
5588 | | - | |
| 5573 | + | |
| 5574 | + | |
5589 | 5575 | | |
5590 | 5576 | | |
5591 | 5577 | | |
| |||
5603 | 5589 | | |
5604 | 5590 | | |
5605 | 5591 | | |
5606 | | - | |
| 5592 | + | |
5607 | 5593 | | |
5608 | | - | |
| 5594 | + | |
5609 | 5595 | | |
5610 | 5596 | | |
5611 | 5597 | | |
| |||
5615 | 5601 | | |
5616 | 5602 | | |
5617 | 5603 | | |
| 5604 | + | |
| 5605 | + | |
5618 | 5606 | | |
5619 | 5607 | | |
5620 | 5608 | | |
5621 | 5609 | | |
5622 | 5610 | | |
5623 | 5611 | | |
| 5612 | + | |
| 5613 | + | |
| 5614 | + | |
| 5615 | + | |
| 5616 | + | |
| 5617 | + | |
| 5618 | + | |
5624 | 5619 | | |
5625 | | - | |
| 5620 | + | |
5626 | 5621 | | |
5627 | 5622 | | |
| 5623 | + | |
| 5624 | + | |
| 5625 | + | |
| 5626 | + | |
| 5627 | + | |
| 5628 | + | |
5628 | 5629 | | |
5629 | 5630 | | |
5630 | 5631 | | |
| |||
0 commit comments