From: Leon Romanovsky <leon@kernel.org>
To: Saeed Mahameed <saeedm@mellanox.com>
Cc: "davem@davemloft.net" <davem@davemloft.net>,
Jason Gunthorpe <jgg@mellanox.com>,
Yamin Friedman <yaminf@mellanox.com>,
"linux-rdma@vger.kernel.org" <linux-rdma@vger.kernel.org>,
Tal Gilboa <talgi@mellanox.com>,
"dledford@redhat.com" <dledford@redhat.com>,
"netdev@vger.kernel.org" <netdev@vger.kernel.org>
Subject: Re: [PATCH net 1/2] linux/dim: Fix overflow in dim calculation
Date: Tue, 23 Jul 2019 21:04:36 +0300 [thread overview]
Message-ID: <20190723180436.GT5125@mtr-leonro.mtl.com> (raw)
In-Reply-To: <4f4bc2958dc1512087f19db64e8e43f1247cf2dd.camel@mellanox.com>
On Tue, Jul 23, 2019 at 05:22:43PM +0000, Saeed Mahameed wrote:
> On Tue, 2019-07-23 at 10:22 +0300, Leon Romanovsky wrote:
> > From: Yamin Friedman <yaminf@mellanox.com>
> >
> > While using net_dim, a dim_sample was used without ever initializing
> > the
> > comps value. Added use of DIV_ROUND_DOWN_ULL() to prevent potential
> > overflow, it should not be a problem to save the final result in an
> > int
> > because after the division by epms the value should not be larger
> > than a
> > few thousand.
> >
> > [ 1040.127124] UBSAN: Undefined behaviour in lib/dim/dim.c:78:23
> > [ 1040.130118] signed integer overflow:
> > [ 1040.131643] 134718714 * 100 cannot be represented in type 'int'
> >
> > Fixes: 398c2b05bbee ("linux/dim: Add completions count to
> > dim_sample")
> > Signed-off-by: Yamin Friedman <yaminf@mellanox.com>
> > Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
> > ---
> > drivers/net/ethernet/broadcom/bcmsysport.c | 2 +-
> > drivers/net/ethernet/broadcom/bnxt/bnxt.c | 2 +-
> > drivers/net/ethernet/broadcom/genet/bcmgenet.c | 2 +-
> > drivers/net/ethernet/mellanox/mlx5/core/en_txrx.c | 4 ++--
> > lib/dim/dim.c | 4 ++--
> > 5 files changed, 7 insertions(+), 7 deletions(-)
> >
> > diff --git a/drivers/net/ethernet/broadcom/bcmsysport.c
> > b/drivers/net/ethernet/broadcom/bcmsysport.c
> > index b9c5cea8db16..9483553ce444 100644
> > --- a/drivers/net/ethernet/broadcom/bcmsysport.c
> > +++ b/drivers/net/ethernet/broadcom/bcmsysport.c
> > @@ -992,7 +992,7 @@ static int bcm_sysport_poll(struct napi_struct
> > *napi, int budget)
> > {
> > struct bcm_sysport_priv *priv =
> > container_of(napi, struct bcm_sysport_priv, napi);
> > - struct dim_sample dim_sample;
> > + struct dim_sample dim_sample = {};
>
> net_dim implementation doesn't care about sample->comp_ctr, so this is
> unnecessary for the sake of fixing the rdma overflow issue, but it
> doens't hurt anyone to have this change in this patch.
Yes, this is why we decided to change all drivers and not mlx5 only.
Thanks
next prev parent reply other threads:[~2019-07-23 18:04 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-07-23 7:22 [PATCH net 0/2] DIM fixes for 5.3 Leon Romanovsky
2019-07-23 7:22 ` [PATCH net 1/2] linux/dim: Fix overflow in dim calculation Leon Romanovsky
2019-07-23 17:22 ` Saeed Mahameed
2019-07-23 18:04 ` Leon Romanovsky [this message]
2019-07-23 7:22 ` [PATCH net 2/2] lib/dim: Fix -Wunused-const-variable warnings Leon Romanovsky
2019-07-23 15:57 ` Bart Van Assche
2019-07-23 17:05 ` Saeed Mahameed
2019-07-23 18:01 ` Leon Romanovsky
2019-07-25 18:34 ` [PATCH net 0/2] DIM fixes for 5.3 David Miller
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=20190723180436.GT5125@mtr-leonro.mtl.com \
--to=leon@kernel.org \
--cc=davem@davemloft.net \
--cc=dledford@redhat.com \
--cc=jgg@mellanox.com \
--cc=linux-rdma@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=saeedm@mellanox.com \
--cc=talgi@mellanox.com \
--cc=yaminf@mellanox.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 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).