]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
nvmet: fix error handling in nvmet_execute_identify_cns_cs_ns()
authorDamien Le Moal <damien.lemoal@opensource.wdc.com>
Tue, 14 Mar 2023 06:20:36 +0000 (15:20 +0900)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 11 May 2023 14:11:13 +0000 (23:11 +0900)
commit7f5838be37d9777c0e735ce9d265de068e26e7fb
tree99cadc8cbb9e17b3f66a2745a8c005050feb9edf
parentd0e34aaea13391e28069c50de5519300d408e985
nvmet: fix error handling in nvmet_execute_identify_cns_cs_ns()

[ Upstream commit ab76e7206b672b2e8818cb121a04506956d6b223 ]

Nvme specifications state that:

If the I/O Command Set associated with the namespace identified by the
NSID field does not support the Identify Namespace data structure
specified by the CSI field, the controller shall abort the command with
a status code of Invalid Field in Command.

In other words, if nvmet_execute_identify_cns_cs_ns() is called for a
target with a block device that is not zoned, we should not return any
data and set the status to NVME_SC_INVALID_FIELD.

While at it, it is also better to revalidate the ns block devie *before*
checking if the block device is zoned, to ensure that
nvmet_execute_identify_cns_cs_ns() operates against updated device
characteristics.

Fixes: aaf2e048af27 ("nvmet: add ZBD over ZNS backend support")
Signed-off-by: Damien Le Moal <damien.lemoal@opensource.wdc.com>
Reviewed-by: Keith Busch <kbusch@kernel.org>
Reviewed-by: Sagi Grimberg <sagi@grimberg.me>
Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/nvme/target/zns.c