Linux block layer
 help / color / mirror / Atom feed
* [PATCH 0/3] null_blk: validate configfs values before power-on
@ 2026-11-26  6:34 Yingjie Wang
  2026-11-26  6:34 ` [PATCH 1/3] null_blk: reject device size overflow Yingjie Wang
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Yingjie Wang @ 2026-11-26  6:34 UTC (permalink / raw)
  To: axboe@kernel.dk
  Cc: linux-block@vger.kernel.org, dlemoal@kernel.org,
	stable@vger.kernel.org

This series fixes three bugs found while fuzzing null_blk's configfs
interface. Setting size or home_node to the values below and writing 1
to power triggers a crash:

  1/3  size=2^44 MiB with zoned=1 wraps the byte capacity to zero.
       The resulting zero zone count causes zone_nr_conv to underflow.
  2/3  size=2^40 MiB with zoned=1 and the default 256 MiB zone size
       requires 2^32 zones. Storing this count in nr_zones truncates
       it to zero, leading to the same failure.
  3/3  home_node=2147483647 is passed to kzalloc_node() without
       validation, causing an out-of-bounds access in SLUB.

The zone count overflow still occurs with only patch 1 applied.

Testing used x86_64 with KASAN, CONFIG_NUMA=y, a two-node QEMU guest,
oops=panic panic_on_warn=1, and null_blk built as a module:
- The unpatched module crashes for all three cases above.
- With only patch 1 applied, the size=2^40 MiB zoned case still crashes.
- With the full series, writing 1 to power fails with EINVAL for all
  three cases and leaves power at 0. Correcting the value and retrying
  succeeds.
- Valid non-zoned devices were tested at 0, 1 and LLONG_MAX / SZ_1M MiB;
  valid zoned devices were tested at 256, 257 and 512 MiB. Tests also
  covered memory-backed read/write, zone reports and a conventional zone.
- home_node values NUMA_NO_NODE, 0 and 1 succeed. Values 2, 63, 64 and
  2147483647 are rejected on power-on.

Testing was limited to x86_64. Sparse NUMA node numbering was not tested.
The reproducers are available on request.

Yingjie Wang (3):
  null_blk: reject device size overflow
  null_blk: reject zone counts that overflow unsigned int
  null_blk: validate the configfs home_node attribute

 drivers/block/null_blk/main.c  | 11 +++++++++++
 drivers/block/null_blk/zoned.c |  8 +++++++-
 2 files changed, 18 insertions(+), 1 deletion(-)


base-commit: 5a29cfaf51105039d156dd8a61d2783e8b653667
-- 
2.43.0


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2026-11-26  7:03 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-26  6:34 [PATCH 0/3] null_blk: validate configfs values before power-on Yingjie Wang
2026-11-26  6:34 ` [PATCH 1/3] null_blk: reject device size overflow Yingjie Wang
2026-11-26  6:34 ` [PATCH 2/3] null_blk: reject zone counts that overflow unsigned int Yingjie Wang
2026-11-26  6:34 ` [PATCH 3/3] null_blk: validate the configfs home_node attribute Yingjie Wang
2026-11-26  7:03 ` [PATCH 0/3] null_blk: validate configfs values before power-on Yingjie Wang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox