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 79AB4367B92; Tue, 21 Jul 2026 22:43:18 +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=1784673799; cv=none; b=mt2F0RqdabgdfZ40I+zqCdBUIE4Rkavn9inVYsM6lbT+mEjb33K5p+YCLakZn92rIhrPdXiH2gMFPf+qhvtAbZUZn2v6Ex7974+BXdbxcIzDIe59V69pnt04AxVS4M95ysAmpzQX4s+y6WoOvhgAlmhyqQNNixw1AX4GQ0NdWMU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784673799; c=relaxed/simple; bh=rThpcGGkAMLNpE/ljn+EQhhVY0VeURTOI02pjEtO/UY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=catXi4QTCh6q9znXLj0i9CKFRG6UJu+r8yh7PIyEbBHtXsUIyVN1NrqOM5sS0CyRVSSma/sWqcr98Mivi5oYFhtz4uVCFiRkFemzI5z1S94d73uC/S9Jdi15fpuXhwl6B34nLz6jN7iBVVJU8bhqpa4l6fw2mS2OVdncjRTyYBg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=H1TzzvUu; 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="H1TzzvUu" Received: by smtp.kernel.org (Postfix) with ESMTPSA id DF1EE1F000E9; Tue, 21 Jul 2026 22:43:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1784673798; bh=3HzfECqWgwnjqINymmBcvepZP+5loDO1oMACSOGMn74=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=H1TzzvUuPq8KEgUijd7FlPaxqHUr906DO+uZx1YS+VaILBaLv7I8uRtGsVnLx6sGg 3MzfRkwGyOrp4XvGuRyeCM5ungIDGUgewCAIkszu6Lkdq22QU0E+BNdlATaM45ZAII gsXHKvOrJ+Gi2JISJos4Tjy1dfr92CwZIXpbMzh4= 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 5.10 298/699] perf c2c: Fix use-after-free in he__get_c2c_hists() error path Date: Tue, 21 Jul 2026 17:20:57 +0200 Message-ID: <20260721152402.420441862@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260721152355.667394603@linuxfoundation.org> References: <20260721152355.667394603@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 5.10-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 fb7d01f3961b7e..d48b00a829dc66 100644 --- a/tools/perf/builtin-c2c.c +++ b/tools/perf/builtin-c2c.c @@ -201,6 +201,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