Skip to content

Commit db1312d

Browse files
hreineckeaxboe
authored andcommitted
nvmet: implement basic In-Band Authentication
Implement NVMe-oF In-Band authentication according to NVMe TPAR 8006. This patch adds three additional configfs entries 'dhchap_key', 'dhchap_ctrl_key', and 'dhchap_hash' to the 'host' configfs directory. The 'dhchap_key' and 'dhchap_ctrl_key' entries need to be in the ASCII format as specified in NVMe Base Specification v2.0 section 8.13.5.8 'Secret representation'. 'dhchap_hash' defaults to 'hmac(sha256)', and can be written to to switch to a different HMAC algorithm. Signed-off-by: Hannes Reinecke <[email protected]> Reviewed-by: Sagi Grimberg <[email protected]> Signed-off-by: Christoph Hellwig <[email protected]> Signed-off-by: Jens Axboe <[email protected]>
1 parent 6490c9e commit db1312d

File tree

9 files changed

+1100
-3
lines changed

9 files changed

+1100
-3
lines changed

drivers/nvme/target/Kconfig

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,3 +83,16 @@ config NVME_TARGET_TCP
8383
devices over TCP.
8484

8585
If unsure, say N.
86+
87+
config NVME_TARGET_AUTH
88+
bool "NVMe over Fabrics In-band Authentication support"
89+
depends on NVME_TARGET
90+
select NVME_COMMON
91+
select CRYPTO
92+
select CRYPTO_HMAC
93+
select CRYPTO_SHA256
94+
select CRYPTO_SHA512
95+
help
96+
This enables support for NVMe over Fabrics In-band Authentication
97+
98+
If unsure, say N.

drivers/nvme/target/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ nvmet-y += core.o configfs.o admin-cmd.o fabrics-cmd.o \
1313
discovery.o io-cmd-file.o io-cmd-bdev.o
1414
nvmet-$(CONFIG_NVME_TARGET_PASSTHRU) += passthru.o
1515
nvmet-$(CONFIG_BLK_DEV_ZONED) += zns.o
16+
nvmet-$(CONFIG_NVME_TARGET_AUTH) += fabrics-cmd-auth.o auth.o
1617
nvme-loop-y += loop.o
1718
nvmet-rdma-y += rdma.o
1819
nvmet-fc-y += fc.o

drivers/nvme/target/admin-cmd.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1018,6 +1018,8 @@ u16 nvmet_parse_admin_cmd(struct nvmet_req *req)
10181018

10191019
if (nvme_is_fabrics(cmd))
10201020
return nvmet_parse_fabrics_admin_cmd(req);
1021+
if (unlikely(!nvmet_check_auth_status(req)))
1022+
return NVME_SC_AUTH_REQUIRED | NVME_SC_DNR;
10211023
if (nvmet_is_disc_subsys(nvmet_req_subsys(req)))
10221024
return nvmet_parse_discovery_cmd(req);
10231025

0 commit comments

Comments
 (0)