* Re: [syzbot] [block?] BUG: sleeping function called from invalid context in null_insert_page
2026-09-04 22:23 [syzbot] [block?] BUG: sleeping function called from invalid context in null_insert_page syzbot
@ 2026-09-09 21:35 ` syzbot
2026-09-14 10:22 ` Forwarded: [PATCH] " syzbot
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: syzbot @ 2026-09-09 21:35 UTC (permalink / raw)
To: linux-block, linux-kernel, syzkaller-bugs
syzbot has found a reproducer for the following issue on:
HEAD commit: 893e11787f78 Merge tag 'x86_urgent_for_7.3-rc3' of git://g..
git tree: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
console output: https://syzkaller.appspot.com/x/log.txt?x=17e50925580000
kernel config: https://syzkaller.appspot.com/x/.config?x=8c5c3949d762a91f
dashboard link: https://syzkaller.appspot.com/bug?extid=95fdab36405e5ffdb680
compiler: gcc (Debian 14.2.0-19) 14.2.0, GNU ld (GNU Binutils for Debian) 2.44
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=10c13749580000
IMPORTANT: if you fix the issue, please add the following tag to the commit:
Reported-by: syzbot+95fdab36405e5ffdb680@syzkaller.appspotmail.com
null_blk: disk syzdev created
BUG: sleeping function called from invalid context at ./include/linux/sched/mm.h:322
in_atomic(): 0, irqs_disabled(): 0, non_block: 0, pid: 6031, name: syz-executor254
preempt_count: 0, expected: 0
RCU nest depth: 1, expected: 0
locks held by syz-executor254/6031: 1, last CPU#0:
#0: ffffffff8edec2e0 (rcu_read_lock){....}-{1:3}, at: rcu_lock_acquire include/linux/rcupdate.h:309 [inline]
#0: ffffffff8edec2e0 (rcu_read_lock){....}-{1:3}, at: rcu_read_lock include/linux/rcupdate.h:849 [inline]
#0: ffffffff8edec2e0 (rcu_read_lock){....}-{1:3}, at: blk_mq_dispatch_queue_requests+0x148/0x7c0 block/blk-mq.c:2872
CPU: 0 UID: 0 PID: 6031 Comm: syz-executor254 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+0x1dc/0x222 kernel/sched/core.c:9256
might_alloc include/linux/sched/mm.h:322 [inline]
slab_pre_alloc_hook mm/slub.c:4636 [inline]
slab_alloc_node mm/slub.c:4974 [inline]
__kmalloc_cache_noprof+0x3e3/0x6d0 mm/slub.c:5559
_kmalloc_noprof include/linux/slab.h:991 [inline]
null_alloc_page drivers/block/null_blk/main.c:878 [inline]
null_insert_page+0x10b/0x6c0 drivers/block/null_blk/main.c:1027
copy_to_nullb drivers/block/null_blk/main.c:1165 [inline]
null_transfer drivers/block/null_blk/main.c:1279 [inline]
null_handle_data_transfer+0x7df/0xe20 drivers/block/null_blk/main.c:1308
null_handle_memory_backed drivers/block/null_blk/main.c:1388 [inline]
null_process_cmd+0x1e3/0x290 drivers/block/null_blk/main.c:1442
null_handle_cmd drivers/block/null_blk/main.c:1465 [inline]
null_queue_rq+0x8e4/0xfb0 drivers/block/null_blk/main.c:1711
null_queue_rqs+0xe9/0x2f0 drivers/block/null_blk/main.c:1725
__blk_mq_flush_list block/blk-mq.c:2827 [inline]
__blk_mq_flush_list+0x9a/0xc0 block/blk-mq.c:2823
blk_mq_dispatch_queue_requests+0x184/0x7c0 block/blk-mq.c:2872
blk_mq_flush_plug_list+0x1f2/0x600 block/blk-mq.c:2960
__blk_flush_plug+0x2c4/0x4b0 block/blk-core.c:1270
blk_finish_plug+0x5c/0xa0 block/blk-core.c:1297
blkdev_writepages+0xf6/0x150 block/fops.c:488
do_writepages+0x278/0x600 mm/page-writeback.c:2560
filemap_writeback+0x22d/0x2e0 mm/filemap.c:387
filemap_fdatawrite_range mm/filemap.c:412 [inline]
file_write_and_wait_range+0xcd/0x140 mm/filemap.c:786
blkdev_fsync+0x6c/0xd0 block/fops.c:596
vfs_fsync_range fs/sync.c:186 [inline]
vfs_fsync fs/sync.c:200 [inline]
do_fsync+0xbf/0x220 fs/sync.c:211
__do_sys_fsync fs/sync.c:216 [inline]
__se_sys_fsync fs/sync.c:214 [inline]
__x64_sys_fsync+0x32/0x50 fs/sync.c:214
do_syscall_x64 arch/x86/entry/syscall_64.c:61 [inline]
do_syscall_64+0x123/0x790 arch/x86/entry/syscall_64.c:84
entry_SYSCALL_64_after_hwframe+0x77/0x7f
RIP: 0033:0x7f756122f3b7
Code: 48 89 fa 4c 89 df e8 98 1d 00 00 8b 93 08 03 00 00 59 5e 48 83 f8 fc 74 1a 5b c3 0f 1f 84 00 00 00 00 00 48 8b 44 24 10 0f 05 <5b> c3 0f 1f 80 00 00 00 00 83 e2 39 83 fa 08 75 de e8 23 ff ff ff
RSP: 002b:00007fffc74cf400 EFLAGS: 00000202 ORIG_RAX: 000000000000004a
RAX: ffffffffffffffda RBX: 0000555566674400 RCX: 00007f756122f3b7
RDX: 0000000000000000 RSI: 0000000000000000 RDI: 0000000000000003
RBP: 000000000000000a R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000202 R12: 00007f756126bae3
R13: 00007fffc74cf450 R14: 00007f7561268060 R15: 00007f7561268140
</TASK>
---
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.
^ permalink raw reply [flat|nested] 6+ messages in thread* Forwarded: [PATCH] BUG: sleeping function called from invalid context in null_insert_page
2026-09-04 22:23 [syzbot] [block?] BUG: sleeping function called from invalid context in null_insert_page syzbot
2026-09-09 21:35 ` syzbot
@ 2026-09-14 10:22 ` syzbot
2026-09-14 10:43 ` syzbot
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: syzbot @ 2026-09-14 10:22 UTC (permalink / raw)
To: linux-kernel
For archival purposes, forwarding an incoming command email to
linux-kernel@vger.kernel.org.
***
Subject: [PATCH] BUG: sleeping function called from invalid context in null_insert_page
Author: jchuang26@m.fudan.edu.cn
#syz test: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
Reported-by: syzbot+95fdab36405e5ffdb680@syzkaller.appspotmail.com
diff --git a/drivers/block/null_blk/main.c b/drivers/block/null_blk/main.c
index 6beb1f5b7..7f3fbac0f 100644
--- a/drivers/block/null_blk/main.c
+++ b/drivers/block/null_blk/main.c
@@ -70,6 +70,7 @@ static DEFINE_MUTEX(lock);
static int null_major;
static DEFINE_IDA(nullb_indexes);
static struct blk_mq_tag_set tag_set;
+static struct blk_mq_tag_set blocking_tag_set;
enum {
NULL_IRQ_NONE = 0,
@@ -1847,34 +1848,44 @@ static int null_init_tag_set(struct blk_mq_tag_set *set, int poll_queues)
return blk_mq_alloc_tag_set(set);
}
-static int null_init_global_tag_set(void)
+static int null_init_global_tag_set(struct blk_mq_tag_set *set, bool blocking)
{
int error;
- if (tag_set.ops)
+ if (set->ops)
return 0;
- tag_set.nr_hw_queues = g_submit_queues;
- tag_set.queue_depth = g_hw_queue_depth;
- tag_set.numa_node = g_home_node;
+ set->nr_hw_queues = g_submit_queues;
+ set->queue_depth = g_hw_queue_depth;
+ set->numa_node = g_home_node;
if (g_no_sched)
- tag_set.flags |= BLK_MQ_F_NO_SCHED_BY_DEFAULT;
+ set->flags |= BLK_MQ_F_NO_SCHED_BY_DEFAULT;
if (g_shared_tag_bitmap)
- tag_set.flags |= BLK_MQ_F_TAG_HCTX_SHARED;
- if (g_blocking)
- tag_set.flags |= BLK_MQ_F_BLOCKING;
+ set->flags |= BLK_MQ_F_TAG_HCTX_SHARED;
+ if (blocking)
+ set->flags |= BLK_MQ_F_BLOCKING;
- error = null_init_tag_set(&tag_set, g_poll_queues);
+ error = null_init_tag_set(set, g_poll_queues);
if (error)
- tag_set.ops = NULL;
+ set->ops = NULL;
return error;
}
static int null_setup_tagset(struct nullb *nullb)
{
if (nullb->dev->shared_tags) {
- nullb->tag_set = &tag_set;
- return null_init_global_tag_set();
+ bool blocking = g_blocking || nullb->dev->blocking;
+
+ /*
+ * Some memory-backed devices can sleep in their request
+ * submission path, which is invalid if the tag set is
+ * non-blocking since the block layer then calls the driver
+ * under rcu_read_lock(). The blocking flag is fixed when a tag
+ * set is allocated, so use a dedicated blocking global tag set
+ * for such devices.
+ */
+ nullb->tag_set = blocking ? &blocking_tag_set : &tag_set;
+ return null_init_global_tag_set(nullb->tag_set, blocking);
}
nullb->tag_set = &nullb->__tag_set;
@@ -2195,6 +2206,8 @@ static int __init null_init(void)
unregister_blkdev(null_major, "nullb");
if (tag_set.ops)
blk_mq_free_tag_set(&tag_set);
+ if (blocking_tag_set.ops)
+ blk_mq_free_tag_set(&blocking_tag_set);
return ret;
}
@@ -2215,6 +2228,8 @@ static void __exit null_exit(void)
if (tag_set.ops)
blk_mq_free_tag_set(&tag_set);
+ if (blocking_tag_set.ops)
+ blk_mq_free_tag_set(&blocking_tag_set);
}
module_init(null_init);
^ permalink raw reply related [flat|nested] 6+ messages in thread* Forwarded: [PATCH] BUG: sleeping function called from invalid context in null_insert_page
2026-09-04 22:23 [syzbot] [block?] BUG: sleeping function called from invalid context in null_insert_page syzbot
2026-09-09 21:35 ` syzbot
2026-09-14 10:22 ` Forwarded: [PATCH] " syzbot
@ 2026-09-14 10:43 ` syzbot
2026-09-15 1:38 ` syzbot
2026-09-17 1:15 ` syzbot
4 siblings, 0 replies; 6+ messages in thread
From: syzbot @ 2026-09-14 10:43 UTC (permalink / raw)
To: linux-kernel
For archival purposes, forwarding an incoming command email to
linux-kernel@vger.kernel.org.
***
Subject: [PATCH] BUG: sleeping function called from invalid context in null_insert_page
Author: jchuang26@m.fudan.edu.cn
#syz test: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 893e11787f78e43b534e252249ac3fff4d1333f8
Reported-by: syzbot+95fdab36405e5ffdb680@syzkaller.appspotmail.com
diff --git a/drivers/block/null_blk/main.c b/drivers/block/null_blk/main.c
index 6beb1f5b7..e22e79b02 100644
--- a/drivers/block/null_blk/main.c
+++ b/drivers/block/null_blk/main.c
@@ -1861,8 +1861,15 @@ static int null_init_global_tag_set(void)
tag_set.flags |= BLK_MQ_F_NO_SCHED_BY_DEFAULT;
if (g_shared_tag_bitmap)
tag_set.flags |= BLK_MQ_F_TAG_HCTX_SHARED;
- if (g_blocking)
- tag_set.flags |= BLK_MQ_F_BLOCKING;
+ /*
+ * Shared tag sets can be used by memory-backed devices, which may
+ * sleep in ->queue_rq() while allocating a page. The flag cannot be
+ * changed after the tag set is allocated, so always mark shared tag
+ * sets as blocking. blk-mq will then use an SRCU read lock instead
+ * of an RCU read lock around dispatch and the allocation is allowed
+ * to sleep.
+ */
+ tag_set.flags |= BLK_MQ_F_BLOCKING;
error = null_init_tag_set(&tag_set, g_poll_queues);
if (error)
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Forwarded: [PATCH] BUG: sleeping function called from invalid context in null_insert_page
2026-09-04 22:23 [syzbot] [block?] BUG: sleeping function called from invalid context in null_insert_page syzbot
` (2 preceding siblings ...)
2026-09-14 10:43 ` syzbot
@ 2026-09-15 1:38 ` syzbot
2026-09-17 1:15 ` syzbot
4 siblings, 0 replies; 6+ messages in thread
From: syzbot @ 2026-09-15 1:38 UTC (permalink / raw)
To: linux-kernel
For archival purposes, forwarding an incoming command email to
linux-kernel@vger.kernel.org.
***
Subject: [PATCH] BUG: sleeping function called from invalid context in null_insert_page
Author: jchuang26@m.fudan.edu.cn
#syz test: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
Reported-by: syzbot+95fdab36405e5ffdb680@syzkaller.appspotmail.com
diff --git a/drivers/block/null_blk/main.c b/drivers/block/null_blk/main.c
index 6beb1f5b7..e22e79b02 100644
--- a/drivers/block/null_blk/main.c
+++ b/drivers/block/null_blk/main.c
@@ -1861,8 +1861,15 @@ static int null_init_global_tag_set(void)
tag_set.flags |= BLK_MQ_F_NO_SCHED_BY_DEFAULT;
if (g_shared_tag_bitmap)
tag_set.flags |= BLK_MQ_F_TAG_HCTX_SHARED;
- if (g_blocking)
- tag_set.flags |= BLK_MQ_F_BLOCKING;
+ /*
+ * Shared tag sets can be used by memory-backed devices, which may
+ * sleep in ->queue_rq() while allocating a page. The flag cannot be
+ * changed after the tag set is allocated, so always mark shared tag
+ * sets as blocking. blk-mq will then use an SRCU read lock instead
+ * of an RCU read lock around dispatch and the allocation is allowed
+ * to sleep.
+ */
+ tag_set.flags |= BLK_MQ_F_BLOCKING;
error = null_init_tag_set(&tag_set, g_poll_queues);
if (error)
^ permalink raw reply related [flat|nested] 6+ messages in thread* Forwarded: [PATCH] BUG: sleeping function called from invalid context in null_insert_page
2026-09-04 22:23 [syzbot] [block?] BUG: sleeping function called from invalid context in null_insert_page syzbot
` (3 preceding siblings ...)
2026-09-15 1:38 ` syzbot
@ 2026-09-17 1:15 ` syzbot
4 siblings, 0 replies; 6+ messages in thread
From: syzbot @ 2026-09-17 1:15 UTC (permalink / raw)
To: linux-kernel
For archival purposes, forwarding an incoming command email to
linux-kernel@vger.kernel.org.
***
Subject: [PATCH] BUG: sleeping function called from invalid context in null_insert_page
Author: jchuang26@m.fudan.edu.cn
#syz test: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
Reported-by: syzbot+95fdab36405e5ffdb680@syzkaller.appspotmail.com
diff --git a/drivers/block/null_blk/main.c b/drivers/block/null_blk/main.c
index 6beb1f5b7..d5ece457e 100644
--- a/drivers/block/null_blk/main.c
+++ b/drivers/block/null_blk/main.c
@@ -1861,8 +1861,17 @@ static int null_init_global_tag_set(void)
tag_set.flags |= BLK_MQ_F_NO_SCHED_BY_DEFAULT;
if (g_shared_tag_bitmap)
tag_set.flags |= BLK_MQ_F_TAG_HCTX_SHARED;
- if (g_blocking)
- tag_set.flags |= BLK_MQ_F_BLOCKING;
+
+ /*
+ * A shared tag set may be used by a memory backed device, whose
+ * ->queue_rq() performs GFP_NOIO allocations and therefore must be
+ * allowed to sleep. blk-mq picks its locking (RCU or SRCU) from
+ * BLK_MQ_F_BLOCKING, so always mark the shared tag set blocking;
+ * otherwise I/O submitted through blk_mq_run_dispatch_ops() runs
+ * under the RCU read lock and triggers "sleeping function called
+ * from invalid context" in null_alloc_page().
+ */
+ tag_set.flags |= BLK_MQ_F_BLOCKING;
error = null_init_tag_set(&tag_set, g_poll_queues);
if (error)
^ permalink raw reply related [flat|nested] 6+ messages in thread