From nobody Sat Feb 7 21:24:16 2026 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 1545012E5D for ; Wed, 2 Apr 2025 02:22:32 +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=1743560553; cv=none; b=U9DE0XbEXcbObsUahIojS5bb2HufTmYIYmwpjbg3+jEqyRJ59gcr+CffOEcR4vWP086svYebgmSVbDrz1eORygcaVVheNpHqTwWUMQRFuMgMkGlPgdFyPHGhNFzlK9HLZ/Xfxoobt0oOxVrGIETCSMeGabnf6Ww8NZlK0pxZdIo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743560553; c=relaxed/simple; bh=F3Pet1LG0fVFF9SVj7fZj8Tnxdw0TQPXJ67sTcw2Iys=; h=Message-ID:Date:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=BxoSGzPuZ2sTlKVqBii8nTCikwtCKsHxfRku1BiJFpTHkmKg4mGY1aZ+Gn26giXZduR70C2VMuJoKEG4ALEhChYXsMMK0YoxFHjOkrgFQ8D5oISoRfk3dXlK5gIPon9KEXxGpnIZ4LVmIZ8ZT4aEwYbxraOwYOXMv5tI5DqFe5k= 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 93DADC4CEEE; Wed, 2 Apr 2025 02:22:32 +0000 (UTC) Received: from rostedt by gandalf with local (Exim 4.98) (envelope-from ) id 1tznlO-00000006MNM-3VBD; Tue, 01 Apr 2025 22:23:34 -0400 Message-ID: <20250402022334.683869963@goodmis.org> User-Agent: quilt/0.68 Date: Tue, 01 Apr 2025 22:23:09 -0400 From: Steven Rostedt To: linux-kernel@vger.kernel.org Cc: Masami Hiramatsu , Mark Rutland , Mathieu Desnoyers , Andrew Morton , Leon Romanovsky , Christian Loehle Subject: [for-linus][PATCH 1/4] ftrace: Have tracing function args depend on PROBE_EVENTS_BTF_ARGS References: <20250402022308.372786127@goodmis.org> 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" From: Steven Rostedt The option PROBE_EVENTS_BTF_ARGS enables the functions btf_find_func_proto() and btf_get_func_param() which are used by the function argument tracing code. The option FUNCTION_TRACE_ARGS was dependent on the same configs that PROBE_EVENTS_BTF_ARGS was dependent on, but it was also dependent on PROBE_EVENTS_BTF_ARGS. In fact, if PROBE_EVENTS_BTF_ARGS is supported then FUNCTION_TRACE_ARGS is supported. Just make FUNCTION_TRACE_ARGS depend on PROBE_EVENTS_BTF_ARGS. Cc: Masami Hiramatsu Cc: Mathieu Desnoyers Cc: Mark Rutland Cc: Leon Romanovsky Link: https://lore.kernel.org/20250401113601.17fa1129@gandalf.local.home Fixes: 533c20b062d7c ("ftrace: Add print_function_args()") Closes: https://lore.kernel.org/all/DB9PR08MB75820599801BAD118D123D7D93AD2@= DB9PR08MB7582.eurprd08.prod.outlook.com/ Reported-by: Christian Loehle Tested-by: Christian Loehle Signed-off-by: Steven Rostedt (Google) Tested-by: Leon Romanovsky --- kernel/trace/Kconfig | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/kernel/trace/Kconfig b/kernel/trace/Kconfig index 033fba0633cf..a3f35c7d83b6 100644 --- a/kernel/trace/Kconfig +++ b/kernel/trace/Kconfig @@ -265,8 +265,7 @@ config FUNCTION_GRAPH_RETADDR =20 config FUNCTION_TRACE_ARGS bool - depends on HAVE_FUNCTION_ARG_ACCESS_API - depends on DEBUG_INFO_BTF + depends on PROBE_EVENTS_BTF_ARGS default y help If supported with function argument access API and BTF, then --=20 2.47.2 From nobody Sat Feb 7 21:24:16 2026 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 39EA929CE1 for ; Wed, 2 Apr 2025 02:22:32 +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=1743560553; cv=none; b=SQuVeHAe4F3eLRuqNn9fSRkixVhtRgWSlX/TjqWyOo5cPO1Otl8RCsqPbsdE18NVoz5QIWrChSRI2LcjNNxf0PPX91VoETIV6WdovcWuJNJznIMUDJy5RC8S8fsokOc6e0dC8Mb/Sfbfy4K1/3YcoMb2CHgUFAPloC+PbNu47LE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743560553; c=relaxed/simple; bh=DCxRafmm3bkIwxe7XnDiqfCO1qxNMhwVeQxCFNCrA6w=; h=Message-ID:Date:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=WOueT1xuwRwi9JiiJXQ3uyvFRrJlgvFQN2SybnOLpFVMGH+9RgPw+dJQxehn9jo0/vMIiuYrLXpOTBFkwFx8w6zg0AkWu9eX8+6y6A4eHhtncYsPpdT5IuiaMds0nlQ5eNbpwekVl7q8DxfQ+OtW7xZdpPITw1UcDPwutL/JQZU= 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 BCB5DC4CEE8; Wed, 2 Apr 2025 02:22:32 +0000 (UTC) Received: from rostedt by gandalf with local (Exim 4.98) (envelope-from ) id 1tznlP-00000006MNq-02B2; Tue, 01 Apr 2025 22:23:35 -0400 Message-ID: <20250402022334.856216750@goodmis.org> User-Agent: quilt/0.68 Date: Tue, 01 Apr 2025 22:23:10 -0400 From: Steven Rostedt To: linux-kernel@vger.kernel.org Cc: Masami Hiramatsu , Mark Rutland , Mathieu Desnoyers , Andrew Morton Subject: [for-linus][PATCH 2/4] tracing: Free module_delta on freeing of persistent ring buffer References: <20250402022308.372786127@goodmis.org> 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" From: Steven Rostedt If a persistent ring buffer is created, a "module_delta" array is also allocated to hold the module deltas of loaded modules that match modules in the scratch area. If this buffer gets freed, the module_delta array is not freed and causes a memory leak. Cc: Masami Hiramatsu Cc: Mathieu Desnoyers Link: https://lore.kernel.org/20250401124525.1f9ac02a@gandalf.local.home Fixes: 35a380ddbc65 ("tracing: Show last module text symbols in the stacktr= ace") Signed-off-by: Steven Rostedt (Google) --- kernel/trace/trace.c | 1 + 1 file changed, 1 insertion(+) diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c index 103b193875b3..de6d7f0e6206 100644 --- a/kernel/trace/trace.c +++ b/kernel/trace/trace.c @@ -9609,6 +9609,7 @@ static void free_trace_buffers(struct trace_array *tr) return; =20 free_trace_buffer(&tr->array_buffer); + kfree(tr->module_delta); =20 #ifdef CONFIG_TRACER_MAX_TRACE free_trace_buffer(&tr->max_buffer); --=20 2.47.2 From nobody Sat Feb 7 21:24:16 2026 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 69EA0130AC8; Wed, 2 Apr 2025 02:22:33 +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=1743560553; cv=none; b=iLTl6XzLbkYQN4J8hg+27IzA5eUIHr46zyKThcj3CH4JtWS/EwrkAwbY5P6bljw3QngJa7RJ3jd4cX97bLcLGLBwWVZdCSZLRavMWe/niATDxofZ1fGAMr8I6edfiPF81iikVQhmXQqbBJIf/tt+6Ae35DqE0zMISJg+VbJSmR8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743560553; c=relaxed/simple; bh=15RPTBSgkhteI6iwl9RvCu+jgBMqWKn7/VmkChot5b4=; h=Message-ID:Date:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=Kh9a3Ura+ITJhbL1fIWmMk3OBPXz+xpmJAwzA89iK9NrmFwqQW4wub7D9YxJmCt8Lk/55viJ1+Xcu5T3m4D8fPVz6SPYEV2AAlsQ79qWNXMdX+2TtBZSE5QgAhYcmx2R4k1XbFHohoUQUT1fQbAFR0+pDrUCGLhIDounVuBOQio= 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 04C08C4CEEF; Wed, 2 Apr 2025 02:22:32 +0000 (UTC) Received: from rostedt by gandalf with local (Exim 4.98) (envelope-from ) id 1tznlP-00000006MOK-0jvp; Tue, 01 Apr 2025 22:23:35 -0400 Message-ID: <20250402022335.029884348@goodmis.org> User-Agent: quilt/0.68 Date: Tue, 01 Apr 2025 22:23:11 -0400 From: Steven Rostedt To: linux-kernel@vger.kernel.org Cc: Masami Hiramatsu , Mark Rutland , Mathieu Desnoyers , Andrew Morton , stable@vger.kernel.org, zhoumin Subject: [for-linus][PATCH 3/4] ftrace: Add cond_resched() to ftrace_graph_set_hash() References: <20250402022308.372786127@goodmis.org> 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" From: zhoumin When the kernel contains a large number of functions that can be traced, the loop in ftrace_graph_set_hash() may take a lot of time to execute. This may trigger the softlockup watchdog. Add cond_resched() within the loop to allow the kernel to remain responsive even when processing a large number of functions. This matches the cond_resched() that is used in other locations of the code that iterates over all functions that can be traced. Cc: stable@vger.kernel.org Fixes: b9b0c831bed26 ("ftrace: Convert graph filter to use hash tables") Link: https://lore.kernel.org/tencent_3E06CE338692017B5809534B9C5C03DA7705@= qq.com Signed-off-by: zhoumin Signed-off-by: Steven Rostedt (Google) --- kernel/trace/ftrace.c | 1 + 1 file changed, 1 insertion(+) diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c index 92015de6203d..1a48aedb5255 100644 --- a/kernel/trace/ftrace.c +++ b/kernel/trace/ftrace.c @@ -6855,6 +6855,7 @@ ftrace_graph_set_hash(struct ftrace_hash *hash, char = *buffer) } } } + cond_resched(); } while_for_each_ftrace_rec(); =20 return fail ? -EINVAL : 0; --=20 2.47.2 From nobody Sat Feb 7 21:24:16 2026 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 6885812FF6F; Wed, 2 Apr 2025 02:22:33 +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=1743560553; cv=none; b=ArjeVGqZxuvVzTsO/brxlrdwqAiDFjWrkrv+96sKk4XGpQdpkQPl1P/h66kG/joZSeT0sapcoij/HEfrqq6ZTF1hZR1wsYqb2XTmgUpfF4M1MUOGeNeU4s4O79Q156b4qWe+iivokMVqzaJMofuGv0pRMRuKmJX8j80S4lKEUBQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743560553; c=relaxed/simple; bh=CaUW0ta9y1HPT2mikD1OR2HWLEd3oigGjMY+qI7XmjI=; h=Message-ID:Date:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=d2pYtNUjEfVn61Kl+tW88Q0cvTvXFZgDieTp5Yl653dUWcStUWYFq0YrEfizH7domnpxaw/+NXb8OKaH3SihbsaF26TcG1F7qeL5xIHdcRYjFzEgSBuGCHyqkmhs28k7A8nYeQfkmLrs3yNpizbhLeKW3KxpB5QA/BmyW4T7pcs= 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 1A33AC4CEF3; Wed, 2 Apr 2025 02:22:33 +0000 (UTC) Received: from rostedt by gandalf with local (Exim 4.98) (envelope-from ) id 1tznlP-00000006MOo-1T4Y; Tue, 01 Apr 2025 22:23:35 -0400 Message-ID: <20250402022335.198455535@goodmis.org> User-Agent: quilt/0.68 Date: Tue, 01 Apr 2025 22:23:12 -0400 From: Steven Rostedt To: linux-kernel@vger.kernel.org Cc: Masami Hiramatsu , Mark Rutland , Mathieu Desnoyers , Andrew Morton , stable@vger.kernel.org, Libo Chen Subject: [for-linus][PATCH 4/4] tracing: Verify event formats that have "%*p.." References: <20250402022308.372786127@goodmis.org> 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" From: Steven Rostedt The trace event verifier checks the formats of trace events to make sure that they do not point at memory that is not in the trace event itself or in data that will never be freed. If an event references data that was allocated when the event triggered and that same data is freed before the event is read, then the kernel can crash by reading freed memory. The verifier runs at boot up (or module load) and scans the print formats of the events and checks their arguments to make sure that dereferenced pointers are safe. If the format uses "%*p.." the verifier will ignore it, and that could be dangerous. Cover this case as well. Also add to the sample code a use case of "%*pbl". Link: https://lore.kernel.org/all/bcba4d76-2c3f-4d11-baf0-02905db953dd@orac= le.com/ Cc: stable@vger.kernel.org Cc: Masami Hiramatsu Cc: Mathieu Desnoyers Fixes: 5013f454a352c ("tracing: Add check of trace event print fmts for der= eferencing pointers") Link: https://lore.kernel.org/20250327195311.2d89ec66@gandalf.local.home Reported-by: Libo Chen Reviewed-by: Libo Chen Tested-by: Libo Chen Signed-off-by: Steven Rostedt (Google) --- kernel/trace/trace_events.c | 7 +++++++ samples/trace_events/trace-events-sample.h | 8 ++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c index 8638b7f7ff85..069e92856bda 100644 --- a/kernel/trace/trace_events.c +++ b/kernel/trace/trace_events.c @@ -470,6 +470,7 @@ static void test_event_printk(struct trace_event_call *= call) case '%': continue; case 'p': + do_pointer: /* Find dereferencing fields */ switch (fmt[i + 1]) { case 'B': case 'R': case 'r': @@ -498,6 +499,12 @@ static void test_event_printk(struct trace_event_call = *call) continue; if (fmt[i + j] =3D=3D '*') { star =3D true; + /* Handle %*pbl case */ + if (!j && fmt[i + 1] =3D=3D 'p') { + arg++; + i++; + goto do_pointer; + } continue; } if ((fmt[i + j] =3D=3D 's')) { diff --git a/samples/trace_events/trace-events-sample.h b/samples/trace_eve= nts/trace-events-sample.h index 999f78d380ae..1a05fc153353 100644 --- a/samples/trace_events/trace-events-sample.h +++ b/samples/trace_events/trace-events-sample.h @@ -319,7 +319,8 @@ TRACE_EVENT(foo_bar, __assign_cpumask(cpum, cpumask_bits(mask)); ), =20 - TP_printk("foo %s %d %s %s %s %s %s %s (%s) (%s) %s", __entry->foo, __ent= ry->bar, + TP_printk("foo %s %d %s %s %s %s %s %s (%s) (%s) %s [%d] %*pbl", + __entry->foo, __entry->bar, =20 /* * Notice here the use of some helper functions. This includes: @@ -370,7 +371,10 @@ TRACE_EVENT(foo_bar, =20 __get_str(str), __get_str(lstr), __get_bitmask(cpus), __get_cpumask(cpum), - __get_str(vstr)) + __get_str(vstr), + __get_dynamic_array_len(cpus), + __get_dynamic_array_len(cpus), + __get_dynamic_array(cpus)) ); =20 /* --=20 2.47.2