Skip to contentSkip to conversation

IB/mlx5: Fix leaking stack memory to userspace

PATCH New Alessio Balsini 2 participants 6 messages Aug 12, 2019 – Aug 13, 2019 Stable branch

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 IB/mlx5: Fix leaking stack memory to userspace

From: Jason Gunthorpe <[email protected]>

mlx5_ib_create_qp_resp was never initialized and only the first 4 bytes were written.

Fixes 41d902cb7c32 ("RDMA/mlx5: Fix definition of mlx5_ib_create_qp_resp")
---
 drivers/infiniband/hw/mlx5/qp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/infiniband/hw/mlx5/qp.c +1 -1
index 5edb09e674a6..82c4e29c1213 100644
@@ -811,7 +811,7 @@ static int create_qp_common(struct mlx5_ib_dev *dev, struct ib_pd *pd,
 			    struct ib_udata *udata, struct mlx5_ib_qp *qp)
 {
 	struct mlx5_ib_resources *devr = &dev->devr;
-	struct mlx5_ib_create_qp_resp resp;
+	struct mlx5_ib_create_qp_resp resp = {};
 	struct mlx5_create_qp_mbox_in *in;
 	struct mlx5_general_caps *gen;
 	struct mlx5_ib_create_qp ucmd;
Signature · 1 line
2.23.0.rc1.153.gdeed80330f-goog
#1 lore raw

PATCH 1/1 IB/mlx5: Fix leaking stack memory to userspace

From: Jason Gunthorpe <[email protected]>

mlx5_ib_create_qp_resp was never initialized and only the first 4 bytes were written.

Fixes 41d902cb7c32 ("RDMA/mlx5: Fix definition of mlx5_ib_create_qp_resp")
---
 drivers/infiniband/hw/mlx5/qp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/infiniband/hw/mlx5/qp.c +1 -1
index 43d277a931c2..c035abfe8c55 100644
@@ -865,7 +865,7 @@ static int create_qp_common(struct mlx5_ib_dev *dev, struct ib_pd *pd,
 {
 	struct mlx5_ib_resources *devr = &dev->devr;
 	struct mlx5_core_dev *mdev = dev->mdev;
-	struct mlx5_ib_create_qp_resp resp;
+	struct mlx5_ib_create_qp_resp resp = {};
 	struct mlx5_create_qp_mbox_in *in;
 	struct mlx5_ib_create_qp ucmd;
 	int inlen = sizeof(*in);
Signature · 1 line
2.23.0.rc1.153.gdeed80330f-goog
#2 lore raw

PATCH 1/1 IB/mlx5: Fix leaking stack memory to userspace

From: Jason Gunthorpe <[email protected]>

commit 0625b4ba1a5d4703c7fb01c497bd6c156908af00 upstream.

mlx5_ib_create_qp_resp was never initialized and only the first 4 bytes were written.

Fixes 41d902cb7c32 ("RDMA/mlx5: Fix definition of mlx5_ib_create_qp_resp")
---
 drivers/infiniband/hw/mlx5/qp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/infiniband/hw/mlx5/qp.c +1 -1
index a7bc89f5dae7..89357d9e489d 100644
@@ -1515,7 +1515,7 @@ static int create_qp_common(struct mlx5_ib_dev *dev, struct ib_pd *pd,
 	struct mlx5_ib_resources *devr = &dev->devr;
 	int inlen = MLX5_ST_SZ_BYTES(create_qp_in);
 	struct mlx5_core_dev *mdev = dev->mdev;
-	struct mlx5_ib_create_qp_resp resp;
+	struct mlx5_ib_create_qp_resp resp = {};
 	struct mlx5_ib_cq *send_cq;
 	struct mlx5_ib_cq *recv_cq;
 	unsigned long flags;
Signature · 1 line
2.23.0.rc1.153.gdeed80330f-goog
maintainer
#3 lore raw
Quoted 8 lines · Alessio Balsini

From: Jason Gunthorpe <[email protected]>

commit 0625b4ba1a5d4703c7fb01c497bd6c156908af00 upstream.

mlx5_ib_create_qp_resp was never initialized and only the first 4 bytes were written.

Fixes 41d902cb7c32 ("RDMA/mlx5: Fix definition of mlx5_ib_create_qp_resp")

This commit only showed up in the following kernel releases:

	4.17 4.18.7 4.19

so why is this "fix" commit needed in anything older than 4.17?

That's why I did not backport it to older kernels, as I do not think it is needed there. Do you?

thanks,

greg k-h

#4 lore raw

Oops, you are totally right, I was still looking at the latest mlx5_ib_create_qp_resp struct while backporting these patches :)

Sorry for that,
Alessio

Quoted 21 lines · Greg KH
Quoted 8 lines · Alessio Balsini

From: Jason Gunthorpe <[email protected]>

commit 0625b4ba1a5d4703c7fb01c497bd6c156908af00 upstream.

mlx5_ib_create_qp_resp was never initialized and only the first 4 bytes were written.

Fixes 41d902cb7c32 ("RDMA/mlx5: Fix definition of mlx5_ib_create_qp_resp")

This commit only showed up in the following kernel releases:

	4.17 4.18.7 4.19

so why is this "fix" commit needed in anything older than 4.17?

That's why I did not backport it to older kernels, as I do not think it is needed there. Do you?

thanks,

greg k-h

maintainer
#5 lore raw
Quoted 4 lines · Alessio Balsini

Oops, you are totally right, I was still looking at the latest mlx5_ib_create_qp_resp struct while backporting these patches :)

Sorry for that,

Not a problem, it's good to have a second pair of eyes on these things :)

greg k-h