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 13D314302F8; Tue, 21 Jul 2026 19:35:15 +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=1784662516; cv=none; b=eVI6z1g2pv/yk0qZYAYMvhUsDQJZmqYc7ueO7DHimnZBSJ3hIitNm2QdbLtV/Qhd2cX7Xm6H8j8KNnRFQKl7G8A04dF7JizufckqV7jiec7aDs8vJnaVqKn0jQCpXwVdPRt6r75TN3HnJkg9W0uv52sV9oM9b2dYAJUEqVpOHgI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784662516; c=relaxed/simple; bh=LkglLgHU16FtIP2bw9RrtgzGy7NZC4zydLbJ5hGjxR4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=bNg9y6Lcit9zodpx/UKmF9Ev79UXItGy3UGWaiMgMqfEii2GWHG066W/34g9Dj+9FUme8Cz07aGJhBfxZBpRXhogB6KULkHUiqI+7rka7DicKjzHWMXEgo4BPQbLhWbmbAc0aoW37CllOWKC+6dyCCt0iur2ntgZa35rQGxti9c= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=2sueTght; 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="2sueTght" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7859A1F000E9; Tue, 21 Jul 2026 19:35:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1784662515; bh=qu9gY+7+kMy6HGQVxvY75UNsqkRiw1UbYzrFu9sswJQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=2sueTghtvs2ANq5GRCsHWs+v4yoA/CClhIJGXrzt3Chd7UVgODMkagTQenuGJLBsR 0QX+HlO1hE+An07gRab0HwjTFHWCzD259dSzG8N/taqcyeS3eDptS8QIPGl2vNPTbK b68hwSTo4BGRbrfQJ/4wHNppblmFK7T6jc9tPeLA= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, sashiko-bot , Jiri Olsa , Arnaldo Carvalho de Melo , Sasha Levin Subject: [PATCH 6.12 0475/1276] perf c2c: Fix use-after-free in he__get_c2c_hists() error path Date: Tue, 21 Jul 2026 17:15:18 +0200 Message-ID: <20260721152456.733616878@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260721152446.065700225@linuxfoundation.org> References: <20260721152446.065700225@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.12-stable review patch. If anyone has any objections, please let me know. ------------------ From: Arnaldo Carvalho de Melo [ Upstream commit 5e5e6196d737c5be03d20647428316b36621608d ] he__get_c2c_hists() assigns c2c_he->hists before calling c2c_hists__init(). If init fails, the error path calls free(hists) but leaves c2c_he->hists pointing to freed memory. On teardown, c2c_he_free() finds the non-NULL pointer and calls hists__delete_entries() on it, causing a use-after-free. Set c2c_he->hists to NULL before freeing so teardown skips the already-freed allocation. Fixes: b2252ae67b687d2b ("perf c2c report: Decode c2c_stats for hist entries") Reported-by: sashiko-bot Cc: Jiri Olsa Assisted-by: Claude:claude-opus-4.6 Signed-off-by: Arnaldo Carvalho de Melo Signed-off-by: Sasha Levin --- tools/perf/builtin-c2c.c | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/perf/builtin-c2c.c b/tools/perf/builtin-c2c.c index 9b1482786d81cd..b02b41059730f9 100644 --- a/tools/perf/builtin-c2c.c +++ b/tools/perf/builtin-c2c.c @@ -216,6 +216,7 @@ he__get_c2c_hists(struct hist_entry *he, ret = c2c_hists__init(hists, sort, nr_header_lines); if (ret) { + c2c_he->hists = NULL; free(hists); return NULL; } -- 2.53.0