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 C6A84298CB2; Thu, 28 May 2026 20:43:57 +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=1780001038; cv=none; b=Z4M2LBM5b1BxtYTHcocpW/pMlIbASGkTx4gstw8wSYt0sJV1TxLEYoDR0zwfoIzNSVYe9MDhSfQRVeLCk8sXvW02caryYfwEcjWZMSRqmLOuYpzq4pWzavWlDMTpJ9aAHXVbeUxransNDqFWpjU62A18LAtgxd7dXDT8LHoroS4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780001038; c=relaxed/simple; bh=8sT6vLSeU1KTQh8Ai+CARPMWYNGTMPAEu/h5MWUlaEo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=DuFCegK4gaXIiafZyZNdib0rAmjkfUy5Vttn5YjXZquFMvPgsAt2P8PZlG8t/m7A0BViFwiMd6gDgeZFHwlgjZDbeZpurlHrR0V01ZmseEZlpk3Zf4DJnq+moqStOu8h5c+v8YPKMcwAyhXE7rXgq9bjtsWtFh4oWcz8gT7zZEo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=h7rbQBJg; 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="h7rbQBJg" Received: by smtp.kernel.org (Postfix) with ESMTPSA id DB68E1F000E9; Thu, 28 May 2026 20:43:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1780001037; bh=gmE8VPjAzO0+fScIUyBS8CH88ti7jsow8qwxawTEsaI=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=h7rbQBJggcYj/tpnJ+6FAzDMQ5/NzNsbOgS2UWhuO0ewLWio82DG1e8mxv1AqwCu8 52zr6MRpvxjYw1geqP92qpMgHv4tsvJfuJjiL3TICwJwQ7WCQX5tlu2PX02lJhiA8G 6HyNTXsJwvw9g4fXguCmu+AnR5EcGZW02oF4s29g= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, David Carlier , Steven Rostedt , Sasha Levin Subject: [PATCH 6.12 259/272] tracing: Avoid NULL return from hist_field_name() on truncation Date: Thu, 28 May 2026 21:50:33 +0200 Message-ID: <20260528194636.352098351@linuxfoundation.org> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260528194629.379955525@linuxfoundation.org> References: <20260528194629.379955525@linuxfoundation.org> User-Agent: quilt/0.69 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.12-stable review patch. If anyone has any objections, please let me know. ------------------ From: David Carlier [ Upstream commit 576ec047d20b368b43c4d5db98c4f2e0f3c101ec ] hist_field_name() returns "" everywhere except the fully-qualified VAR_REF/EXPR case, where snprintf() truncation returns NULL early and bypasses the bottom NULL->"" guard. Callers don't expect NULL: strcat(expr, hist_field_name(field, 0)) at trace_events_hist.c:1758 and the strcmp() in the sort-key match loop at :4804 both deref it. system and event_name are bounded by MAX_EVENT_NAME_LEN, but the field name on a VAR_REF is kstrdup'd from a histogram variable name parsed out of the trigger string and has no length cap, so a long enough var name in a fully qualified reference can reach the truncation path. Keep the length check but leave field_name as "" on overflow. Link: https://patch.msgid.link/20260508195747.25492-1-devnexen@gmail.com Fixes: 5ec1d1e97de1 ("tracing: Rebuild full_name on each hist_field_name() call") Signed-off-by: David Carlier Signed-off-by: Steven Rostedt Signed-off-by: Sasha Levin --- kernel/trace/trace_events_hist.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/kernel/trace/trace_events_hist.c b/kernel/trace/trace_events_hist.c index 2d085115afde3..2a1e3537332d5 100644 --- a/kernel/trace/trace_events_hist.c +++ b/kernel/trace/trace_events_hist.c @@ -1347,10 +1347,8 @@ static const char *hist_field_name(struct hist_field *field, len = snprintf(full_name, sizeof(full_name), "%s.%s.%s", field->system, field->event_name, field->name); - if (len >= sizeof(full_name)) - return NULL; - - field_name = full_name; + if (len < sizeof(full_name)) + field_name = full_name; } else field_name = field->name; } else if (field->flags & HIST_FIELD_FL_TIMESTAMP) -- 2.53.0