From: John Garry <john.g.garry@oracle.com>
To: Keith Busch <kbusch@kernel.org>
Cc: Chao Shi <coshi036@gmail.com>, Jens Axboe <axboe@kernel.dk>,
linux-nvme@lists.infradead.org, linux-kernel@vger.kernel.org,
Christoph Hellwig <hch@lst.de>, Sagi Grimberg <sagi@grimberg.me>,
Daniel Wagner <dwagner@suse.de>, Hannes Reinecke <hare@suse.de>,
Maurizio Lombardi <mlombard@arkamax.eu>,
Sungwoo Kim <iam@sung-woo.kim>, Dave Tian <daveti@purdue.edu>,
Weidong Zhu <weizhu@fiu.edu>
Subject: Re: [PATCH v3] nvme: core: reject invalid LBA data size from Identify Namespace
Date: Wed, 3 Jun 2026 11:08:10 +0100 [thread overview]
Message-ID: <539bb4aa-30a3-457c-8c77-c0d660376c3a@oracle.com> (raw)
In-Reply-To: <c6046eb2-9594-4355-9f4c-21a6f3bd8131@oracle.com>
On 02/06/2026 17:18, John Garry wrote:
>
>> I say we can ignore the sparse warning, or we
>> can rewrite this to avoid the check_shl_overflow entirely.
>
FWIW, adding a separate function keeps sparse happy for me:
diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index ea837b94d3e5..3ec98038668e 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -2364,6 +2364,11 @@ static int nvme_query_fdp_info(struct nvme_ns
*ns, struct nvme_ns_info *info)
return ret;
}
+static bool nvme_valid_ds(u64 nsze, signed int shift, u64 *capacity)
+{
+ return check_shl_overflow(nsze, shift, capacity);
+}
+
static int nvme_update_ns_info_block(struct nvme_ns *ns,
struct nvme_ns_info *info)
{
@@ -2407,10 +2412,8 @@ static int nvme_update_ns_info_block(struct
nvme_ns *ns,
goto out;
}
- if (id->lbaf[lbaf].ds < SECTOR_SHIFT ||
- check_shl_overflow(le64_to_cpu(id->nsze),
- id->lbaf[lbaf].ds - SECTOR_SHIFT,
- &capacity)) {
+ if (nvme_valid_ds(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);
next prev parent reply other threads:[~2026-06-03 10:08 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-15 18:58 Chao Shi
2026-05-20 19:33 ` Keith Busch
2026-06-02 13:10 ` John Garry
2026-06-02 15:15 ` Keith Busch
2026-06-02 15:42 ` Keith Busch
2026-06-02 16:18 ` John Garry
2026-06-03 10:08 ` John Garry [this message]
2026-06-23 20:37 ` Chao S
2026-06-24 13:14 ` John Garry
2026-07-13 16:58 ` Chao S
2026-07-14 8:18 ` John Garry
2026-07-14 16:07 ` Chao S
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=539bb4aa-30a3-457c-8c77-c0d660376c3a@oracle.com \
--to=john.g.garry@oracle.com \
--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=kbusch@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-nvme@lists.infradead.org \
--cc=mlombard@arkamax.eu \
--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
all inboxes | Powered by JetHome®