Skip to contentSkip to conversation

RDMA/cma: Initialize traffic_class to 0 for multicast path records

PATCH In review Mark Zhang 2 participants 4 messages Sep 26, 2023 – Sep 27, 2023 InfiniBand

lore
Share & tools
lore

Mark Zhang

author
#0 lore raw

PATCH 1/1 RDMA/cma: Initialize traffic_class to 0 for multicast path records

Initialize traffic_class to 0 so that it wouldn't have a random value, which causes a random IP DSCP in RoCEv2.

Fixes b5de0c60cc30 ("RDMA/cma: Fix use after free race in roce multicast join")
---
 drivers/infiniband/core/cma.c | 1 +
 1 file changed, 1 insertion(+)
drivers/infiniband/core/cma.c +1 -0
index c343edf2f664..d3a72f4b9863 100644
@@ -4990,6 +4990,7 @@ static int cma_iboe_join_multicast(struct rdma_id_private *id_priv,
 	ib.rec.rate = IB_RATE_PORT_CURRENT;
 	ib.rec.hop_limit = 1;
 	ib.rec.mtu = iboe_get_mtu(ndev->mtu);
+	ib.rec.traffic_class = 0;
 
 	if (addr->sa_family == AF_INET) {
 		if (gid_type == IB_GID_TYPE_ROCE_UDP_ENCAP) {
Signature · 1 line
2.37.1
maintainer
#1 lore raw
Quoted 2 lines · Mark Zhang

Initialize traffic_class to 0 so that it wouldn't have a random value, which causes a random IP DSCP in RoCEv2.

It will be great to see call trace which explains how. I think that ib.rec.sl has same issue.

drivers/infiniband/core/cma.c +1 -1
index c343edf2f664..1e2cd7c8716e 100644
@@ -4968,7 +4968,7 @@ static int cma_iboe_join_multicast(struct rdma_id_private *id_priv,
        int err = 0;
        struct sockaddr *addr = (struct sockaddr *)&mc->addr;
        struct net_device *ndev = NULL;
-       struct ib_sa_multicast ib;
+       struct ib_sa_multicast ib = {};
        enum ib_gid_type gid_type;
        bool send_only;
 

Thanks

Quoted 22 lines
Fixes b5de0c60cc30 ("RDMA/cma: Fix use after free race in roce multicast join")
---
 drivers/infiniband/core/cma.c | 1 +
 1 file changed, 1 insertion(+)
drivers/infiniband/core/cma.c +1 -0
index c343edf2f664..d3a72f4b9863 100644
@@ -4990,6 +4990,7 @@ static int cma_iboe_join_multicast(struct rdma_id_private *id_priv,
 	ib.rec.rate = IB_RATE_PORT_CURRENT;
 	ib.rec.hop_limit = 1;
 	ib.rec.mtu = iboe_get_mtu(ndev->mtu);
+	ib.rec.traffic_class = 0;
 
 	if (addr->sa_family == AF_INET) {
 		if (gid_type == IB_GID_TYPE_ROCE_UDP_ENCAP) {
Signature · 1 line
2.37.1
author
#2 lore raw
Quoted 6 lines · Leon Romanovsky
Quoted 2 lines · Mark Zhang

Initialize traffic_class to 0 so that it wouldn't have a random value, which causes a random IP DSCP in RoCEv2.

It will be great to see call trace which explains how. I think that ib.rec.sl has same issue.

Yes ib.rec.sl and ib.rec.flow_label should have the same issue, I just not able to reproduce as somehow they are 0 in my setups.

These fields will be used to generate the ah:
cma_iboe_join_multicast
cma_make_mc_event
ib_init_ah_from_mcmember

drivers/infiniband/core/cma.c static int cma_iboe_join_multicast(struct rdma_id_private *id_priv, · line 4973

Quoted 12 lines
drivers/infiniband/core/cma.c +1 -1
index c343edf2f664..1e2cd7c8716e 100644
@@ -4968,7 +4968,7 @@ static int cma_iboe_join_multicast(struct rdma_id_private *id_priv,
         int err = 0;
         struct sockaddr *addr = (struct sockaddr *)&mc->addr;
         struct net_device *ndev = NULL;
-       struct ib_sa_multicast ib;
+       struct ib_sa_multicast ib = {};
         enum ib_gid_type gid_type;
         bool send_only;

I think this patch is great. So what should I do now? Send this as v1, or you will do it?

Thanks

Quoted 24 lines

Thanks

Quoted 22 lines
Fixes b5de0c60cc30 ("RDMA/cma: Fix use after free race in roce multicast join")
---
  drivers/infiniband/core/cma.c | 1 +
  1 file changed, 1 insertion(+)
drivers/infiniband/core/cma.c +1 -0
index c343edf2f664..d3a72f4b9863 100644
@@ -4990,6 +4990,7 @@ static int cma_iboe_join_multicast(struct rdma_id_private *id_priv,
  	ib.rec.rate = IB_RATE_PORT_CURRENT;
  	ib.rec.hop_limit = 1;
  	ib.rec.mtu = iboe_get_mtu(ndev->mtu);
+	ib.rec.traffic_class = 0;
 
  	if (addr->sa_family == AF_INET) {
  		if (gid_type == IB_GID_TYPE_ROCE_UDP_ENCAP) {
Signature · 1 line
2.37.1
maintainer
#3 lore raw
Quoted 16 lines · Mark Zhang
Quoted 6 lines · Leon Romanovsky
Quoted 2 lines · Mark Zhang

Initialize traffic_class to 0 so that it wouldn't have a random value, which causes a random IP DSCP in RoCEv2.

It will be great to see call trace which explains how. I think that ib.rec.sl has same issue.

Yes ib.rec.sl and ib.rec.flow_label should have the same issue, I just not able to reproduce as somehow they are 0 in my setups.

These fields will be used to generate the ah:
cma_iboe_join_multicast
cma_make_mc_event
ib_init_ah_from_mcmember

Quoted 15 lines

drivers/infiniband/core/cma.c static int cma_iboe_join_multicast(struct rdma_id_private *id_priv, · line 4973

Quoted 12 lines
drivers/infiniband/core/cma.c +1 -1
index c343edf2f664..1e2cd7c8716e 100644
@@ -4968,7 +4968,7 @@ static int cma_iboe_join_multicast(struct rdma_id_private *id_priv,
         int err = 0;
         struct sockaddr *addr = (struct sockaddr *)&mc->addr;
         struct net_device *ndev = NULL;
-       struct ib_sa_multicast ib;
+       struct ib_sa_multicast ib = {};
         enum ib_gid_type gid_type;
         bool send_only;

I think this patch is great. So what should I do now? Send this as v1, or you will do it?

Send v1 with updated commit message.

Thanks

Quoted 27 lines

Thanks

Quoted 23 lines

Thanks

Quoted 21 lines
Fixes b5de0c60cc30 ("RDMA/cma: Fix use after free race in roce multicast join")
---
  drivers/infiniband/core/cma.c | 1 +
  1 file changed, 1 insertion(+)
drivers/infiniband/core/cma.c +1 -0
index c343edf2f664..d3a72f4b9863 100644
@@ -4990,6 +4990,7 @@ static int cma_iboe_join_multicast(struct rdma_id_private *id_priv,
  	ib.rec.rate = IB_RATE_PORT_CURRENT;
  	ib.rec.hop_limit = 1;
  	ib.rec.mtu = iboe_get_mtu(ndev->mtu);
+	ib.rec.traffic_class = 0;
  	if (addr->sa_family == AF_INET) {
  		if (gid_type == IB_GID_TYPE_ROCE_UDP_ENCAP) {
Signature · 1 line
2.37.1