DPDK patches and discussions
 help / color / mirror / Atom feed
From: Ajit Khaparde <ajit.khaparde@broadcom.com>
To: Somnath Kotur <somnath.kotur@broadcom.com>
Cc: Stephen Hemminger <stephen@networkplumber.org>, dev <dev@dpdk.org>
Subject: Re: [dpdk-dev] [PATCH] net/bnxt: fix undefined shift in vers_get
Date: Tue, 2 Nov 2021 21:14:33 -0700	[thread overview]
Message-ID: <CACZ4nhuEi=OKy5SX-BZnY2Sa4xA3zvdm_RUyqQTfLJJOzxYn2A@mail.gmail.com> (raw)
In-Reply-To: <CACZ4nhvgiwKovZQoPSpV1q0qS7XUieY4U1eZmXoF3pLVfLcRTQ@mail.gmail.com>

On Tue, Nov 2, 2021 at 9:13 PM Ajit Khaparde <ajit.khaparde@broadcom.com> wrote:
>
> On Tue, Nov 2, 2021 at 7:18 PM Somnath Kotur <somnath.kotur@broadcom.com> wrote:
> >
> >
> >
> > On Wed, 3 Nov 2021, 02:57 Stephen Hemminger, <stephen@networkplumber.org> wrote:
> >>
> >> UBSan testing revealed undefined shift here.
> >>
> >> The firmware returns the version in bytes; and shifting a 8 bit
> >> quantity here can lead to undefined behaviour or truncation.
> >> The fix is to promote the bytes to 32 bit before shifting.
> >>
> >> Bugzilla ID: 838
> >> Fixes: 9a891c1764ea ("net/bnxt: update HWRM to version 1.9.2")
> >> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
> >> ---
> >>  drivers/net/bnxt/bnxt_hwrm.c | 6 +++---
> >>  1 file changed, 3 insertions(+), 3 deletions(-)
> >>
> >> diff --git a/drivers/net/bnxt/bnxt_hwrm.c b/drivers/net/bnxt/bnxt_hwrm.c
> >> index 82e89b7c8af7..f3d46bafd265 100644
> >> --- a/drivers/net/bnxt/bnxt_hwrm.c
> >> +++ b/drivers/net/bnxt/bnxt_hwrm.c
> >> @@ -1260,9 +1260,9 @@ int bnxt_hwrm_ver_get(struct bnxt *bp, uint32_t timeout)
> >>                 resp->hwrm_intf_upd_8b, resp->hwrm_fw_maj_8b,
> >>                 resp->hwrm_fw_min_8b, resp->hwrm_fw_bld_8b,
> >>                 resp->hwrm_fw_rsvd_8b);
> >> -       bp->fw_ver = (resp->hwrm_fw_maj_8b << 24) |
> >> -                    (resp->hwrm_fw_min_8b << 16) |
> >> -                    (resp->hwrm_fw_bld_8b << 8) |
> >> +       bp->fw_ver = ((uint32_t)resp->hwrm_fw_maj_8b << 24) |
> >> +                    ((uint32_t)resp->hwrm_fw_min_8b << 16) |
> >> +                    ((uint32_t)resp->hwrm_fw_bld_8b << 8) |
> >>                      resp->hwrm_fw_rsvd_8b;
> >>         PMD_DRV_LOG(INFO, "Driver HWRM version: %d.%d.%d\n",
> >>                 HWRM_VERSION_MAJOR, HWRM_VERSION_MINOR, HWRM_VERSION_UPDATE);
> >> --
> >> 2.30.2
> >
> > Acked-by: Somnath Kotur <somnath.kotur@broadcom.com>
> Acked-by: Ajit Khaparde <ajit.khaparde@broadcom.com>
>
> Patch applied to dpdk-next-net-brcm. Thanks

FYI -
During commit, I updated the commit headline a bit -
net/bnxt: fix undefined shift in ver get

>
> >>
> >>

      reply	other threads:[~2021-11-03  4:14 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-02 21:27 Stephen Hemminger
2021-11-03  2:18 ` Somnath Kotur
2021-11-03  4:13   ` Ajit Khaparde
2021-11-03  4:14     ` Ajit Khaparde [this message]

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='CACZ4nhuEi=OKy5SX-BZnY2Sa4xA3zvdm_RUyqQTfLJJOzxYn2A@mail.gmail.com' \
    --to=ajit.khaparde@broadcom.com \
    --cc=dev@dpdk.org \
    --cc=somnath.kotur@broadcom.com \
    --cc=stephen@networkplumber.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;
as well as URLs for NNTP newsgroup(s).