From: <shao.mingyin@zte.com.cn>
To: <kbusch@kernel.org>, <hch@lst.de>
Cc: <axboe@kernel.dk>, <sagi@grimberg.me>,
<linux-nvme@lists.infradead.org>, <linux-kernel@vger.kernel.org>,
<stable@vger.kernel.org>
Subject: [PATCH v2 1/2] nvme: zns: reject an out-of-range zone append size limit
Date: Sun, 22 Nov 2026 22:48:31 +0800 (CST) [thread overview]
Message-ID: <20261122224831886ognkZtXtygomcSayJJdF8@zte.com.cn> (raw)
In-Reply-To: <20261122224829803Cnc907ditjVjp2YzW1gmE@zte.com.cn>
From: Shao Mingyin <shao.mingyin@zte.com.cn>
nvme_set_max_append() derives a sector limit by shifting 1 by ZASL + 3.
ZASL is a byte from the Identify Controller ZNS data. Values of 29 or
larger require a shift of at least 32 bits, which is undefined for the
32-bit operand. ZASL = 28 shifts into bit 31, which a signed operand
cannot express either.
Use an unsigned shift for representable values. If the reported limit
exceeds the range of max_zone_append, use max_hw_sectors, the same
limit used when ZASL is zero. The hardware transfer limit is smaller
than any append limit that requires a shift of at least 32 bits.
Fixes: 240e6ee272c0 ("nvme: support for zoned namespaces")
Cc: stable@vger.kernel.org
Signed-off-by: Shao Mingyin <shao.mingyin@zte.com.cn>
---
Changes in v2:
- Drop the warning for values the driver cannot represent (Christoph).
- Clarify that such a value can be valid and why the fallback is safe.
v1: https://lore.kernel.org/r/20261115012752774qFGtgUXwZKwN-2LDj0D80@zte.com.cn
drivers/nvme/host/zns.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/nvme/host/zns.c b/drivers/nvme/host/zns.c
index e31ec6f4f94fbe872d346516b02dd1e6a2223872..a93f3b152faaad34199e0d6276536be0c0ae8767 100644
--- a/drivers/nvme/host/zns.c
+++ b/drivers/nvme/host/zns.c
@@ -27,8 +27,8 @@ static int nvme_set_max_append(struct nvme_ctrl *ctrl)
return status;
}
- if (id->zasl)
- ctrl->max_zone_append = 1 << (id->zasl + 3);
+ if (id->zasl && id->zasl + 3 < 32)
+ ctrl->max_zone_append = 1U << (id->zasl + 3);
else
ctrl->max_zone_append = ctrl->max_hw_sectors;
kfree(id);
base-commit: 909ef7a9a30fa139e69e555e3606680f5cca7726
--
2.43.0
next prev parent reply other threads:[~2026-11-22 14:48 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-22 14:48 [PATCH v2 0/2] nvme: ZNS append limit and FDP feature decoding shao.mingyin
2026-11-22 14:48 ` shao.mingyin [this message]
2026-11-25 5:24 ` [PATCH v2 1/2] nvme: zns: reject an out-of-range zone append size limit Christoph Hellwig
2026-11-22 14:48 ` [PATCH v2 2/2] nvme: decode the FDP Get Features result as a dword shao.mingyin
2026-11-25 5:24 ` Christoph Hellwig
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=20261122224831886ognkZtXtygomcSayJJdF8@zte.com.cn \
--to=shao.mingyin@zte.com.cn \
--cc=axboe@kernel.dk \
--cc=hch@lst.de \
--cc=kbusch@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-nvme@lists.infradead.org \
--cc=sagi@grimberg.me \
--cc=stable@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 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®