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 A54F153A7; Fri, 6 Dec 2024 15:24:52 +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=1733498692; cv=none; b=dHcfq4a4ND9QwLotwvWxawJPsCpDQkPR3hk++1043eHh9DyM9kp6c3GUbUQ3XvYeCoel6St0qFaMCxGHQkH/9W5fUsUXksIWBtuMKygPeJyN1op42QhB+zKlZCqDeMxRM45myfTdZjvW6hyoamYyFg17699Rprky84gQJybr8/U= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733498692; c=relaxed/simple; bh=m5Ojzxg31GB8kHo673QcSSg/bXCsZcDT6wSRAcHQL9w=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=rINhOT4a4whUbkYbBbyibmOgLkN8f/Ax1ifFhwNSfknxMTZMfaFjA2FJHIUZdPDbiCQy7xszMWZGZLbdFQ0DwV0vCfrJ6AQkFhhJxOEgrikx6y84AVgd3+Dh1SQ+3QHooQAttaiHqRHK4syYB9gcca3M1qTirSjlL4U2936bsRE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=k+eh/kAO; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="k+eh/kAO" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 14321C4CED1; Fri, 6 Dec 2024 15:24:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1733498692; bh=m5Ojzxg31GB8kHo673QcSSg/bXCsZcDT6wSRAcHQL9w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=k+eh/kAOpYy7v0MIuWSuZduwvURKseuPdAl6pHIJ4yaK4PDsW7W14UY7zODxE6AA6 5vpco8gvP+bLeapYVuZVGHbmWuIbdby287FN5yrqq5UzsHsrrBf3CHayQtSyUeiHZl NXZ47+C3FsAhF38z6wCvUt22I547oBZKudwJvhGI= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Masami Hiramatsu , Mark Rutland , Mathieu Desnoyers , guoweikang , "Steven Rostedt (Google)" Subject: [PATCH 6.6 628/676] ftrace: Fix regression with module command in stack_trace_filter Date: Fri, 6 Dec 2024 15:37:27 +0100 Message-ID: <20241206143717.898491392@linuxfoundation.org> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20241206143653.344873888@linuxfoundation.org> References: <20241206143653.344873888@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: guoweikang commit 45af52e7d3b8560f21d139b3759735eead8b1653 upstream. When executing the following command: # echo "write*:mod:ext3" > /sys/kernel/tracing/stack_trace_filter The current mod command causes a null pointer dereference. While commit 0f17976568b3f ("ftrace: Fix regression with module command in stack_trace_filter") has addressed part of the issue, it left a corner case unhandled, which still results in a kernel crash. 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 registered func probes"); Signed-off-by: guoweikang Signed-off-by: Steven Rostedt (Google) Signed-off-by: Greg Kroah-Hartman --- kernel/trace/ftrace.c | 3 +++ 1 file changed, 3 insertions(+) --- a/kernel/trace/ftrace.c +++ b/kernel/trace/ftrace.c @@ -4562,6 +4562,9 @@ ftrace_mod_callback(struct trace_array * char *func; int ret; + if (!tr) + return -ENODEV; + /* match_records() modifies func, and we need the original */ func = kstrdup(func_orig, GFP_KERNEL); if (!func)