Skip to content

fix sbitmap initialization and null_blk shared tagset behavior#58

Closed
blktests-ci[bot] wants to merge 2 commits intolinus-master_basefrom
series/985147=>linus-master
Closed

fix sbitmap initialization and null_blk shared tagset behavior#58
blktests-ci[bot] wants to merge 2 commits intolinus-master_basefrom
series/985147=>linus-master

Conversation

@blktests-ci
Copy link
Copy Markdown

@blktests-ci blktests-ci Bot commented Jul 24, 2025

Pull request for series with
subject: fix sbitmap initialization and null_blk shared tagset behavior
version: 1
url: https://patchwork.kernel.org/project/linux-block/list/?series=985147

@blktests-ci
Copy link
Copy Markdown
Author

blktests-ci Bot commented Jul 24, 2025

Upstream branch: 25fae0b
series: https://patchwork.kernel.org/project/linux-block/list/?series=985147
version: 1

@blktests-ci blktests-ci Bot force-pushed the linus-master_base branch 2 times, most recently from 6637119 to f092a9b Compare July 31, 2025 04:25
@blktests-ci
Copy link
Copy Markdown
Author

blktests-ci Bot commented Jul 31, 2025

Upstream branch: 260f6f4
series: https://patchwork.kernel.org/project/linux-block/list/?series=985147
version: 1

@blktests-ci blktests-ci Bot force-pushed the series/985147=>linus-master branch from d4404cf to 799965c Compare July 31, 2025 04:33
@blktests-ci blktests-ci Bot force-pushed the linus-master_base branch from f092a9b to 0b59764 Compare July 31, 2025 17:58
@blktests-ci
Copy link
Copy Markdown
Author

blktests-ci Bot commented Jul 31, 2025

Upstream branch: d6084bb
series: https://patchwork.kernel.org/project/linux-block/list/?series=985147
version: 1

@blktests-ci blktests-ci Bot force-pushed the series/985147=>linus-master branch from 799965c to eb0225b Compare July 31, 2025 18:07
@blktests-ci blktests-ci Bot force-pushed the linus-master_base branch from 0b59764 to aee5bd3 Compare July 31, 2025 19:11
@blktests-ci
Copy link
Copy Markdown
Author

blktests-ci Bot commented Jul 31, 2025

Upstream branch: 831462f
series: https://patchwork.kernel.org/project/linux-block/list/?series=985147
version: 1

@blktests-ci blktests-ci Bot force-pushed the series/985147=>linus-master branch from eb0225b to 8538687 Compare July 31, 2025 19:21
@blktests-ci blktests-ci Bot force-pushed the linus-master_base branch from aee5bd3 to ef18525 Compare July 31, 2025 20:07
@blktests-ci
Copy link
Copy Markdown
Author

blktests-ci Bot commented Jul 31, 2025

Upstream branch: c93529a
series: https://patchwork.kernel.org/project/linux-block/list/?series=985147
version: 1

@blktests-ci blktests-ci Bot force-pushed the series/985147=>linus-master branch from 8538687 to 746320f Compare July 31, 2025 20:16
@blktests-ci blktests-ci Bot force-pushed the linus-master_base branch from ef18525 to 3851b3f Compare July 31, 2025 20:55
@blktests-ci
Copy link
Copy Markdown
Author

blktests-ci Bot commented Jul 31, 2025

Upstream branch: cbbf0a7
series: https://patchwork.kernel.org/project/linux-block/list/?series=985147
version: 1

@blktests-ci blktests-ci Bot force-pushed the series/985147=>linus-master branch from 746320f to d497799 Compare July 31, 2025 21:04
@blktests-ci blktests-ci Bot force-pushed the linus-master_base branch from 3851b3f to 28b3384 Compare July 31, 2025 23:42
@blktests-ci
Copy link
Copy Markdown
Author

blktests-ci Bot commented Jul 31, 2025

Upstream branch: 6a68cec
series: https://patchwork.kernel.org/project/linux-block/list/?series=985147
version: 1

@blktests-ci blktests-ci Bot force-pushed the series/985147=>linus-master branch from d497799 to 31508da Compare July 31, 2025 23:51
@blktests-ci blktests-ci Bot force-pushed the linus-master_base branch from 28b3384 to 8ab9be5 Compare August 1, 2025 00:45
@blktests-ci
Copy link
Copy Markdown
Author

blktests-ci Bot commented Aug 1, 2025

Upstream branch: f2d282e
series: https://patchwork.kernel.org/project/linux-block/list/?series=985147
version: 1

@blktests-ci blktests-ci Bot force-pushed the series/985147=>linus-master branch from 31508da to 1f7c21d Compare August 1, 2025 00:54
@blktests-ci blktests-ci Bot force-pushed the linus-master_base branch from 8ab9be5 to 5b90760 Compare August 1, 2025 04:53
@blktests-ci
Copy link
Copy Markdown
Author

blktests-ci Bot commented Aug 1, 2025

Upstream branch: 89748ac
series: https://patchwork.kernel.org/project/linux-block/list/?series=985147
version: 1

@blktests-ci blktests-ci Bot force-pushed the series/985147=>linus-master branch from 1f7c21d to bef3eb6 Compare August 1, 2025 05:02
@blktests-ci blktests-ci Bot force-pushed the linus-master_base branch from 5b90760 to 3893da1 Compare August 1, 2025 12:00
@blktests-ci
Copy link
Copy Markdown
Author

blktests-ci Bot commented Aug 9, 2025

Upstream branch: 2988dfe
series: https://patchwork.kernel.org/project/linux-block/list/?series=985147
version: 1

@blktests-ci blktests-ci Bot force-pushed the series/985147=>linus-master branch from 007586e to c5fd524 Compare August 9, 2025 06:18
@blktests-ci blktests-ci Bot force-pushed the linus-master_base branch from 1356209 to ae9bce3 Compare August 9, 2025 06:21
@blktests-ci
Copy link
Copy Markdown
Author

blktests-ci Bot commented Aug 9, 2025

Upstream branch: c30a135
series: https://patchwork.kernel.org/project/linux-block/list/?series=985147
version: 1

@blktests-ci blktests-ci Bot force-pushed the series/985147=>linus-master branch from c5fd524 to 20672cf Compare August 9, 2025 06:33
@blktests-ci blktests-ci Bot force-pushed the linus-master_base branch from ae9bce3 to e263d6e Compare August 9, 2025 15:26
@blktests-ci
Copy link
Copy Markdown
Author

blktests-ci Bot commented Aug 9, 2025

Upstream branch: 561c803
series: https://patchwork.kernel.org/project/linux-block/list/?series=985147
version: 1

@blktests-ci blktests-ci Bot force-pushed the series/985147=>linus-master branch from 20672cf to dee83e3 Compare August 9, 2025 15:39
@blktests-ci blktests-ci Bot force-pushed the linus-master_base branch from e263d6e to 77110f5 Compare August 10, 2025 05:58
@blktests-ci
Copy link
Copy Markdown
Author

blktests-ci Bot commented Aug 10, 2025

Upstream branch: b96ddbc
series: https://patchwork.kernel.org/project/linux-block/list/?series=985147
version: 1

@blktests-ci blktests-ci Bot force-pushed the series/985147=>linus-master branch from dee83e3 to 3a5caee Compare August 10, 2025 06:11
@blktests-ci blktests-ci Bot force-pushed the linus-master_base branch from 77110f5 to a2e0474 Compare August 10, 2025 06:39
@blktests-ci
Copy link
Copy Markdown
Author

blktests-ci Bot commented Aug 10, 2025

Upstream branch: 2b38afc
series: https://patchwork.kernel.org/project/linux-block/list/?series=985147
version: 1

@blktests-ci blktests-ci Bot force-pushed the series/985147=>linus-master branch from 3a5caee to 5d61311 Compare August 10, 2025 06:51
@blktests-ci blktests-ci Bot force-pushed the linus-master_base branch from a2e0474 to 36a8aec Compare August 10, 2025 16:54
@blktests-ci
Copy link
Copy Markdown
Author

blktests-ci Bot commented Aug 10, 2025

Upstream branch: 8f5ae30
series: https://patchwork.kernel.org/project/linux-block/list/?series=985147
version: 1

@blktests-ci blktests-ci Bot force-pushed the series/985147=>linus-master branch from 5d61311 to 4a0aeda Compare August 10, 2025 17:06
@blktests-ci blktests-ci Bot force-pushed the linus-master_base branch from 36a8aec to 1a46df6 Compare August 12, 2025 04:07
@blktests-ci
Copy link
Copy Markdown
Author

blktests-ci Bot commented Aug 12, 2025

Upstream branch: 53e760d
series: https://patchwork.kernel.org/project/linux-block/list/?series=985147
version: 1

@blktests-ci
Copy link
Copy Markdown
Author

blktests-ci Bot commented Aug 12, 2025

Upstream branch: 0e39a73
series: https://patchwork.kernel.org/project/linux-block/list/?series=985147
version: 1

@blktests-ci
Copy link
Copy Markdown
Author

blktests-ci Bot commented Aug 12, 2025

Upstream branch: 8742b2d
series: https://patchwork.kernel.org/project/linux-block/list/?series=985147
version: 1

@blktests-ci
Copy link
Copy Markdown
Author

blktests-ci Bot commented Aug 13, 2025

Upstream branch: 91325f3
series: https://patchwork.kernel.org/project/linux-block/list/?series=985147
version: 1

@blktests-ci
Copy link
Copy Markdown
Author

blktests-ci Bot commented Aug 13, 2025

Upstream branch: 3a4a036
series: https://patchwork.kernel.org/project/linux-block/list/?series=985147
version: 1

@blktests-ci
Copy link
Copy Markdown
Author

blktests-ci Bot commented Aug 13, 2025

Upstream branch: dfc0f63
series: https://patchwork.kernel.org/project/linux-block/list/?series=985147
version: 1

@blktests-ci
Copy link
Copy Markdown
Author

blktests-ci Bot commented Aug 14, 2025

Upstream branch: 0cc5352
series: https://patchwork.kernel.org/project/linux-block/list/?series=985147
version: 1

@blktests-ci
Copy link
Copy Markdown
Author

blktests-ci Bot commented Aug 14, 2025

Upstream branch: 24ea63e
series: https://patchwork.kernel.org/project/linux-block/list/?series=985147
version: 1

@blktests-ci
Copy link
Copy Markdown
Author

blktests-ci Bot commented Aug 15, 2025

Upstream branch: d7ee5bd
series: https://patchwork.kernel.org/project/linux-block/list/?series=985147
version: 1

We observed a kernel crash when the I/O scheduler allocates an sbitmap
for a hardware queue (hctx) that has no associated software queues (ctx),
and later attempts to free it. When no software queues are mapped to a
hardware queue, the sbitmap is initialized with a depth of zero. In such
cases, the sbitmap_init_node() function should set sb->alloc_hint to NULL.
However, if this is not done, sb->alloc_hint may contain garbage, and
calling sbitmap_free() will pass this invalid pointer to free_percpu(),
resulting in a kernel crash.

Example crash trace:
==================================================================
Kernel attempted to read user page (28) - exploit attempt? (uid: 0)
BUG: Kernel NULL pointer dereference on read at 0x00000028
Faulting instruction address: 0xc000000000708f88
Oops: Kernel access of bad area, sig: 11 [#1]
LE PAGE_SIZE=64K MMU=Radix  SMP NR_CPUS=2048 NUMA pSeries
[...]
CPU: 5 UID: 0 PID: 5491 Comm: mk_nullb_shared Kdump: loaded Tainted: G    B               6.16.0-rc5+ #294 VOLUNTARY
Tainted: [B]=BAD_PAGE
Hardware name: IBM,9043-MRX POWER10 (architected) 0x800200 0xf000006 of:IBM,FW1060.00 (NM1060_028) hv:phyp pSeries
[...]
NIP [c000000000708f88] free_percpu+0x144/0xba8
LR [c000000000708f84] free_percpu+0x140/0xba8
Call Trace:
    free_percpu+0x140/0xba8 (unreliable)
    kyber_exit_hctx+0x94/0x124
    blk_mq_exit_sched+0xe4/0x214
    elevator_exit+0xa8/0xf4
    elevator_switch+0x3b8/0x5d8
    elv_update_nr_hw_queues+0x14c/0x300
    blk_mq_update_nr_hw_queues+0x5cc/0x670
    nullb_update_nr_hw_queues+0x118/0x1f8 [null_blk]
    nullb_device_submit_queues_store+0xac/0x170 [null_blk]
    configfs_write_iter+0x1dc/0x2d0
    vfs_write+0x5b0/0x77c
    ksys_write+0xa0/0x180
    system_call_exception+0x1b0/0x4f0
    system_call_vectored_common+0x15c/0x2ec

If the sbitmap depth is zero, sb->alloc_hint memory is NOT allocated, but
the pointer is not explicitly set to NULL. Later, during sbitmap_free(),
the kernel attempts to free sb->alloc_hint, which is a per cpu pointer
variable, regardless of whether it was valid, leading to a crash.

This patch ensures that sb->alloc_hint is explicitly set to NULL in
sbitmap_init_node() when the requested depth is zero. This prevents
free_percpu() from freeing sb->alloc_hint and thus avoids the observed
crash.

Reviewed-by: Damien Le Moal <[email protected]>
Reviewed-by: Hannes Reinecke <[email protected]>
Signed-off-by: Nilay Shroff <[email protected]>
Reviewed-by: Yu Kuai <[email protected]>
@blktests-ci
Copy link
Copy Markdown
Author

blktests-ci Bot commented Aug 20, 2025

Upstream branch: b19a97d
series: https://patchwork.kernel.org/project/linux-block/list/?series=985147
version: 1

When a user updates the number of submit or poll queues on a null_blk
device, the block layer creates new hardware queues (hctxs). However, if
the device is using a shared tagset, null_blk does not map any software
queues (ctx) to the newly created hctx (via null_map_queues()), resulting
in those hardware queues being left unused for I/O. This behavior is
misleading, as the user may expect the new queues to be functional, even
though they are effectively ignored. To avoid this confusion and potential
misconfiguration:
- Reject runtime updates to submit_queues or poll_queues via sysfs when
  the device uses a shared tagset by returning -EINVAL.
- During configuration validation (prior to powering on the device), reset
  submit_queues and poll_queues to the module parameters (g_submit_queues
  and g_poll_queues) if the shared tagset is enabled.

This ensures consistent behavior and avoids creating unused hardware queues
(hctxs) due to ineffective runtime queue updates.

Signed-off-by: Nilay Shroff <[email protected]>
Reviewed-by: Damien Le Moal <[email protected]>
Reviewed-by: Yu Kuai <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants