[syzbot] [mm?] WARNING: bad unlock balance in madvise_cold_or_pageout_pte_range

21 views
Skip to first unread message

syzbot

unread,
Apr 2, 2024, 1:32:29 PMApr 2
to ak...@linux-foundation.org, linux-...@vger.kernel.org, linu...@kvack.org, syzkall...@googlegroups.com
Hello,

syzbot found the following issue on:

HEAD commit: c0b832517f62 Add linux-next specific files for 20240402
git tree: linux-next
console output: https://syzkaller.appspot.com/x/log.txt?x=155b7db1180000
kernel config: https://syzkaller.appspot.com/x/.config?x=afcaf46d374cec8c
dashboard link: https://syzkaller.appspot.com/bug?extid=c641706ad4e9688cccdf
compiler: Debian clang version 15.0.6, GNU ld (GNU Binutils for Debian) 2.40

Unfortunately, I don't have any reproducer for this issue yet.

Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/0d36ec76edc7/disk-c0b83251.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/6f9bb4e37dd0/vmlinux-c0b83251.xz
kernel image: https://storage.googleapis.com/syzbot-assets/2349287b14b7/bzImage-c0b83251.xz

IMPORTANT: if you fix the issue, please add the following tag to the commit:
Reported-by: syzbot+c64170...@syzkaller.appspotmail.com

=====================================
WARNING: bad unlock balance detected!
6.9.0-rc2-next-20240402-syzkaller #0 Not tainted
-------------------------------------
syz-executor.4/9211 is trying to release lock (ptlock_ptr(ptdesc)) at:
[<ffffffff81f01c0f>] spin_unlock include/linux/spinlock.h:391 [inline]
[<ffffffff81f01c0f>] madvise_cold_or_pageout_pte_range+0x170f/0x3990 mm/madvise.c:480
but there are no more locks to release!

other info that might help us debug this:
1 lock held by syz-executor.4/9211:
#0: ffff888067e40b18 (&mm->mmap_lock){++++}-{3:3}, at: mmap_read_lock include/linux/mmap_lock.h:144 [inline]
#0: ffff888067e40b18 (&mm->mmap_lock){++++}-{3:3}, at: do_madvise+0x481/0x44a0 mm/madvise.c:1429

stack backtrace:
CPU: 0 PID: 9211 Comm: syz-executor.4 Not tainted 6.9.0-rc2-next-20240402-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 03/27/2024
Call Trace:
<TASK>
__dump_stack lib/dump_stack.c:88 [inline]
dump_stack_lvl+0x241/0x360 lib/dump_stack.c:114
print_unlock_imbalance_bug+0x256/0x2c0 kernel/locking/lockdep.c:5194
__lock_release kernel/locking/lockdep.c:5431 [inline]
lock_release+0x599/0x9f0 kernel/locking/lockdep.c:5774
__raw_spin_unlock include/linux/spinlock_api_smp.h:141 [inline]
_raw_spin_unlock+0x16/0x50 kernel/locking/spinlock.c:186
spin_unlock include/linux/spinlock.h:391 [inline]
madvise_cold_or_pageout_pte_range+0x170f/0x3990 mm/madvise.c:480
walk_pmd_range mm/pagewalk.c:143 [inline]
walk_pud_range mm/pagewalk.c:221 [inline]
walk_p4d_range mm/pagewalk.c:256 [inline]
walk_pgd_range+0xba1/0x1810 mm/pagewalk.c:293
__walk_page_range+0x132/0x720 mm/pagewalk.c:395
walk_page_range+0x58f/0x7c0 mm/pagewalk.c:521
madvise_cold_page_range mm/madvise.c:562 [inline]
madvise_cold mm/madvise.c:584 [inline]
madvise_vma_behavior mm/madvise.c:1028 [inline]
madvise_walk_vmas mm/madvise.c:1256 [inline]
do_madvise+0x1e7b/0x44a0 mm/madvise.c:1442
__do_sys_madvise mm/madvise.c:1457 [inline]
__se_sys_madvise mm/madvise.c:1455 [inline]
__x64_sys_madvise+0xa6/0xc0 mm/madvise.c:1455
do_syscall_64+0xfb/0x240
entry_SYSCALL_64_after_hwframe+0x72/0x7a
RIP: 0033:0x7ff60947dda9
Code: 28 00 00 00 75 05 48 83 c4 28 c3 e8 e1 20 00 00 90 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 b0 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007ff60a1b50c8 EFLAGS: 00000246 ORIG_RAX: 000000000000001c
RAX: ffffffffffffffda RBX: 00007ff6095abf80 RCX: 00007ff60947dda9
RDX: 0000000000000014 RSI: 0000000000600000 RDI: 0000000020000000
RBP: 00007ff6094ca47a R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
R13: 000000000000000b R14: 00007ff6095abf80 R15: 00007fffacd4bc68
</TASK>
------------[ cut here ]------------
pvqspinlock: lock 0xffff88802ed23120 has corrupted value 0x0!
WARNING: CPU: 1 PID: 9211 at kernel/locking/qspinlock_paravirt.h:510 __pv_queued_spin_unlock_slowpath+0x241/0x2f0 kernel/locking/qspinlock_paravirt.h:508
Modules linked in:
CPU: 1 PID: 9211 Comm: syz-executor.4 Not tainted 6.9.0-rc2-next-20240402-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 03/27/2024
RIP: 0010:__pv_queued_spin_unlock_slowpath+0x241/0x2f0 kernel/locking/qspinlock_paravirt.h:508
Code: 65 47 6e f6 4c 89 f0 48 c1 e8 03 0f b6 04 18 84 c0 0f 85 9f 00 00 00 41 8b 16 48 c7 c7 c0 26 cb 8b 4c 89 f6 e8 90 f3 cb f5 90 <0f> 0b 90 90 eb 8d 44 89 f1 80 e1 07 38 c1 0f 8c 26 ff ff ff 4c 89
RSP: 0018:ffffc9000e477238 EFLAGS: 00010246
RAX: 5e9807e53cfb4f00 RBX: dffffc0000000000 RCX: 0000000000040000
RDX: ffffc9000b3b8000 RSI: 000000000003ffff RDI: 0000000000040000
RBP: dffffc0000000000 R08: ffffffff81580192 R09: fffffbfff1c39b10
R10: dffffc0000000000 R11: fffffbfff1c39b10 R12: 1ffff11005da4626
R13: ffff88802ed23130 R14: ffff88802ed23120 R15: ffff88802ed23120
FS: 00007ff60a1b56c0(0000) GS:ffff8880b9500000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00007fea8ecdaab3 CR3: 000000005d0fe000 CR4: 00000000003506f0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
Call Trace:
<TASK>
__raw_callee_save___pv_queued_spin_unlock_slowpath+0x15/0x30
.slowpath+0x9/0x16
pv_queued_spin_unlock arch/x86/include/asm/paravirt.h:589 [inline]
queued_spin_unlock arch/x86/include/asm/qspinlock.h:57 [inline]
do_raw_spin_unlock+0x13c/0x8b0 kernel/locking/spinlock_debug.c:142
__raw_spin_unlock include/linux/spinlock_api_smp.h:142 [inline]
_raw_spin_unlock+0x1e/0x50 kernel/locking/spinlock.c:186
spin_unlock include/linux/spinlock.h:391 [inline]
madvise_cold_or_pageout_pte_range+0x170f/0x3990 mm/madvise.c:480
walk_pmd_range mm/pagewalk.c:143 [inline]
walk_pud_range mm/pagewalk.c:221 [inline]
walk_p4d_range mm/pagewalk.c:256 [inline]
walk_pgd_range+0xba1/0x1810 mm/pagewalk.c:293
__walk_page_range+0x132/0x720 mm/pagewalk.c:395
walk_page_range+0x58f/0x7c0 mm/pagewalk.c:521
madvise_cold_page_range mm/madvise.c:562 [inline]
madvise_cold mm/madvise.c:584 [inline]
madvise_vma_behavior mm/madvise.c:1028 [inline]
madvise_walk_vmas mm/madvise.c:1256 [inline]
do_madvise+0x1e7b/0x44a0 mm/madvise.c:1442
__do_sys_madvise mm/madvise.c:1457 [inline]
__se_sys_madvise mm/madvise.c:1455 [inline]
__x64_sys_madvise+0xa6/0xc0 mm/madvise.c:1455
do_syscall_64+0xfb/0x240
entry_SYSCALL_64_after_hwframe+0x72/0x7a
RIP: 0033:0x7ff60947dda9
Code: 28 00 00 00 75 05 48 83 c4 28 c3 e8 e1 20 00 00 90 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 b0 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007ff60a1b50c8 EFLAGS: 00000246 ORIG_RAX: 000000000000001c
RAX: ffffffffffffffda RBX: 00007ff6095abf80 RCX: 00007ff60947dda9
RDX: 0000000000000014 RSI: 0000000000600000 RDI: 0000000020000000
RBP: 00007ff6094ca47a R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
R13: 000000000000000b R14: 00007ff6095abf80 R15: 00007fffacd4bc68
</TASK>


---
This report is generated by a bot. It may contain errors.
See https://goo.gl/tpsmEJ for more information about syzbot.
syzbot engineers can be reached at syzk...@googlegroups.com.

syzbot will keep track of this issue. See:
https://goo.gl/tpsmEJ#status for how to communicate with syzbot.

If the report is already addressed, let syzbot know by replying with:
#syz fix: exact-commit-title

If you want to overwrite report's subsystems, reply with:
#syz set subsystems: new-subsystem
(See the list of subsystem names on the web dashboard)

If the report is a duplicate of another one, reply with:
#syz dup: exact-subject-of-another-report

If you want to undo deduplication, reply with:
#syz undup

David Hildenbrand

unread,
Apr 3, 2024, 4:55:21 AMApr 3
to syzbot, ak...@linux-foundation.org, linux-...@vger.kernel.org, linu...@kvack.org, syzkall...@googlegroups.com, Ryan Roberts
I'd suspect:

commit 38456b4a3c609b205d5fdc6ef5347824a83fd818
Author: Ryan Roberts <ryan.r...@arm.com>
Date: Wed Mar 27 14:45:37 2024 +0000

mm: madvise: avoid split during MADV_PAGEOUT and MADV_COLD

but I don't immediately see the issue. CCing Ryan.

--
Cheers,

David / dhildenb

Ryan Roberts

unread,
Apr 3, 2024, 6:04:12 AMApr 3
to David Hildenbrand, syzbot, ak...@linux-foundation.org, linux-...@vger.kernel.org, linu...@kvack.org, syzkall...@googlegroups.com
Yes I believe this is the same issue that Barry reported [1]. I have a fix that
will be in my v6 of the swap-out series (hopefully today). I've already asked
Andrew to remove my v5 series from mm-unstable.

Sorry about this!

[1] https://lore.kernel.org/linux-mm/cbef3584-d3a7-4843...@arm.com/


syzbot

unread,
Apr 4, 2024, 6:56:26 AMApr 4
to ak...@linux-foundation.org, da...@redhat.com, linux-...@vger.kernel.org, linu...@kvack.org, ryan.r...@arm.com, syzkall...@googlegroups.com
syzbot has found a reproducer for the following issue on:

HEAD commit: 727900b675b7 Add linux-next specific files for 20240403
git tree: linux-next
console+strace: https://syzkaller.appspot.com/x/log.txt?x=11f66223180000
kernel config: https://syzkaller.appspot.com/x/.config?x=afcaf46d374cec8c
dashboard link: https://syzkaller.appspot.com/bug?extid=c641706ad4e9688cccdf
compiler: Debian clang version 15.0.6, GNU ld (GNU Binutils for Debian) 2.40
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=12a62423180000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=13764a3d180000

Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/f8fb4daa7a83/disk-727900b6.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/d2a6994aee53/vmlinux-727900b6.xz
kernel image: https://storage.googleapis.com/syzbot-assets/6759e5411c39/bzImage-727900b6.xz

IMPORTANT: if you fix the issue, please add the following tag to the commit:
Reported-by: syzbot+c64170...@syzkaller.appspotmail.com

=====================================
WARNING: bad unlock balance detected!
6.9.0-rc2-next-20240403-syzkaller #0 Not tainted
-------------------------------------
syz-executor799/5099 is trying to release lock (ptlock_ptr(ptdesc)) at:
[<ffffffff81f01f3f>] spin_unlock include/linux/spinlock.h:391 [inline]
[<ffffffff81f01f3f>] madvise_cold_or_pageout_pte_range+0x170f/0x3990 mm/madvise.c:480
but there are no more locks to release!

other info that might help us debug this:
1 lock held by syz-executor799/5099:
#0: ffff888015073a98 (&mm->mmap_lock){++++}-{3:3}
, at: mmap_read_lock include/linux/mmap_lock.h:144 [inline]
, at: do_madvise+0x481/0x44a0 mm/madvise.c:1429

stack backtrace:
CPU: 1 PID: 5099 Comm: syz-executor799 Not tainted 6.9.0-rc2-next-20240403-syzkaller #0
RIP: 0033:0x7f3928ac2419
Code: 28 00 00 00 75 05 48 83 c4 28 c3 e8 51 18 00 00 90 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 b0 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007f3928a5c218 EFLAGS: 00000246 ORIG_RAX: 000000000000001c
RAX: ffffffffffffffda RBX: 00007f3928b4c318 RCX: 00007f3928ac2419
RDX: 0000000000000014 RSI: 00000000dfc3efff RDI: 00000000203c1000
RBP: 00007f3928b4c310 R08: 00007ffd7796b097 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 00007f3928b19064
R13: 000000080000000e R14: 000000200000007f R15: 00000000dfc3efff
</TASK>
------------[ cut here ]------------
pvqspinlock: lock 0xffff88802ec45b40 has corrupted value 0x0!
WARNING: CPU: 1 PID: 5099 at kernel/locking/qspinlock_paravirt.h:510 __pv_queued_spin_unlock_slowpath+0x241/0x2f0 kernel/locking/qspinlock_paravirt.h:508
Modules linked in:

CPU: 1 PID: 5099 Comm: syz-executor799 Not tainted 6.9.0-rc2-next-20240403-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 03/27/2024
RIP: 0010:__pv_queued_spin_unlock_slowpath+0x241/0x2f0 kernel/locking/qspinlock_paravirt.h:508
Code: 85 0a 6e f6 4c 89 f0 48 c1 e8 03 0f b6 04 18 84 c0 0f 85 9f 00 00 00 41 8b 16 48 c7 c7 c0 26 cb 8b 4c 89 f6 e8 40 b3 cb f5 90 <0f> 0b 90 90 eb 8d 44 89 f1 80 e1 07 38 c1 0f 8c 26 ff ff ff 4c 89
RSP: 0018:ffffc9000364f238 EFLAGS: 00010246

RAX: 9a7270b7f8439200 RBX: dffffc0000000000 RCX: ffff888023139e00
RDX: 0000000000000000 RSI: 0000000000000000 RDI: 0000000000000000
RBP: dffffc0000000000 R08: ffffffff81580152 R09: 1ffffffff1f526cd
R10: dffffc0000000000 R11: fffffbfff1f526ce R12: 1ffff11005d88b6a
R13: ffff88802ec45b50 R14: ffff88802ec45b40 R15: ffff88802ec45b40
FS: 00007f3928a5c6c0(0000) GS:ffff8880b9500000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 0000561c1eec8018 CR3: 00000000213dc000 CR4: 00000000003506f0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
Call Trace:
<TASK>
__raw_callee_save___pv_queued_spin_unlock_slowpath+0x15/0x30
.slowpath+0x9/0x16
pv_queued_spin_unlock arch/x86/include/asm/paravirt.h:589 [inline]
queued_spin_unlock arch/x86/include/asm/qspinlock.h:57 [inline]
do_raw_spin_unlock+0x13c/0x8b0 kernel/locking/spinlock_debug.c:142
__raw_spin_unlock include/linux/spinlock_api_smp.h:142 [inline]
_raw_spin_unlock+0x1e/0x50 kernel/locking/spinlock.c:186
spin_unlock include/linux/spinlock.h:391 [inline]
madvise_cold_or_pageout_pte_range+0x170f/0x3990 mm/madvise.c:480
walk_pmd_range mm/pagewalk.c:143 [inline]
walk_pud_range mm/pagewalk.c:221 [inline]
walk_p4d_range mm/pagewalk.c:256 [inline]
walk_pgd_range+0xba1/0x1810 mm/pagewalk.c:293
__walk_page_range+0x132/0x720 mm/pagewalk.c:395
walk_page_range+0x58f/0x7c0 mm/pagewalk.c:521
madvise_cold_page_range mm/madvise.c:562 [inline]
madvise_cold mm/madvise.c:584 [inline]
madvise_vma_behavior mm/madvise.c:1028 [inline]
madvise_walk_vmas mm/madvise.c:1256 [inline]
do_madvise+0x1e7b/0x44a0 mm/madvise.c:1442


---
If you want syzbot to run the reproducer, reply with:
#syz test: git://repo/address.git branch-or-commit-hash
If you attach or paste a git patch, syzbot will apply it before testing.

Ryan Roberts

unread,
Apr 4, 2024, 7:23:47 AMApr 4
to syzbot, ak...@linux-foundation.org, da...@redhat.com, linux-...@vger.kernel.org, linu...@kvack.org, syzkall...@googlegroups.com
#syz test: git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm mm-unstable

mm-unstable now has the fix; let's check it actually fixes the problem.

Hillf Danton

unread,
Apr 4, 2024, 7:45:07 AMApr 4
to syzbot, linux-...@vger.kernel.org, syzkall...@googlegroups.com
On Thu, 04 Apr 2024 03:56:24 -0700
> syzbot has found a reproducer for the following issue on:
>
> HEAD commit: 727900b675b7 Add linux-next specific files for 20240403
> git tree: linux-next
> C reproducer: https://syzkaller.appspot.com/x/repro.c?x=13764a3d180000

#syz test https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git 727900b675b7

--- x/mm/madvise.c
+++ y/mm/madvise.c
@@ -482,10 +482,7 @@ restart:
err = split_folio(folio);
folio_unlock(folio);
folio_put(folio);
- if (err)
- continue;
- start_pte = pte =
- pte_offset_map_lock(mm, pmd, addr, &ptl);
+ start_pte = pte = pte_offset_map_lock(mm, pmd, addr, &ptl);
if (!start_pte)
break;
arch_enter_lazy_mmu_mode();
--

syzbot

unread,
Apr 4, 2024, 4:35:06 PMApr 4
to ak...@linux-foundation.org, da...@redhat.com, linux-...@vger.kernel.org, linu...@kvack.org, ryan.r...@arm.com, syzkall...@googlegroups.com
Hello,

syzbot has tested the proposed patch and the reproducer did not trigger any issue:

Reported-and-tested-by: syzbot+c64170...@syzkaller.appspotmail.com

Tested on:

commit: e04f7296 __mod_memcg_lruvec_state(): enhance diagnostics
git tree: git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm mm-unstable
console output: https://syzkaller.appspot.com/x/log.txt?x=10888115180000
kernel config: https://syzkaller.appspot.com/x/.config?x=1ba2443e2eb20292
dashboard link: https://syzkaller.appspot.com/bug?extid=c641706ad4e9688cccdf
compiler: Debian clang version 15.0.6, GNU ld (GNU Binutils for Debian) 2.40

Note: no patches were applied.
Note: testing is done by a robot and is best-effort only.

syzbot

unread,
Apr 4, 2024, 6:19:06 PMApr 4
to hda...@sina.com, linux-...@vger.kernel.org, syzkall...@googlegroups.com
Hello,

syzbot has tested the proposed patch and the reproducer did not trigger any issue:

Reported-and-tested-by: syzbot+c64170...@syzkaller.appspotmail.com

Tested on:

commit: 727900b6 Add linux-next specific files for 20240403
git tree: https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
console output: https://syzkaller.appspot.com/x/log.txt?x=17446b3d180000
kernel config: https://syzkaller.appspot.com/x/.config?x=afcaf46d374cec8c
dashboard link: https://syzkaller.appspot.com/bug?extid=c641706ad4e9688cccdf
compiler: Debian clang version 15.0.6, GNU ld (GNU Binutils for Debian) 2.40
patch: https://syzkaller.appspot.com/x/patch.diff?x=1268c903180000
Reply all
Reply to author
Forward
0 new messages