Skip to content

Commit 55072cd

Browse files
committed
Merge tag 'nvme-6.7-2023-11-22' of git://git.infradead.org/nvme into block-6.7
Pull NVMe fixes from Keith: "nvme fixes for Linux 6.7 - TCP TLS fixes (Hannes) - Authentifaction fixes (Mark, Hannes) - Properly terminate target names (Christoph)" * tag 'nvme-6.7-2023-11-22' of git://git.infradead.org/nvme: nvme: move nvme_stop_keep_alive() back to original position nvmet-tcp: always initialize tls_handshake_tmo_work nvmet: nul-terminate the NQNs passed in the connect command nvme: blank out authentication fabrics options if not configured nvme: catch errors from nvme_configure_metadata() nvme-tcp: only evaluate 'tls' option if TLS is selected nvme-auth: set explanation code for failure2 msgs nvme-auth: unlock mutex in one place only
2 parents 98c598a + 3af755a commit 55072cd

File tree

8 files changed

+37
-22
lines changed

8 files changed

+37
-22
lines changed

drivers/nvme/host/auth.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -757,12 +757,11 @@ static void nvme_queue_auth_work(struct work_struct *work)
757757
__func__, chap->qid);
758758
mutex_lock(&ctrl->dhchap_auth_mutex);
759759
ret = nvme_auth_dhchap_setup_host_response(ctrl, chap);
760+
mutex_unlock(&ctrl->dhchap_auth_mutex);
760761
if (ret) {
761-
mutex_unlock(&ctrl->dhchap_auth_mutex);
762762
chap->error = ret;
763763
goto fail2;
764764
}
765-
mutex_unlock(&ctrl->dhchap_auth_mutex);
766765

767766
/* DH-HMAC-CHAP Step 3: send reply */
768767
dev_dbg(ctrl->device, "%s: qid %d send reply\n",
@@ -839,6 +838,8 @@ static void nvme_queue_auth_work(struct work_struct *work)
839838
}
840839

841840
fail2:
841+
if (chap->status == 0)
842+
chap->status = NVME_AUTH_DHCHAP_FAILURE_FAILED;
842843
dev_dbg(ctrl->device, "%s: qid %d send failure2, status %x\n",
843844
__func__, chap->qid, chap->status);
844845
tl = nvme_auth_set_dhchap_failure2_data(ctrl, chap);

drivers/nvme/host/core.c

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -482,7 +482,6 @@ EXPORT_SYMBOL_GPL(nvme_cancel_tagset);
482482

483483
void nvme_cancel_admin_tagset(struct nvme_ctrl *ctrl)
484484
{
485-
nvme_stop_keep_alive(ctrl);
486485
if (ctrl->admin_tagset) {
487486
blk_mq_tagset_busy_iter(ctrl->admin_tagset,
488487
nvme_cancel_request, ctrl);
@@ -1814,16 +1813,18 @@ static int nvme_init_ms(struct nvme_ns *ns, struct nvme_id_ns *id)
18141813
return ret;
18151814
}
18161815

1817-
static void nvme_configure_metadata(struct nvme_ns *ns, struct nvme_id_ns *id)
1816+
static int nvme_configure_metadata(struct nvme_ns *ns, struct nvme_id_ns *id)
18181817
{
18191818
struct nvme_ctrl *ctrl = ns->ctrl;
1819+
int ret;
18201820

1821-
if (nvme_init_ms(ns, id))
1822-
return;
1821+
ret = nvme_init_ms(ns, id);
1822+
if (ret)
1823+
return ret;
18231824

18241825
ns->features &= ~(NVME_NS_METADATA_SUPPORTED | NVME_NS_EXT_LBAS);
18251826
if (!ns->ms || !(ctrl->ops->flags & NVME_F_METADATA_SUPPORTED))
1826-
return;
1827+
return 0;
18271828

18281829
if (ctrl->ops->flags & NVME_F_FABRICS) {
18291830
/*
@@ -1832,7 +1833,7 @@ static void nvme_configure_metadata(struct nvme_ns *ns, struct nvme_id_ns *id)
18321833
* remap the separate metadata buffer from the block layer.
18331834
*/
18341835
if (WARN_ON_ONCE(!(id->flbas & NVME_NS_FLBAS_META_EXT)))
1835-
return;
1836+
return 0;
18361837

18371838
ns->features |= NVME_NS_EXT_LBAS;
18381839

@@ -1859,6 +1860,7 @@ static void nvme_configure_metadata(struct nvme_ns *ns, struct nvme_id_ns *id)
18591860
else
18601861
ns->features |= NVME_NS_METADATA_SUPPORTED;
18611862
}
1863+
return 0;
18621864
}
18631865

18641866
static void nvme_set_queue_limits(struct nvme_ctrl *ctrl,
@@ -2032,7 +2034,11 @@ static int nvme_update_ns_info_block(struct nvme_ns *ns,
20322034
ns->lba_shift = id->lbaf[lbaf].ds;
20332035
nvme_set_queue_limits(ns->ctrl, ns->queue);
20342036

2035-
nvme_configure_metadata(ns, id);
2037+
ret = nvme_configure_metadata(ns, id);
2038+
if (ret < 0) {
2039+
blk_mq_unfreeze_queue(ns->disk->queue);
2040+
goto out;
2041+
}
20362042
nvme_set_chunk_sectors(ns, id);
20372043
nvme_update_disk_info(ns->disk, ns, id);
20382044

@@ -4348,6 +4354,7 @@ void nvme_stop_ctrl(struct nvme_ctrl *ctrl)
43484354
{
43494355
nvme_mpath_stop(ctrl);
43504356
nvme_auth_stop(ctrl);
4357+
nvme_stop_keep_alive(ctrl);
43514358
nvme_stop_failfast_work(ctrl);
43524359
flush_work(&ctrl->async_event_work);
43534360
cancel_work_sync(&ctrl->fw_act_work);

drivers/nvme/host/fabrics.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -667,8 +667,10 @@ static const match_table_t opt_tokens = {
667667
#endif
668668
{ NVMF_OPT_FAIL_FAST_TMO, "fast_io_fail_tmo=%d" },
669669
{ NVMF_OPT_DISCOVERY, "discovery" },
670+
#ifdef CONFIG_NVME_HOST_AUTH
670671
{ NVMF_OPT_DHCHAP_SECRET, "dhchap_secret=%s" },
671672
{ NVMF_OPT_DHCHAP_CTRL_SECRET, "dhchap_ctrl_secret=%s" },
673+
#endif
672674
#ifdef CONFIG_NVME_TCP_TLS
673675
{ NVMF_OPT_TLS, "tls" },
674676
#endif

drivers/nvme/host/fc.c

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2530,12 +2530,6 @@ __nvme_fc_abort_outstanding_ios(struct nvme_fc_ctrl *ctrl, bool start_queues)
25302530
* clean up the admin queue. Same thing as above.
25312531
*/
25322532
nvme_quiesce_admin_queue(&ctrl->ctrl);
2533-
2534-
/*
2535-
* Open-coding nvme_cancel_admin_tagset() as fc
2536-
* is not using nvme_cancel_request().
2537-
*/
2538-
nvme_stop_keep_alive(&ctrl->ctrl);
25392533
blk_sync_queue(ctrl->ctrl.admin_q);
25402534
blk_mq_tagset_busy_iter(&ctrl->admin_tag_set,
25412535
nvme_fc_terminate_exchange, &ctrl->ctrl);
@@ -3138,27 +3132,28 @@ nvme_fc_create_association(struct nvme_fc_ctrl *ctrl)
31383132
nvme_unquiesce_admin_queue(&ctrl->ctrl);
31393133

31403134
ret = nvme_init_ctrl_finish(&ctrl->ctrl, false);
3141-
if (!ret && test_bit(ASSOC_FAILED, &ctrl->flags))
3142-
ret = -EIO;
31433135
if (ret)
31443136
goto out_disconnect_admin_queue;
3145-
3137+
if (test_bit(ASSOC_FAILED, &ctrl->flags)) {
3138+
ret = -EIO;
3139+
goto out_stop_keep_alive;
3140+
}
31463141
/* sanity checks */
31473142

31483143
/* FC-NVME does not have other data in the capsule */
31493144
if (ctrl->ctrl.icdoff) {
31503145
dev_err(ctrl->ctrl.device, "icdoff %d is not supported!\n",
31513146
ctrl->ctrl.icdoff);
31523147
ret = NVME_SC_INVALID_FIELD | NVME_SC_DNR;
3153-
goto out_disconnect_admin_queue;
3148+
goto out_stop_keep_alive;
31543149
}
31553150

31563151
/* FC-NVME supports normal SGL Data Block Descriptors */
31573152
if (!nvme_ctrl_sgl_supported(&ctrl->ctrl)) {
31583153
dev_err(ctrl->ctrl.device,
31593154
"Mandatory sgls are not supported!\n");
31603155
ret = NVME_SC_INVALID_FIELD | NVME_SC_DNR;
3161-
goto out_disconnect_admin_queue;
3156+
goto out_stop_keep_alive;
31623157
}
31633158

31643159
if (opts->queue_size > ctrl->ctrl.maxcmd) {
@@ -3205,6 +3200,8 @@ nvme_fc_create_association(struct nvme_fc_ctrl *ctrl)
32053200

32063201
out_term_aen_ops:
32073202
nvme_fc_term_aen_ops(ctrl);
3203+
out_stop_keep_alive:
3204+
nvme_stop_keep_alive(&ctrl->ctrl);
32083205
out_disconnect_admin_queue:
32093206
dev_warn(ctrl->ctrl.device,
32103207
"NVME-FC{%d}: create_assoc failed, assoc_id %llx ret %d\n",

drivers/nvme/host/rdma.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1080,6 +1080,7 @@ static int nvme_rdma_setup_ctrl(struct nvme_rdma_ctrl *ctrl, bool new)
10801080
nvme_rdma_free_io_queues(ctrl);
10811081
}
10821082
destroy_admin:
1083+
nvme_stop_keep_alive(&ctrl->ctrl);
10831084
nvme_quiesce_admin_queue(&ctrl->ctrl);
10841085
blk_sync_queue(ctrl->ctrl.admin_q);
10851086
nvme_rdma_stop_queue(&ctrl->queues[0]);

drivers/nvme/host/tcp.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1916,7 +1916,7 @@ static int nvme_tcp_alloc_admin_queue(struct nvme_ctrl *ctrl)
19161916
int ret;
19171917
key_serial_t pskid = 0;
19181918

1919-
if (ctrl->opts->tls) {
1919+
if (IS_ENABLED(CONFIG_NVME_TCP_TLS) && ctrl->opts->tls) {
19201920
if (ctrl->opts->tls_key)
19211921
pskid = key_serial(ctrl->opts->tls_key);
19221922
else
@@ -2237,6 +2237,7 @@ static int nvme_tcp_setup_ctrl(struct nvme_ctrl *ctrl, bool new)
22372237
nvme_tcp_destroy_io_queues(ctrl, new);
22382238
}
22392239
destroy_admin:
2240+
nvme_stop_keep_alive(ctrl);
22402241
nvme_tcp_teardown_admin_queue(ctrl, false);
22412242
return ret;
22422243
}

drivers/nvme/target/fabrics-cmd.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,8 @@ static void nvmet_execute_admin_connect(struct nvmet_req *req)
244244
goto out;
245245
}
246246

247+
d->subsysnqn[NVMF_NQN_FIELD_LEN - 1] = '\0';
248+
d->hostnqn[NVMF_NQN_FIELD_LEN - 1] = '\0';
247249
status = nvmet_alloc_ctrl(d->subsysnqn, d->hostnqn, req,
248250
le32_to_cpu(c->kato), &ctrl);
249251
if (status)
@@ -313,6 +315,8 @@ static void nvmet_execute_io_connect(struct nvmet_req *req)
313315
goto out;
314316
}
315317

318+
d->subsysnqn[NVMF_NQN_FIELD_LEN - 1] = '\0';
319+
d->hostnqn[NVMF_NQN_FIELD_LEN - 1] = '\0';
316320
ctrl = nvmet_ctrl_find_get(d->subsysnqn, d->hostnqn,
317321
le16_to_cpu(d->cntlid), req);
318322
if (!ctrl) {

drivers/nvme/target/tcp.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1854,6 +1854,8 @@ static int nvmet_tcp_tls_handshake(struct nvmet_tcp_queue *queue)
18541854
}
18551855
return ret;
18561856
}
1857+
#else
1858+
static void nvmet_tcp_tls_handshake_timeout(struct work_struct *w) {}
18571859
#endif
18581860

18591861
static void nvmet_tcp_alloc_queue(struct nvmet_tcp_port *port,
@@ -1911,9 +1913,9 @@ static void nvmet_tcp_alloc_queue(struct nvmet_tcp_port *port,
19111913
list_add_tail(&queue->queue_list, &nvmet_tcp_queue_list);
19121914
mutex_unlock(&nvmet_tcp_queue_mutex);
19131915

1914-
#ifdef CONFIG_NVME_TARGET_TCP_TLS
19151916
INIT_DELAYED_WORK(&queue->tls_handshake_tmo_work,
19161917
nvmet_tcp_tls_handshake_timeout);
1918+
#ifdef CONFIG_NVME_TARGET_TCP_TLS
19171919
if (queue->state == NVMET_TCP_Q_TLS_HANDSHAKE) {
19181920
struct sock *sk = queue->sock->sk;
19191921

0 commit comments

Comments
 (0)