linux-trace-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Steven Rostedt <rostedt@goodmis.org>
To: linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org
Cc: Masami Hiramatsu <mhiramat@kernel.org>,
	Mark Rutland <mark.rutland@arm.com>,
	Mathieu Desnoyers <mathieu.desnoyers@efficios.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	Peter Zijlstra <peterz@infradead.org>,
	Thomas Gleixner <tglx@linutronix.de>,
	Linus Torvalds <torvalds@linux-foundation.org>,
	Ludwig Rydberg <ludwig.rydberg@gaisler.com>,
	Andreas Larsson <andreas@gaisler.com>
Subject: [PATCH 0/2] lib/atomic64: ring-buffer: Fix infinite recursion on some 32bit archs
Date: Mon, 20 Jan 2025 18:56:55 -0500	[thread overview]
Message-ID: <20250120235655.144537620@goodmis.org> (raw)

It was reported that the tracing ring buffer code would cause an infinite
recursion and crash on risc32 and sparc32 architectures. The reason is that
they use the generic atomic64 operations which call raw_spin_locks. As
raw_spin_locks can be traced this would cause an infinite recursion, because
the atomic64 operations call raw_spin_locks. Instead, the generic atomic64
operations should be calling arch_spin_locks as this is architecture
specific implementation and the locks that are taken should never have any
other locks taken while they are held, and are always taking with interrupts
disabled. This means they do not need to be tested by lockdep either.

Another issue was that locks should not be taken in NMI context and the ring
buffer can be called in NMI. If the arch uses the generic atomic64
operations, do not allow events to be recorded in NMI as the atomic64
operations are not safe in NMI context.

Steven Rostedt (2):
      ring-buffer: Do not allow events in NMI with generic atomic64 cmpxchg()
      atomic64: Use arch_spin_locks instead of raw_spin_locks

----
 kernel/trace/ring_buffer.c |  9 ++++--
 lib/atomic64.c             | 78 ++++++++++++++++++++++++++++------------------
 2 files changed, 55 insertions(+), 32 deletions(-)

             reply	other threads:[~2025-01-20 23:57 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-01-20 23:56 Steven Rostedt [this message]
2025-01-20 23:56 ` [PATCH 1/2] ring-buffer: Do not allow events in NMI with generic atomic64 cmpxchg() Steven Rostedt
2025-01-21  7:59   ` Masami Hiramatsu
2025-01-20 23:56 ` [PATCH 2/2] atomic64: Use arch_spin_locks instead of raw_spin_locks Steven Rostedt
2025-01-21  8:04   ` Masami Hiramatsu

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=20250120235655.144537620@goodmis.org \
    --to=rostedt@goodmis.org \
    --cc=akpm@linux-foundation.org \
    --cc=andreas@gaisler.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-trace-kernel@vger.kernel.org \
    --cc=ludwig.rydberg@gaisler.com \
    --cc=mark.rutland@arm.com \
    --cc=mathieu.desnoyers@efficios.com \
    --cc=mhiramat@kernel.org \
    --cc=peterz@infradead.org \
    --cc=tglx@linutronix.de \
    --cc=torvalds@linux-foundation.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;
as well as URLs for NNTP newsgroup(s).