diff mbox series

[rdma-next,v1] RDMA/cma: Initialize ib_sa_multicast structure to 0 when join

Message ID 20230927090511.603595-1-markzhang@nvidia.com (mailing list archive)
State Accepted
Headers show
Series [rdma-next,v1] RDMA/cma: Initialize ib_sa_multicast structure to 0 when join | expand

Commit Message

Mark Zhang Sept. 27, 2023, 9:05 a.m. UTC
Initialize the structure to 0 so that it's fields won't have random
values. For example fields like rec.traffic_class (as well as
rec.flow_label and rec.sl) is used to generate the user AH through:
  cma_iboe_join_multicast
    cma_make_mc_event
      ib_init_ah_from_mcmember

And a random traffic_class causes a random IP DSCP in RoCEv2.

Fixes: b5de0c60cc30 ("RDMA/cma: Fix use after free race in roce multicast join")
Signed-off-by: Mark Zhang <markzhang@nvidia.com>
---
Changelog:
v1:
 * Initialize the ib_sa_multicast structure instead of the rec.traffic_class field only
v0: https://lore.kernel.org/all/20230926072541.564177-1-markzhang@nvidia.com/
---
 drivers/infiniband/core/cma.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Leon Romanovsky Oct. 2, 2023, 8:53 a.m. UTC | #1
On Wed, 27 Sep 2023 12:05:11 +0300, Mark Zhang wrote:
> Initialize the structure to 0 so that it's fields won't have random
> values. For example fields like rec.traffic_class (as well as
> rec.flow_label and rec.sl) is used to generate the user AH through:
>   cma_iboe_join_multicast
>     cma_make_mc_event
>       ib_init_ah_from_mcmember
> 
> [...]

Applied, thanks!

[1/1] RDMA/cma: Initialize ib_sa_multicast structure to 0 when join
      https://git.kernel.org/rdma/rdma/c/76ad7aca17e88e

Best regards,
diff mbox series

Patch

diff --git a/drivers/infiniband/core/cma.c b/drivers/infiniband/core/cma.c
index c343edf2f664..1e2cd7c8716e 100644
--- a/drivers/infiniband/core/cma.c
+++ b/drivers/infiniband/core/cma.c
@@ -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;