From: Keith Busch <kbusch@kernel.org>
To: Chao Shi <coshi036@gmail.com>
Cc: Jens Axboe <axboe@kernel.dk>, Christoph Hellwig <hch@lst.de>,
Sagi Grimberg <sagi@grimberg.me>, Daniel Wagner <dwagner@suse.de>,
Hannes Reinecke <hare@suse.de>,
linux-nvme@lists.infradead.org, linux-kernel@vger.kernel.org,
Sungwoo Kim <iam@sung-woo.kim>, Dave Tian <daveti@purdue.edu>,
Weidong Zhu <weizhu@fiu.edu>
Subject: Re: [PATCH] nvme: core: reject invalid LBA data size from Identify Namespace
Date: Mon, 20 Apr 2026 08:51:11 -0600 [thread overview]
Message-ID: <aeY9X1jEZrITd6mw@kbusch-mbp> (raw)
In-Reply-To: <20260418042835.420281-1-coshi036@gmail.com>
On Sat, Apr 18, 2026 at 12:28:34AM -0400, Chao Shi wrote:
> memflags = blk_mq_freeze_queue(ns->disk->queue);
> + if (id->lbaf[lbaf].ds < SECTOR_SHIFT ||
> + check_shl_overflow(le64_to_cpu(id->nsze),
> + id->lbaf[lbaf].ds - SECTOR_SHIFT,
> + &capacity)) {
> + dev_warn_once(ns->ctrl->device,
> + "invalid LBA data size %u, skipping namespace\n",
> + id->lbaf[lbaf].ds);
> + ret = -EIO;
I think ENODEV is more appropriate errno.
> + blk_mq_unfreeze_queue(ns->disk->queue, memflags);
> + goto out;
I don't see any particular reason why we shouldn't validate this value
before starting the queue updates and freezing the queue, like we for
the ncap field up higher. Doing that would make the error case much
simpler. Case in point, you're missing the corresponding
queue_limits_cancel_update() for this error case.
> + }
> ns->head->lba_shift = id->lbaf[lbaf].ds;
> ns->head->nuse = le64_to_cpu(id->nuse);
> - capacity = nvme_lba_to_sect(ns->head, le64_to_cpu(id->nsze));
> nvme_set_ctrl_limits(ns->ctrl, &lim, false);
> nvme_configure_metadata(ns->ctrl, ns->head, id, nvm, info);
> nvme_set_chunk_sectors(ns, id, &lim);
> --
> 2.43.0
>
next prev parent reply other threads:[~2026-04-20 14:51 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-18 4:28 [PATCH] nvme: core: reject invalid LBA data size from Identify Namespace Chao Shi
2026-04-20 12:22 ` Daniel Wagner
2026-04-20 14:54 ` Keith Busch
2026-04-20 12:22 ` Maurizio Lombardi
2026-04-20 14:51 ` Keith Busch [this message]
2026-04-20 23:11 ` [PATCH v2 0/1] " Chao Shi
2026-04-20 23:11 ` [PATCH v2 1/1] " Chao Shi
2026-04-21 0:25 ` [PATCH v2 0/1] " 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=aeY9X1jEZrITd6mw@kbusch-mbp \
--to=kbusch@kernel.org \
--cc=axboe@kernel.dk \
--cc=coshi036@gmail.com \
--cc=daveti@purdue.edu \
--cc=dwagner@suse.de \
--cc=hare@suse.de \
--cc=hch@lst.de \
--cc=iam@sung-woo.kim \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-nvme@lists.infradead.org \
--cc=sagi@grimberg.me \
--cc=weizhu@fiu.edu \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox