Skip to contentSkip to conversation

Fix 4.4 IB merge window regressions

PATCH In review Mike Marciniszyn 3 participants 5 messages Nov 30, 2015 2 messages not in the archive InfiniBand

lore
Share & tools
lore
#0 lore raw

cover Fix 4.4 IB merge window regressions

This two patch series fixes regressions for qib and hfi1 introduced in the 4.4 merge window.

These are critical for 4.4 and for rebasing the qib/hfi1 refactoring.

---

Ira Weiny (1):
IB/qib: Fix qib_mr structure

Mike Marciniszyn (1):
IB/core: correct issue with sge copyin corrupting wr

 drivers/infiniband/core/uverbs_cmd.c  |   15 ++++++++++-----
 drivers/infiniband/hw/qib/qib_verbs.h |    2 +-
 2 files changed, 11 insertions(+), 6 deletions(-)
Signature · 5 lines
Mike
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): 20151130143326.24060.35941.stgit-K+u1se/DcYrLESAwzcoQNrvm/[email protected]

#2 lore raw

PATCH 1/2 IB/core: correct issue with sge copyin corrupting wr

Commit e622f2f4ad21 ("IB: split struct ib_send_wr") introduced a regression for HCAs whose user mode post sends go through ib_uverbs_post_send().

The code didn't account for the fact that the first sge is offset by an operation dependent length. The allocation did, but the pointer to the sge list is computed without that knowledge.

Store the operation dependent length in an automatic and compute the sge list copy in destination using that length.

---
 drivers/infiniband/core/uverbs_cmd.c |   15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)
drivers/infiniband/core/uverbs_cmd.c +10 -5
index 94816ae..4cb8e9d 100644
@@ -2446,6 +2446,7 @@ ssize_t ib_uverbs_post_send(struct ib_uverbs_file *file,
 	int                             i, sg_ind;
 	int				is_ud;
 	ssize_t                         ret = -EINVAL;
+	size_t                          next_size;
 
 	if (copy_from_user(&cmd, buf, sizeof cmd))
 		return -EFAULT;
@@ -2490,7 +2491,8 @@ ssize_t ib_uverbs_post_send(struct ib_uverbs_file *file,
 				goto out_put;
 			}
 
-			ud = alloc_wr(sizeof(*ud), user_wr->num_sge);
+			next_size = sizeof(*ud);
+			ud = alloc_wr(next_size, user_wr->num_sge);
 			if (!ud) {
 				ret = -ENOMEM;
 				goto out_put;
@@ -2511,7 +2513,8 @@ ssize_t ib_uverbs_post_send(struct ib_uverbs_file *file,
 			   user_wr->opcode == IB_WR_RDMA_READ) {
 			struct ib_rdma_wr *rdma;
 
-			rdma = alloc_wr(sizeof(*rdma), user_wr->num_sge);
+			next_size = sizeof(*rdma);
+			rdma = alloc_wr(next_size, user_wr->num_sge);
 			if (!rdma) {
 				ret = -ENOMEM;
 				goto out_put;
@@ -2525,7 +2528,8 @@ ssize_t ib_uverbs_post_send(struct ib_uverbs_file *file,
 			   user_wr->opcode == IB_WR_ATOMIC_FETCH_AND_ADD) {
 			struct ib_atomic_wr *atomic;
 
-			atomic = alloc_wr(sizeof(*atomic), user_wr->num_sge);
+			next_size = sizeof(*atomic);
+			atomic = alloc_wr(next_size, user_wr->num_sge);
 			if (!atomic) {
 				ret = -ENOMEM;
 				goto out_put;
@@ -2540,7 +2544,8 @@ ssize_t ib_uverbs_post_send(struct ib_uverbs_file *file,
 		} else if (user_wr->opcode == IB_WR_SEND ||
 			   user_wr->opcode == IB_WR_SEND_WITH_IMM ||
 			   user_wr->opcode == IB_WR_SEND_WITH_INV) {
-			next = alloc_wr(sizeof(*next), user_wr->num_sge);
+			next_size = sizeof(*next);
+			next = alloc_wr(next_size, user_wr->num_sge);
 			if (!next) {
 				ret = -ENOMEM;
 				goto out_put;
@@ -2572,7 +2577,7 @@ ssize_t ib_uverbs_post_send(struct ib_uverbs_file *file,
 
 		if (next->num_sge) {
 			next->sg_list = (void *) next +
-				ALIGN(sizeof *next, sizeof (struct ib_sge));
+				ALIGN(next_size, sizeof(struct ib_sge));
 			if (copy_from_user(next->sg_list,
 					   buf + sizeof cmd +
 					   cmd.wr_count * cmd.wqe_size +

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

#3 lore raw

PATCH 2/2 IB/qib: Fix qib_mr structure

In reply to a message not in the archive

From: Ira Weiny <[email protected]>

struct qib_mr requires the mr member be the last because struct qib_mregion contains a dynamic array at the end. The additions of members should have been placed before this structure as the comment noted.

Failure to do so was causing random memory corruption. Reproducing this bug was easy to do by running the client and server of ib_write_bw -s 8 -n 5 on the same node.

This BUG() was tripped in a slab debug kernel:

kernel BUG at mm/slab.c:2572!

Fixes 38071a461f0a ("IB/qib: Support the new memory registration API")
---
 drivers/infiniband/hw/qib/qib_verbs.h |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/infiniband/hw/qib/qib_verbs.h +1 -1
index 2baf5ad..bc803f3 100644
@@ -329,9 +329,9 @@ struct qib_sge {
 struct qib_mr {
 	struct ib_mr ibmr;
 	struct ib_umem *umem;
-	struct qib_mregion mr;  /* must be last */
 	u64 *pages;
 	u32 npages;
+	struct qib_mregion mr;  /* must be last */
 };
 
 /*

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

#4 lore raw
In reply to a message not in the archive
Quoted 5 lines · Mike Marciniszyn

This two patch series fixes regressions for qib and hfi1 introduced in the 4.4 merge window.

These are critical for 4.4 and for rebasing the qib/hfi1 refactoring.

Doug, Greg,

It should also be noted that without this change to uverbs_cmd the hfi1 driver is at least partially (ib_write_bw test) broken in staging-next.

Greg, if Linus pulls these from Doug into rc4 will you pull them into staging-next?

Ira

Quoted 6 lines

---

Ira Weiny (1):
IB/qib: Fix qib_mr structure

Quoted 14 lines

Mike Marciniszyn (1):
IB/core: correct issue with sge copyin corrupting wr

 drivers/infiniband/core/uverbs_cmd.c  |   15 ++++++++++-----
 drivers/infiniband/hw/qib/qib_verbs.h |    2 +-
 2 files changed, 11 insertions(+), 6 deletions(-)
Signature · 5 lines
Mike
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

A message that is not in the archive (sent off-list or not yet received): 20151130180519.GA9201-W4f6Xiosr+yv7QzWx2u06xL4W9x8LtSr@public.gmane.org

#6 lore raw
Quoted 7 lines · ira.weiny
Quoted 5 lines · Mike Marciniszyn

This two patch series fixes regressions for qib and hfi1 introduced in the 4.4 merge window.

These are critical for 4.4 and for rebasing the qib/hfi1 refactoring.

Quoted 7 lines

Doug, Greg,

It should also be noted that without this change to uverbs_cmd the hfi1 driver is at least partially (ib_write_bw test) broken in staging-next.

Greg, if Linus pulls these from Doug into rc4 will you pull them into staging-next?

Yes, I try to always sync up on the -rc releases.
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html