From nobody Sat Nov 23 09:33:50 2024 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 B5CE923098E for ; Thu, 21 Nov 2024 02:10:16 +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=1732155016; cv=none; b=F7pKEpR/a7XiPdpdKE/tVUu05EZB3ekNLOPJ8AXZ9CSrQOtJkZ8rq5DB62K34ZkAZUOiABXO6Inr3et9yY0Ql/5V6Ze0IluIYUHDGQUb6E2tRPqhXKiQek+26SC4RWUUtJeofvsYuJgpKWoEYY7Gbm/nFbxgNlE+FCYsqO/TWaY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732155016; c=relaxed/simple; bh=BdDrSsbgvrK7uSMlaoRE3Ct9mpLRzFKAgwFn+eQCwE0=; h=Date:From:To:Cc:Subject:Message-ID:MIME-Version:Content-Type; b=lqbmT2BnlkoxUSSeOZ4RTfmbFhk+dm5k0/fTlbO624agAf8spYppJAP0z1NbEzggJOF+CD0pa21ioaHg22euSfdAY3pGcsXr+wcfAdGtZn7jZRR8qfyzRsGeiQZyKBM07Uj20kHLtLspLdsz66PBXOro5Qv/AS/pGB/kG7O/57M= 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 8868EC4CECD; Thu, 21 Nov 2024 02:10:15 +0000 (UTC) Date: Wed, 20 Nov 2024 21:10:51 -0500 From: Steven Rostedt To: LKML Cc: Masami Hiramatsu , Mark Rutland , Mathieu Desnoyers , guoweikang Subject: [for-next][PATCH] ftrace: Fix regression with module command in stack_trace_filter Message-ID: <20241120211051.6d085095@gandalf.local.home> X-Mailer: Claws Mail 3.20.0git84 (GTK+ 2.24.33; x86_64-pc-linux-gnu) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace.git trace/for-next Head SHA1: 45af52e7d3b8560f21d139b3759735eead8b1653 guoweikang (1): ftrace: Fix regression with module command in stack_trace_filter ---- kernel/trace/ftrace.c | 3 +++ 1 file changed, 3 insertions(+) --------------------------- commit 45af52e7d3b8560f21d139b3759735eead8b1653 Author: guoweikang Date: Wed Nov 20 13:27:49 2024 +0800 ftrace: Fix regression with module command in stack_trace_filter =20 When executing the following command: =20 # echo "write*:mod:ext3" > /sys/kernel/tracing/stack_trace_filter =20 The current mod command causes a null pointer dereference. While commit 0f17976568b3f ("ftrace: Fix regression with module command in stack_tra= ce_filter") has addressed part of the issue, it left a corner case unhandled, which= still results in a kernel crash. =20 Cc: stable@vger.kernel.org Cc: Masami Hiramatsu Cc: Mark Rutland Cc: Mathieu Desnoyers Link: https://lore.kernel.org/20241120052750.275463-1-guoweikang.kernel= @gmail.com Fixes: 04ec7bb642b77 ("tracing: Have the trace_array hold the list of r= egistered func probes"); Signed-off-by: guoweikang Signed-off-by: Steven Rostedt (Google) diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c index 4c28dd177ca6..5ff0822342ac 100644 --- a/kernel/trace/ftrace.c +++ b/kernel/trace/ftrace.c @@ -5076,6 +5076,9 @@ ftrace_mod_callback(struct trace_array *tr, struct ft= race_hash *hash, char *func; int ret; =20 + if (!tr) + return -ENODEV; + /* match_records() modifies func, and we need the original */ func =3D kstrdup(func_orig, GFP_KERNEL); if (!func)