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-next>] [day] [month] [year] [list]
Message-Id: <20171227224908.11007-1-andi@firstfloor.org>
Date:   Wed, 27 Dec 2017 14:49:08 -0800
From:   Andi Kleen <andi@...stfloor.org>
To:     peterz@...radead.org
Cc:     linux-kernel@...r.kernel.org, Andi Kleen <ak@...ux.intel.com>,
        Tommi Rantala <tommi.t.rantala@...ia.com>
Subject: [PATCH] perf/x86/intel: Fix minor memleak on Skylake perf initialization

From: Andi Kleen <ak@...ux.intel.com>

Tommi reports:

I'm seeing this kmemleak report in v4.15-rc4:

unreferenced object 0xffff8801f3d5d720 (size 64):
  comm "swapper/0", pid 1, jiffies 4294667312 (age 2687.423s)
  hex dump (first 32 bytes):
    60 d1 41 ad ff ff ff ff 20 d1 41 ad ff ff ff ff  `.A..... .A.....
    80 d0 41 ad ff ff ff ff 40 d0 41 ad ff ff ff ff  ..A.....@.......
  backtrace:
    [<00000000ab01886a>] intel_pmu_init+0x1844/0x1d38
    [<00000000cf20c5f0>] init_hw_perf_events+0x8c/0x66f
    [<00000000dd69189d>] do_one_initcall+0x7b/0x1d0
    [<000000008ee1f02a>] kernel_init_freeable+0x163/0x2f9
    [<00000000e32ca8d9>] kernel_init+0xf/0x120
    [<0000000038a99264>] ret_from_fork+0x24/0x30
    [<00000000ace6d26f>] 0xffffffffffffffff

$ ./scripts/faddr2line vmlinux intel_pmu_init+0x1844/0x1d38
intel_pmu_init+0x1844/0x1d38:
intel_pmu_init at arch/x86/events/intel/core.c:4296

Which matches line:
                extra_attr = merge_attr(extra_attr, skl_format_attr);

So looks like "extra_attr" is leaked here.

Free the attribute in this case.

Reported-by: Tommi Rantala <tommi.t.rantala@...ia.com>
Cc: Tommi Rantala <tommi.t.rantala@...ia.com>
Fixes: a5df70c354c26 ( perf/x86: Only show format attributes)
Signed-off-by: Andi Kleen <ak@...ux.intel.com>
---
 arch/x86/events/intel/core.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/arch/x86/events/intel/core.c b/arch/x86/events/intel/core.c
index 09c26a4f139c..71321f48e1e6 100644
--- a/arch/x86/events/intel/core.c
+++ b/arch/x86/events/intel/core.c
@@ -3855,6 +3855,7 @@ __init int intel_pmu_init(void)
 	struct extra_reg *er;
 	int version, i;
 	struct attribute **extra_attr = NULL;
+	bool extra_attr_allocated = false;
 	char *name;
 
 	if (!cpu_has(&boot_cpu_data, X86_FEATURE_ARCH_PERFMON)) {
@@ -4294,6 +4295,7 @@ __init int intel_pmu_init(void)
 		extra_attr = boot_cpu_has(X86_FEATURE_RTM) ?
 			hsw_format_attr : nhm_format_attr;
 		extra_attr = merge_attr(extra_attr, skl_format_attr);
+		extra_attr_allocated = true;
 		x86_pmu.cpu_events = get_hsw_events_attrs();
 		intel_pmu_pebs_data_source_skl(
 			boot_cpu_data.x86_model == INTEL_FAM6_SKYLAKE_X);
@@ -4324,6 +4326,8 @@ __init int intel_pmu_init(void)
 	if (version >= 2 && extra_attr) {
 		x86_pmu.format_attrs = merge_attr(intel_arch3_formats_attr,
 						  extra_attr);
+		if (extra_attr_allocated)
+			kfree(extra_attr);
 		WARN_ON(!x86_pmu.format_attrs);
 	}
 
-- 
2.14.3

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ