Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1646043

Re: mm, something wring in page_lock_anon_vma_read()?

From Hugh Dickins <hughd@google.com>
Newsgroups linux.kernel
Subject Re: mm, something wring in page_lock_anon_vma_read()?
Date 2017-05-20 04:10 +0200
Message-ID <tJ209-2WG-3@gated-at.bofh.it> (permalink)
References <tIqnU-qA-19@gated-at.bofh.it> <tILVn-84l-3@gated-at.bofh.it> <tIMHM-hj-13@gated-at.bofh.it> <tIYfT-57-1@gated-at.bofh.it> <tJ1ns-2mZ-1@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


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

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

mm, something wring in page_lock_anon_vma_read()? Xishi Qiu <qiuxishi@huawei.com> - 2017-05-18 12:00 +0200
  Re: mm, something wring in page_lock_anon_vma_read()? Xishi Qiu <qiuxishi@huawei.com> - 2017-05-19 11:00 +0200
    Re: mm, something wring in page_lock_anon_vma_read()? Xishi Qiu <qiuxishi@huawei.com> - 2017-05-19 11:50 +0200
      Re: mm, something wring in page_lock_anon_vma_read()? Hugh Dickins <hughd@google.com> - 2017-05-20 00:10 +0200
        Re: mm, something wring in page_lock_anon_vma_read()? Xishi Qiu <qiuxishi@huawei.com> - 2017-05-20 03:30 +0200
          Re: mm, something wring in page_lock_anon_vma_read()? Hugh Dickins <hughd@google.com> - 2017-05-20 04:10 +0200
            Re: mm, something wring in page_lock_anon_vma_read()? Xishi Qiu <qiuxishi@huawei.com> - 2017-05-20 04:30 +0200
              Re: mm, something wring in page_lock_anon_vma_read()? Hugh Dickins <hughd@google.com> - 2017-05-20 04:50 +0200
                Re: mm, something wring in page_lock_anon_vma_read()? zhong jiang <zhongjiang@huawei.com> - 2017-05-20 05:10 +0200
                Re: mm, something wring in page_lock_anon_vma_read()? Vlastimil Babka <vbabka@suse.cz> - 2017-05-22 19:00 +0200
                Re: mm, something wring in page_lock_anon_vma_read()? zhong jiang <zhongjiang@huawei.com> - 2017-05-23 11:30 +0200
                Re: mm, something wring in page_lock_anon_vma_read()? Vlastimil Babka <vbabka@suse.cz> - 2017-05-23 11:40 +0200
                Re: mm, something wring in page_lock_anon_vma_read()? zhong jiang <zhongjiang@huawei.com> - 2017-05-23 12:40 +0200
                Re: mm, something wring in page_lock_anon_vma_read()? Xishi Qiu <qiuxishi@huawei.com> - 2017-05-22 12:00 +0200
                Re: mm, something wring in page_lock_anon_vma_read()? Hugh Dickins <hughd@google.com> - 2017-05-22 21:30 +0200
                Re: mm, something wring in page_lock_anon_vma_read()? Xishi Qiu <qiuxishi@huawei.com> - 2017-05-23 04:30 +0200
                Re: mm, something wring in page_lock_anon_vma_read()? Hugh Dickins <hughd@google.com> - 2017-05-23 05:00 +0200

csiph-web