mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-08 03:40:35 +09:00
nvmet: always initialize cqe.result
[ Upstream commit cd0c1b8e045a8d2785342b385cb2684d9b48e426 ] 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 <dwagner@suse.de> Reviewed-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Keith Busch <kbusch@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
f3ab45aacd
commit
30d35b24b7
@@ -944,6 +944,7 @@ bool nvmet_req_init(struct nvmet_req *req, struct nvmet_cq *cq,
|
|||||||
req->metadata_sg_cnt = 0;
|
req->metadata_sg_cnt = 0;
|
||||||
req->transfer_len = 0;
|
req->transfer_len = 0;
|
||||||
req->metadata_len = 0;
|
req->metadata_len = 0;
|
||||||
|
req->cqe->result.u64 = 0;
|
||||||
req->cqe->status = 0;
|
req->cqe->status = 0;
|
||||||
req->cqe->sq_head = 0;
|
req->cqe->sq_head = 0;
|
||||||
req->ns = NULL;
|
req->ns = NULL;
|
||||||
|
|||||||
@@ -336,7 +336,6 @@ done:
|
|||||||
pr_debug("%s: ctrl %d qid %d nvme status %x error loc %d\n",
|
pr_debug("%s: ctrl %d qid %d nvme status %x error loc %d\n",
|
||||||
__func__, ctrl->cntlid, req->sq->qid,
|
__func__, ctrl->cntlid, req->sq->qid,
|
||||||
status, req->error_loc);
|
status, req->error_loc);
|
||||||
req->cqe->result.u64 = 0;
|
|
||||||
if (req->sq->dhchap_step != NVME_AUTH_DHCHAP_MESSAGE_SUCCESS2 &&
|
if (req->sq->dhchap_step != NVME_AUTH_DHCHAP_MESSAGE_SUCCESS2 &&
|
||||||
req->sq->dhchap_step != NVME_AUTH_DHCHAP_MESSAGE_FAILURE2) {
|
req->sq->dhchap_step != NVME_AUTH_DHCHAP_MESSAGE_FAILURE2) {
|
||||||
unsigned long auth_expire_secs = ctrl->kato ? ctrl->kato : 120;
|
unsigned long auth_expire_secs = ctrl->kato ? ctrl->kato : 120;
|
||||||
@@ -528,8 +527,6 @@ void nvmet_execute_auth_receive(struct nvmet_req *req)
|
|||||||
status = nvmet_copy_to_sgl(req, 0, d, al);
|
status = nvmet_copy_to_sgl(req, 0, d, al);
|
||||||
kfree(d);
|
kfree(d);
|
||||||
done:
|
done:
|
||||||
req->cqe->result.u64 = 0;
|
|
||||||
|
|
||||||
if (req->sq->dhchap_step == NVME_AUTH_DHCHAP_MESSAGE_SUCCESS2)
|
if (req->sq->dhchap_step == NVME_AUTH_DHCHAP_MESSAGE_SUCCESS2)
|
||||||
nvmet_auth_sq_free(req->sq);
|
nvmet_auth_sq_free(req->sq);
|
||||||
else if (req->sq->dhchap_step == NVME_AUTH_DHCHAP_MESSAGE_FAILURE1) {
|
else if (req->sq->dhchap_step == NVME_AUTH_DHCHAP_MESSAGE_FAILURE1) {
|
||||||
|
|||||||
@@ -225,9 +225,6 @@ static void nvmet_execute_admin_connect(struct nvmet_req *req)
|
|||||||
if (status)
|
if (status)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
/* zero out initial completion result, assign values as needed */
|
|
||||||
req->cqe->result.u32 = 0;
|
|
||||||
|
|
||||||
if (c->recfmt != 0) {
|
if (c->recfmt != 0) {
|
||||||
pr_warn("invalid connect version (%d).\n",
|
pr_warn("invalid connect version (%d).\n",
|
||||||
le16_to_cpu(c->recfmt));
|
le16_to_cpu(c->recfmt));
|
||||||
@@ -305,9 +302,6 @@ static void nvmet_execute_io_connect(struct nvmet_req *req)
|
|||||||
if (status)
|
if (status)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
/* zero out initial completion result, assign values as needed */
|
|
||||||
req->cqe->result.u32 = 0;
|
|
||||||
|
|
||||||
if (c->recfmt != 0) {
|
if (c->recfmt != 0) {
|
||||||
pr_warn("invalid connect version (%d).\n",
|
pr_warn("invalid connect version (%d).\n",
|
||||||
le16_to_cpu(c->recfmt));
|
le16_to_cpu(c->recfmt));
|
||||||
|
|||||||
Reference in New Issue
Block a user