Skip to contentSkip to conversation

RDMA/nes: do not leak uninitialized resp.reserved to userspace Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit

PATCH In review Colin King 3 participants 4 messages Sep 4, 2017 – Sep 5, 2017

Subsystems (3)
lore
Share & tools
lore

Colin King

author
#0 lore raw

PATCH v2 1/1 RDMA/nes: do not leak uninitialized resp.reserved to userspace Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit

From: Colin Ian King <[email protected]>

resp.reserved has not been initialized and so the copy_to_user (via ib_copy_to_udata) is copying uninitialized data from the stack back to user space which is a potential information leak. Fix this by initializing all of resp to zero.

V2: Initialize all of the struct rather than just resp.reserved as suggested by Leon Romanovsky.

---
 drivers/infiniband/hw/nes/nes_verbs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/infiniband/hw/nes/nes_verbs.c +1 -1
index f0dc5f4aa177..8998d11449c0 100644
@@ -1437,7 +1437,7 @@ static struct ib_cq *nes_create_cq(struct ib_device *ibdev,
 	struct nes_hw_cqp_wqe *cqp_wqe;
 	struct nes_pbl *nespbl = NULL;
 	struct nes_create_cq_req req;
-	struct nes_create_cq_resp resp;
+	struct nes_create_cq_resp resp = { 0 };
 	u32 cq_num = 0;
 	u32 opcode = 0;
 	u32 pbl_entries = 1;
Signature · 1 line
2.14.1
Reviewed-by on v2 1/1
#1 lore raw
Quoted 9 lines · Colin King

From: Colin Ian King <[email protected]>

resp.reserved has not been initialized and so the copy_to_user (via ib_copy_to_udata) is copying uninitialized data from the stack back to user space which is a potential information leak. Fix this by initializing all of resp to zero.

V2: Initialize all of the struct rather than just resp.reserved as suggested by Leon Romanovsky.

Small nitpick, it is better to put changelog under "---" marker, so it won't be visible in the git log.

Thanks

#2 lore raw
In reply to Colin King
Quoted 6 lines · Colin King

From: Colin Ian King <[email protected]>

resp.reserved has not been initialized and so the copy_to_user (via ib_copy_to_udata) is copying uninitialized data from the stack back to user space which is a potential information leak. Fix this by initializing all of resp to zero.

Reserved field is not copied as the length of reserved is subtracted from the size of resp and passed to ib_copy_to_udata.

if (ib_copy_to_udata(udata, &resp, sizeof resp - sizeof resp.reserved)) {

This patch is not necessary.

Chien

#3 lore raw
Quoted 8 lines · Chien Tin Tung
Quoted 6 lines · Colin King

From: Colin Ian King <[email protected]>

resp.reserved has not been initialized and so the copy_to_user (via ib_copy_to_udata) is copying uninitialized data from the stack back to user space which is a potential information leak. Fix this by initializing all of resp to zero.

Quoted 7 lines

Reserved field is not copied as the length of reserved is subtracted from the size of resp and passed to ib_copy_to_udata.

if (ib_copy_to_udata(udata, &resp, sizeof resp - sizeof resp.reserved)) {

This patch is not necessary.

Apologies, I completely overlooked that.

Quoted 7 lines

Chien
--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html