* [syzbot] [mm?] BUG: sleeping function called from invalid context in shmem_undo_range
@ 2026-04-24 0:23 syzbot
2026-04-24 2:34 ` Arjan van de Ven
0 siblings, 1 reply; 2+ messages in thread
From: syzbot @ 2026-04-24 0:23 UTC (permalink / raw)
To: akpm, baolin.wang, hughd, linux-kernel, linux-mm, syzkaller-bugs
Hello,
syzbot found the following issue on:
HEAD commit: 2a4c0c11c019 Merge tag 's390-7.1-1' of git://git.kernel.or..
git tree: upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=109c12d2580000
kernel config: https://syzkaller.appspot.com/x/.config?x=24c8da4692f901cb
dashboard link: https://syzkaller.appspot.com/bug?extid=9722a25de70a85ff48a1
compiler: gcc (Debian 14.2.0-19) 14.2.0, GNU ld (GNU Binutils for Debian) 2.44
userspace arch: i386
Unfortunately, I don't have any reproducer for this issue yet.
Downloadable assets:
disk image (non-bootable): https://storage.googleapis.com/syzbot-assets/d900f083ada3/non_bootable_disk-2a4c0c11.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/acfb852f3eb2/vmlinux-2a4c0c11.xz
kernel image: https://storage.googleapis.com/syzbot-assets/d8166ea5d3da/bzImage-2a4c0c11.xz
IMPORTANT: if you fix the issue, please add the following tag to the commit:
Reported-by: syzbot+9722a25de70a85ff48a1@syzkaller.appspotmail.com
BUG: sleeping function called from invalid context at mm/shmem.c:1150
in_atomic(): 0, irqs_disabled(): 0, non_block: 0, pid: 5904, name: rm
preempt_count: 0, expected: 0
RCU nest depth: 1, expected: 0
2 locks held by rm/5904:
#0: ffff88802b0d0410 (sb_writers#5){.+.+}-{0:0}, at: filename_unlinkat+0x1ad/0x730 fs/namei.c:5545
#1: ffffffff8e7e5260 (rcu_read_lock){....}-{1:3}, at: rcu_lock_acquire.constprop.0+0x7/0x30 include/linux/rcupdate.h:300
CPU: 1 UID: 0 PID: 5904 Comm: rm Not tainted syzkaller #0 PREEMPT(full)
Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.16.3-debian-1.16.3-2 04/01/2014
Call Trace:
<TASK>
__dump_stack lib/dump_stack.c:94 [inline]
dump_stack_lvl+0x100/0x190 lib/dump_stack.c:120
__might_resched.cold+0x1ec/0x232 kernel/sched/core.c:9162
shmem_undo_range+0x447/0x1570 mm/shmem.c:1150
shmem_truncate_range mm/shmem.c:1277 [inline]
shmem_evict_inode+0x3f3/0xc40 mm/shmem.c:1407
evict+0x3c2/0xad0 fs/inode.c:841
iput_final fs/inode.c:1960 [inline]
iput.part.0+0x605/0xf50 fs/inode.c:2009
iput+0x35/0x40 fs/inode.c:1975
filename_unlinkat+0x466/0x730 fs/namei.c:5572
__do_sys_unlink fs/namei.c:5603 [inline]
__se_sys_unlink fs/namei.c:5600 [inline]
__x64_sys_unlink+0x46/0x70 fs/namei.c:5600
do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline]
do_syscall_64+0x10b/0xf80 arch/x86/entry/syscall_64.c:94
entry_SYSCALL_64_after_hwframe+0x77/0x7f
RIP: 0033:0x7eff00dbe937
Code: 00 00 e9 a9 fd ff ff 66 2e 0f 1f 84 00 00 00 00 00 66 90 b8 5f 00 00 00 0f 05 c3 0f 1f 84 00 00 00 00 00 b8 57 00 00 00 0f 05 <48> 3d 00 f0 ff ff 77 01 c3 48 8b 15 91 b4 0d 00 f7 d8 64 89 02 b8
RSP: 002b:00007ffef2c377b8 EFLAGS: 00000246 ORIG_RAX: 0000000000000057
RAX: ffffffffffffffda RBX: 00007ffef2c37dd7 RCX: 00007eff00dbe937
RDX: 00007ffef2c377c8 RSI: 00007ffef2c37dd7 RDI: 00007ffef2c37dd7
RBP: 0000000000000008 R08: 00007ffef2c37dc0 R09: 0000000000000000
R10: 0000000000000100 R11: 0000000000000246 R12: 0000000000000000
R13: 00007eff00f4e9cc R14: 00007eff00faa000 R15: 000055fe0234bd98
</TASK>
================================================
WARNING: lock held when returning to user space!
syzkaller #0 Tainted: G W
------------------------------------------------
rm/5904 is leaving the kernel with locks still held!
1 lock held by rm/5904:
#0: ffffffff8e7e5260 (rcu_read_lock){....}-{1:3}, at: rcu_lock_acquire.constprop.0+0x7/0x30 include/linux/rcupdate.h:300
------------[ cut here ]------------
Voluntary context switch within RCU read-side critical section!
WARNING: kernel/rcu/tree_plugin.h:332 at rcu_note_context_switch+0x859/0x19c0 kernel/rcu/tree_plugin.h:332, CPU#1: rm/5904
Modules linked in:
CPU: 1 UID: 0 PID: 5904 Comm: rm Tainted: G W syzkaller #0 PREEMPT(full)
Tainted: [W]=WARN
Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.16.3-debian-1.16.3-2 04/01/2014
RIP: 0010:rcu_note_context_switch+0x859/0x19c0 kernel/rcu/tree_plugin.h:332
Code: c1 ea 03 80 3c 02 00 0f 85 9b 0b 00 00 48 8b 53 28 b9 01 00 00 00 4c 89 ef e8 a3 cf fe ff e9 1d f9 ff ff 48 8d 3d b7 5e f1 0e <67> 48 0f b9 3a e9 99 f8 ff ff 48 b8 00 00 00 00 00 fc ff df 48 8d
RSP: 0000:ffffc9000407fcf0 EFLAGS: 00010002
RAX: 0000000000000001 RBX: ffff88802b33c3c0 RCX: ffffffff81ee0fc1
RDX: 0000000000000000 RSI: ffffffff8c1c1000 RDI: ffffffff90dfe2a0
RBP: ffff8880267b2500 R08: 0000000000000000 R09: fffffbfff21b89ca
R10: ffffffff90dc4e57 R11: ffffffff94142590 R12: 0000000000000000
R13: ffff8880267b29c4 R14: ffff88802b33b380 R15: ffffffff90dc81c4
FS: 00007eff00c00c80(0000) GS:ffff8880971e2000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00007eff00da0850 CR3: 000000004cf7d000 CR4: 0000000000352ef0
Call Trace:
<TASK>
__schedule+0x276/0x6820 kernel/sched/core.c:7043
__schedule_loop kernel/sched/core.c:7267 [inline]
schedule+0xdd/0x390 kernel/sched/core.c:7282
__exit_to_user_mode_loop kernel/entry/common.c:54 [inline]
exit_to_user_mode_loop kernel/entry/common.c:98 [inline]
__exit_to_user_mode_prepare include/linux/irq-entry-common.h:207 [inline]
irqentry_exit_to_user_mode_prepare include/linux/irq-entry-common.h:252 [inline]
irqentry_exit_to_user_mode include/linux/irq-entry-common.h:323 [inline]
irqentry_exit+0x359/0x790 kernel/entry/common.c:162
asm_sysvec_apic_timer_interrupt+0x1a/0x20 arch/x86/include/asm/idtentry.h:697
RIP: 0033:0x7eff00dbe937
Code: 00 00 e9 a9 fd ff ff 66 2e 0f 1f 84 00 00 00 00 00 66 90 b8 5f 00 00 00 0f 05 c3 0f 1f 84 00 00 00 00 00 b8 57 00 00 00 0f 05 <48> 3d 00 f0 ff ff 77 01 c3 48 8b 15 91 b4 0d 00 f7 d8 64 89 02 b8
RSP: 002b:00007ffef2c377b8 EFLAGS: 00000246
RAX: 0000000000000000 RBX: 00007ffef2c37dd7 RCX: 00007eff00dbe937
RDX: 00007ffef2c377c8 RSI: 00007ffef2c37dd7 RDI: 00007ffef2c37dd7
RBP: 0000000000000008 R08: 00007ffef2c37dc0 R09: 0000000000000000
R10: 0000000000000100 R11: 0000000000000246 R12: 0000000000000000
R13: 00007eff00f4e9cc R14: 00007eff00faa000 R15: 000055fe0234bd98
</TASK>
----------------
Code disassembly (best guess):
0: c1 ea 03 shr $0x3,%edx
3: 80 3c 02 00 cmpb $0x0,(%rdx,%rax,1)
7: 0f 85 9b 0b 00 00 jne 0xba8
d: 48 8b 53 28 mov 0x28(%rbx),%rdx
11: b9 01 00 00 00 mov $0x1,%ecx
16: 4c 89 ef mov %r13,%rdi
19: e8 a3 cf fe ff call 0xfffecfc1
1e: e9 1d f9 ff ff jmp 0xfffff940
23: 48 8d 3d b7 5e f1 0e lea 0xef15eb7(%rip),%rdi # 0xef15ee1
* 2a: 67 48 0f b9 3a ud1 (%edx),%rdi <-- trapping instruction
2f: e9 99 f8 ff ff jmp 0xfffff8cd
34: 48 b8 00 00 00 00 00 movabs $0xdffffc0000000000,%rax
3b: fc ff df
3e: 48 rex.W
3f: 8d .byte 0x8d
---
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 syzkaller@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
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [syzbot] [mm?] BUG: sleeping function called from invalid context in shmem_undo_range
2026-04-24 0:23 [syzbot] [mm?] BUG: sleeping function called from invalid context in shmem_undo_range syzbot
@ 2026-04-24 2:34 ` Arjan van de Ven
0 siblings, 0 replies; 2+ messages in thread
From: Arjan van de Ven @ 2026-04-24 2:34 UTC (permalink / raw)
To: linux-mm
Cc: syzbot+9722a25de70a85ff48a1, akpm, baolin.wang, hughd,
linux-kernel, syzkaller-bugs
This email is created by automation to help kernel developers
deal with a large volume of AI generated bug reports by decoding
oopses into more actionable information.
Decoded Backtrace
shmem_undo_range (mm/shmem.c:1108-1151) -- crash site
------------------------------------------------------
1108 static void shmem_undo_range(struct inode *inode, loff_t lstart,
1109 uoff_t lend, bool unfalloc)
1110 {
1111 struct address_space *mapping = inode->i_mapping;
1112 struct shmem_inode_info *info = SHMEM_I(inode);
1113 pgoff_t start = (lstart + PAGE_SIZE - 1) >> PAGE_SHIFT;
1114 pgoff_t end = (lend + 1) >> PAGE_SHIFT;
1115 struct folio_batch fbatch;
1116 pgoff_t indices[FOLIO_BATCH_SIZE];
1117 struct folio *folio;
1118 bool same_folio;
1119 long nr_swaps_freed = 0;
1120 pgoff_t index;
1121 int i;
...
1129 folio_batch_init(&fbatch);
1130 index = start;
1131 while (index < end && find_lock_entries(mapping, &index,
1132 end - 1, &fbatch, indices)) {
1133 for (i = 0; i < folio_batch_count(&fbatch); i++) {
1134 folio = fbatch.folios[i];
1135 if (xa_is_value(folio)) {
...
1143 }
1144 if (!unfalloc || !folio_test_uptodate(folio))
1145 truncate_inode_folio(mapping, folio);
1146 folio_unlock(folio);
1147 }
1148 folio_batch_remove_exceptionals(&fbatch);
1149 folio_batch_release(&fbatch);
1150 cond_resched(); /* <-- BUG fires here; RCU nest depth=1 */
1151 }
filename_unlinkat (fs/namei.c:5526-5587) -- top-level caller
-------------------------------------------------------------
5526 int filename_unlinkat(int dfd, struct filename *name)
5527 {
...
5545 error = mnt_want_write(path.mnt); /* lock #0 (sb_writers) */
5546 if (error)
5547 goto exit_path_put;
5548 retry_deleg:
5549 dentry = start_dirop(path.dentry, &last, lookup_flags);
...
5563 inode = dentry->d_inode;
5564 ihold(inode);
5565 error = security_path_unlink(&path, dentry);
5566 if (error)
5567 goto exit_end_dirop;
5568 error = vfs_unlink(mnt_idmap(path.mnt), path.dentry->d_inode,
5569 dentry, &delegated_inode);
5570 exit_end_dirop:
5571 end_dirop(dentry);
5572 iput(inode); /* triggers shmem_evict_inode -> shmem_undo_range */
...
5579 mnt_drop_write(path.mnt);
...
5587 }
Tentative Analysis
The crash is triggered by running rm(1) on a tmpfs/shmem file. The call
chain is:
sys_unlink -> filename_unlinkat -> iput -> iput_final -> evict
-> shmem_evict_inode -> shmem_truncate_range -> shmem_undo_range
-> cond_resched() <-- BUG fires here
At crash time, two locks are held (in acquisition order):
#0 sb_writers#5 -- acquired at filename_unlinkat+0x1ad
(fs/namei.c:5545 -- mnt_want_write)
#1 rcu_read_lock -- acquired at rcu_lock_acquire.constprop.0
(include/linux/rcupdate.h:300)
Lock #1 (rcu_read_lock) was acquired AFTER mnt_want_write (lock #0 is
always recorded first in the lockdep list) and before the iput() call
at line 5572. That window contains start_dirop(), security_path_unlink()
and vfs_unlink() (which calls fsnotify_unlink() and d_delete_notify() on
the success path).
On a PREEMPT(full) kernel, rcu_read_lock() increments
current->rcu_read_lock_nesting instead of disabling preemption.
cond_resched() -> __cond_resched() -> __might_resched() checks that
counter, finds it is 1 (not 0), and fires the BUG.
The same leaked rcu_read_lock persists all the way back to userspace
("lock held when returning to user space!"), and a timer interrupt
firing during the syscall produces a third warning:
"Voluntary context switch within RCU read-side critical section!"
All three messages are symptoms of a single rcu_read_lock() call that
is never matched by an rcu_read_unlock() somewhere between
mnt_want_write and iput in filename_unlinkat.
Potential Solution
Find the rcu_read_lock() call that is missing its matching
rcu_read_unlock() in the vfs_unlink() / fsnotify_unlink() /
d_delete_notify() code path. Adding a WARN_ON(rcu_read_lock_held())
to iput() (alongside the existing might_sleep() check) should produce
a backtrace pointing at the exact acquisition site on the next
reproduction.
More information
Oops-Analysis: http://oops.fenrus.org/reports/lkml/69eab803.a00a0220.17a17.004b.GAE_google.com/report.html
Assisted-by: GitHub Copilot:claude-sonnet-4.6 linux-kernel-oops-x86.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-04-24 2:34 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-24 0:23 [syzbot] [mm?] BUG: sleeping function called from invalid context in shmem_undo_range syzbot
2026-04-24 2:34 ` Arjan van de Ven
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox