From: Ravi Bangoria <ravi.bangoria@amd.com>
To: Peter Zijlstra <peterz@infradead.org>
Cc: "mingo@kernel.org" <mingo@kernel.org>,
"lucas.demarchi@intel.com" <lucas.demarchi@intel.com>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"willy@infradead.org" <willy@infradead.org>,
"acme@kernel.org" <acme@kernel.org>,
"namhyung@kernel.org" <namhyung@kernel.org>,
"mark.rutland@arm.com" <mark.rutland@arm.com>,
"alexander.shishkin@linux.intel.com"
<alexander.shishkin@linux.intel.com>,
"jolsa@kernel.org" <jolsa@kernel.org>,
"irogers@google.com" <irogers@google.com>,
"adrian.hunter@intel.com" <adrian.hunter@intel.com>,
"kan.liang@linux.intel.com" <kan.liang@linux.intel.com>,
"Bangoria, Ravikumar" <ravi.bangoria@amd.com>
Subject: Re: [PATCH 19/19] perf: Make perf_pmu_unregister() useable
Date: Mon, 25 Nov 2024 09:40:28 +0530 [thread overview]
Message-ID: <ae1f9492-dae0-4ce8-aa6b-f1890faf67e7@amd.com> (raw)
In-Reply-To: <20241104135519.715883982@infradead.org>
Hi Peter,
> @@ -6507,6 +6540,7 @@ static void perf_mmap_close(struct vm_ar
> unsigned long size = perf_data_size(rb);
> bool detach_rest = false;
>
> + /* FIXIES vs perf_pmu_unregister() */
> if (event->pmu->event_unmapped)
> event->pmu->event_unmapped(event, vma->vm_mm);
I assume you are already aware of the race between __pmu_detach_event()
and perf_mmap_close() since you have put that comment. In any case, below
sequence of operations triggers a splat when perf_mmap_close() tries to
access event->rb, event->pmu etc. which were already freed by
__pmu_detach_event().
Sequence:
Kernel Userspace
------ ---------
perf_pmu_register()
fd = perf_event_open()
p = mmap(fd)
perf_pmu_unregister()
munmap(p)
close(fd)
Splat:
BUG: kernel NULL pointer dereference, address: 0000000000000088
#PF: supervisor read access in kernel mode
#PF: error_code(0x0000) - not-present page
PGD 105f90067 P4D 105f90067 PUD 11a94a067 PMD 0
Oops: Oops: 0000 [#1] PREEMPT SMP NOPTI
CPU: 49 UID: 0 PID: 3456 Comm: perf-event-mmap Tainted: G OE 6.12.0-vanilla-dirty #273
Tainted: [O]=OOT_MODULE, [E]=UNSIGNED_MODULE
Hardware name: Dell Inc. PowerEdge R6515/07PXPY, BIOS 2.7.3 03/31/2022
RIP: 0010:perf_mmap_close+0x69/0x316
Code: [...]
RSP: 0018:ffffc90003773970 EFLAGS: 00010246
RAX: 0000000000000000 RBX: 0000000000000000 RCX: 0000000000000000
RDX: ffff888125c2d400 RSI: ffff88bf7c8a1900 RDI: ffff888125c2d400
RBP: ffff888103ccaf40 R08: 0000000000000000 R09: 0000000000000000
R10: 3030303030303030 R11: 3030303030303030 R12: ffff88811f58d080
R13: ffffc90003773a70 R14: ffffc90003773a28 R15: 00007fcc1df1d000
FS: 00007fcc1e72e6c0(0000) GS:ffff88bf7c880000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 0000000000000088 CR3: 000000010396c003 CR4: 0000000000f70ef0
PKRU: 55555554
Call Trace:
<TASK>
? __die_body.cold+0x19/0x27
? page_fault_oops+0x15a/0x2f0
? exc_page_fault+0x7e/0x180
? asm_exc_page_fault+0x26/0x30
? perf_mmap_close+0x69/0x316
remove_vma+0x2f/0x70
vms_complete_munmap_vmas+0xdc/0x190
do_vmi_align_munmap+0x1d7/0x250
do_vmi_munmap+0xd0/0x180
__vm_munmap+0xa2/0x170
? hrtimer_start_range_ns+0x26f/0x3b0
__x64_sys_munmap+0x1b/0x30
do_syscall_64+0x82/0x160
? srso_alias_return_thunk+0x5/0xfbef5
? tty_insert_flip_string_and_push_buffer+0x8d/0xc0
? srso_alias_return_thunk+0x5/0xfbef5
? remove_wait_queue+0x24/0x60
? srso_alias_return_thunk+0x5/0xfbef5
? n_tty_write+0x36f/0x520
? srso_alias_return_thunk+0x5/0xfbef5
? __wake_up+0x44/0x60
? srso_alias_return_thunk+0x5/0xfbef5
? file_tty_write.isra.0+0x20c/0x2c0
? srso_alias_return_thunk+0x5/0xfbef5
? vfs_write+0x290/0x450
? srso_alias_return_thunk+0x5/0xfbef5
? srso_alias_return_thunk+0x5/0xfbef5
? syscall_exit_to_user_mode+0x10/0x210
? srso_alias_return_thunk+0x5/0xfbef5
? do_syscall_64+0x8e/0x160
? __rseq_handle_notify_resume+0xa6/0x4e0
? __pfx_hrtimer_wakeup+0x10/0x10
? srso_alias_return_thunk+0x5/0xfbef5
? syscall_exit_to_user_mode+0x1d5/0x210
? srso_alias_return_thunk+0x5/0xfbef5
? do_syscall_64+0x8e/0x160
? exc_page_fault+0x7e/0x180
entry_SYSCALL_64_after_hwframe+0x76/0x7e
RIP: 0033:0x7fcc1e849eab
Code: [...]
RSP: 002b:00007fcc1e72de08 EFLAGS: 00000202 ORIG_RAX: 000000000000000b
RAX: ffffffffffffffda RBX: 00007fcc1e72ecdc RCX: 00007fcc1e849eab
RDX: 0000000000011000 RSI: 0000000000011000 RDI: 00007fcc1df1d000
RBP: 00007fcc1e72dec0 R08: 0000000000000000 R09: 00000000ffffffff
R10: 0000000000000000 R11: 0000000000000202 R12: 00007fcc1e72e6c0
R13: ffffffffffffff88 R14: 0000000000000000 R15: 00007ffd1a4ce000
</TASK>
next prev parent reply other threads:[~2024-11-25 4:10 UTC|newest]
Thread overview: 85+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-04 13:39 [PATCH 00/19] perf: Make perf_pmu_unregister() usable Peter Zijlstra
2024-11-04 13:39 ` [PATCH 01/19] lockdep: Fix might_fault() Peter Zijlstra
2025-03-01 20:06 ` [tip: locking/core] lockdep/mm: Fix might_fault() lockdep check of current->mm->mmap_lock tip-bot2 for Peter Zijlstra
2024-11-04 13:39 ` [PATCH 02/19] perf: Fix pmus_lock vs pmus_srcu ordering Peter Zijlstra
2025-03-01 20:07 ` [tip: perf/core] perf/core: Fix pmus_lock vs. " tip-bot2 for Peter Zijlstra
2024-11-04 13:39 ` [PATCH 03/19] perf: Fix perf_pmu_register() vs perf_init_event() Peter Zijlstra
2024-11-04 15:36 ` Uros Bizjak
2024-11-05 12:01 ` Peter Zijlstra
2025-03-01 20:07 ` [tip: perf/core] perf/core: Fix perf_pmu_register() vs. perf_init_event() tip-bot2 for Peter Zijlstra
2024-11-04 13:39 ` [PATCH 04/19] perf: Simplify perf_event_alloc() error path Peter Zijlstra
2025-03-01 20:07 ` [tip: perf/core] perf/core: Simplify the " tip-bot2 for Peter Zijlstra
2025-03-04 8:57 ` tip-bot2 for Peter Zijlstra
2025-03-06 7:57 ` [PATCH 04/19] perf: Simplify " Lai, Yi
2025-03-06 9:24 ` Ingo Molnar
2025-03-07 3:16 ` Lai, Yi
2025-03-07 11:33 ` Ingo Molnar
2024-11-04 13:39 ` [PATCH 05/19] perf: Simplify perf_pmu_register() " Peter Zijlstra
2025-03-01 20:07 ` [tip: perf/core] perf/core: Simplify the " tip-bot2 for Peter Zijlstra
2025-03-04 8:57 ` tip-bot2 for Peter Zijlstra
2024-11-04 13:39 ` [PATCH 06/19] perf: Simplify perf_pmu_register() Peter Zijlstra
2024-11-20 13:06 ` Ravi Bangoria
2024-11-20 14:46 ` Peter Zijlstra
2024-11-20 15:53 ` Ravi Bangoria
2025-03-01 20:07 ` [tip: perf/core] perf/core: " tip-bot2 for Peter Zijlstra
2025-03-04 8:57 ` tip-bot2 for Peter Zijlstra
2025-03-25 19:47 ` [PATCH 06/19] perf: " Sidhartha Kumar
2024-11-04 13:39 ` [PATCH 07/19] perf: Simplify perf_init_event() Peter Zijlstra
2025-03-01 20:07 ` [tip: perf/core] perf/core: " tip-bot2 for Peter Zijlstra
2025-03-04 8:57 ` tip-bot2 for Peter Zijlstra
2024-11-04 13:39 ` [PATCH 08/19] perf: Simplify perf_event_alloc() Peter Zijlstra
2025-03-01 20:07 ` [tip: perf/core] perf/core: " tip-bot2 for Peter Zijlstra
2025-03-04 8:57 ` tip-bot2 for Peter Zijlstra
2024-11-04 13:39 ` [PATCH 09/19] perf: Merge pmu_disable_count into cpu_pmu_context Peter Zijlstra
2025-03-01 20:07 ` [tip: perf/core] perf/core: Merge struct pmu::pmu_disable_count into struct perf_cpu_pmu_context::pmu_disable_count tip-bot2 for Peter Zijlstra
2025-03-04 8:57 ` tip-bot2 for Peter Zijlstra
2024-11-04 13:39 ` [PATCH 10/19] perf: Add this_cpc() helper Peter Zijlstra
2025-03-01 20:07 ` [tip: perf/core] perf/core: " tip-bot2 for Peter Zijlstra
2025-03-04 8:57 ` tip-bot2 for Peter Zijlstra
2024-11-04 13:39 ` [PATCH 11/19] perf: Detach perf_cpu_pmu_context and pmu lifetimes Peter Zijlstra
2025-03-03 12:29 ` [tip: perf/core] perf/core: Detach 'struct perf_cpu_pmu_context' and 'struct pmu' lifetimes tip-bot2 for Peter Zijlstra
2025-03-04 8:56 ` tip-bot2 for Peter Zijlstra
2024-11-04 13:39 ` [PATCH 12/19] perf: Introduce perf_free_addr_filters() Peter Zijlstra
2025-03-01 20:07 ` [tip: perf/core] perf/core: " tip-bot2 for Peter Zijlstra
2025-03-04 8:57 ` tip-bot2 for Peter Zijlstra
2024-11-04 13:39 ` [PATCH 13/19] perf: Robustify perf_event_free_bpf_prog() Peter Zijlstra
2025-03-01 20:07 ` [tip: perf/core] perf/bpf: " tip-bot2 for Peter Zijlstra
2025-03-04 8:57 ` tip-bot2 for Peter Zijlstra
2024-11-04 13:39 ` [PATCH 14/19] perf: Simplify perf_mmap() control flow Peter Zijlstra
2025-03-01 20:07 ` [tip: perf/core] perf/core: Simplify the " tip-bot2 for Peter Zijlstra
2025-03-04 8:57 ` tip-bot2 for Peter Zijlstra
2024-11-04 13:39 ` [PATCH 15/19] perf: Fix perf_mmap() failure path Peter Zijlstra
2025-03-01 19:17 ` Ingo Molnar
2025-03-03 12:38 ` Lorenzo Stoakes
2025-03-04 8:46 ` [tip: perf/core] perf/core: " tip-bot2 for Peter Zijlstra
2025-03-04 8:56 ` tip-bot2 for Peter Zijlstra
2024-11-04 13:39 ` [PATCH 16/19] perf: Further simplify perf_mmap() Peter Zijlstra
2025-03-01 20:07 ` [tip: perf/core] perf/core: " tip-bot2 for Peter Zijlstra
2025-03-04 8:57 ` tip-bot2 for Peter Zijlstra
2024-11-04 13:39 ` [PATCH 17/19] perf: Remove retry loop from perf_mmap() Peter Zijlstra
2025-03-01 20:07 ` [tip: perf/core] perf/core: " tip-bot2 for Peter Zijlstra
2025-03-04 8:56 ` tip-bot2 for Peter Zijlstra
2024-11-04 13:39 ` [PATCH 18/19] perf: Lift event->mmap_mutex in perf_mmap() Peter Zijlstra
2025-03-01 20:07 ` [tip: perf/core] perf/core: " tip-bot2 for Peter Zijlstra
2025-03-04 8:56 ` tip-bot2 for Peter Zijlstra
2024-11-04 13:39 ` [PATCH 19/19] perf: Make perf_pmu_unregister() useable Peter Zijlstra
2024-11-05 15:08 ` Liang, Kan
2024-11-05 15:16 ` Peter Zijlstra
2024-11-05 15:25 ` Liang, Kan
2024-11-25 4:10 ` Ravi Bangoria [this message]
2024-12-17 9:12 ` Peter Zijlstra
2024-12-17 11:52 ` Peter Zijlstra
2024-12-19 9:33 ` Ravi Bangoria
2024-12-19 10:56 ` Ravi Bangoria
2025-01-03 4:24 ` Ravi Bangoria
2025-01-17 0:03 ` Peter Zijlstra
2025-01-17 5:20 ` Ravi Bangoria
2025-01-17 8:36 ` Peter Zijlstra
2025-01-17 13:04 ` Peter Zijlstra
2025-01-17 21:04 ` Peter Zijlstra
2025-01-20 11:15 ` Ravi Bangoria
2025-01-03 4:29 ` Ravi Bangoria
2024-12-16 18:02 ` [PATCH 00/19] perf: Make perf_pmu_unregister() usable Lucas De Marchi
2025-03-01 20:00 ` Ingo Molnar
2025-03-03 3:25 ` Ravi Bangoria
2025-03-03 9:16 ` Peter Zijlstra
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ae1f9492-dae0-4ce8-aa6b-f1890faf67e7@amd.com \
--to=ravi.bangoria@amd.com \
--cc=acme@kernel.org \
--cc=adrian.hunter@intel.com \
--cc=alexander.shishkin@linux.intel.com \
--cc=irogers@google.com \
--cc=jolsa@kernel.org \
--cc=kan.liang@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=lucas.demarchi@intel.com \
--cc=mark.rutland@arm.com \
--cc=mingo@kernel.org \
--cc=namhyung@kernel.org \
--cc=peterz@infradead.org \
--cc=willy@infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®