Skip to contentSkip to conversation

infiniband: Fix uninit-value in ucma_connect()

PATCH New Peilin Ye 2 participants 4 messages Jul 25, 2020 – Jul 27, 2020 InfiniBand

lore
Share & tools
lore

Peilin Ye

author
#0 lore raw

PATCH 1/1 infiniband: Fix uninit-value in ucma_connect()

ucma_connect() is reading uninitialized memory when in_len is less than offsetof(struct rdma_ucm_connect, ece). Fix it.

---
 drivers/infiniband/core/ucma.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/infiniband/core/ucma.c +1 -1
index 5b87eee8ccc8..a591fdccdce0 100644
@@ -1079,7 +1079,7 @@ static ssize_t ucma_connect(struct ucma_file *file, const char __user *inbuf,
 {
 	struct rdma_conn_param conn_param;
 	struct rdma_ucm_ece ece = {};
-	struct rdma_ucm_connect cmd;
+	struct rdma_ucm_connect cmd = {};
 	struct ucma_context *ctx;
 	size_t in_size;
 	int ret;
Signature · 1 line
2.25.1
author
#1 lore raw

PATCH 1/1 infiniband: Prevent uninit-value in ucma_accept()

ucma_accept() is reading uninitialized memory when in_len is less than offsetof(struct rdma_ucm_accept, ece). Fix it.

---
 drivers/infiniband/core/ucma.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/infiniband/core/ucma.c +1 -1
index a591fdccdce0..842d297903c0 100644
@@ -1134,7 +1134,7 @@ static ssize_t ucma_listen(struct ucma_file *file, const char __user *inbuf,
 static ssize_t ucma_accept(struct ucma_file *file, const char __user *inbuf,
 			   int in_len, int out_len)
 {
-	struct rdma_ucm_accept cmd;
+	struct rdma_ucm_accept cmd = {};
 	struct rdma_conn_param conn_param;
 	struct rdma_ucm_ece ece = {};
 	struct ucma_context *ctx;
Signature · 6 lines
2.25.1

_______________________________________________
Linux-kernel-mentees mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees
author
#2 lore raw

PATCH v2 1/1 infiniband: Prevent uninit-value in ucma_accept()

ucma_accept() is reading uninitialized memory when in_len is less than offsetof(struct rdma_ucm_accept, ece). Fix it.

---
Change in v2:
- syzbot has reported this bug as "KMSAN: uninit-value in xa_load". Add "Reported-and-tested-by:" and "Link:" tags for it.

 drivers/infiniband/core/ucma.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/infiniband/core/ucma.c +1 -1
index a591fdccdce0..842d297903c0 100644
@@ -1134,7 +1134,7 @@ static ssize_t ucma_listen(struct ucma_file *file, const char __user *inbuf,
 static ssize_t ucma_accept(struct ucma_file *file, const char __user *inbuf,
 			   int in_len, int out_len)
 {
-	struct rdma_ucm_accept cmd;
+	struct rdma_ucm_accept cmd = {};
 	struct rdma_conn_param conn_param;
 	struct rdma_ucm_ece ece = {};
 	struct ucma_context *ctx;
Signature · 1 line
2.25.1
#3 lore raw

Re: [Linux-kernel-mentees] [PATCH v2] infiniband: Prevent uninit-value in ucma_accept()

Quoted 6 lines · Peilin Ye

ucma_accept() is reading uninitialized memory when in_len is less than offsetof(struct rdma_ucm_accept, ece). Fix it.

Quoted 7 lines

---
Change in v2:
- syzbot has reported this bug as "KMSAN: uninit-value in xa_load". Add "Reported-and-tested-by:" and "Link:" tags for it.

 drivers/infiniband/core/ucma.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Already fixed:

https://lore.kernel.org/r/[email protected]

Jason