All of lore.kernel.org
 help / color / mirror / Atom feed
From: Maks <mi9992828@gmail.com>
To: linux-block@vger.kernel.org
Cc: Jens Axboe <axboe@kernel.dk>
Subject: block: zero logical block size leads to infinite loop in set_init_blocksize()
Date: Thu,  3 Sep 2026 20:41:24 +0300	[thread overview]
Message-ID: <20260903174124.51009-1-mi9992828@gmail.com> (raw)

Hi,

I hit a soft lockup in set_init_blocksize() with a block device whose
logical_block_size was zero.

I understand that logical_block_size == 0 violates the block layer
contract and that the driver which allowed this value needs to be fixed.

However, the generic block code currently turns this invariant violation
into a non-terminating loop:

while (bsize < PAGE_SIZE) {
    if (size & bsize)
        break;
    bsize <<= 1;
}

With bsize == 0, the value never changes.

In my case this resulted in:

watchdog: BUG: soft lockup - CPU#0 stuck for 26s! [(udev-worker):...]
RIP: set_init_blocksize+0x28/0x60

Call Trace:
  blkdev_get_whole+...
  bdev_open+...

Is this considered acceptable behavior for a broken driver, or should
the generic block layer defensively detect this case and fail the open
instead of spinning indefinitely?

If adding such a check is considered worthwhile, I can prepare a patch.

Thanks,
Maks

             reply	other threads:[~2026-09-03 17:41 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-03 17:41 Maks [this message]
2026-09-03 17:55 ` block: zero logical block size leads to infinite loop in set_init_blocksize() Keith Busch
2026-09-03 18:50   ` Maksim Ivanov
2026-09-09 19:11   ` Maks
2026-09-09 19:51     ` Keith Busch

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260903174124.51009-1-mi9992828@gmail.com \
    --to=mi9992828@gmail.com \
    --cc=axboe@kernel.dk \
    --cc=linux-block@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.