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:	Fri, 30 Sep 2011 13:36:21 +0200
From:	Witold Krecicki <wpk@...m.net>
To:	Paul Menage <paul@...lmenage.org>, Li Zefan <lizf@...fujitsu.com>,
	containers@...ts.linux-foundation.org
Cc:	linux-kernel@...r.kernel.org, Witold Krecicki <wpk@...m.net>
Subject: [PATCH 2/6] cgroup: make 'cgroup_is_descendant' function take cgroup as a 'descendant of' argument

Make currently unused (previously used by cgroup_ns) 'cgroup_is_descendant' function
take cgroup as a 'descendant of' argument instead of task.

Signed-off-by: Witold Krecicki <wpk@...m.net>
---
 include/linux/cgroup.h |    5 +++--
 kernel/cgroup.c        |   16 +++++++---------
 2 files changed, 10 insertions(+), 11 deletions(-)

diff --git a/include/linux/cgroup.h b/include/linux/cgroup.h
index ee51f79..6965591 100644
--- a/include/linux/cgroup.h
+++ b/include/linux/cgroup.h
@@ -440,8 +440,9 @@ int cgroup_path(const struct cgroup *cgrp, char *buf, int buflen);
 
 int cgroup_task_count(const struct cgroup *cgrp);
 
-/* Return true if cgrp is a descendant of the task's cgroup */
-int cgroup_is_descendant(const struct cgroup *cgrp, struct task_struct *task);
+/* Return true if cgrp is a descendant of the topcgrp */
+int cgroup_is_descendant(const struct cgroup *cgrp,
+			  const struct cgroup *topcgrp);
 
 /*
  * When the subsys has to access css and may add permanent refcnt to css,
diff --git a/kernel/cgroup.c b/kernel/cgroup.c
index a4d002c..0177472 100644
--- a/kernel/cgroup.c
+++ b/kernel/cgroup.c
@@ -4684,30 +4684,28 @@ void cgroup_exit(struct task_struct *tsk, int run_callbacks)
 }
 
 /**
- * cgroup_is_descendant - see if @cgrp is a descendant of @task's cgrp
+ * cgroup_is_descendant - see if @cgrp is a descendant of @topcgrp
  * @cgrp: the cgroup in question
- * @task: the task in question
+ * @topcgrp: the top cgroup
  *
- * See if @cgrp is a descendant of @task's cgroup in the appropriate
+ * See if @cgrp is a descendant of @topcgrp in the appropriate
  * hierarchy.
  *
  * If we are sending in dummytop, then presumably we are creating
  * the top cgroup in the subsystem.
  *
- * Called only by the ns (nsproxy) cgroup.
  */
-int cgroup_is_descendant(const struct cgroup *cgrp, struct task_struct *task)
+int cgroup_is_descendant(const struct cgroup *cgrp,
+			  const struct cgroup *topcgrp)
 {
 	int ret;
-	struct cgroup *target;
 
 	if (cgrp == dummytop)
 		return 1;
 
-	target = task_cgroup_from_root(task, cgrp->root);
-	while (cgrp != target && cgrp!= cgrp->top_cgroup)
+	while (cgrp != topcgrp && cgrp != cgrp->top_cgroup)
 		cgrp = cgrp->parent;
-	ret = (cgrp == target);
+	ret = (cgrp == topcgrp);
 	return ret;
 }
 
-- 
1.7.4.1

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