From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
To: Mike Galbraith <efault@gmx.de>, Vitaly Wool <vitaly.wool@konsulko.com>
Cc: Oleksandr Natalenko <oleksandr@natalenko.name>,
linux-kernel@vger.kernel.org, linux-mm@kvack.org,
Andrew Morton <akpm@linux-foundation.org>,
Steven Rostedt <rostedt@goodmis.org>,
Thomas Gleixner <tglx@linutronix.de>,
linux-rt-users@vger.kernel.org
Subject: Re: scheduling while atomic in z3fold
Date: Wed, 2 Dec 2020 23:08:26 +0100 [thread overview]
Message-ID: <20201202220826.5chy56mbgvrwmg3d@linutronix.de> (raw)
In-Reply-To: <fca7ecadf1bddafb7e88cbeb4a57d1464c87b044.camel@gmx.de>
On 2020-12-02 03:30:27 [+0100], Mike Galbraith wrote:
> > > In an LTP install, ./runltp -f mm. Shortly after box starts swapping
> > > insanely, it explodes quite reliably here with either z3fold or
> > > zsmalloc.. but not with zbud.
>
> What I'm seeing is the below. rt_mutex_has_waiters() says yup we have
> a waiter, rt_mutex_top_waiter() emits the missing cached leftmost, and
> rt_mutex_dequeue_pi() chokes on it. Lock is buggered.
correct. So this:
diff --git a/mm/z3fold.c b/mm/z3fold.c
--- a/mm/z3fold.c
+++ b/mm/z3fold.c
@@ -342,7 +342,7 @@ static inline void free_handle(unsigned long handle)
if (is_free) {
struct z3fold_pool *pool = slots_to_pool(slots);
-
+ memset(slots, 0xee, sizeof(struct z3fold_buddy_slots));
kmem_cache_free(pool->c_handle, slots);
}
}
@@ -548,8 +549,10 @@ static void __release_z3fold_page(struct z3fold_header *zhdr, bool locked)
set_bit(HANDLES_ORPHANED, &zhdr->slots->pool);
read_unlock(&zhdr->slots->lock);
- if (is_free)
+ if (is_free) {
+ memset(zhdr->slots, 0xdd, sizeof(struct z3fold_buddy_slots));
kmem_cache_free(pool->c_handle, zhdr->slots);
+ }
if (locked)
z3fold_page_unlock(zhdr);
resulted in:
|[ 377.200696] Out of memory: Killed process 284358 (oom01) total-vm:15780488kB, anon-rss:150624kB, file-rss:0kB, shmem-rss:0kB, UID:0 pgtables:16760kB oom_score_adj:0
|[ 377.205438] ------------[ cut here ]------------
|[ 377.205441] pvqspinlock: lock 0xffff8880105c6828 has corrupted value 0xdddddddd!
|[ 377.205448] WARNING: CPU: 6 PID: 72 at kernel/locking/qspinlock_paravirt.h:498 __pv_queued_spin_unlock_slowpath+0xb3/0xc0
|[ 377.205455] Modules linked in:
|[ 377.205456] CPU: 6 PID: 72 Comm: oom_reaper Not tainted 5.10.0-rc6-rt13-rt+ #103
|[ 377.205458] Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.14.0-1 04/01/2014
|[ 377.205460] RIP: 0010:__pv_queued_spin_unlock_slowpath+0xb3/0xc0
…
|[ 377.205475] Call Trace:
|[ 377.205477] __raw_callee_save___pv_queued_spin_unlock_slowpath+0x11/0x20
|[ 377.205481] .slowpath+0x9/0xe
|[ 377.205483] _raw_spin_unlock_irqrestore+0x5/0x50
|[ 377.205486] rt_mutex_futex_unlock+0x9e/0xb0
|[ 377.205488] z3fold_free+0x2b0/0x470
|[ 377.205491] zswap_free_entry+0x7d/0xc0
|[ 377.205493] zswap_frontswap_invalidate_page+0x87/0x90
|[ 377.205495] __frontswap_invalidate_page+0x58/0x90
|[ 377.205496] swap_range_free.constprop.0+0x99/0xb0
|[ 377.205499] swapcache_free_entries+0x131/0x390
|[ 377.205501] free_swap_slot+0x99/0xc0
|[ 377.205502] __swap_entry_free+0x8a/0xa0
|[ 377.205504] free_swap_and_cache+0x36/0xd0
|[ 377.205506] zap_pte_range+0x16a/0x940
|[ 377.205509] unmap_page_range+0x1d8/0x310
|[ 377.205514] __oom_reap_task_mm+0xe7/0x190
|[ 377.205520] oom_reap_task_mm+0x5a/0x280
|[ 377.205521] oom_reaper+0x98/0x1c0
|[ 377.205525] kthread+0x18c/0x1b0
|[ 377.205528] ret_from_fork+0x22/0x30
|[ 377.205531] ---[ end trace 0000000000000002 ]---
Then I reverted commit
4a3ac9311dac3 ("mm/z3fold.c: add inter-page compaction")
and it seems to work now. Any suggestions? It looks like use-after-free.
Sebastian
next prev parent reply other threads:[~2020-12-02 22:09 UTC|newest]
Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-11-28 14:05 scheduling while atomic in z3fold Oleksandr Natalenko
2020-11-28 14:09 ` Oleksandr Natalenko
2020-11-28 14:27 ` Oleksandr Natalenko
2020-11-29 6:41 ` Mike Galbraith
2020-11-29 7:48 ` Mike Galbraith
2020-11-29 9:21 ` Mike Galbraith
2020-11-29 10:56 ` Mike Galbraith
2020-11-29 11:29 ` Oleksandr Natalenko
2020-11-29 11:41 ` Mike Galbraith
2020-11-30 13:20 ` Sebastian Andrzej Siewior
2020-11-30 13:53 ` Oleksandr Natalenko
2020-11-30 14:28 ` Sebastian Andrzej Siewior
2020-11-30 14:42 ` Mike Galbraith
2020-11-30 14:52 ` Sebastian Andrzej Siewior
2020-11-30 15:01 ` Mike Galbraith
2020-11-30 15:03 ` Mike Galbraith
2020-11-30 16:03 ` Sebastian Andrzej Siewior
2020-11-30 16:27 ` Mike Galbraith
2020-11-30 16:32 ` Sebastian Andrzej Siewior
2020-11-30 16:36 ` Mike Galbraith
2020-11-30 19:09 ` Mike Galbraith
2020-11-30 16:53 ` Mike Galbraith
2020-12-02 2:30 ` Mike Galbraith
2020-12-02 22:08 ` Sebastian Andrzej Siewior [this message]
2020-12-03 2:16 ` Mike Galbraith
2020-12-03 8:18 ` Mike Galbraith
2020-12-03 13:39 ` Sebastian Andrzej Siewior
2020-12-03 14:07 ` Vitaly Wool
2020-12-06 9:18 ` Mike Galbraith
[not found] ` <cad7848c-7fd3-b4a4-c079-5896bb47ee49@konsulko.com>
2020-12-07 2:18 ` Mike Galbraith
2020-12-07 11:52 ` Vitaly Wool
2020-12-07 12:34 ` Mike Galbraith
2020-12-07 15:21 ` Vitaly Wool
2020-12-07 15:41 ` Sebastian Andrzej Siewior
2020-12-07 15:41 ` Mike Galbraith
2020-12-08 23:26 ` Vitaly Wool
2020-12-09 6:13 ` Mike Galbraith
2020-12-09 6:31 ` Mike Galbraith
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=20201202220826.5chy56mbgvrwmg3d@linutronix.de \
--to=bigeasy@linutronix.de \
--cc=akpm@linux-foundation.org \
--cc=efault@gmx.de \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=linux-rt-users@vger.kernel.org \
--cc=oleksandr@natalenko.name \
--cc=rostedt@goodmis.org \
--cc=tglx@linutronix.de \
--cc=vitaly.wool@konsulko.com \
/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;
as well as URLs for NNTP newsgroup(s).