From: zhong jiang <zhongjiang@huawei.com> To: Andrea Arcangeli <aarcange@redhat.com> Cc: Mike Rapoport <rppt@linux.vnet.ibm.com>, Peter Xu <peterx@redhat.com>, Andrew Morton <akpm@linux-foundation.org>, Dmitry Vyukov <dvyukov@google.com>, syzbot <syzbot+cbb52e396df3e565ab02@syzkaller.appspotmail.com>, Michal Hocko <mhocko@kernel.org>, <cgroups@vger.kernel.org>, Johannes Weiner <hannes@cmpxchg.org>, LKML <linux-kernel@vger.kernel.org>, Linux-MM <linux-mm@kvack.org>, syzkaller-bugs <syzkaller-bugs@googlegroups.com>, Vladimir Davydov <vdavydov.dev@gmail.com>, David Rientjes <rientjes@google.com>, Hugh Dickins <hughd@google.com>, Matthew Wilcox <willy@infradead.org>, Mel Gorman <mgorman@suse.de>, Vlastimil Babka <vbabka@suse.cz> Subject: Re: KASAN: use-after-free Read in get_mem_cgroup_from_mm Date: Sat, 16 Mar 2019 17:38:54 +0800 [thread overview] Message-ID: <5C8CC42E.1090208@huawei.com> (raw) In-Reply-To: <20190315213944.GD9967@redhat.com> On 2019/3/16 5:39, Andrea Arcangeli wrote: > On Fri, Mar 08, 2019 at 03:10:08PM +0800, zhong jiang wrote: >> I can reproduce the issue in arm64 qemu machine. The issue will leave after applying the >> patch. >> >> Tested-by: zhong jiang <zhongjiang@huawei.com> > Thanks a lot for the quick testing! > >> Meanwhile, I just has a little doubt whether it is necessary to use RCU to free the task struct or not. >> I think that mm->owner alway be NULL after failing to create to process. Because we call mm_clear_owner. > I wish it was enough, but the problem is that the other CPU may be in > the middle of get_mem_cgroup_from_mm() while this runs, and it would > dereference mm->owner while it is been freed without the call_rcu > affter we clear mm->owner. What prevents this race is the As you had said, It would dereference mm->owner after we clear mm->owner. But after we clear mm->owner, mm->owner should be NULL. Is it right? And mem_cgroup_from_task will check the parameter. you mean that it is possible after checking the parameter to clear the owner . and the NULL pointer will trigger. :-( Thanks, zhong jiang > rcu_read_lock() in get_mem_cgroup_from_mm() and the corresponding > call_rcu to free the task struct in the fork failure path (again only > if CONFIG_MEMCG=y is defined). Considering you can reproduce this tiny > race on arm64 qemu (perhaps tcg JIT timing variantions helps?), you > might also in theory be able to still reproduce the race condition if > you remove the call_rcu from delayed_free_task and you replace it with > free_task. > > . >
WARNING: multiple messages have this Message-ID (diff)
From: zhong jiang <zhongjiang@huawei.com> To: Andrea Arcangeli <aarcange@redhat.com> Cc: Mike Rapoport <rppt@linux.vnet.ibm.com>, Peter Xu <peterx@redhat.com>, Andrew Morton <akpm@linux-foundation.org>, Dmitry Vyukov <dvyukov@google.com>, syzbot <syzbot+cbb52e396df3e565ab02@syzkaller.appspotmail.com>, Michal Hocko <mhocko@kernel.org>, cgroups@vger.kernel.org, Johannes Weiner <hannes@cmpxchg.org>, LKML <linux-kernel@vger.kernel.org>, Linux-MM <linux-mm@kvack.org>, syzkaller-bugs <syzkaller-bugs@googlegroups.com>, Vladimir Davydov <vdavydov.dev@gmail.com>, David Rientjes <rientjes@google.com>, Hugh Dickins <hughd@google.com>, Matthew Wilcox <willy@infradead.org>, Mel Gorman <mgorman@suse.de>, Vlastimil Babka <vbabka@suse.cz> Subject: Re: KASAN: use-after-free Read in get_mem_cgroup_from_mm Date: Sat, 16 Mar 2019 17:38:54 +0800 [thread overview] Message-ID: <5C8CC42E.1090208@huawei.com> (raw) In-Reply-To: <20190315213944.GD9967@redhat.com> On 2019/3/16 5:39, Andrea Arcangeli wrote: > On Fri, Mar 08, 2019 at 03:10:08PM +0800, zhong jiang wrote: >> I can reproduce the issue in arm64 qemu machine. The issue will leave after applying the >> patch. >> >> Tested-by: zhong jiang <zhongjiang@huawei.com> > Thanks a lot for the quick testing! > >> Meanwhile, I just has a little doubt whether it is necessary to use RCU to free the task struct or not. >> I think that mm->owner alway be NULL after failing to create to process. Because we call mm_clear_owner. > I wish it was enough, but the problem is that the other CPU may be in > the middle of get_mem_cgroup_from_mm() while this runs, and it would > dereference mm->owner while it is been freed without the call_rcu > affter we clear mm->owner. What prevents this race is the As you had said, It would dereference mm->owner after we clear mm->owner. But after we clear mm->owner, mm->owner should be NULL. Is it right? And mem_cgroup_from_task will check the parameter. you mean that it is possible after checking the parameter to clear the owner . and the NULL pointer will trigger. :-( Thanks, zhong jiang > rcu_read_lock() in get_mem_cgroup_from_mm() and the corresponding > call_rcu to free the task struct in the fork failure path (again only > if CONFIG_MEMCG=y is defined). Considering you can reproduce this tiny > race on arm64 qemu (perhaps tcg JIT timing variantions helps?), you > might also in theory be able to still reproduce the race condition if > you remove the call_rcu from delayed_free_task and you replace it with > free_task. > > . >
next prev parent reply other threads:[~2019-03-16 9:39 UTC|newest] Thread overview: 42+ messages / expand[flat|nested] mbox.gz Atom feed top 2018-11-07 1:52 KASAN: use-after-free Read in get_mem_cgroup_from_mm syzbot 2018-12-04 15:43 ` syzbot 2019-03-03 16:19 ` zhong jiang 2019-03-03 16:19 ` zhong jiang 2019-03-04 7:40 ` Dmitry Vyukov 2019-03-04 7:40 ` Dmitry Vyukov 2019-03-04 14:00 ` zhong jiang 2019-03-04 14:00 ` zhong jiang 2019-03-04 14:11 ` Dmitry Vyukov 2019-03-04 14:11 ` Dmitry Vyukov 2019-03-04 15:32 ` zhong jiang 2019-03-04 15:32 ` zhong jiang 2019-03-05 6:26 ` Dmitry Vyukov 2019-03-05 6:26 ` Dmitry Vyukov 2019-03-05 6:42 ` zhong jiang 2019-03-05 6:42 ` zhong jiang 2019-03-06 2:05 ` Andrea Arcangeli 2019-03-06 5:53 ` zhong jiang 2019-03-06 5:53 ` zhong jiang 2019-03-06 6:26 ` Mike Rapoport 2019-03-06 7:41 ` zhong jiang 2019-03-06 7:41 ` zhong jiang 2019-03-06 8:12 ` Peter Xu 2019-03-06 13:07 ` zhong jiang 2019-03-06 13:07 ` zhong jiang 2019-03-06 18:29 ` Andrea Arcangeli 2019-03-07 7:58 ` zhong jiang 2019-03-07 7:58 ` zhong jiang 2019-03-06 8:20 ` Mike Rapoport 2019-03-08 7:10 ` zhong jiang 2019-03-08 7:10 ` zhong jiang 2019-03-15 21:39 ` Andrea Arcangeli 2019-03-16 9:38 ` zhong jiang [this message] 2019-03-16 9:38 ` zhong jiang 2019-03-16 19:42 ` Andrea Arcangeli 2019-03-18 6:23 ` zhong jiang 2019-03-18 6:23 ` zhong jiang 2019-03-04 21:51 ` Matthew Wilcox 2019-03-05 3:09 ` zhong jiang 2019-03-05 3:09 ` zhong jiang 2019-03-22 9:36 ` syzbot 2019-03-22 9:36 ` syzbot
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=5C8CC42E.1090208@huawei.com \ --to=zhongjiang@huawei.com \ --cc=aarcange@redhat.com \ --cc=akpm@linux-foundation.org \ --cc=cgroups@vger.kernel.org \ --cc=dvyukov@google.com \ --cc=hannes@cmpxchg.org \ --cc=hughd@google.com \ --cc=linux-kernel@vger.kernel.org \ --cc=linux-mm@kvack.org \ --cc=mgorman@suse.de \ --cc=mhocko@kernel.org \ --cc=peterx@redhat.com \ --cc=rientjes@google.com \ --cc=rppt@linux.vnet.ibm.com \ --cc=syzbot+cbb52e396df3e565ab02@syzkaller.appspotmail.com \ --cc=syzkaller-bugs@googlegroups.com \ --cc=vbabka@suse.cz \ --cc=vdavydov.dev@gmail.com \ --cc=willy@infradead.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: linkBe 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.