From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796384930; b=V4hg9E5987zpiCaLZiUffquJMuLIeFNraVGCj2H/ZAuu9D1QeBESV3OCnTisdphnR0oR 4btX0pTBxJQQ7s6rrBPIbbH8UZ59ozRVSkf+8QOGvdxOLhrIIlk7uttaFoeyL5J1cur0V G+yE6A/mO6/h0c+QSA9VHhSsvyJ/rbW2Uc+KcmnrfDf/g1vrgAUdLab3Z1UmL2s4Fudy0 TKxCLvGek81HMiy2HoDPRKi/k3+PpdM+FO9F3mAkt6l9yxifMC2qU3Lnrq9bYB6ZuuyFp k0BfgBSrNO+D7oyV+ogoRA44A3EIlZrsu1+7DDaTtNdgxIFpfX8fi4lyatLaRCd1QRg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796384930; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=ibGC9DTbuy78dPxBpeVb85XR9gjCy+SOgSMsBDtwX8I=; b=ysWyrhlptL5/ItuLhkHjIC0VO4Kp95bsuRhvUjBF6IMO2/A3ozPELKMF6PMLERysezE4 vRtT0DYKMBEne5zsGnb1Y8smA24QeQ5aAiFKRL8TJTKfem13zcVyHEYQjzhlZmW/T8V+I fTY28BbJJ+DXCUalB5heotA8CJEHF/gwOainC1YKy9cKRYL9vDYLKLPy27Y3G1Nfd0BnM mUftd+g9kY6sPALqB6cAfp4Pw9BkHx3LDWun8fShwqigqc/zLnsw5DrnkEKAEkqDeJoYO 88sobYINqbtSlnZR1rmZ6fbhG31KBqhtTH2Zy1LuX/TtOZyoRocfq6eXllcEmscDXAA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=b2zcjkXB; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 42D9E606A322; Fri, 4 Dec 2026 11:48:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=b2zcjkXB Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6F3E11F000C2; Fri, 4 Dec 2026 11:48:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796384929; bh=ibGC9DTbuy78dPxBpeVb85XR9gjCy+SOgSMsBDtwX8I=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=b2zcjkXBgSpyCYvoaIjDofetYmwwpMZzz3djR826efjm6X1+FFZTsC6O/Dxtj136B QENqqN33bCw9vzd7G7UV+wtcbZdTKO7FUtUAalxMBgE8NlhL1b7GJ9IWO5IPzslJgm 9Gvy8Sol4u4bsq2Krnmpz25d+WP1VdMNC6DK0ORg= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Ian Rogers , Arnaldo Carvalho de Melo , Sasha Levin Subject: [PATCH 6.6 0352/1167] perf test code-reading: Fix duplicate kernel maps and machine leak Date: Fri, 4 Dec 2026 18:56:19 +0900 Message-ID: <20261204100711.161238040@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100702.047403948@linuxfoundation.org> References: <20261204100702.047403948@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: stable@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: Ian Rogers [ Upstream commit 58bf7b7af359d4c6f1af29fd8d2067bbcff1d8c7 ] In do_test_code_reading(), machine__new_host(&host_env) already calls machine__create_kernel_maps(machine). Calling machine__create_kernel_maps(machine) a second time immediately afterwards duplicates all kernel module maps in machine->kmaps, causing dso__load_kcore()'s module validation (do_validate_kcore_modules()) to fail and fall back to /proc/kallsyms. Furthermore, when try_kcore is true and !have_kcore, returning TEST_CODE_READING_NO_KCORE directly bypasses out_err, leaking the entire struct machine, its kernel/module maps and DSOs, all kallsyms symbols, and host_env. Remove the redundant machine__create_kernel_maps() call, check for !machine after machine__new_host(), and jump to out_err when returning TEST_CODE_READING_NO_KCORE. Fixes: 0fd4008ed755c52d ("perf test: Use machine__new_host in mmap thread code reading test") Assisted-by: Antigravity:gemini-3.1-pro Signed-off-by: Ian Rogers Signed-off-by: Arnaldo Carvalho de Melo [ sashal: Dropped the host_env/perf_env__init() setup since this tree's machine__new_host() takes no arguments, keeping the manual machine->env = &perf_env placed after the new NULL check. ] Signed-off-by: Sasha Levin --- tools/perf/tests/code-reading.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/tools/perf/tests/code-reading.c b/tools/perf/tests/code-reading.c index ff249555ca57a..dd5f668d86d63 100644 --- a/tools/perf/tests/code-reading.c +++ b/tools/perf/tests/code-reading.c @@ -579,13 +579,11 @@ static int do_test_code_reading(bool try_kcore) pid = getpid(); machine = machine__new_host(); - machine->env = &perf_env; - - ret = machine__create_kernel_maps(machine); - if (ret < 0) { - pr_debug("machine__create_kernel_maps failed\n"); + if (!machine) { + pr_debug("machine__new_host failed\n"); goto out_err; } + machine->env = &perf_env; /* Force the use of kallsyms instead of vmlinux to try kcore */ if (try_kcore) @@ -603,8 +601,10 @@ static int do_test_code_reading(bool try_kcore) have_kcore = dso__is_kcore(dso); /* 2nd time through we just try kcore */ - if (try_kcore && !have_kcore) - return TEST_CODE_READING_NO_KCORE; + if (try_kcore && !have_kcore) { + err = TEST_CODE_READING_NO_KCORE; + goto out_err; + } /* No point getting kernel events if there is no kernel object */ if (!have_vmlinux && !have_kcore) -- 2.53.0