From: Joonsoo Kim <js1304@gmail.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: Johannes Weiner <hannes@cmpxchg.org>,
Michal Hocko <mhocko@suse.cz>,
cgroups@vger.kernel.org, linux-mm@kvack.org,
linux-kernel@vger.kernel.org,
Joonsoo Kim <iamjoonsoo.kim@lge.com>
Subject: [PATCH] mm/memcontrol: fix NULL pointer dereference when use_hierarchy is 0
Date: Tue, 17 Feb 2015 14:24:59 +0900 [thread overview]
Message-ID: <1424150699-5395-1-git-send-email-iamjoonsoo.kim@lge.com> (raw)
It can be possible to return NULL in parent_mem_cgroup()
if use_hierarchy is 0. So, we need to check NULL in the loop on
mem_cgroup_low(). Without it, following NULL pointer dereference happens.
[ 33.607531] BUG: unable to handle kernel NULL pointer dereference at 00000000000000b0
[ 33.608008] IP: [<ffffffff811dcf60>] mem_cgroup_low+0x40/0x90
[ 33.608008] PGD 1d893067 PUD 1cf41067 PMD 0
[ 33.608008] Oops: 0000 [#12] SMP
[ 33.608008] Modules linked in:
[ 33.608008] CPU: 1 PID: 3936 Comm: as Tainted: G D 3.19.0-next-20150216 #156
[ 33.608008] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS Bochs 01/01/2011
[ 33.608008] task: ffff88001d9c8000 ti: ffff88000cb14000 task.ti: ffff88000cb14000
[ 33.608008] RIP: 0010:[<ffffffff811dcf60>] [<ffffffff811dcf60>] mem_cgroup_low+0x40/0x90
[ 33.608008] RSP: 0000:ffff88000cb17a88 EFLAGS: 00010286
[ 33.608008] RAX: 0000000000000000 RBX: ffff88000cb17bc0 RCX: 0000000000000000
[ 33.608008] RDX: ffff88001f491400 RSI: 0000000000000000 RDI: 0000000000000000
[ 33.608008] RBP: ffff88000cb17a88 R08: 0000000000000160 R09: 0000000000000000
[ 33.608008] R10: 0000000000000000 R11: 0000000002b8c101 R12: 0000000000000000
[ 33.608008] R13: 0000000000000000 R14: ffff88001fff9e08 R15: ffff88001da95800
[ 33.608008] FS: 00002b7a12715380(0000) GS:ffff88001fa40000(0000) knlGS:0000000000000000
[ 33.608008] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[ 33.608008] CR2: 00000000000000b0 CR3: 000000000762f000 CR4: 00000000000007e0
[ 33.608008] Stack:
[ 33.608008] ffff88000cb17b18 ffffffff811838ec ffff88000cb17cd8 0000000000000000
[ 33.608008] 0000000000000000 0001000000000000 000280da00000000 ffff88001fff8780
[ 33.608008] ffff88000cb17af8 ffffffff810e1d7e ffff88001fff8780 000000030000000c
[ 33.608008] Call Trace:
[ 33.608008] [<ffffffff811838ec>] shrink_zone+0xac/0x2d0
[ 33.608008] [<ffffffff810e1d7e>] ? ktime_get+0x3e/0xa0
[ 33.608008] [<ffffffff81183e94>] do_try_to_free_pages+0x174/0x440
[ 33.608008] [<ffffffff8117f1a8>] ? throttle_direct_reclaim+0x98/0x250
[ 33.608008] [<ffffffff8118421a>] try_to_free_pages+0xba/0x150
[ 33.608008] [<ffffffff81176d10>] __alloc_pages_nodemask+0x5a0/0x950
[ 33.608008] [<ffffffff811c09ff>] alloc_pages_vma+0xaf/0x200
[ 33.608008] [<ffffffff811a0717>] handle_mm_fault+0x1287/0x17e0
[ 33.608008] [<ffffffff81059e9e>] ? kvm_clock_read+0x1e/0x20
[ 33.608008] [<ffffffff81059e9e>] ? kvm_clock_read+0x1e/0x20
[ 33.608008] [<ffffffff8101e6a9>] ? sched_clock+0x9/0x10
[ 33.608008] [<ffffffff810605f1>] __do_page_fault+0x191/0x440
[ 33.608008] [<ffffffff81060955>] trace_do_page_fault+0x45/0x100
[ 33.608008] [<ffffffff8105968e>] do_async_page_fault+0x1e/0xd0
[ 33.608008] [<ffffffff8176f628>] async_page_fault+0x28/0x30
[ 33.608008] Code: 48 8b 15 cc 21 b4 00 48 39 d6 74 53 48 8b 8e b0 00 00 00 48 39 8e 28 01 00 00 72 43 31 c9 48 39 fe 75 1d eb 35 66 0f 1f 44 00 00 <48> 8b 86 b0 00 00 00 48 39 86 28 01 00 00 72 30 48 39 f7 74 1a
[ 33.608008] RIP [<ffffffff811dcf60>] mem_cgroup_low+0x40/0x90
[ 33.608008] RSP <ffff88000cb17a88>
[ 33.608008] CR2: 00000000000000b0
[ 33.608008] BUG: unable to handle kernel [ 33.653499] ---[ end trace e264a32717ffda51 ]---
Signed-off-by: Joonsoo Kim <iamjoonsoo.kim@lge.com>
---
mm/memcontrol.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index d18d3a6..507cfea 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -5431,6 +5431,8 @@ bool mem_cgroup_low(struct mem_cgroup *root, struct mem_cgroup *memcg)
while (memcg != root) {
memcg = parent_mem_cgroup(memcg);
+ if (!memcg)
+ break;
if (memcg == root_mem_cgroup)
break;
--
1.9.1
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
next reply other threads:[~2015-02-17 5:25 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-02-17 5:24 Joonsoo Kim [this message]
2015-02-17 8:33 ` Michal Hocko
2015-02-17 12:28 ` Johannes Weiner
2015-02-25 1:20 ` Joonsoo Kim
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=1424150699-5395-1-git-send-email-iamjoonsoo.kim@lge.com \
--to=js1304@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=cgroups@vger.kernel.org \
--cc=hannes@cmpxchg.org \
--cc=iamjoonsoo.kim@lge.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mhocko@suse.cz \
/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