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]
Date:	Wed, 08 Feb 2012 00:26:42 +0530
From:	"Srivatsa S. Bhat" <srivatsa.bhat@...ux.vnet.ibm.com>
To:	paul@...lmenage.org, a.p.zijlstra@...llo.nl, mingo@...e.hu,
	rjw@...k.pl, tj@...nel.org
Cc:	frank.rowand@...sony.com, pjt@...gle.com, tglx@...utronix.de,
	lizf@...fujitsu.com, prashanth@...ux.vnet.ibm.com,
	paulmck@...ux.vnet.ibm.com, vatsa@...ux.vnet.ibm.com,
	srivatsa.bhat@...ux.vnet.ibm.com, linux-kernel@...r.kernel.org,
	linux-pm@...r.kernel.org
Subject: [PATCH 2/4] cpuset: Split up update_cpumask() so that its
 functionality can be reused

update_cpumask() expects the new cpuset in the form of characters (owing to
the fact that it expects cpuset updates from userspace). This might not be
appropriate if an in-kernel user wants to call it.

So, split up the function so that its functionality can be reused. That is,
introduce do_update_cpumask() and offload the core work to it.

Reported-by: Prashanth K. Nageshappa <prashanth@...ux.vnet.ibm.com>
Signed-off-by: Srivatsa S. Bhat <srivatsa.bhat@...ux.vnet.ibm.com>
Cc: stable@...r.kernel.org
---

 kernel/cpuset.c |   61 ++++++++++++++++++++++++++++++++++++++-----------------
 1 files changed, 42 insertions(+), 19 deletions(-)

diff --git a/kernel/cpuset.c b/kernel/cpuset.c
index 5e2323b..2be71da 100644
--- a/kernel/cpuset.c
+++ b/kernel/cpuset.c
@@ -864,13 +864,14 @@ static void update_tasks_cpumask(struct cpuset *cs, struct ptr_heap *heap)
 	cgroup_scan_tasks(&scan);
 }
 
+
 /**
- * update_cpumask - update the cpus_allowed mask of a cpuset and all tasks in it
+ * do_update_cpumask - update the cpus_allowed mask of a cpuset and all tasks
+ * in it
  * @cs: the cpuset to consider
- * @buf: buffer of cpu numbers written to this cpuset
+ * @trialcs: the updated cpuset value requested
  */
-static int update_cpumask(struct cpuset *cs, struct cpuset *trialcs,
-			  const char *buf)
+static int do_update_cpumask(struct cpuset *cs, struct cpuset *trialcs)
 {
 	struct ptr_heap heap;
 	int retval;
@@ -880,22 +881,9 @@ static int update_cpumask(struct cpuset *cs, struct cpuset *trialcs,
 	if (cs == &top_cpuset)
 		return -EACCES;
 
-	/*
-	 * An empty cpus_allowed is ok only if the cpuset has no tasks.
-	 * Since cpulist_parse() fails on an empty mask, we special case
-	 * that parsing.  The validate_change() call ensures that cpusets
-	 * with tasks have cpus.
-	 */
-	if (!*buf) {
-		cpumask_clear(trialcs->cpus_allowed);
-	} else {
-		retval = cpulist_parse(buf, trialcs->cpus_allowed);
-		if (retval < 0)
-			return retval;
-
-		if (!cpumask_subset(trialcs->cpus_allowed, cpu_active_mask))
+	if (!cpumask_subset(trialcs->cpus_allowed, cpu_active_mask))
 			return -EINVAL;
-	}
+
 	retval = validate_change(cs, trialcs);
 	if (retval < 0)
 		return retval;
@@ -925,9 +913,44 @@ static int update_cpumask(struct cpuset *cs, struct cpuset *trialcs,
 
 	if (is_load_balanced)
 		async_rebuild_sched_domains();
+
 	return 0;
 }
 
+/**
+ * update_cpumask - update the cpus_allowed mask of a cpuset and all tasks in it
+ * @cs: the cpuset to consider
+ * @buf: buffer of cpu numbers written to this cpuset
+ */
+static int update_cpumask(struct cpuset *cs, struct cpuset *trialcs,
+			  const char *buf)
+{
+	int retval;
+
+	/* top_cpuset.cpus_allowed tracks cpu_online_map; it's read-only */
+	if (cs == &top_cpuset)
+		return -EACCES;
+
+	/*
+	 * An empty cpus_allowed is ok only if the cpuset has no tasks.
+	 * Since cpulist_parse() fails on an empty mask, we special case
+	 * that parsing.  The validate_change() call ensures that cpusets
+	 * with tasks have cpus.
+	 */
+	if (!*buf) {
+		cpumask_clear(trialcs->cpus_allowed);
+	} else {
+		retval = cpulist_parse(buf, trialcs->cpus_allowed);
+		if (retval < 0)
+			return retval;
+
+		if (!cpumask_subset(trialcs->cpus_allowed, cpu_active_mask))
+			return -EINVAL;
+	}
+
+	return do_update_cpumask(cs, trialcs);
+}
+
 /*
  * cpuset_migrate_mm
  *

--
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