linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH for-rc] RDMA/cma: Remove open coding for overflow in cma_connect_ib
@ 2021-11-22 16:48 Håkon Bugge
  2021-11-23  9:11 ` Leon Romanovsky
  0 siblings, 1 reply; 4+ messages in thread
From: Håkon Bugge @ 2021-11-22 16:48 UTC (permalink / raw)
  To: Doug Ledford, Jason Gunthorpe; +Cc: Leon Romanovsky, linux-rdma, linux-kernel

The existing test is 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>
---
 drivers/infiniband/core/cma.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/infiniband/core/cma.c b/drivers/infiniband/core/cma.c
index 835ac54..0435768 100644
--- a/drivers/infiniband/core/cma.c
+++ b/drivers/infiniband/core/cma.c
@@ -4093,8 +4093,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] 4+ messages in thread

* Re: [PATCH for-rc] RDMA/cma: Remove open coding for overflow in cma_connect_ib
  2021-11-22 16:48 [PATCH for-rc] RDMA/cma: Remove open coding for overflow in cma_connect_ib Håkon Bugge
@ 2021-11-23  9:11 ` Leon Romanovsky
  2021-11-23  9:50   ` Haakon Bugge
  0 siblings, 1 reply; 4+ messages in thread
From: Leon Romanovsky @ 2021-11-23  9:11 UTC (permalink / raw)
  To: Håkon Bugge; +Cc: Doug Ledford, Jason Gunthorpe, linux-rdma, linux-kernel

On Mon, Nov 22, 2021 at 05:48:53PM +0100, Håkon Bugge wrote:
> The existing test is 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>
> ---
>  drivers/infiniband/core/cma.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/drivers/infiniband/core/cma.c b/drivers/infiniband/core/cma.c
> index 835ac54..0435768 100644
> --- a/drivers/infiniband/core/cma.c
> +++ b/drivers/infiniband/core/cma.c
> @@ -4093,8 +4093,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;

The same check exists in cma_resolve_ib_udp too.

Thanks

>  
>  	if (req.private_data_len) {
> -- 
> 1.8.3.1
> 

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

* Re: [PATCH for-rc] RDMA/cma: Remove open coding for overflow in cma_connect_ib
  2021-11-23  9:11 ` Leon Romanovsky
@ 2021-11-23  9:50   ` Haakon Bugge
  2021-11-23 10:01     ` Haakon Bugge
  0 siblings, 1 reply; 4+ messages in thread
From: Haakon Bugge @ 2021-11-23  9:50 UTC (permalink / raw)
  To: Leon Romanovsky
  Cc: Doug Ledford, Jason Gunthorpe, OFED mailing list, linux-kernel



> On 23 Nov 2021, at 10:11, Leon Romanovsky <leon@kernel.org> wrote:
> 
> On Mon, Nov 22, 2021 at 05:48:53PM +0100, Håkon Bugge wrote:
>> The existing test is 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>
>> ---
>> drivers/infiniband/core/cma.c | 3 +--
>> 1 file changed, 1 insertion(+), 2 deletions(-)
>> 
>> diff --git a/drivers/infiniband/core/cma.c b/drivers/infiniband/core/cma.c
>> index 835ac54..0435768 100644
>> --- a/drivers/infiniband/core/cma.c
>> +++ b/drivers/infiniband/core/cma.c
>> @@ -4093,8 +4093,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;
> 
> The same check exists in cma_resolve_ib_udp too.

Thanks for pointing it out Leon. Will send a v2.


Thxs, Håkon

> 
> Thanks
> 
>> 
>> 	if (req.private_data_len) {
>> -- 
>> 1.8.3.1


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

* Re: [PATCH for-rc] RDMA/cma: Remove open coding for overflow in cma_connect_ib
  2021-11-23  9:50   ` Haakon Bugge
@ 2021-11-23 10:01     ` Haakon Bugge
  0 siblings, 0 replies; 4+ messages in thread
From: Haakon Bugge @ 2021-11-23 10:01 UTC (permalink / raw)
  To: Leon Romanovsky; +Cc: Jason Gunthorpe, OFED mailing list, linux-kernel



> On 23 Nov 2021, at 10:50, Haakon Bugge <haakon.bugge@oracle.com> wrote:
> 
> 
> 
>> On 23 Nov 2021, at 10:11, Leon Romanovsky <leon@kernel.org> wrote:
>> 
>> On Mon, Nov 22, 2021 at 05:48:53PM +0100, Håkon Bugge wrote:
>>> The existing test is 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>
>>> ---
>>> drivers/infiniband/core/cma.c | 3 +--
>>> 1 file changed, 1 insertion(+), 2 deletions(-)
>>> 
>>> diff --git a/drivers/infiniband/core/cma.c b/drivers/infiniband/core/cma.c
>>> index 835ac54..0435768 100644
>>> --- a/drivers/infiniband/core/cma.c
>>> +++ b/drivers/infiniband/core/cma.c
>>> @@ -4093,8 +4093,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;
>> 
>> The same check exists in cma_resolve_ib_udp too.
> 
> Thanks for pointing it out Leon. Will send a v2.

Be aware, will change $Subject slightly.


Håkon

> 
> 
> Thxs, Håkon
> 
>> 
>> Thanks
>> 
>>> 
>>> 	if (req.private_data_len) {
>>> -- 
>>> 1.8.3.1


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

end of thread, other threads:[~2021-11-23 10:02 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-22 16:48 [PATCH for-rc] RDMA/cma: Remove open coding for overflow in cma_connect_ib Håkon Bugge
2021-11-23  9:11 ` Leon Romanovsky
2021-11-23  9:50   ` Haakon Bugge
2021-11-23 10:01     ` Haakon Bugge

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).