RDMA/cma: Remove open coding of overflow checking for private_data_len
PATCH v2 1/1 RDMA/cma: Remove open coding of overflow checking for private_data_len
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 <[email protected]>
---
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(-)
drivers/infiniband/core/cma.c +2 -4
@@ -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) {
Signature · 1 line
1.8.3.1
Quoted 8 lines · Håkon Bugge
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 <[email protected]>---
Quoted 8 lines
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 <[email protected]>
Quoted 8 lines · Håkon Bugge
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 <[email protected]>Reviewed-by Leon Romanovsky <[email protected]>---
Quoted 7 lines
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