From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 C8AA52D0C94; Sat, 12 Sep 2026 19:36:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789241794; cv=none; b=rcUtEiBxabvDT4pm24WiIU1vmjiaD1RiG796wFo91otOlRmOKDbAhD51Xx471xxLdZopILDA4Q2korB4vi0H6jplz+ejIGXEFZh1We58WkiwCVFQavtHLQ0tpEa5D0oBp4Iwn81wo5zXzlLaLF202c19Ijsujsuk/Yq7zU2+PQc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789241794; c=relaxed/simple; bh=RuFsW0wXudKnQ76Y83o0mKPASdHiXVStEu1a0LLDK9Q=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=b+lPSfPjKmMzuaRpyQ+9Y52QIx9O3Hs/4iPwuo+66AFPF5K0ReZO7lkOAxMDDWhnJRMf1ojUjmIXu66Es3cREGaS25GKwclzVI7fH3oEhDK/gWh+nhCcWZDwEh/xTHbD6nJOt6DfMomoTmoB8q4/bv9CDk+g9LTRZAdFNXpLNlw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=W3To4wTu; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="W3To4wTu" Received: by smtp.kernel.org (Postfix) with ESMTPSA id CC18D1F000FF; Sat, 12 Sep 2026 19:36:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1789241793; bh=JfBThHVW4Wi/kxG0xYwfMtYdBWAjLiIqBng/OelvM5g=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=W3To4wTuPLkZUz+hfSYVEziuKWAK6AI4sXvApgIpJFoSz/yeV7/+G3BZN0b+fOKMO ptgE2iDlNu/FB7PgZiZhXKEw++uX8Gg7djMCL1LTPPblMqcgbtnohOtjvtPMSgcKGg mL3ZGLxI7V4YL1B5G5sHVJkM+ef7h6g3EFa8XvWo= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, "Masami Hiramatsu (Google)" , Steven Rostedt , Alexander Martyniuk , Sasha Levin Subject: [PATCH 5.10 210/798] tracing/mmiotrace: Add NULL check for mmio_trace_array in logging functions Date: Sat, 12 Sep 2026 08:57:18 +0200 Message-ID: <20260912065521.914447263@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260912065516.948645775@linuxfoundation.org> References: <20260912065516.948645775@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 5.10-stable review patch. If anyone has any objections, please let me know. ------------------ From: Masami Hiramatsu (Google) commit 12b80cdbc54cf615b4717a4e8180063408091ea2 upstream. mmio_trace_rw() and mmio_trace_mapping() retrieve mmio_trace_array into tr and pass it to __trace_mmiotrace_rw() and __trace_mmiotrace_map(). If these functions are invoked while mmio_trace_array is NULL (e.g. before initialization or after disabled), accessing tr->array_buffer.buffer will result in a NULL pointer dereference crash. Fix this by adding an explicit NULL check for tr at the beginning of __trace_mmiotrace_rw() and __trace_mmiotrace_map(). Link: https://patch.msgid.link/178524300062.56416.8362487250709962380.stgit@devnote2 Fixes: f984b51e0779 ("ftrace: add mmiotrace plugin") Assisted-by: Antigravity:gemini-3.6-flash Signed-off-by: Masami Hiramatsu (Google) Signed-off-by: Steven Rostedt Signed-off-by: Alexander Martyniuk Signed-off-by: Sasha Levin --- kernel/trace/trace_mmiotrace.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/kernel/trace/trace_mmiotrace.c b/kernel/trace/trace_mmiotrace.c index 55ba76bea98b1..ce45c5ee5227e 100644 --- a/kernel/trace/trace_mmiotrace.c +++ b/kernel/trace/trace_mmiotrace.c @@ -297,11 +297,15 @@ static void __trace_mmiotrace_rw(struct trace_array *tr, struct mmiotrace_rw *rw) { struct trace_event_call *call = &event_mmiotrace_rw; - struct trace_buffer *buffer = tr->array_buffer.buffer; + struct trace_buffer *buffer; struct ring_buffer_event *event; struct trace_mmiotrace_rw *entry; int pc = preempt_count(); + if (!tr) + return; + + buffer = tr->array_buffer.buffer; event = trace_buffer_lock_reserve(buffer, TRACE_MMIO_RW, sizeof(*entry), 0, pc); if (!event) { @@ -325,11 +329,15 @@ static void __trace_mmiotrace_map(struct trace_array *tr, struct mmiotrace_map *map) { struct trace_event_call *call = &event_mmiotrace_map; - struct trace_buffer *buffer = tr->array_buffer.buffer; + struct trace_buffer *buffer; struct ring_buffer_event *event; struct trace_mmiotrace_map *entry; int pc = preempt_count(); + if (!tr) + return; + + buffer = tr->array_buffer.buffer; event = trace_buffer_lock_reserve(buffer, TRACE_MMIO_MAP, sizeof(*entry), 0, pc); if (!event) { -- 2.53.0