2021-07-25 08:21:25

by syzbot

[permalink] [raw]
Subject: [syzbot] BUG: sleeping function called from invalid context in folio_copy

Hello,

syzbot found the following issue on:

HEAD commit: b1347210b01d Add linux-next specific files for 20210721
git tree: linux-next
console output: https://syzkaller.appspot.com/x/log.txt?x=1417aeca300000
kernel config: https://syzkaller.appspot.com/x/.config?x=86c6d14fadc3db60
dashboard link: https://syzkaller.appspot.com/bug?extid=bb4c69145b4a52b40b27
compiler: gcc (Debian 10.2.1-6) 10.2.1 20210110, GNU ld (GNU Binutils for Debian) 2.35.1
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=1202e6ca300000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=12ca875a300000

IMPORTANT: if you fix the issue, please add the following tag to the commit:
Reported-by: [email protected]

BUG: sleeping function called from invalid context at mm/util.c:761
in_atomic(): 1, irqs_disabled(): 0, non_block: 0, pid: 1660, name: kcompactd0
1 lock held by kcompactd0/1660:
#0: ffff8880111a4f70 (&mapping->private_lock){+.+.}-{2:2}, at: spin_lock include/linux/spinlock.h:359 [inline]
#0: ffff8880111a4f70 (&mapping->private_lock){+.+.}-{2:2}, at: __buffer_migrate_page+0x3a8/0xa80 mm/migrate.c:722
Preemption disabled at:
[<0000000000000000>] 0x0
CPU: 0 PID: 1660 Comm: kcompactd0 Not tainted 5.14.0-rc2-next-20210721-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
Call Trace:
__dump_stack lib/dump_stack.c:88 [inline]
dump_stack_lvl+0xcd/0x134 lib/dump_stack.c:105
___might_sleep.cold+0x1f3/0x239 kernel/sched/core.c:9182
folio_copy+0x10c/0x1a0 mm/util.c:761
folio_migrate_copy+0x19/0x30 mm/migrate.c:619
__buffer_migrate_page+0x820/0xa80 mm/migrate.c:757
move_to_new_page+0x339/0xf00 mm/migrate.c:904
__unmap_and_move mm/migrate.c:1069 [inline]
unmap_and_move mm/migrate.c:1210 [inline]
migrate_pages+0x2867/0x3890 mm/migrate.c:1487
compact_zone+0x1abb/0x3860 mm/compaction.c:2393
kcompactd_do_work+0x2c9/0x730 mm/compaction.c:2808
kcompactd+0x262/0xd10 mm/compaction.c:2903
kthread+0x3e5/0x4d0 kernel/kthread.c:319
ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:295
BUG: sleeping function called from invalid context at mm/util.c:761
in_atomic(): 1, irqs_disabled(): 0, non_block: 0, pid: 1660, name: kcompactd0
1 lock held by kcompactd0/1660:
#0: ffff8880111a4f70 (&mapping->private_lock){+.+.}-{2:2}, at: spin_lock include/linux/spinlock.h:359 [inline]
#0: ffff8880111a4f70 (&mapping->private_lock){+.+.}-{2:2}, at: __buffer_migrate_page+0x3a8/0xa80 mm/migrate.c:722
Preemption disabled at:
[<0000000000000000>] 0x0
CPU: 0 PID: 1660 Comm: kcompactd0 Tainted: G W 5.14.0-rc2-next-20210721-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
Call Trace:
__dump_stack lib/dump_stack.c:88 [inline]
dump_stack_lvl+0xcd/0x134 lib/dump_stack.c:105
___might_sleep.cold+0x1f3/0x239 kernel/sched/core.c:9182
folio_copy+0x10c/0x1a0 mm/util.c:761
folio_migrate_copy+0x19/0x30 mm/migrate.c:619
__buffer_migrate_page+0x820/0xa80 mm/migrate.c:757
move_to_new_page+0x339/0xf00 mm/migrate.c:904
__unmap_and_move mm/migrate.c:1069 [inline]
unmap_and_move mm/migrate.c:1210 [inline]
migrate_pages+0x2867/0x3890 mm/migrate.c:1487
compact_zone+0x1abb/0x3860 mm/compaction.c:2393
kcompactd_do_work+0x2c9/0x730 mm/compaction.c:2808
kcompactd+0x262/0xd10 mm/compaction.c:2903
kthread+0x3e5/0x4d0 kernel/kthread.c:319
ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:295


---
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 [email protected].

syzbot will keep track of this issue. See:
https://goo.gl/tpsmEJ#status for how to communicate with syzbot.
syzbot can test patches for this issue, for details see:
https://goo.gl/tpsmEJ#testing-patches


2021-07-26 05:23:18

by Andrew Morton

[permalink] [raw]
Subject: Re: [syzbot] BUG: sleeping function called from invalid context in folio_copy

(Cc Matthew)

(It might not be a folio thing at all - I haven't checked yet)

On Sun, 25 Jul 2021 01:18:27 -0700 syzbot <[email protected]> wrote:

> Hello,
>
> syzbot found the following issue on:
>
> HEAD commit: b1347210b01d Add linux-next specific files for 20210721
> git tree: linux-next
> console output: https://syzkaller.appspot.com/x/log.txt?x=1417aeca300000
> kernel config: https://syzkaller.appspot.com/x/.config?x=86c6d14fadc3db60
> dashboard link: https://syzkaller.appspot.com/bug?extid=bb4c69145b4a52b40b27
> compiler: gcc (Debian 10.2.1-6) 10.2.1 20210110, GNU ld (GNU Binutils for Debian) 2.35.1
> syz repro: https://syzkaller.appspot.com/x/repro.syz?x=1202e6ca300000
> C reproducer: https://syzkaller.appspot.com/x/repro.c?x=12ca875a300000
>
> IMPORTANT: if you fix the issue, please add the following tag to the commit:
> Reported-by: [email protected]
>
> BUG: sleeping function called from invalid context at mm/util.c:761
> in_atomic(): 1, irqs_disabled(): 0, non_block: 0, pid: 1660, name: kcompactd0
> 1 lock held by kcompactd0/1660:
> #0: ffff8880111a4f70 (&mapping->private_lock){+.+.}-{2:2}, at: spin_lock include/linux/spinlock.h:359 [inline]
> #0: ffff8880111a4f70 (&mapping->private_lock){+.+.}-{2:2}, at: __buffer_migrate_page+0x3a8/0xa80 mm/migrate.c:722
> Preemption disabled at:
> [<0000000000000000>] 0x0
> CPU: 0 PID: 1660 Comm: kcompactd0 Not tainted 5.14.0-rc2-next-20210721-syzkaller #0
> Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
> Call Trace:
> __dump_stack lib/dump_stack.c:88 [inline]
> dump_stack_lvl+0xcd/0x134 lib/dump_stack.c:105
> ___might_sleep.cold+0x1f3/0x239 kernel/sched/core.c:9182
> folio_copy+0x10c/0x1a0 mm/util.c:761
> folio_migrate_copy+0x19/0x30 mm/migrate.c:619
> __buffer_migrate_page+0x820/0xa80 mm/migrate.c:757
> move_to_new_page+0x339/0xf00 mm/migrate.c:904
> __unmap_and_move mm/migrate.c:1069 [inline]
> unmap_and_move mm/migrate.c:1210 [inline]
> migrate_pages+0x2867/0x3890 mm/migrate.c:1487
> compact_zone+0x1abb/0x3860 mm/compaction.c:2393
> kcompactd_do_work+0x2c9/0x730 mm/compaction.c:2808
> kcompactd+0x262/0xd10 mm/compaction.c:2903
> kthread+0x3e5/0x4d0 kernel/kthread.c:319
> ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:295
> BUG: sleeping function called from invalid context at mm/util.c:761
> in_atomic(): 1, irqs_disabled(): 0, non_block: 0, pid: 1660, name: kcompactd0
> 1 lock held by kcompactd0/1660:
> #0: ffff8880111a4f70 (&mapping->private_lock){+.+.}-{2:2}, at: spin_lock include/linux/spinlock.h:359 [inline]
> #0: ffff8880111a4f70 (&mapping->private_lock){+.+.}-{2:2}, at: __buffer_migrate_page+0x3a8/0xa80 mm/migrate.c:722
> Preemption disabled at:
> [<0000000000000000>] 0x0
> CPU: 0 PID: 1660 Comm: kcompactd0 Tainted: G W 5.14.0-rc2-next-20210721-syzkaller #0
> Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
> Call Trace:
> __dump_stack lib/dump_stack.c:88 [inline]
> dump_stack_lvl+0xcd/0x134 lib/dump_stack.c:105
> ___might_sleep.cold+0x1f3/0x239 kernel/sched/core.c:9182
> folio_copy+0x10c/0x1a0 mm/util.c:761
> folio_migrate_copy+0x19/0x30 mm/migrate.c:619
> __buffer_migrate_page+0x820/0xa80 mm/migrate.c:757
> move_to_new_page+0x339/0xf00 mm/migrate.c:904
> __unmap_and_move mm/migrate.c:1069 [inline]
> unmap_and_move mm/migrate.c:1210 [inline]
> migrate_pages+0x2867/0x3890 mm/migrate.c:1487
> compact_zone+0x1abb/0x3860 mm/compaction.c:2393
> kcompactd_do_work+0x2c9/0x730 mm/compaction.c:2808
> kcompactd+0x262/0xd10 mm/compaction.c:2903
> kthread+0x3e5/0x4d0 kernel/kthread.c:319
> ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:295
>
>
> ---
> 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 [email protected].
>
> syzbot will keep track of this issue. See:
> https://goo.gl/tpsmEJ#status for how to communicate with syzbot.
> syzbot can test patches for this issue, for details see:
> https://goo.gl/tpsmEJ#testing-patches

2021-07-26 12:50:33

by Matthew Wilcox

[permalink] [raw]
Subject: Re: [syzbot] BUG: sleeping function called from invalid context in folio_copy

On Sun, Jul 25, 2021 at 10:18:34PM -0700, Andrew Morton wrote:
> (Cc Matthew)
>
> (It might not be a folio thing at all - I haven't checked yet)

Already fixed, thanks. folio_copy() had a cond_resched() in it,
even if it was only copying a single page. Now it only calls
cond_resched() if it's copying more than one page.

We discussed this in the folio call on Friday, because we're leaving a
bit of a landmine here for whoever tries to make multi-page folios work
with buffer_heads. There's not much we can do about it for now; it'll
just be one of the many problems to be dealt with. Hopefully filesystems
will convert to iomap instead of trying to make buffer_heads support
multiple pages.