Skip to content

Commit cd0c1b8

Browse files
igawkeithbusch
authored andcommitted
nvmet: always initialize cqe.result
The spec doesn't mandate that the first two double words (aka results) for the command queue entry need to be set to 0 when they are not used (not specified). Though, the target implemention returns 0 for TCP and FC but not for RDMA. Let's make RDMA behave the same and thus explicitly initializing the result field. This prevents leaking any data from the stack. Signed-off-by: Daniel Wagner <[email protected]> Reviewed-by: Christoph Hellwig <[email protected]> Signed-off-by: Keith Busch <[email protected]>
1 parent d76584e commit cd0c1b8

File tree

3 files changed

+1
-9
lines changed

3 files changed

+1
-9
lines changed

drivers/nvme/target/core.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -957,6 +957,7 @@ bool nvmet_req_init(struct nvmet_req *req, struct nvmet_cq *cq,
957957
req->metadata_sg_cnt = 0;
958958
req->transfer_len = 0;
959959
req->metadata_len = 0;
960+
req->cqe->result.u64 = 0;
960961
req->cqe->status = 0;
961962
req->cqe->sq_head = 0;
962963
req->ns = NULL;

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

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,6 @@ void nvmet_execute_auth_send(struct nvmet_req *req)
333333
pr_debug("%s: ctrl %d qid %d nvme status %x error loc %d\n",
334334
__func__, ctrl->cntlid, req->sq->qid,
335335
status, req->error_loc);
336-
req->cqe->result.u64 = 0;
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;
@@ -516,8 +515,6 @@ void nvmet_execute_auth_receive(struct nvmet_req *req)
516515
status = nvmet_copy_to_sgl(req, 0, d, al);
517516
kfree(d);
518517
done:
519-
req->cqe->result.u64 = 0;
520-
521518
if (req->sq->dhchap_step == NVME_AUTH_DHCHAP_MESSAGE_SUCCESS2)
522519
nvmet_auth_sq_free(req->sq);
523520
else if (req->sq->dhchap_step == NVME_AUTH_DHCHAP_MESSAGE_FAILURE1) {

drivers/nvme/target/fabrics-cmd.c

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -226,9 +226,6 @@ static void nvmet_execute_admin_connect(struct nvmet_req *req)
226226
if (status)
227227
goto out;
228228

229-
/* zero out initial completion result, assign values as needed */
230-
req->cqe->result.u32 = 0;
231-
232229
if (c->recfmt != 0) {
233230
pr_warn("invalid connect version (%d).\n",
234231
le16_to_cpu(c->recfmt));
@@ -305,9 +302,6 @@ static void nvmet_execute_io_connect(struct nvmet_req *req)
305302
if (status)
306303
goto out;
307304

308-
/* zero out initial completion result, assign values as needed */
309-
req->cqe->result.u32 = 0;
310-
311305
if (c->recfmt != 0) {
312306
pr_warn("invalid connect version (%d).\n",
313307
le16_to_cpu(c->recfmt));

0 commit comments

Comments
 (0)