Skip to contentSkip to conversation

nvmet-auth: reject incomplete DHCHAP messages

PATCH Applied Jérémy Jean 4 participants 5 messages Nov 2 – Nov 10

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 nvmet-auth: reject incomplete DHCHAP messages

Commit c9359401036e ("nvmet-auth: reject undersized AUTH_SEND payloads") only ensures that AUTH_SEND has auth_type and auth_id before nvmet_execute_auth_send() starts parsing the payload, but the DHCHAP path reads t_id before it verifies message lengths. A two-byte DHCHAP NEGOTIATE payload can therefore still trigger an OOB read that KASAN reports as:

  BUG: KASAN: slab-out-of-bounds in nvmet_execute_auth_send
  Read of size 2 at addr ffff8880030d8364

Require the payload to cover the minimum DHCHAP message length before parsing it.

Fixes c9359401036e ("nvmet-auth: reject undersized AUTH_SEND payloads")

---

Changes in v2:
- Check the minimum DHCHAP message length.

v1 (2026-08-11 18:03:35 +0000): https://lore.kernel.org/all/[email protected]/

 drivers/nvme/target/fabrics-cmd-auth.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/nvme/target/fabrics-cmd-auth.c +1 -1
index 70136f6c22e8..a15f21fc41e4 100644
@@ -301,7 +301,7 @@ void nvmet_execute_auth_send(struct nvmet_req *req)
 		nvmet_check_transfer_len(req, tl);
 		return;
 	}
-	if (tl < offsetof(struct nvmf_auth_dhchap_success2_data, rsvd1)) {
+	if (tl < sizeof(struct nvmf_auth_dhchap_failure_data)) {
 		status = NVME_SC_INVALID_FIELD | NVME_STATUS_DNR;
 		req->error_loc =
 			offsetof(struct nvmf_auth_send_command, tl);
Signature · 1 line
2.47.3
maintainer Reviewed-by on v2 1/1
#2 lore raw
In reply to Jérémy Jean
Quoted 32 lines · Jérémy Jean

Commit c9359401036e ("nvmet-auth: reject undersized AUTH_SEND payloads") only ensures that AUTH_SEND has auth_type and auth_id before nvmet_execute_auth_send() starts parsing the payload, but the DHCHAP path reads t_id before it verifies message lengths. A two-byte DHCHAP NEGOTIATE payload can therefore still trigger an OOB read that KASAN reports as:

   BUG: KASAN: slab-out-of-bounds in nvmet_execute_auth_send
   Read of size 2 at addr ffff8880030d8364

Require the payload to cover the minimum DHCHAP message length before parsing it.

Fixes c9359401036e ("nvmet-auth: reject undersized AUTH_SEND payloads")

---

Changes in v2:
- Check the minimum DHCHAP message length.

v1 (2026-08-11 18:03:35 +0000): https://lore.kernel.org/all/[email protected]/

  drivers/nvme/target/fabrics-cmd-auth.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/nvme/target/fabrics-cmd-auth.c +0 -0
index 70136f6c22e8..a15f21fc41e4 100644

drivers/nvme/target/fabrics-cmd-auth.c void nvmet_execute_auth_send(struct nvmet_req *req) · line 307

Quoted 8 lines
drivers/nvme/target/fabrics-cmd-auth.c +1 -1
@@ -301,7 +301,7 @@ void nvmet_execute_auth_send(struct nvmet_req *req)
  		nvmet_check_transfer_len(req, tl);
  		return;
  	}
-	if (tl < offsetof(struct nvmf_auth_dhchap_success2_data, rsvd1)) {
+	if (tl < sizeof(struct nvmf_auth_dhchap_failure_data)) {
  		status = NVME_SC_INVALID_FIELD | NVME_STATUS_DNR;
  		req->error_loc =
  			offsetof(struct nvmf_auth_send_command, tl);

Cheers,

Hannes

Signature · 4 lines
Dr. Hannes Reinecke                  Kernel Storage Architect
[email protected]                                +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
maintainer Applied
#3 lore raw
In reply to Jérémy Jean
Quoted 7 lines · Jérémy Jean

Commit c9359401036e ("nvmet-auth: reject undersized AUTH_SEND payloads") only ensures that AUTH_SEND has auth_type and auth_id before nvmet_execute_auth_send() starts parsing the payload, but the DHCHAP path reads t_id before it verifies message lengths. A two-byte DHCHAP NEGOTIATE payload can therefore still trigger an OOB read that KASAN reports as:

Quoted 5 lines
  BUG: KASAN: slab-out-of-bounds in nvmet_execute_auth_send
  Read of size 2 at addr ffff8880030d8364

Require the payload to cover the minimum DHCHAP message length before parsing it.

Thanks, applied to nvme-7.4.

maintainer
#4 lore raw
In reply to Jérémy Jean
Quoted 32 lines · Jérémy Jean

Commit c9359401036e ("nvmet-auth: reject undersized AUTH_SEND payloads") only ensures that AUTH_SEND has auth_type and auth_id before nvmet_execute_auth_send() starts parsing the payload, but the DHCHAP path reads t_id before it verifies message lengths. A two-byte DHCHAP NEGOTIATE payload can therefore still trigger an OOB read that KASAN reports as:

   BUG: KASAN: slab-out-of-bounds in nvmet_execute_auth_send
   Read of size 2 at addr ffff8880030d8364

Require the payload to cover the minimum DHCHAP message length before parsing it.

Fixes c9359401036e ("nvmet-auth: reject undersized AUTH_SEND payloads")

---

Changes in v2:
- Check the minimum DHCHAP message length.

v1 (2026-08-11 18:03:35 +0000): https://lore.kernel.org/all/[email protected]/

  drivers/nvme/target/fabrics-cmd-auth.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/nvme/target/fabrics-cmd-auth.c +0 -0
index 70136f6c22e8..a15f21fc41e4 100644

drivers/nvme/target/fabrics-cmd-auth.c void nvmet_execute_auth_send(struct nvmet_req *req) · line 307

Quoted 8 lines
drivers/nvme/target/fabrics-cmd-auth.c +1 -1
@@ -301,7 +301,7 @@ void nvmet_execute_auth_send(struct nvmet_req *req)
  		nvmet_check_transfer_len(req, tl);
  		return;
  	}
-	if (tl < offsetof(struct nvmf_auth_dhchap_success2_data, rsvd1)) {
+	if (tl < sizeof(struct nvmf_auth_dhchap_failure_data)) {
  		status = NVME_SC_INVALID_FIELD | NVME_STATUS_DNR;
  		req->error_loc =
  			offsetof(struct nvmf_auth_send_command, tl);

Reviewed=by: Hannes Reinecke <[email protected]>

Cheers,

Hannes

Signature · 4 lines
Dr. Hannes Reinecke                  Kernel Storage Architect
[email protected]                                +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