Linux-NVME Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] nvmet: reject invalid write-protect feature values
@ 2026-11-09 13:55 Sreeraj S Kurup
  2026-11-09 14:11 ` sashiko-bot
  2026-11-09 14:24 ` [PATCH v2] " Sreeraj S Kurup
  0 siblings, 2 replies; 4+ messages in thread
From: Sreeraj S Kurup @ 2026-11-09 13:55 UTC (permalink / raw)
  To: hch, sagi, kch, linux-nvme, linux-kernel
  Cc: kbusch, hare, hare, Sreeraj S Kurup

The Set Features handler for namespace write protection currently
accepts unsupported values. The default case in the write-protect
switch leaves the status unchanged, causing the command to return
success even though no valid setting was applied.

Return NVME_SC_INVALID_FIELD | NVME_STATUS_DNR for unsupported
values. This also prevents issuing a namespace-change notification
for an invalid request.

Signed-off-by: Sreeraj S Kurup <sreekuttan2156239@gmail.com>
---
 drivers/nvme/target/admin-cmd.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/nvme/target/admin-cmd.c b/drivers/nvme/target/admin-cmd.c
index f12d83098644..ee8be237485e 100644
--- a/drivers/nvme/target/admin-cmd.c
+++ b/drivers/nvme/target/admin-cmd.c
@@ -1223,6 +1223,7 @@ static u16 nvmet_set_feat_write_protect(struct nvmet_req *req)
 		status = 0;
 		break;
 	default:
+		status = NVME_SC_INVALID_FIELD | NVME_STATUS_DNR;
 		break;
 	}
 
-- 
2.55.0



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] nvmet: reject invalid write-protect feature values
  2026-11-09 13:55 [PATCH] nvmet: reject invalid write-protect feature values Sreeraj S Kurup
@ 2026-11-09 14:11 ` sashiko-bot
  2026-11-09 14:24 ` [PATCH v2] " Sreeraj S Kurup
  1 sibling, 0 replies; 4+ messages in thread
From: sashiko-bot @ 2026-11-09 14:11 UTC (permalink / raw)
  To: Sreeraj S Kurup, linux-nvme

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Low] nvmet: missing Fixes trailer for nvmet_set_feat_write_protect()
  regression
--

commit a435e948ad0b0443cd38d58e0a87dcc11c315ea6
Author: Sreeraj S Kurup <sreekuttan2156239@gmail.com>

> nvmet: reject invalid write-protect feature values
>
> The Set Features handler for namespace write protection currently
> accepts unsupported values. The default case in the write-protect
> switch leaves the status unchanged, causing the command to return
> success even though no valid setting was applied.
>
> Return NVME_SC_INVALID_FIELD | NVME_STATUS_DNR for unsupported
> values. This also prevents issuing a namespace-change notification
> for an invalid request.
>
> Signed-off-by: Sreeraj S Kurup <sreekuttan2156239@gmail.com>

[Severity: Low]
Commit 3a1f7c79ae6d ("nvmet: make nvmet_find_namespace() req based") removed
the initial error status assignment in nvmet_set_feat_write_protect(),
leaving status set to 0 after nvmet_req_find_ns() succeeds.  Should this
include:

  Fixes: 3a1f7c79ae6d ("nvmet: make nvmet_find_namespace() req based")

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261109135536.2772-1-sreekuttan2156239@gmail.com?part=1


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH v2] nvmet: reject invalid write-protect feature values
  2026-11-09 13:55 [PATCH] nvmet: reject invalid write-protect feature values Sreeraj S Kurup
  2026-11-09 14:11 ` sashiko-bot
@ 2026-11-09 14:24 ` Sreeraj S Kurup
  2026-11-10  7:17   ` Hannes Reinecke
  1 sibling, 1 reply; 4+ messages in thread
From: Sreeraj S Kurup @ 2026-11-09 14:24 UTC (permalink / raw)
  To: sreekuttan2156239
  Cc: hare, hare, hch, kbusch, kch, linux-kernel, linux-nvme, sagi

The Set Features handler for namespace write protection currently
accepts unsupported values. The default case in the write-protect
switch leaves the status unchanged, causing the command to return
success even though no valid setting was applied.

Return NVME_SC_INVALID_FIELD | NVME_STATUS_DNR for unsupported
values. This also prevents issuing a namespace-change notification
for an invalid request.

Fixes: 3a1f7c79ae6d ("nvmet: make nvmet_find_namespace() req based")
Signed-off-by: Sreeraj S Kurup <sreekuttan2156239@gmail.com>
---
v2:
 - Add Fixes trailer

 drivers/nvme/target/admin-cmd.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/nvme/target/admin-cmd.c b/drivers/nvme/target/admin-cmd.c
index f12d83098644..ee8be237485e 100644
--- a/drivers/nvme/target/admin-cmd.c
+++ b/drivers/nvme/target/admin-cmd.c
@@ -1223,6 +1223,7 @@ static u16 nvmet_set_feat_write_protect(struct nvmet_req *req)
 		status = 0;
 		break;
 	default:
+		status = NVME_SC_INVALID_FIELD | NVME_STATUS_DNR;
 		break;
 	}
 
-- 
2.55.0



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] nvmet: reject invalid write-protect feature values
  2026-11-09 14:24 ` [PATCH v2] " Sreeraj S Kurup
@ 2026-11-10  7:17   ` Hannes Reinecke
  0 siblings, 0 replies; 4+ messages in thread
From: Hannes Reinecke @ 2026-11-10  7:17 UTC (permalink / raw)
  To: Sreeraj S Kurup; +Cc: hare, hch, kbusch, kch, linux-kernel, linux-nvme, sagi

On 11/9/26 3:24 PM, Sreeraj S Kurup wrote:
> The Set Features handler for namespace write protection currently
> accepts unsupported values. The default case in the write-protect
> switch leaves the status unchanged, causing the command to return
> success even though no valid setting was applied.
> 
> Return NVME_SC_INVALID_FIELD | NVME_STATUS_DNR for unsupported
> values. This also prevents issuing a namespace-change notification
> for an invalid request.
> 
> Fixes: 3a1f7c79ae6d ("nvmet: make nvmet_find_namespace() req based")
> Signed-off-by: Sreeraj S Kurup <sreekuttan2156239@gmail.com>
> ---
> v2:
>   - Add Fixes trailer
> 
>   drivers/nvme/target/admin-cmd.c | 1 +
>   1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/nvme/target/admin-cmd.c b/drivers/nvme/target/admin-cmd.c
> index f12d83098644..ee8be237485e 100644
> --- a/drivers/nvme/target/admin-cmd.c
> +++ b/drivers/nvme/target/admin-cmd.c
> @@ -1223,6 +1223,7 @@ static u16 nvmet_set_feat_write_protect(struct nvmet_req *req)
>   		status = 0;
>   		break;
>   	default:
> +		status = NVME_SC_INVALID_FIELD | NVME_STATUS_DNR;
>   		break;
>   	}
>   

Please send new versions as individual patchsets, not as replies to the
original patch.

Reviewed-by: Hannes Reinecke <hare@kernel.org>

Cheers,

Hannes
-- 
Dr. Hannes Reinecke                  Kernel Storage Architect
hare@suse.de                                +49 911 74053 688
SUSE Software Solutions GmbH, Frankenstr. 146, 90461 Nürnberg
HRB 36809 (AG Nürnberg), GF: I. Totev, A. McDonald, W. Knoblich


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-11-10  7:19 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-09 13:55 [PATCH] nvmet: reject invalid write-protect feature values Sreeraj S Kurup
2026-11-09 14:11 ` sashiko-bot
2026-11-09 14:24 ` [PATCH v2] " Sreeraj S Kurup
2026-11-10  7:17   ` Hannes Reinecke

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox