Skip to contentSkip to conversation

Address an issue with hardened user copy

PATCH In review Bob Pearson 3 participants 4 messages Aug 11, 2020 – Aug 14, 2020 InfiniBand

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Address an issue with hardened user copy

by copying to user space from the stack instead of slab cache. This affects the rdma_rxe driver causing a warning once per boot. The alternative is to ifigure out how to whitelist the xxx_qp struct but this seems simple and clean.

---
 drivers/infiniband/core/uverbs_std_types_qp.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/infiniband/core/uverbs_std_types_qp.c +4 -2
index 3bf8dcdfe7eb..2f8b14003b95 100644
@@ -98,6 +98,7 @@ static int UVERBS_HANDLER(UVERBS_METHOD_QP_CREATE)(
 	struct ib_device *device;
 	u64 user_handle;
 	int ret;
+	int qp_num;
 
 	ret = uverbs_copy_from_or_zero(&cap, attrs,
 			       UVERBS_ATTR_CREATE_QP_CAP);
@@ -293,9 +294,10 @@ static int UVERBS_HANDLER(UVERBS_METHOD_QP_CREATE)(
 	if (ret)
 		return ret;
 
+	/* copy from stack to avoid whitelisting issues */
+	qp_num = qp->qp_num;
 	ret = uverbs_copy_to(attrs, UVERBS_ATTR_CREATE_QP_RESP_QP_NUM,
-			     &qp->qp_num,
-			     sizeof(qp->qp_num));
+			     &qp_num, sizeof(qp_num));
 
 	return ret;
 err_put:
Signature · 1 line
2.25.1
#1 lore raw
Quoted 3 lines · Bob Pearson

by copying to user space from the stack instead of slab cache. This affects the rdma_rxe driver causing a warning once per boot. The alternative is to ifigure out how to whitelist the xxx_qp struct

ifigure -> figure

Quoted 1 line

but this seems simple and clean.

We have multiple cases like this in the code, what is the error exactly? And what is "hardened user copy"?

Quoted 2 lines

---

Signed-off-by is missing.

Quoted 31 lines
 drivers/infiniband/core/uverbs_std_types_qp.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/infiniband/core/uverbs_std_types_qp.c +4 -3
index 3bf8dcdfe7eb..2f8b14003b95 100644
@@ -98,6 +98,7 @@ static int UVERBS_HANDLER(UVERBS_METHOD_QP_CREATE)(
 	struct ib_device *device;
 	u64 user_handle;
 	int ret;
+	int qp_num;
 
 	ret = uverbs_copy_from_or_zero(&cap, attrs,
 			       UVERBS_ATTR_CREATE_QP_CAP);
@@ -293,9 +294,10 @@ static int UVERBS_HANDLER(UVERBS_METHOD_QP_CREATE)(
 	if (ret)
 		return ret;
 
+	/* copy from stack to avoid whitelisting issues */
+	qp_num = qp->qp_num;
 	ret = uverbs_copy_to(attrs, UVERBS_ATTR_CREATE_QP_RESP_QP_NUM,
-			     &qp->qp_num,
-			     sizeof(qp->qp_num));
+			     &qp_num, sizeof(qp_num));
 
 	return ret;
 err_put:
--

2.25.1

#2 lore raw
Quoted 5 lines · Leon Romanovsky
Quoted 3 lines · Bob Pearson

by copying to user space from the stack instead of slab cache. This affects the rdma_rxe driver causing a warning once per boot. The alternative is to ifigure out how to whitelist the xxx_qp struct

Quoted 7 lines

ifigure -> figure

Quoted 1 line

but this seems simple and clean.

We have multiple cases like this in the code, what is the error exactly? And what is "hardened user copy"?

read https://lwn.net/Articles/727322/

maintainer
#3 lore raw
In reply to Leon Romanovsky
Quoted 10 lines · Leon Romanovsky
Quoted 3 lines · Bob Pearson

by copying to user space from the stack instead of slab cache. This affects the rdma_rxe driver causing a warning once per boot. The alternative is to ifigure out how to whitelist the xxx_qp struct

ifigure -> figure

Quoted 1 line

but this seems simple and clean.

Quoted 6 lines

We have multiple cases like this in the code, what is the error exactly? And what is "hardened user copy"?

Quoted 1 line

Signed-off-by is missing.

Can't take any patches without signed-off-by

Jason