Skip to content

Commit 6431ecb

Browse files
igawvijay-suman
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]> (cherry picked from commit cd0c1b8) Orabug: 36897348 CVE: CVE-2024-41079 Signed-off-by: Himanshu Madhani <[email protected]> Reviewed-by: Alok Tiwari <[email protected]> Signed-off-by: Vijayendra Suman <[email protected]>
1 parent 053276e commit 6431ecb

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
@@ -941,6 +941,7 @@ bool nvmet_req_init(struct nvmet_req *req, struct nvmet_cq *cq,
941941
req->metadata_sg_cnt = 0;
942942
req->transfer_len = 0;
943943
req->metadata_len = 0;
944+
req->cqe->result.u64 = 0;
944945
req->cqe->status = 0;
945946
req->cqe->sq_head = 0;
946947
req->ns = NULL;

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

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,6 @@ void nvmet_execute_auth_send(struct nvmet_req *req)
336336
pr_debug("%s: ctrl %d qid %d nvme status %x error loc %d\n",
337337
__func__, ctrl->cntlid, req->sq->qid,
338338
status, req->error_loc);
339-
req->cqe->result.u64 = 0;
340339
if (req->sq->dhchap_step != NVME_AUTH_DHCHAP_MESSAGE_SUCCESS2 &&
341340
req->sq->dhchap_step != NVME_AUTH_DHCHAP_MESSAGE_FAILURE2) {
342341
unsigned long auth_expire_secs = ctrl->kato ? ctrl->kato : 120;
@@ -528,8 +527,6 @@ void nvmet_execute_auth_receive(struct nvmet_req *req)
528527
status = nvmet_copy_to_sgl(req, 0, d, al);
529528
kfree(d);
530529
done:
531-
req->cqe->result.u64 = 0;
532-
533530
if (req->sq->dhchap_step == NVME_AUTH_DHCHAP_MESSAGE_SUCCESS2)
534531
nvmet_auth_sq_free(req->sq);
535532
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
@@ -225,9 +225,6 @@ static void nvmet_execute_admin_connect(struct nvmet_req *req)
225225
if (status)
226226
goto out;
227227

228-
/* zero out initial completion result, assign values as needed */
229-
req->cqe->result.u32 = 0;
230-
231228
if (c->recfmt != 0) {
232229
pr_warn("invalid connect version (%d).\n",
233230
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)