From: Leon Romanovsky <leon@kernel.org>
To: Jason Gunthorpe <jgg@ziepe.ca>
Cc: Dan Carpenter <dan.carpenter@oracle.com>,
Yishai Hadas <yishaih@mellanox.com>,
Doug Ledford <dledford@redhat.com>,
linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org,
kernel-janitors@vger.kernel.org
Subject: Re: [PATCH] IB/mlx4: prevent undefined shift in set_user_sq_size()
Date: Mon, 10 Jun 2019 14:08:58 +0000 [thread overview]
Message-ID: <20190610140858.GA6369@mtr-leonro.mtl.com> (raw)
In-Reply-To: <20190610132849.GD18468@ziepe.ca>
On Mon, Jun 10, 2019 at 10:28:49AM -0300, Jason Gunthorpe wrote:
> On Sat, Jun 08, 2019 at 12:22:31PM +0300, Dan Carpenter wrote:
> > The ucmd->log_sq_bb_count is a u8 that comes from the user. If it's
> > larger than the number of bits in an int then that's undefined behavior.
> > It turns out this doesn't really cause an issue at runtime but it's
> > still nice to clean it up.
> >
> > Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> > ---
> > drivers/infiniband/hw/mlx4/qp.c | 3 ++-
> > 1 file changed, 2 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/infiniband/hw/mlx4/qp.c b/drivers/infiniband/hw/mlx4/qp.c
> > index 5221c0794d1d..9f6eb23e8044 100644
> > --- a/drivers/infiniband/hw/mlx4/qp.c
> > +++ b/drivers/infiniband/hw/mlx4/qp.c
> > @@ -439,7 +439,8 @@ static int set_user_sq_size(struct mlx4_ib_dev *dev,
> > struct mlx4_ib_create_qp *ucmd)
> > {
> > /* Sanity check SQ size before proceeding */
> > - if ((1 << ucmd->log_sq_bb_count) > dev->dev->caps.max_wqes ||
> > + if (ucmd->log_sq_bb_count > 31 ||
> > + (1 << ucmd->log_sq_bb_count) > dev->dev->caps.max_wqes ||
>
> Surely this should use check_shl_overflow() ?
Yes
>
> Jason
WARNING: multiple messages have this Message-ID (diff)
From: Leon Romanovsky <leon@kernel.org>
To: Jason Gunthorpe <jgg@ziepe.ca>
Cc: Dan Carpenter <dan.carpenter@oracle.com>,
Yishai Hadas <yishaih@mellanox.com>,
Doug Ledford <dledford@redhat.com>,
linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org,
kernel-janitors@vger.kernel.org
Subject: Re: [PATCH] IB/mlx4: prevent undefined shift in set_user_sq_size()
Date: Mon, 10 Jun 2019 17:08:58 +0300 [thread overview]
Message-ID: <20190610140858.GA6369@mtr-leonro.mtl.com> (raw)
In-Reply-To: <20190610132849.GD18468@ziepe.ca>
On Mon, Jun 10, 2019 at 10:28:49AM -0300, Jason Gunthorpe wrote:
> On Sat, Jun 08, 2019 at 12:22:31PM +0300, Dan Carpenter wrote:
> > The ucmd->log_sq_bb_count is a u8 that comes from the user. If it's
> > larger than the number of bits in an int then that's undefined behavior.
> > It turns out this doesn't really cause an issue at runtime but it's
> > still nice to clean it up.
> >
> > Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> > ---
> > drivers/infiniband/hw/mlx4/qp.c | 3 ++-
> > 1 file changed, 2 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/infiniband/hw/mlx4/qp.c b/drivers/infiniband/hw/mlx4/qp.c
> > index 5221c0794d1d..9f6eb23e8044 100644
> > --- a/drivers/infiniband/hw/mlx4/qp.c
> > +++ b/drivers/infiniband/hw/mlx4/qp.c
> > @@ -439,7 +439,8 @@ static int set_user_sq_size(struct mlx4_ib_dev *dev,
> > struct mlx4_ib_create_qp *ucmd)
> > {
> > /* Sanity check SQ size before proceeding */
> > - if ((1 << ucmd->log_sq_bb_count) > dev->dev->caps.max_wqes ||
> > + if (ucmd->log_sq_bb_count > 31 ||
> > + (1 << ucmd->log_sq_bb_count) > dev->dev->caps.max_wqes ||
>
> Surely this should use check_shl_overflow() ?
Yes
>
> Jason
next prev parent reply other threads:[~2019-06-10 14:08 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-06-08 9:22 [PATCH] IB/mlx4: prevent undefined shift in set_user_sq_size() Dan Carpenter
2019-06-08 9:22 ` Dan Carpenter
2019-06-10 13:28 ` Jason Gunthorpe
2019-06-10 13:28 ` Jason Gunthorpe
2019-06-10 14:08 ` Leon Romanovsky [this message]
2019-06-10 14:08 ` Leon Romanovsky
2019-06-11 10:07 ` Dan Carpenter
2019-06-11 10:07 ` Dan Carpenter
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=20190610140858.GA6369@mtr-leonro.mtl.com \
--to=leon@kernel.org \
--cc=dan.carpenter@oracle.com \
--cc=dledford@redhat.com \
--cc=jgg@ziepe.ca \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rdma@vger.kernel.org \
--cc=yishaih@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 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.