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 1DD9538A721 for ; Thu, 16 Apr 2026 08:41: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=1776328912; cv=none; b=IGoeVJZaTrIGCxxqXxWi+U8A4fkfJ1aXsW9HDQ5MAkqsP/PLH4RsVIMpfDTLfKvgZ8soyetYQ0DTpyVFY4SSJgI30Z79V0NrTDUOM9qkEYMZU2wUmX6NbsnHMzlzoQc0vvv+ojfELmDxTLVTU54TQfn9YttS0ll8mTpijIVXnZQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776328912; c=relaxed/simple; bh=pGQkb28/qMQLZ9h8EpLWkyQaacTnDN0MKgraTTc1cDA=; h=Message-ID:Date:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=r960U1dQnaEpw9cWwNZMe2f33S1HRR47Ho8xMf3zA2QsojIKJAjLHYgDjgQvGFFFTMPf4PZhRGFSnecC3gWjGCk6ljuBdfECRZKbq0tkYMispbQCprRs/IBd2sC8sXxHCJP4jzhEV5jlWGRlNyeXZ6ngZwSiPMEbCUe70CV6NaM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=pU4IxJb+; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="pU4IxJb+" Received: by smtp.kernel.org (Postfix) with ESMTPSA id C68E5C2BCB3; Thu, 16 Apr 2026 08:41:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1776328911; bh=pGQkb28/qMQLZ9h8EpLWkyQaacTnDN0MKgraTTc1cDA=; h=Date:From:To:Cc:Subject:References:From; b=pU4IxJb+P7lVAoufuk/jYGxsOeaOTqVrJ9D8ptd6XjtH4I++0/VI1vK+tCMylyzYn Ud2LWaqYPtUuA8BYgX9gyPZtEB7tJ2DcG9JRAjAax+6INP1w++1HvxfNwcYIDvi3v5 QMbGmg9QYatjbDpBP/1NYLg2F6i/wLDaTLk8I6hlVzs1EuLdoqCo2PrZqfvLr7pV+/ UDJLlXjtjBlWZev+yFzf2FOLgCvmdSAXY6pECeNs+HveZ6dKk0i0/sLAcLdHvkKTvV cqKsIG92MF3kqiUWnup7Vme8ihZlIxn/936UFeGpJl9yUct4lPagQkTnRBPoEwJqOa 4oLvkO7uZDDkA== Received: from rostedt by gandalf with local (Exim 4.99.1) (envelope-from ) id 1wDIJq-00000005avR-0rBy; Thu, 16 Apr 2026 04:43:26 -0400 Message-ID: <20260416084326.069067160@kernel.org> User-Agent: quilt/0.69 Date: Thu, 16 Apr 2026 04:42:56 -0400 From: Steven Rostedt To: linux-kernel@vger.kernel.org Cc: Masami Hiramatsu , Mark Rutland , Mathieu Desnoyers , Andrew Morton , Tom Zanussi , Pengpeng Hou Subject: [for-next][PATCH 2/5] tracing: Rebuild full_name on each hist_field_name() call References: <20260416084254.980129867@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 From: Pengpeng Hou hist_field_name() uses a static MAX_FILTER_STR_VAL buffer for fully qualified variable-reference names, but it currently appends into that buffer with strcat() without rebuilding it first. As a result, repeated calls append a new "system.event.field" name onto the previous one, which can eventually run past the end of full_name. Build the name with snprintf() on each call and return NULL if the fully qualified name does not fit in MAX_FILTER_STR_VAL. Link: https://patch.msgid.link/20260401112224.85582-1-pengpeng@iscas.ac.cn Fixes: 067fe038e70f ("tracing: Add variable reference handling to hist triggers") Reviewed-by: Tom Zanussi Tested-by: Tom Zanussi Signed-off-by: Pengpeng Hou Signed-off-by: Steven Rostedt (Google) --- kernel/trace/trace_events_hist.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/kernel/trace/trace_events_hist.c b/kernel/trace/trace_events_hist.c index 67cb92310864..b2b675c7d663 100644 --- a/kernel/trace/trace_events_hist.c +++ b/kernel/trace/trace_events_hist.c @@ -1361,12 +1361,14 @@ static const char *hist_field_name(struct hist_field *field, field->flags & HIST_FIELD_FL_VAR_REF) { if (field->system) { static char full_name[MAX_FILTER_STR_VAL]; + int len; + + len = snprintf(full_name, sizeof(full_name), "%s.%s.%s", + field->system, field->event_name, + field->name); + if (len >= sizeof(full_name)) + return NULL; - strcat(full_name, field->system); - strcat(full_name, "."); - strcat(full_name, field->event_name); - strcat(full_name, "."); - strcat(full_name, field->name); field_name = full_name; } else field_name = field->name; -- 2.51.0