From: Leon Romanovsky <leon@kernel.org>
To: "Håkon Bugge" <haakon.bugge@oracle.com>
Cc: Doug Ledford <dledford@redhat.com>,
Jason Gunthorpe <jgg@ziepe.ca>,
linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH for-rc] RDMA/cma: Remove open coding for overflow in cma_connect_ib
Date: Tue, 23 Nov 2021 11:11:51 +0200 [thread overview]
Message-ID: <YZywV4lRV7g4Bj87@unreal> (raw)
In-Reply-To: <1637599733-11096-1-git-send-email-haakon.bugge@oracle.com>
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
>
next prev parent reply other threads:[~2021-11-23 9:11 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
2021-11-23 9:50 ` Haakon Bugge
2021-11-23 10:01 ` Haakon Bugge
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=YZywV4lRV7g4Bj87@unreal \
--to=leon@kernel.org \
--cc=dledford@redhat.com \
--cc=haakon.bugge@oracle.com \
--cc=jgg@ziepe.ca \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rdma@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox