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 6546146D2A0; Tue, 21 Jul 2026 18:07:38 +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=1784657259; cv=none; b=Tt2K/SmAXLXJHYnWeq+PKvXb0qnxHVc+OoiseGsQ/7df1CHSI3Ps5sWxOSUVvbBRHir4mhzpFMCwg2xkalpVhSBQ8UudI07Qr7zQdpPRU2uWJ2zNC12opf+K/DqpjJ8YkYvurk96hFU+RLqhx6ctEako1d6pDuhXOr5MIEM1e04= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784657259; c=relaxed/simple; bh=SU0+GYDL8ejgVWX5f7Lste5nWSgPLn0GUn25O0GG2QQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=qzPQHItYziJZs5nCnsKVitUNGyGk69gbf8FhoaFPR9x97yZsta/m7iPIp93FVstyu7RIp6aj+dYoxFW1AS5v5thV6q2twZnuj4MvBXAMJgjR17z8nJTzTpIs8llbSrnHs8vNJpF8b2sQJIXq/H2fWOFcSFFZp4WXCmWaxLdJhok= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=RjKFgf+Z; 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="RjKFgf+Z" Received: by smtp.kernel.org (Postfix) with ESMTPSA id CA0EC1F00A3E; Tue, 21 Jul 2026 18:07:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1784657258; bh=8ZHWz4YpvVuyMD1QfL/H06aDuUobZ4Z/mFBE97kNu7g=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=RjKFgf+Zr0LTK1QfS20d8rNJpHmYGR3x3fU0/j8No7hQf4yMfCECnZea0ms1xPMd4 0pFo6DjxW6KYunpo5BQQBp769O0ULErc//R5OoWWtm2L1OvNcVXfBUHzPMyS+yMBLL bYlzmx/hEy7xOwSk/fvmVj++t3W8KZYOysrBLmVM= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, sashiko-bot , Ian Rogers , Arnaldo Carvalho de Melo , Sasha Levin Subject: [PATCH 6.18 0695/1611] perf hists: Fix snprintf() in hists__scnprintf_title() UID filter path Date: Tue, 21 Jul 2026 17:13:31 +0200 Message-ID: <20260721152531.014273538@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260721152514.750365251@linuxfoundation.org> References: <20260721152514.750365251@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Arnaldo Carvalho de Melo [ Upstream commit 227a8748742f0263f1fe3131449b44563b77a209 ] hists__scnprintf_title() accumulates formatted output into a buffer using scnprintf() for all filter clauses except the UID filter, which uses snprintf(). If the buffer fills up and snprintf() returns more than the remaining space, printed exceeds size and the next 'size - printed' underflows, causing later scnprintf() calls to write past the buffer. Switch the UID filter clause to scnprintf() to match the rest of the function. Fixes: 25c312dbf88ca402 ("perf hists: Move hists__scnprintf_title() away from the TUI code") Reported-by: sashiko-bot Reviewed-by: Ian Rogers Cc: Arnaldo Carvalho de Melo Assisted-by: Claude:claude-opus-4.6 Signed-off-by: Arnaldo Carvalho de Melo Signed-off-by: Sasha Levin --- tools/perf/util/hist.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tools/perf/util/hist.c b/tools/perf/util/hist.c index ef4b569f7df463..bd894054021b66 100644 --- a/tools/perf/util/hist.c +++ b/tools/perf/util/hist.c @@ -2960,9 +2960,10 @@ int __hists__scnprintf_title(struct hists *hists, char *bf, size_t size, bool sh ev_name, sample_freq_str, enable_ref ? ref : " ", nr_events); - if (hists->uid_filter_str) - printed += snprintf(bf + printed, size - printed, - ", UID: %s", hists->uid_filter_str); + if (hists->uid_filter_str) { + printed += scnprintf(bf + printed, size - printed, + ", UID: %s", hists->uid_filter_str); + } if (thread) { if (hists__has(hists, thread)) { printed += scnprintf(bf + printed, size - printed, -- 2.53.0