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>] [day] [month] [year] [list]
Message-Id: <1212440902-31215-1-git-send-email-maxk@qualcomm.com>
Date:	Mon,  2 Jun 2008 14:08:21 -0700
From:	Max Krasnyansky <maxk@...lcomm.com>
To:	mingo@...e.hu
Cc:	pj@....com, a.p.zijlstra@...llo.nl, linux-kernel@...r.kernel.org,
	menage@...gle.com, rostedt@...dmis.org,
	Max Krasnyansky <maxk@...lcomm.com>
Subject: [PATCH] sched: Fix memory leak in the cpu hotplug handing logic

This is an updated/split up version of the patch I sent earlier.

Basically the issue is that we are leaking doms_cur on cpu hotplug events.
doms_cur is allocated in the arch_init_sched_domains() which is called for
every hotplug event. So we just keep reallocating doms_cur without freeing it.
This patch introduces free_sched_domains() function that cleans things up.

Note that doms_cur can also come from cpusets via partition_sched_domains().
That path is already handled correctly.

This just a bug fix and should go into 2.6.26 and probably -stable as well.

Signed-off-by: Max Krasnyansky <maxk@...lcomm.com>
---
 kernel/sched.c |   15 +++++++++++++++
 1 files changed, 15 insertions(+), 0 deletions(-)

diff --git a/kernel/sched.c b/kernel/sched.c
index 8dcdec6..465f3c8 100644
--- a/kernel/sched.c
+++ b/kernel/sched.c
@@ -6855,6 +6855,19 @@ void __attribute__((weak)) arch_update_cpu_topology(void)
 }
 
 /*
+ * Free current domain masks.
+ * Called after all cpus are attached to NULL domain.
+ */
+static void free_sched_domains(void)
+{
+	ndoms_cur = 0;
+	if (doms_cur != &fallback_doms) {
+		kfree(doms_cur);
+		doms_cur = &fallback_doms;
+	}
+}
+
+/*
  * Set up scheduler domains and groups. Callers must hold the hotplug lock.
  * For now this just excludes isolated cpus, but could be used to
  * exclude other special cases in the future.
@@ -6974,6 +6987,7 @@ int arch_reinit_sched_domains(void)
 
 	get_online_cpus();
 	detach_destroy_domains(&cpu_online_map);
+	free_sched_domains();
 	err = arch_init_sched_domains(&cpu_online_map);
 	put_online_cpus();
 
@@ -7058,6 +7072,7 @@ static int update_sched_domains(struct notifier_block *nfb,
 	case CPU_DOWN_PREPARE:
 	case CPU_DOWN_PREPARE_FROZEN:
 		detach_destroy_domains(&cpu_online_map);
+		free_sched_domains();
 		return NOTIFY_OK;
 
 	case CPU_UP_CANCELED:
-- 
1.5.4.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ