lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20241205084500.823660-2-quic_zhonhan@quicinc.com>
Date: Thu, 5 Dec 2024 16:44:58 +0800
From: Zhongqiu Han <quic_zhonhan@...cinc.com>
To: <peterz@...radead.org>, <mingo@...hat.com>, <acme@...nel.org>,
        <namhyung@...nel.org>, <mark.rutland@....com>,
        <alexander.shishkin@...ux.intel.com>, <jolsa@...nel.org>,
        <irogers@...gle.com>, <adrian.hunter@...el.com>,
        <kan.liang@...ux.intel.com>, <song@...nel.org>,
        <james.clark@...aro.org>, <yangyicong@...ilicon.com>
CC: <linux-perf-users@...r.kernel.org>, <linux-kernel@...r.kernel.org>,
        <bpf@...r.kernel.org>, <quic_zhonhan@...cinc.com>
Subject: [PATCH v2 1/3] perf header: Fix one memory leakage in process_bpf_btf()

If __perf_env__insert_btf() returns false due to a duplicate btf node
insertion, the temporary node will leak. Add a check to ensure the memory
is freed if the function returns false.

Fixes: a70a1123174a ("perf bpf: Save BTF information as headers to perf.data")
Signed-off-by: Zhongqiu Han <quic_zhonhan@...cinc.com>
Reviewed-by: Namhyung Kim <namhyung@...nel.org>
---
 tools/perf/util/header.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c
index 3451e542b69a..fbba6ffafec4 100644
--- a/tools/perf/util/header.c
+++ b/tools/perf/util/header.c
@@ -3205,7 +3205,8 @@ static int process_bpf_btf(struct feat_fd *ff, void *data __maybe_unused)
 		if (__do_read(ff, node->data, data_size))
 			goto out;
 
-		__perf_env__insert_btf(env, node);
+		if (!__perf_env__insert_btf(env, node))
+			free(node);
 		node = NULL;
 	}
 
-- 
2.25.1


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ