Skip to content

Commit 468f21f

Browse files
ring-buffer: Do not allow events in NMI with generic atomic64 cmpxchg()
JIRA: https://issues.redhat.com/browse/RHEL-86682 commit cd2375a Author: Steven Rostedt <[email protected]> Date: Mon Jan 20 18:56:56 2025 -0500 ring-buffer: Do not allow events in NMI with generic atomic64 cmpxchg() Some architectures can not safely do atomic64 operations in NMI context. Since the ring buffer relies on atomic64 operations to do its time keeping, if an event is requested in NMI context, reject it for these architectures. Cc: [email protected] Cc: Mark Rutland <[email protected]> Cc: Mathieu Desnoyers <[email protected]> Cc: Andrew Morton <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Thomas Gleixner <[email protected]> Cc: Linus Torvalds <[email protected]> Cc: Andreas Larsson <[email protected]> Link: https://lore.kernel.org/[email protected] Fixes: c84897c ("ring-buffer: Remove 32bit timestamp logic") Closes: https://lore.kernel.org/all/[email protected]/ Reported-by: Ludwig Rydberg <[email protected]> Reviewed-by: Masami Hiramatsu (Google) <[email protected]> Signed-off-by: Steven Rostedt (Google) <[email protected]> Signed-off-by: Jerome Marchand <[email protected]>
1 parent 327bff6 commit 468f21f

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

kernel/trace/ring_buffer.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4398,8 +4398,13 @@ rb_reserve_next_event(struct trace_buffer *buffer,
43984398
int nr_loops = 0;
43994399
int add_ts_default;
44004400

4401-
/* ring buffer does cmpxchg, make sure it is safe in NMI context */
4402-
if (!IS_ENABLED(CONFIG_ARCH_HAVE_NMI_SAFE_CMPXCHG) &&
4401+
/*
4402+
* ring buffer does cmpxchg as well as atomic64 operations
4403+
* (which some archs use locking for atomic64), make sure this
4404+
* is safe in NMI context
4405+
*/
4406+
if ((!IS_ENABLED(CONFIG_ARCH_HAVE_NMI_SAFE_CMPXCHG) ||
4407+
IS_ENABLED(CONFIG_GENERIC_ATOMIC64)) &&
44034408
(unlikely(in_nmi()))) {
44044409
return NULL;
44054410
}

0 commit comments

Comments
 (0)