All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 0/2] block: make some queue limits checks more robust
@ 2025-07-29  9:14 John Garry
  2025-07-29  9:14 ` [PATCH v2 1/2] block: avoid possible overflow for chunk_sectors check in blk_stack_limits() John Garry
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: John Garry @ 2025-07-29  9:14 UTC (permalink / raw)
  To: axboe
  Cc: linux-block, martin.petersen, hch, hare, bvanassche, dlemoal,
	John Garry

This series contains a couple of changes to make request queue limits
checks more robust.

About the change to enforce a power-of-2 physical block size, I audited
the drivers which set this. All look ok to comply with this rule, as
follows:

drivers/block/brd.c - uses PAGE_SIZE, so ok

drivers/block/drbd/drbd_main.c - uses bdev_physical_block_size(), so ok

drivers/block/loop.c - uses same size as LBS (which must be a 
power-of-2), so ok

drivers/block/mtip32xx/mtip32xx.c - uses 4096, so ok

drivers/block/n64cart.c - uses 4096, so ok

drivers/block/nbd.c - uses same size as LBS (which must be a 
power-of-2), so ok

drivers/block/null_blk/main.c - uses same size as LBS (which must be a
power-of-2), so ok

drivers/block/rnbd/rnbd-clt.c - drivers/block/rnbd/rnbd-srv.c - uses
bdev_physical_block_size() to fill in
rnbd_msg_open_rsp.physical_block_size, and rnbd-clt.c fills in
queue_limits.physical_block_size from
rnbd_msg_open_rsp.physical_block_size, so looks ok

drivers/block/sunvdc.c not sure on this one. For v1.2 spec we have 
vio_disk_attr_info.phys_block_size, but I cannot
find a spec detailing it.
https://oss.oracle.com/sparcdocs/hypervisor-api-3.0draft7.pdf has
earlier specs. FWIW, no rules on power-of-2 not mentioned for
vdisk_block_size in that spec, so unlikely to have rules for physical
block size. Default pbs is VDC_DEFAULT_BLK_SIZE = 512, and other sizes
in driver are all power-of-2, so likely phys_block_size
will be a power-of-2 always

drivers/block/ublk_drv.c - uses 1 << p->physical_bs_shift, so ok

drivers/block/virtio_blk.c - according to [0], should be ok

drivers/block/zloop.c - uses same size as LBS (which must be a
power-of-2), so ok

drivers/block/zram/zram_drv.c - uses PAGE_SIZE, so ok

drivers/md/bcache/super.c - uses same size as LBS (which must be a
power-of-2), so ok

drivers/md/dm-crypt.c - uses same size as LBS (which must be a
power-of-2), so ok

drivers/md/dm-ebs-target.c - ebs_ctr() -> __ebs_check_bs() ensures a
power-of-2, so ok

drivers/md/dm-integrity.c - uses same size as LBS (which must be a
power-of-2), so ok

drivers/md/dm-log-writes.c - uses bdev_physical_block_size(), so ok

drivers/md/dm-vdo/dm-vdo-target.c - VDO_BLOCK_SIZE = 4096, so ok

drivers/md/dm-verity-target.c - uses 1 << v->data_dev_block_bits, so ok

drivers/md/dm-writecache.c - writecache_ctr() line 2376 ensure
blocksize is a power-of-2, so ok

drivers/md/dm-zoned-target.c - uses same size as LBS (which must be a
power-of-2), so ok

drivers/nvdimm/pmem.c - uses PAGE_SIZE, so ok

drivers/nvme/host/core.c - may not be ok, so pbs comes from npwg and
spec does not mandate this is a power-of-2. According to [1], nothing
like this has been seen.

drivers/scsi/sd.c - uses (1 << (buffer[13] & 0xf)) * sector_size in
sdkp->physical_block_size, so ok

drivers/scsi/sd_zbc.c - uses sdkp->physical_block_size, so ok

drivers/target/target_core_iblock.c - uses bdev_physical_block_size(), so ok

[0] https://lore.kernel.org/linux-block/aa4b8526-5346-4004-a3b7-abcffd201b1a@kernel.org/
[1] https://lore.kernel.org/linux-block/yq1qzy8x5m8.fsf@ca-mkp.ca.oracle.com/

Changes since RFC:
- Add RB tags (thanks!)

John Garry (2):
  block: avoid possible overflow for chunk_sectors check in
    blk_stack_limits()
  block: Enforce power-of-2 physical block size

 block/blk-settings.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

-- 
2.43.5


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

end of thread, other threads:[~2025-07-29 12:27 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-29  9:14 [PATCH v2 0/2] block: make some queue limits checks more robust John Garry
2025-07-29  9:14 ` [PATCH v2 1/2] block: avoid possible overflow for chunk_sectors check in blk_stack_limits() John Garry
2025-07-29 11:05   ` Damien Le Moal
2025-07-29  9:14 ` [PATCH v2 2/2] block: Enforce power-of-2 physical block size John Garry
2025-07-29 10:19   ` Hannes Reinecke
2025-07-29 11:03   ` Damien Le Moal
2025-07-29 12:27 ` [PATCH v2 0/2] block: make some queue limits checks more robust Jens Axboe

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.