linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH for-rc v2] RDMA/cma: Remove open coding of overflow checking for private_data_len
@ 2021-11-23 10:06 Håkon Bugge
  2021-11-25 11:35 ` Leon Romanovsky
  2021-11-25 17:37 ` Jason Gunthorpe
  0 siblings, 2 replies; 3+ messages in thread
From: Håkon Bugge @ 2021-11-23 10:06 UTC (permalink / raw)
  To: Jason Gunthorpe; +Cc: Leon Romanovsky, linux-rdma, linux-kernel

The existing tests are a little hard to comprehend. Use
check_add_overflow() instead.

Fixes: 04ded1672402 ("RDMA/cma: Verify private data length")
Signed-off-by: Håkon Bugge <haakon.bugge@oracle.com>

---

v1 -> v2:

   * Also fixed same issue in cma_resolve_ib_udp() as pointed out
     by Leon
---
 drivers/infiniband/core/cma.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/infiniband/core/cma.c b/drivers/infiniband/core/cma.c
index 835ac54..8a98aa9 100644
--- a/drivers/infiniband/core/cma.c
+++ b/drivers/infiniband/core/cma.c
@@ -4033,8 +4033,7 @@ static int cma_resolve_ib_udp(struct rdma_id_private *id_priv,
 
 	memset(&req, 0, sizeof req);
 	offset = cma_user_data_offset(id_priv);
-	req.private_data_len = offset + conn_param->private_data_len;
-	if (req.private_data_len < conn_param->private_data_len)
+	if (check_add_overflow(offset, conn_param->private_data_len, &req.private_data_len))
 		return -EINVAL;
 
 	if (req.private_data_len) {
@@ -4093,8 +4092,7 @@ static int cma_connect_ib(struct rdma_id_private *id_priv,
 
 	memset(&req, 0, sizeof req);
 	offset = cma_user_data_offset(id_priv);
-	req.private_data_len = offset + conn_param->private_data_len;
-	if (req.private_data_len < conn_param->private_data_len)
+	if (check_add_overflow(offset, conn_param->private_data_len, &req.private_data_len))
 		return -EINVAL;
 
 	if (req.private_data_len) {
-- 
1.8.3.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH for-rc v2] RDMA/cma: Remove open coding of overflow checking for private_data_len
  2021-11-23 10:06 [PATCH for-rc v2] RDMA/cma: Remove open coding of overflow checking for private_data_len Håkon Bugge
@ 2021-11-25 11:35 ` Leon Romanovsky
  2021-11-25 17:37 ` Jason Gunthorpe
  1 sibling, 0 replies; 3+ messages in thread
From: Leon Romanovsky @ 2021-11-25 11:35 UTC (permalink / raw)
  To: Håkon Bugge; +Cc: Jason Gunthorpe, linux-rdma, linux-kernel

On Tue, Nov 23, 2021 at 11:06:18AM +0100, Håkon Bugge wrote:
> The existing tests are a little hard to comprehend. Use
> check_add_overflow() instead.
> 
> Fixes: 04ded1672402 ("RDMA/cma: Verify private data length")
> Signed-off-by: Håkon Bugge <haakon.bugge@oracle.com>
> 
> ---
> 
> v1 -> v2:
> 
>    * Also fixed same issue in cma_resolve_ib_udp() as pointed out
>      by Leon
> ---
>  drivers/infiniband/core/cma.c | 6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)
> 

Thanks,
Reviewed-by: Leon Romanovsky <leonro@nvidia.com>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH for-rc v2] RDMA/cma: Remove open coding of overflow checking for private_data_len
  2021-11-23 10:06 [PATCH for-rc v2] RDMA/cma: Remove open coding of overflow checking for private_data_len Håkon Bugge
  2021-11-25 11:35 ` Leon Romanovsky
@ 2021-11-25 17:37 ` Jason Gunthorpe
  1 sibling, 0 replies; 3+ messages in thread
From: Jason Gunthorpe @ 2021-11-25 17:37 UTC (permalink / raw)
  To: Håkon Bugge; +Cc: Leon Romanovsky, linux-rdma, linux-kernel

On Tue, Nov 23, 2021 at 11:06:18AM +0100, Håkon Bugge wrote:
> The existing tests are a little hard to comprehend. Use
> check_add_overflow() instead.
> 
> Fixes: 04ded1672402 ("RDMA/cma: Verify private data length")
> Signed-off-by: Håkon Bugge <haakon.bugge@oracle.com>
> Reviewed-by: Leon Romanovsky <leonro@nvidia.com>
> ---
> 
> v1 -> v2:
> 
>    * Also fixed same issue in cma_resolve_ib_udp() as pointed out
>      by Leon
> ---
>  drivers/infiniband/core/cma.c | 6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)

Applied to for-next, thanks

Jason

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-11-25 17:39 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-23 10:06 [PATCH for-rc v2] RDMA/cma: Remove open coding of overflow checking for private_data_len Håkon Bugge
2021-11-25 11:35 ` Leon Romanovsky
2021-11-25 17:37 ` Jason Gunthorpe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).