From: Li Zefan <lizefan-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
To: Tejun Heo <tj-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
Cc: LKML <linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
Cgroups <cgroups-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>
Subject: [PATCH 7/8] cgroup: fix an almost harmless off-by-one bug
Date: Tue, 12 Mar 2013 14:52:15 +0800 [thread overview]
Message-ID: <513ED09F.2020906@huawei.com> (raw)
In-Reply-To: <513ED010.5060906-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
The 3rd parameter of flex_array_prealloc() is the number of elements,
not the index of the last element.
The effect of the bug is, when opening cgroup.procs, a flex array will
be allocated and all elements of the array is allocated with GFP_KERNEL
flag, but the last one is GFP_ATOMIC, , and if we fail to allocate memory
for it, it'll trigger a BUG_ON().
Signed-off-by: Li Zefan <lizefan-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
---
kernel/cgroup.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/kernel/cgroup.c b/kernel/cgroup.c
index 3206137..4b92b9a 100644
--- a/kernel/cgroup.c
+++ b/kernel/cgroup.c
@@ -2076,7 +2076,7 @@ static int cgroup_attach_proc(struct cgroup *cgrp, struct task_struct *leader)
if (!group)
return -ENOMEM;
/* pre-allocate to guarantee space while iterating in rcu read-side. */
- retval = flex_array_prealloc(group, 0, group_size - 1, GFP_KERNEL);
+ retval = flex_array_prealloc(group, 0, group_size, GFP_KERNEL);
if (retval)
goto out_free_group_list;
--
1.8.0.2
WARNING: multiple messages have this Message-ID (diff)
From: Li Zefan <lizefan@huawei.com>
To: Tejun Heo <tj@kernel.org>
Cc: LKML <linux-kernel@vger.kernel.org>, Cgroups <cgroups@vger.kernel.org>
Subject: [PATCH 7/8] cgroup: fix an almost harmless off-by-one bug
Date: Tue, 12 Mar 2013 14:52:15 +0800 [thread overview]
Message-ID: <513ED09F.2020906@huawei.com> (raw)
In-Reply-To: <513ED010.5060906@huawei.com>
The 3rd parameter of flex_array_prealloc() is the number of elements,
not the index of the last element.
The effect of the bug is, when opening cgroup.procs, a flex array will
be allocated and all elements of the array is allocated with GFP_KERNEL
flag, but the last one is GFP_ATOMIC, , and if we fail to allocate memory
for it, it'll trigger a BUG_ON().
Signed-off-by: Li Zefan <lizefan@huawei.com>
---
kernel/cgroup.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/kernel/cgroup.c b/kernel/cgroup.c
index 3206137..4b92b9a 100644
--- a/kernel/cgroup.c
+++ b/kernel/cgroup.c
@@ -2076,7 +2076,7 @@ static int cgroup_attach_proc(struct cgroup *cgrp, struct task_struct *leader)
if (!group)
return -ENOMEM;
/* pre-allocate to guarantee space while iterating in rcu read-side. */
- retval = flex_array_prealloc(group, 0, group_size - 1, GFP_KERNEL);
+ retval = flex_array_prealloc(group, 0, group_size, GFP_KERNEL);
if (retval)
goto out_free_group_list;
--
1.8.0.2
next prev parent reply other threads:[~2013-03-12 6:52 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-03-12 6:49 [PATCH 0/8] cgroup: a bunch of cleanups Li Zefan
2013-03-12 6:49 ` Li Zefan
2013-03-12 6:50 ` [PATCH 1/8] cgroup: remove cgroup_is_descentant() Li Zefan
2013-03-12 6:50 ` [PATCH 2/8] cgroup: remove unused variables in cgroup_destroy_locked() Li Zefan
2013-03-12 6:50 ` [PATCH 3/8] cgroup: hold cgroup_mutex before calling css_offline() Li Zefan
2013-03-12 6:50 ` [PATCH 4/8] cgroup: don't bother to resize pid array Li Zefan
2013-03-12 6:50 ` [PATCH 5/8] cgroup: remove useless code in cgroup_write_event_control() Li Zefan
[not found] ` <513ED010.5060906-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
2013-03-12 6:51 ` [PATCH 0/8] cgroup: a bunch of cleanups Li Zefan
2013-03-12 6:51 ` Li Zefan
2013-03-12 6:52 ` Li Zefan [this message]
2013-03-12 6:52 ` [PATCH 7/8] cgroup: fix an almost harmless off-by-one bug Li Zefan
2013-03-12 6:52 ` [PATCH 8/8] cgroup: consolidate cgroup_attach_task() and cgroup_attach_proc() Li Zefan
2013-03-12 6:52 ` Li Zefan
2013-03-12 22:38 ` [PATCH 0/8] cgroup: a bunch of cleanups Tejun Heo
2013-03-12 22:38 ` Tejun Heo
[not found] ` <20130312223839.GM25266-Gd/HAXX7CRxy/B6EtB590w@public.gmane.org>
2013-03-13 1:06 ` Li Zefan
2013-03-13 1:06 ` Li Zefan
2013-03-12 6:53 ` [PATCH 6/8] cgroup: remove unneeded includes from cgroup.h Li Zefan
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=513ED09F.2020906@huawei.com \
--to=lizefan-hv44wf8li93qt0dzr+alfa@public.gmane.org \
--cc=cgroups-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=tj-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.