<feed xmlns='http://www.w3.org/2005/Atom'>
<title>kernel.git/mm/z3fold.c, branch linux-5.2.y</title>
<subtitle>Hosts the 0x221E linux distro kernel.
</subtitle>
<id>https://git.0xinfinity.dev/distro/kernel.git/atom?h=linux-5.2.y</id>
<link rel='self' href='https://git.0xinfinity.dev/distro/kernel.git/atom?h=linux-5.2.y'/>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/'/>
<updated>2019-10-05T11:14:10Z</updated>
<entry>
<title>z3fold: fix memory leak in kmem cache</title>
<updated>2019-10-05T11:14:10Z</updated>
<author>
<name>Vitaly Wool</name>
</author>
<published>2019-09-23T22:36:51Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=5377b8767d64a2a8728702ed7b1ca8d7b1783f01'/>
<id>urn:sha1:5377b8767d64a2a8728702ed7b1ca8d7b1783f01</id>
<content type='text'>
commit 63398413c00c7836ea87a1fa205c91d2199b25cf upstream.

Currently there is a leak in init_z3fold_page() -- it allocates handles
from kmem cache even for headless pages, but then they are never used and
never freed, so eventually kmem cache may get exhausted.  This patch
provides a fix for that.

Link: http://lkml.kernel.org/r/20190917185352.44cf285d3ebd9e64548de5de@gmail.com
Signed-off-by: Vitaly Wool &lt;vitalywool@gmail.com&gt;
Reported-by: Markus Linnala &lt;markus.linnala@gmail.com&gt;
Tested-by: Markus Linnala &lt;markus.linnala@gmail.com&gt;
Cc: Dan Streetman &lt;ddstreet@ieee.org&gt;
Cc: Henry Burns &lt;henrywolfeburns@gmail.com&gt;
Cc: Shakeel Butt &lt;shakeelb@google.com&gt;
Cc: Vlastimil Babka &lt;vbabka@suse.cz&gt;
Cc: &lt;stable@vger.kernel.org&gt;
Signed-off-by: Andrew Morton &lt;akpm@linux-foundation.org&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;

</content>
</entry>
<entry>
<title>z3fold: fix retry mechanism in page reclaim</title>
<updated>2019-10-05T11:14:09Z</updated>
<author>
<name>Vitaly Wool</name>
</author>
<published>2019-09-23T22:33:02Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=ed99d2d1af39aa2e1539d3f778d92fd3177b2fe2'/>
<id>urn:sha1:ed99d2d1af39aa2e1539d3f778d92fd3177b2fe2</id>
<content type='text'>
commit 3f9d2b5766aea06042630ac60b7316fd0cebf06f upstream.

z3fold_page_reclaim()'s retry mechanism is broken: on a second iteration
it will have zhdr from the first one so that zhdr is no longer in line
with struct page.  That leads to crashes when the system is stressed.

Fix that by moving zhdr assignment up.

While at it, protect against using already freed handles by using own
local slots structure in z3fold_page_reclaim().

Link: http://lkml.kernel.org/r/20190908162919.830388dc7404d1e2c80f4095@gmail.com
Signed-off-by: Vitaly Wool &lt;vitalywool@gmail.com&gt;
Reported-by: Markus Linnala &lt;markus.linnala@gmail.com&gt;
Reported-by: Chris Murphy &lt;bugzilla@colorremedies.com&gt;
Reported-by: Agustin Dall'Alba &lt;agustin@dallalba.com.ar&gt;
Cc: "Maciej S. Szmigiero" &lt;mail@maciej.szmigiero.name&gt;
Cc: Shakeel Butt &lt;shakeelb@google.com&gt;
Cc: Henry Burns &lt;henrywolfeburns@gmail.com&gt;
Cc: &lt;stable@vger.kernel.org&gt;
Signed-off-by: Andrew Morton &lt;akpm@linux-foundation.org&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;

</content>
</entry>
<entry>
<title>Revert "mm/z3fold.c: fix race between migration and destruction"</title>
<updated>2019-10-01T07:01:40Z</updated>
<author>
<name>Vitaly Wool</name>
</author>
<published>2019-09-23T22:32:56Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=d17860e1e8944fd89a6645d2ebd4654e62ab9d9c'/>
<id>urn:sha1:d17860e1e8944fd89a6645d2ebd4654e62ab9d9c</id>
<content type='text'>
commit 6e73fd25e2c7510b7dfadbaf701f31d4bff9c75b upstream.

With the original commit applied, z3fold_zpool_destroy() may get blocked
on wait_event() for indefinite time.  Revert this commit for the time
being to get rid of this problem since the issue the original commit
addresses is less severe.

Link: http://lkml.kernel.org/r/20190910123142.7a9c8d2de4d0acbc0977c602@gmail.com
Fixes: d776aaa9895eb6eb77 ("mm/z3fold.c: fix race between migration and destruction")
Reported-by: Agustín Dall'Alba &lt;agustin@dallalba.com.ar&gt;
Signed-off-by: Vitaly Wool &lt;vitalywool@gmail.com&gt;
Cc: Vlastimil Babka &lt;vbabka@suse.cz&gt;
Cc: Vitaly Wool &lt;vitalywool@gmail.com&gt;
Cc: Shakeel Butt &lt;shakeelb@google.com&gt;
Cc: Jonathan Adams &lt;jwadams@google.com&gt;
Cc: Henry Burns &lt;henrywolfeburns@gmail.com&gt;
Cc: &lt;stable@vger.kernel.org&gt;
Signed-off-by: Andrew Morton &lt;akpm@linux-foundation.org&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;

</content>
</entry>
<entry>
<title>mm/z3fold.c: fix lock/unlock imbalance in z3fold_page_isolate</title>
<updated>2019-09-19T07:11:06Z</updated>
<author>
<name>Gustavo A. R. Silva</name>
</author>
<published>2019-08-30T23:04:43Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=7c218ebc78995ab1cd8e53e1d7ed4844d4340644'/>
<id>urn:sha1:7c218ebc78995ab1cd8e53e1d7ed4844d4340644</id>
<content type='text'>
commit 14108b9131a47ff18a3c640f583eb2d625c75c0d upstream.

Fix lock/unlock imbalance by unlocking *zhdr* before return.

Addresses Coverity ID 1452811 ("Missing unlock")

Link: http://lkml.kernel.org/r/20190826030634.GA4379@embeddedor
Fixes: d776aaa9895e ("mm/z3fold.c: fix race between migration and destruction")
Signed-off-by: Gustavo A. R. Silva &lt;gustavo@embeddedor.com&gt;
Reviewed-by: Andrew Morton &lt;akpm@linux-foundation.org&gt;
Cc: Henry Burns &lt;henrywolfeburns@gmail.com&gt;
Cc: Vitaly Wool &lt;vitalywool@gmail.com&gt;
Cc: Shakeel Butt &lt;shakeelb@google.com&gt;
Signed-off-by: Andrew Morton &lt;akpm@linux-foundation.org&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;

</content>
</entry>
<entry>
<title>mm/z3fold.c: remove z3fold_migration trylock</title>
<updated>2019-09-19T07:11:06Z</updated>
<author>
<name>Henry Burns</name>
</author>
<published>2019-07-16T23:26:18Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=1894d857ce860cb76bd866bb5d951217034f3f6f'/>
<id>urn:sha1:1894d857ce860cb76bd866bb5d951217034f3f6f</id>
<content type='text'>
commit be03074c9af25d06cf8e9ebddfcd284c0bf7f947 upstream.

z3fold_page_migrate() will never succeed because it attempts to acquire
a lock that has already been taken by migrate.c in __unmap_and_move().

  __unmap_and_move() migrate.c
    trylock_page(oldpage)
    move_to_new_page(oldpage_newpage)
      a_ops-&gt;migrate_page(oldpage, newpage)
        z3fold_page_migrate(oldpage, newpage)
          trylock_page(oldpage)

Link: http://lkml.kernel.org/r/20190710213238.91835-1-henryburns@google.com
Fixes: 1f862989b04a ("mm/z3fold.c: support page migration")
Signed-off-by: Henry Burns &lt;henryburns@google.com&gt;
Reviewed-by: Shakeel Butt &lt;shakeelb@google.com&gt;
Cc: Vitaly Wool &lt;vitalywool@gmail.com&gt;
Cc: Vitaly Vul &lt;vitaly.vul@sony.com&gt;
Cc: Jonathan Adams &lt;jwadams@google.com&gt;
Cc: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
Cc: Snild Dolkow &lt;snild@sony.com&gt;
Cc: Thomas Gleixner &lt;tglx@linutronix.de&gt;
Signed-off-by: Andrew Morton &lt;akpm@linux-foundation.org&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;

</content>
</entry>
<entry>
<title>mm/z3fold.c: fix race between migration and destruction</title>
<updated>2019-08-29T06:30:25Z</updated>
<author>
<name>Henry Burns</name>
</author>
<published>2019-08-25T00:54:37Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=764fa2f4ff59591fd04b504f8f8fb46ec16641a9'/>
<id>urn:sha1:764fa2f4ff59591fd04b504f8f8fb46ec16641a9</id>
<content type='text'>
commit d776aaa9895eb6eb770908e899cb7f5bd5025b3c upstream.

In z3fold_destroy_pool() we call destroy_workqueue(&amp;pool-&gt;compact_wq).
However, we have no guarantee that migration isn't happening in the
background at that time.

Migration directly calls queue_work_on(pool-&gt;compact_wq), if destruction
wins that race we are using a destroyed workqueue.

Link: http://lkml.kernel.org/r/20190809213828.202833-1-henryburns@google.com
Signed-off-by: Henry Burns &lt;henryburns@google.com&gt;
Cc: Vitaly Wool &lt;vitalywool@gmail.com&gt;
Cc: Shakeel Butt &lt;shakeelb@google.com&gt;
Cc: Jonathan Adams &lt;jwadams@google.com&gt;
Cc: Henry Burns &lt;henrywolfeburns@gmail.com&gt;
Cc: &lt;stable@vger.kernel.org&gt;
Signed-off-by: Andrew Morton &lt;akpm@linux-foundation.org&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;

</content>
</entry>
<entry>
<title>mm/z3fold.c: fix z3fold_destroy_pool() race condition</title>
<updated>2019-08-25T14:10:21Z</updated>
<author>
<name>Henry Burns</name>
</author>
<published>2019-08-13T22:37:25Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=a6b0004e741c4a42975fff5d773f2da6cf598b7c'/>
<id>urn:sha1:a6b0004e741c4a42975fff5d773f2da6cf598b7c</id>
<content type='text'>
commit b997052bc3ac444a0bceab1093aff7ae71ed419e upstream.

The constraint from the zpool use of z3fold_destroy_pool() is there are
no outstanding handles to memory (so no active allocations), but it is
possible for there to be outstanding work on either of the two wqs in
the pool.

Calling z3fold_deregister_migration() before the workqueues are drained
means that there can be allocated pages referencing a freed inode,
causing any thread in compaction to be able to trip over the bad pointer
in PageMovable().

Link: http://lkml.kernel.org/r/20190726224810.79660-2-henryburns@google.com
Fixes: 1f862989b04a ("mm/z3fold.c: support page migration")
Signed-off-by: Henry Burns &lt;henryburns@google.com&gt;
Reviewed-by: Shakeel Butt &lt;shakeelb@google.com&gt;
Reviewed-by: Jonathan Adams &lt;jwadams@google.com&gt;
Cc: Vitaly Vul &lt;vitaly.vul@sony.com&gt;
Cc: Vitaly Wool &lt;vitalywool@gmail.com&gt;
Cc: David Howells &lt;dhowells@redhat.com&gt;
Cc: Thomas Gleixner &lt;tglx@linutronix.de&gt;
Cc: Al Viro &lt;viro@zeniv.linux.org.uk&gt;
Cc: Henry Burns &lt;henrywolfeburns@gmail.com&gt;
Cc: &lt;stable@vger.kernel.org&gt;
Signed-off-by: Andrew Morton &lt;akpm@linux-foundation.org&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;

</content>
</entry>
<entry>
<title>mm/z3fold.c: fix z3fold_destroy_pool() ordering</title>
<updated>2019-08-25T14:10:21Z</updated>
<author>
<name>Henry Burns</name>
</author>
<published>2019-08-13T22:37:21Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=d87e9ae7f6059350188379fd28d813ca7776de0a'/>
<id>urn:sha1:d87e9ae7f6059350188379fd28d813ca7776de0a</id>
<content type='text'>
commit 6051d3bd3b91e96c59e62b8be2dba1cc2b19ee40 upstream.

The constraint from the zpool use of z3fold_destroy_pool() is there are
no outstanding handles to memory (so no active allocations), but it is
possible for there to be outstanding work on either of the two wqs in
the pool.

If there is work queued on pool-&gt;compact_workqueue when it is called,
z3fold_destroy_pool() will do:

   z3fold_destroy_pool()
     destroy_workqueue(pool-&gt;release_wq)
     destroy_workqueue(pool-&gt;compact_wq)
       drain_workqueue(pool-&gt;compact_wq)
         do_compact_page(zhdr)
           kref_put(&amp;zhdr-&gt;refcount)
             __release_z3fold_page(zhdr, ...)
               queue_work_on(pool-&gt;release_wq, &amp;pool-&gt;work) *BOOM*

So compact_wq needs to be destroyed before release_wq.

Link: http://lkml.kernel.org/r/20190726224810.79660-1-henryburns@google.com
Fixes: 5d03a6613957 ("mm/z3fold.c: use kref to prevent page free/compact race")
Signed-off-by: Henry Burns &lt;henryburns@google.com&gt;
Reviewed-by: Shakeel Butt &lt;shakeelb@google.com&gt;
Reviewed-by: Jonathan Adams &lt;jwadams@google.com&gt;
Cc: Vitaly Vul &lt;vitaly.vul@sony.com&gt;
Cc: Vitaly Wool &lt;vitalywool@gmail.com&gt;
Cc: David Howells &lt;dhowells@redhat.com&gt;
Cc: Thomas Gleixner &lt;tglx@linutronix.de&gt;
Cc: Al Viro &lt;viro@zeniv.linux.org.uk
Cc: Henry Burns &lt;henrywolfeburns@gmail.com&gt;
Cc: &lt;stable@vger.kernel.org&gt;
Signed-off-by: Andrew Morton &lt;akpm@linux-foundation.org&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;

</content>
</entry>
<entry>
<title>mm/z3fold.c: reinitialize zhdr structs after migration</title>
<updated>2019-08-06T17:08:10Z</updated>
<author>
<name>Henry Burns</name>
</author>
<published>2019-07-16T23:26:21Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=8a3dfde5a2b2b914ff1a8c9112dd9c0b08580a11'/>
<id>urn:sha1:8a3dfde5a2b2b914ff1a8c9112dd9c0b08580a11</id>
<content type='text'>
[ Upstream commit c92d2f38563db20c20c8db2f98fa1349290477d5 ]

z3fold_page_migration() calls memcpy(new_zhdr, zhdr, PAGE_SIZE).
However, zhdr contains fields that can't be directly coppied over (ex:
list_head, a circular linked list).  We only need to initialize the
linked lists in new_zhdr, as z3fold_isolate_page() already ensures that
these lists are empty

Additionally it is possible that zhdr-&gt;work has been placed in a
workqueue.  In this case we shouldn't migrate the page, as zhdr-&gt;work
references zhdr as opposed to new_zhdr.

Link: http://lkml.kernel.org/r/20190716000520.230595-1-henryburns@google.com
Fixes: 1f862989b04ade61d3 ("mm/z3fold.c: support page migration")
Signed-off-by: Henry Burns &lt;henryburns@google.com&gt;
Reviewed-by: Shakeel Butt &lt;shakeelb@google.com&gt;
Cc: Vitaly Vul &lt;vitaly.vul@sony.com&gt;
Cc: Vitaly Wool &lt;vitalywool@gmail.com&gt;
Cc: Jonathan Adams &lt;jwadams@google.com&gt;
Signed-off-by: Andrew Morton &lt;akpm@linux-foundation.org&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
Signed-off-by: Sasha Levin &lt;sashal@kernel.org&gt;
</content>
</entry>
<entry>
<title>mm/z3fold: don't try to use buddy slots after free</title>
<updated>2019-08-06T17:08:10Z</updated>
<author>
<name>Vitaly Wool</name>
</author>
<published>2019-07-16T23:25:48Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=8bd71641fc130b609246bb3433d09d06a5567a7a'/>
<id>urn:sha1:8bd71641fc130b609246bb3433d09d06a5567a7a</id>
<content type='text'>
[ Upstream commit bb9a374dfa3a2f46581455ab66cd1d24c5e3d183 ]

As reported by Henry Burns:

Running z3fold stress testing with address sanitization showed zhdr-&gt;slots
was being used after it was freed.

  z3fold_free(z3fold_pool, handle)
    free_handle(handle)
      kmem_cache_free(pool-&gt;c_handle, zhdr-&gt;slots)
    release_z3fold_page_locked_list(kref)
      __release_z3fold_page(zhdr, true)
        zhdr_to_pool(zhdr)
          slots_to_pool(zhdr-&gt;slots)  *BOOM*

To fix this, add pointer to the pool back to z3fold_header and modify
zhdr_to_pool to return zhdr-&gt;pool.

Link: http://lkml.kernel.org/r/20190708134808.e89f3bfadd9f6ffd7eff9ba9@gmail.com
Fixes: 7c2b8baa61fe  ("mm/z3fold.c: add structure for buddy handles")
Signed-off-by: Vitaly Wool &lt;vitalywool@gmail.com&gt;
Reported-by: Henry Burns &lt;henryburns@google.com&gt;
Reviewed-by: Shakeel Butt &lt;shakeelb@google.com&gt;
Cc: Jonathan Adams &lt;jwadams@google.com&gt;
Signed-off-by: Andrew Morton &lt;akpm@linux-foundation.org&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
Signed-off-by: Sasha Levin &lt;sashal@kernel.org&gt;
</content>
</entry>
</feed>
