From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756269AbdETCCc (ORCPT ); Fri, 19 May 2017 22:02:32 -0400 Received: from mail-pf0-f174.google.com ([209.85.192.174]:34726 "EHLO mail-pf0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755798AbdETCC1 (ORCPT ); Fri, 19 May 2017 22:02:27 -0400 Date: Fri, 19 May 2017 19:02:17 -0700 (PDT) From: Hugh Dickins X-X-Sender: hugh@eggly.anvils To: Xishi Qiu cc: Hugh Dickins , Andrew Morton , Tejun Heo , Michal Hocko , Johannes Weiner , Mel Gorman , Michal Hocko , Vlastimil Babka , Minchan Kim , David Rientjes , Joonsoo Kim , aarcange@redhat.com, sumeet.keswani@hpe.com, Rik van Riel , Linux MM , LKML , zhong jiang Subject: Re: mm, something wring in page_lock_anon_vma_read()? In-Reply-To: <591F9A09.6010707@huawei.com> Message-ID: References: <591D6D79.7030704@huawei.com> <591EB25C.9080901@huawei.com> <591EBE71.7080402@huawei.com> <591F9A09.6010707@huawei.com> User-Agent: Alpine 2.11 (LSU 23 2013-08-11) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, 20 May 2017, Xishi Qiu wrote: > On 2017/5/20 6:00, Hugh Dickins wrote: > > > > You're ignoring the rcu_read_lock() on entry to page_lock_anon_vma_read(), > > and the SLAB_DESTROY_BY_RCU (recently renamed SLAB_TYPESAFE_BY_RCU) nature > > of the anon_vma_cachep kmem cache. It is not safe to muck with anon_vma-> > > root in anon_vma_free(), others could still be looking at it. > > > > Hugh > > > > Hi Hugh, > > Thanks for your reply. > > SLAB_DESTROY_BY_RCU will let it call call_rcu() in free_slab(), but if the > anon_vma *reuse* by someone again, access root_anon_vma is not safe, right? That is safe, on reuse it is still a struct anon_vma; then the test for !page_mapped(page) will show that it's no longer a reliable anon_vma for this page, so page_lock_anon_vma_read() returns NULL. But of course, if page->_mapcount has been corrupted or misaccounted, it may think page_mapped(page) when actually page is not mapped, and the anon_vma is not good for it. > > e.g. if I clean the root pointer before free it, then access root_anon_vma > in page_lock_anon_vma_read() is NULL pointer access, right? Yes, cleaning root pointer before free may result in NULL pointer access. Hugh > > anon_vma_free() > ... > anon_vma->root = NULL; > kmem_cache_free(anon_vma_cachep, anon_vma); > ... > > Thanks, > Xishi Qiu