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

20 views
Skip to first unread message

syzbot

unread,
Jul 25, 2021, 4:18:28 AM7/25/21
to ak...@linux-foundation.org, linux-...@vger.kernel.org, linu...@kvack.org, syzkall...@googlegroups.com
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: syzbot+bb4c69...@syzkaller.appspotmail.com

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 syzk...@googlegroups.com.

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

Andrew Morton

unread,
Jul 26, 2021, 1:18:36 AM7/26/21
to syzbot, linux-...@vger.kernel.org, linu...@kvack.org, syzkall...@googlegroups.com, Matthew Wilcox
(Cc Matthew)

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

syzbot

unread,
Jul 26, 2021, 4:31:09 AM7/26/21
to chouhan.sh...@gmail.com, syzkall...@googlegroups.com
Hello,

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

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

Tested on:

commit: ff117646 Linux 5.14-rc3
git tree: upstream
kernel config: https://syzkaller.appspot.com/x/.config?x=4c93349bb5f9dc76
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

Note: testing is done by a robot and is best-effort only.

Matthew Wilcox

unread,
Jul 26, 2021, 8:47:09 AM7/26/21
to Andrew Morton, syzbot, linux-...@vger.kernel.org, linu...@kvack.org, syzkall...@googlegroups.com
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.

syzbot

unread,
Jul 27, 2021, 12:15:11 AM7/27/21
to syzkall...@googlegroups.com, wang...@vivo.com
Hello,

syzbot tried to test the proposed patch but the build/boot failed:

failed to apply patch:
can't find file to patch at input line 5
Perhaps you used the wrong -p or --strip option?
The text leading up to this was:
--------------------------
|diff --git a/mm/folio-compat.c b/mm/folio-compat.c
|index 5b6ae1d..13ec6aa
|--- a/mm/folio-compat.c
|+++ b/mm/folio-compat.c
--------------------------
No file to patch. Skipping patch.
1 out of 1 hunk ignored
checking file mm/migrate.c
Hunk #1 FAILED at 614.
Hunk #2 FAILED at 647.
2 out of 2 hunks FAILED



Tested on:

commit: 3dbdb38e Merge branch 'for-5.14' of git://git.kernel.o..
git tree: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
patch: https://syzkaller.appspot.com/x/patch.diff?x=16d5ac66300000

syzbot

unread,
Jul 27, 2021, 9:06:11 AM7/27/21
to syzkall...@googlegroups.com, wang...@vivo.com
Hello,

syzbot tried to test the proposed patch but the build/boot failed:

failed to checkout kernel repo git://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/Thanks: failed to run ["git" "fetch" "--force" "6e274abda436d30078c0e5fb9703cc1905bba23f" "Thanks"]: exit status 128
fatal: couldn't find remote ref Thanks



Tested on:

commit: [unknown
git tree: git://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git Thanks
patch: https://syzkaller.appspot.com/x/patch.diff?x=1608e862300000

Reply all
Reply to author
Forward
0 new messages