From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C5E7A1F5614 for ; Tue, 21 Jan 2025 20:21:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737490879; cv=none; b=TzWk5kQif31jQgdT9onZ7A6KxA0eCyszzcuGnbfTvmTU5mf2wyrYSzOGAgoPUtyZg8E0a7OhOeBaag9c/chxFQiUDnzKKQs1HcgakUUc66LXmi8+xEuC7bVJGvNGkGiZ35nl3o4hbhMLzYmbidfI2W0EoDKCoYatsZg0V+i/MAA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737490879; c=relaxed/simple; bh=mTy56stzaneGfS/2Hi+zXSzLroZ0PNwj2Ce4gAzkTck=; h=Message-ID:Date:From:To:Cc:Subject; b=Nj2I+7CenT5rp1dqZ+smE/4LURcTah1TBbscAgf5C+mzQD8izKOv5BFTb7+LBR7E4eCVCTYC9Ykt8S3g8tl5vmBj2QQ0E3hEi0rBEQcx9I3vR1IlykTxiFuvBUUg9Q4Hl/AZ9v89Av4sTjCWPhMQdsFVlWICmhclywljqsSxnXg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3B392C4CEDF; Tue, 21 Jan 2025 20:21:19 +0000 (UTC) Received: from rostedt by gandalf with local (Exim 4.98) (envelope-from ) id 1taKkV-00000000L6b-07jh; Tue, 21 Jan 2025 15:21:23 -0500 Message-ID: <20250121201942.978460684@goodmis.org> User-Agent: quilt/0.68 Date: Tue, 21 Jan 2025 15:19:42 -0500 From: Steven Rostedt To: linux-kernel@vger.kernel.org Cc: Masami Hiramatsu , Mark Rutland , Mathieu Desnoyers , Andrew Morton Subject: [for-next][PATCH 0/2] ring-buffer: atomic: ring-buffer: Fix infinite recursion on some 32bit archs Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: It was reported[1] 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. [1] https://lore.kernel.org/all/86fb4f86-a0e4-45a2-a2df-3154acc4f086@gaisler.com/ git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace.git ring-buffer/for-next Head SHA1: b71b3c12081866affb87c641019473cdee8a8f8c 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(-)