Skip to content

Commit c320008

Browse files
committed
Merge tag 'block-6.6-2023-10-20' of git://git.kernel.dk/linux
Pull block fixes from Jens Axboe: "A fix for a regression with sed-opal and saved keys, and outside of that an NVMe pull request fixing a few minor issues on that front" * tag 'block-6.6-2023-10-20' of git://git.kernel.dk/linux: nvme-pci: add BOGUS_NID for Intel 0a54 device nvmet-auth: complete a request only after freeing the dhchap pointers nvme: sanitize metadata bounce buffer for reads block: Fix regression in sed-opal for a saved key. nvme-auth: use chap->s2 to indicate bidirectional authentication nvmet-tcp: Fix a possible UAF in queue intialization setup nvme-rdma: do not try to stop unallocated queues
2 parents 747b762 + c341455 commit c320008

File tree

7 files changed

+25
-18
lines changed

7 files changed

+25
-18
lines changed

block/sed-opal.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2888,12 +2888,11 @@ static int opal_lock_unlock(struct opal_dev *dev,
28882888
if (lk_unlk->session.who > OPAL_USER9)
28892889
return -EINVAL;
28902890

2891-
ret = opal_get_key(dev, &lk_unlk->session.opal_key);
2892-
if (ret)
2893-
return ret;
28942891
mutex_lock(&dev->dev_lock);
28952892
opal_lock_check_for_saved_key(dev, lk_unlk);
2896-
ret = __opal_lock_unlock(dev, lk_unlk);
2893+
ret = opal_get_key(dev, &lk_unlk->session.opal_key);
2894+
if (!ret)
2895+
ret = __opal_lock_unlock(dev, lk_unlk);
28972896
mutex_unlock(&dev->dev_lock);
28982897

28992898
return ret;

drivers/nvme/host/auth.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,7 @@ static int nvme_auth_process_dhchap_success1(struct nvme_ctrl *ctrl,
341341
struct nvmf_auth_dhchap_success1_data *data = chap->buf;
342342
size_t size = sizeof(*data);
343343

344-
if (chap->ctrl_key)
344+
if (chap->s2)
345345
size += chap->hash_len;
346346

347347
if (size > CHAP_BUF_SIZE) {
@@ -825,7 +825,7 @@ static void nvme_queue_auth_work(struct work_struct *work)
825825
goto fail2;
826826
}
827827

828-
if (chap->ctrl_key) {
828+
if (chap->s2) {
829829
/* DH-HMAC-CHAP Step 5: send success2 */
830830
dev_dbg(ctrl->device, "%s: qid %d send success2\n",
831831
__func__, chap->qid);

drivers/nvme/host/ioctl.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,9 +108,13 @@ static void *nvme_add_user_metadata(struct request *req, void __user *ubuf,
108108
if (!buf)
109109
goto out;
110110

111-
ret = -EFAULT;
112-
if ((req_op(req) == REQ_OP_DRV_OUT) && copy_from_user(buf, ubuf, len))
113-
goto out_free_meta;
111+
if (req_op(req) == REQ_OP_DRV_OUT) {
112+
ret = -EFAULT;
113+
if (copy_from_user(buf, ubuf, len))
114+
goto out_free_meta;
115+
} else {
116+
memset(buf, 0, len);
117+
}
114118

115119
bip = bio_integrity_alloc(bio, GFP_KERNEL, 1);
116120
if (IS_ERR(bip)) {

drivers/nvme/host/pci.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3329,7 +3329,8 @@ static const struct pci_device_id nvme_id_table[] = {
33293329
{ PCI_VDEVICE(INTEL, 0x0a54), /* Intel P4500/P4600 */
33303330
.driver_data = NVME_QUIRK_STRIPE_SIZE |
33313331
NVME_QUIRK_DEALLOCATE_ZEROES |
3332-
NVME_QUIRK_IGNORE_DEV_SUBNQN, },
3332+
NVME_QUIRK_IGNORE_DEV_SUBNQN |
3333+
NVME_QUIRK_BOGUS_NID, },
33333334
{ PCI_VDEVICE(INTEL, 0x0a55), /* Dell Express Flash P4600 */
33343335
.driver_data = NVME_QUIRK_STRIPE_SIZE |
33353336
NVME_QUIRK_DEALLOCATE_ZEROES, },

drivers/nvme/host/rdma.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -638,6 +638,9 @@ static void __nvme_rdma_stop_queue(struct nvme_rdma_queue *queue)
638638

639639
static void nvme_rdma_stop_queue(struct nvme_rdma_queue *queue)
640640
{
641+
if (!test_bit(NVME_RDMA_Q_ALLOCATED, &queue->flags))
642+
return;
643+
641644
mutex_lock(&queue->queue_lock);
642645
if (test_and_clear_bit(NVME_RDMA_Q_LIVE, &queue->flags))
643646
__nvme_rdma_stop_queue(queue);

drivers/nvme/target/fabrics-cmd-auth.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -333,19 +333,21 @@ void nvmet_execute_auth_send(struct nvmet_req *req)
333333
__func__, ctrl->cntlid, req->sq->qid,
334334
status, req->error_loc);
335335
req->cqe->result.u64 = 0;
336-
nvmet_req_complete(req, status);
337336
if (req->sq->dhchap_step != NVME_AUTH_DHCHAP_MESSAGE_SUCCESS2 &&
338337
req->sq->dhchap_step != NVME_AUTH_DHCHAP_MESSAGE_FAILURE2) {
339338
unsigned long auth_expire_secs = ctrl->kato ? ctrl->kato : 120;
340339

341340
mod_delayed_work(system_wq, &req->sq->auth_expired_work,
342341
auth_expire_secs * HZ);
343-
return;
342+
goto complete;
344343
}
345344
/* Final states, clear up variables */
346345
nvmet_auth_sq_free(req->sq);
347346
if (req->sq->dhchap_step == NVME_AUTH_DHCHAP_MESSAGE_FAILURE2)
348347
nvmet_ctrl_fatal_error(ctrl);
348+
349+
complete:
350+
nvmet_req_complete(req, status);
349351
}
350352

351353
static int nvmet_auth_challenge(struct nvmet_req *req, void *d, int al)
@@ -514,11 +516,12 @@ void nvmet_execute_auth_receive(struct nvmet_req *req)
514516
kfree(d);
515517
done:
516518
req->cqe->result.u64 = 0;
517-
nvmet_req_complete(req, status);
519+
518520
if (req->sq->dhchap_step == NVME_AUTH_DHCHAP_MESSAGE_SUCCESS2)
519521
nvmet_auth_sq_free(req->sq);
520522
else if (req->sq->dhchap_step == NVME_AUTH_DHCHAP_MESSAGE_FAILURE1) {
521523
nvmet_auth_sq_free(req->sq);
522524
nvmet_ctrl_fatal_error(ctrl);
523525
}
526+
nvmet_req_complete(req, status);
524527
}

drivers/nvme/target/tcp.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -372,6 +372,7 @@ static void nvmet_tcp_fatal_error(struct nvmet_tcp_queue *queue)
372372

373373
static void nvmet_tcp_socket_error(struct nvmet_tcp_queue *queue, int status)
374374
{
375+
queue->rcv_state = NVMET_TCP_RECV_ERR;
375376
if (status == -EPIPE || status == -ECONNRESET)
376377
kernel_sock_shutdown(queue->sock, SHUT_RDWR);
377378
else
@@ -910,15 +911,11 @@ static int nvmet_tcp_handle_icreq(struct nvmet_tcp_queue *queue)
910911
iov.iov_len = sizeof(*icresp);
911912
ret = kernel_sendmsg(queue->sock, &msg, &iov, 1, iov.iov_len);
912913
if (ret < 0)
913-
goto free_crypto;
914+
return ret; /* queue removal will cleanup */
914915

915916
queue->state = NVMET_TCP_Q_LIVE;
916917
nvmet_prepare_receive_pdu(queue);
917918
return 0;
918-
free_crypto:
919-
if (queue->hdr_digest || queue->data_digest)
920-
nvmet_tcp_free_crypto(queue);
921-
return ret;
922919
}
923920

924921
static void nvmet_tcp_handle_req_failure(struct nvmet_tcp_queue *queue,

0 commit comments

Comments
 (0)