From: Aleksa Sarai <cyphar@cyphar.com>
To: tj@kernel.org
Cc: linux-kernel@vger.kernel.org, cgroups@vger.kernel.org,
Aleksa Sarai <cyphar@cyphar.com>
Subject: [PATCH 2/2] cgroup: pids: fix invalid get/put usage
Date: Sun, 23 Aug 2015 23:10:32 +1000 [thread overview]
Message-ID: <1440335432-4202-3-git-send-email-cyphar@cyphar.com> (raw)
In-Reply-To: <1440335432-4202-1-git-send-email-cyphar@cyphar.com>
Fix incorrect usage of css_get and css_put to put a different css in
pids_{cancel_,}attach() than the one grabbed in pids_can_attach(). This
could lead to quite serious memory leakage (and unsafe operations on the
putted css).
Signed-off-by: Aleksa Sarai <cyphar@cyphar.com>
---
kernel/cgroup_pids.c | 13 +------------
1 file changed, 1 insertion(+), 12 deletions(-)
diff --git a/kernel/cgroup_pids.c b/kernel/cgroup_pids.c
index d75488824ae2..f116ca77a658 100644
--- a/kernel/cgroup_pids.c
+++ b/kernel/cgroup_pids.c
@@ -177,7 +177,7 @@ static int pids_can_attach(struct cgroup_subsys_state *css,
* we either fail and hit ->cancel_attach() or succeed and hit
* ->attach().
*/
- old_css = task_get_css(task, pids_cgrp_id);
+ old_css = task_css(task, pids_cgrp_id);
old_pids = css_pids(old_css);
pids_charge(pids, 1);
@@ -202,19 +202,9 @@ static void pids_cancel_attach(struct cgroup_subsys_state *css,
pids_charge(old_pids, 1);
pids_uncharge(pids, 1);
- css_put(old_css);
}
}
-static void pids_attach(struct cgroup_subsys_state *css,
- struct cgroup_taskset *tset)
-{
- struct task_struct *task;
-
- cgroup_taskset_for_each(task, tset)
- css_put(task_css(task, pids_cgrp_id));
-}
-
static int pids_can_fork(struct task_struct *task, void **priv_p)
{
struct cgroup_subsys_state *css;
@@ -354,7 +344,6 @@ static struct cftype pids_files[] = {
struct cgroup_subsys pids_cgrp_subsys = {
.css_alloc = pids_css_alloc,
.css_free = pids_css_free,
- .attach = pids_attach,
.can_attach = pids_can_attach,
.cancel_attach = pids_cancel_attach,
.can_fork = pids_can_fork,
--
2.5.0
next prev parent reply other threads:[~2015-08-23 13:10 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-08-23 12:24 Bad Reference Semantics in PIDs Controller Aleksa Sarai
2015-08-23 13:10 ` [PATCH 0/2] cgroup: pids: fix invalid reference semantics Aleksa Sarai
[not found] ` <1440335432-4202-1-git-send-email-cyphar-gVpy/LI/lHzQT0dZR+AlfA@public.gmane.org>
2015-08-23 13:10 ` [PATCH 1/2] cgroup: get a ref to source csses when migrating Aleksa Sarai
[not found] ` <1440335432-4202-2-git-send-email-cyphar-gVpy/LI/lHzQT0dZR+AlfA@public.gmane.org>
2015-08-24 18:45 ` Tejun Heo
[not found] ` <20150824184507.GB28944-qYNAdHglDFBN0TnZuCh8vA@public.gmane.org>
2015-08-25 2:00 ` Aleksa Sarai
2015-08-25 18:14 ` Tejun Heo
2015-08-23 13:10 ` Aleksa Sarai [this message]
2015-08-24 19:00 ` [PATCH 2/2] cgroup: pids: fix invalid get/put usage Tejun Heo
2015-08-23 13:13 ` [PATCH 0/2] cgroup: pids: fix invalid reference semantics Aleksa Sarai
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1440335432-4202-3-git-send-email-cyphar@cyphar.com \
--to=cyphar@cyphar.com \
--cc=cgroups@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=tj@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox