From: Leon Romanovsky <leon@kernel.org>
To: Dan Carpenter <dan.carpenter@oracle.com>
Cc: Jason Gunthorpe <jgg@ziepe.ca>,
Aharon Landau <aharonl@nvidia.com>,
Mark Zhang <markzhang@nvidia.com>,
Neta Ostrovsky <netao@nvidia.com>,
Gal Pressman <galpress@amazon.com>,
linux-rdma@vger.kernel.org, kernel-janitors@vger.kernel.org
Subject: Re: [PATCH] RDMA/nldev: prevent underflow in nldev_stat_set_counter_dynamic_doit()
Date: Wed, 16 Mar 2022 11:08:20 +0200 [thread overview]
Message-ID: <YjGpBOCMPOwMBwgg@unreal> (raw)
In-Reply-To: <20220316083948.GC30941@kili>
On Wed, Mar 16, 2022 at 11:39:48AM +0300, Dan Carpenter wrote:
> This code checks "index" for an upper bound but it does not check for
> negatives. Change the type to unsigned to prevent underflows.
>
> Fixes: 3c3c1f141639 ("RDMA/nldev: Allow optional-counter status configuration through RDMA netlink")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> ---
> Could we not use a nldev_policy[] to tighten the bounds checking even
> more?
We are doing it, when calling to nlmsg_parse() at the beginning of nldev_stat_set_doit().
The entry_attr, which used as input to index, is tb[RDMA_NLDEV_ATTR_STAT_HWCOUNTER_INDEX].
However it is not enough and we still need your change, because input
can be large enough to be casted to negative value.
Thanks,
Reviewed-by: Leon Romanovsky <leonro@nvidia.com>
next prev parent reply other threads:[~2022-03-16 9:09 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-16 8:39 [PATCH] RDMA/nldev: prevent underflow in nldev_stat_set_counter_dynamic_doit() Dan Carpenter
2022-03-16 9:08 ` Leon Romanovsky [this message]
2022-03-18 18:46 ` Jason Gunthorpe
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=YjGpBOCMPOwMBwgg@unreal \
--to=leon@kernel.org \
--cc=aharonl@nvidia.com \
--cc=dan.carpenter@oracle.com \
--cc=galpress@amazon.com \
--cc=jgg@ziepe.ca \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-rdma@vger.kernel.org \
--cc=markzhang@nvidia.com \
--cc=netao@nvidia.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.