From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 42383A0C4B; Wed, 3 Nov 2021 03:18:28 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 0C73440E0F; Wed, 3 Nov 2021 03:18:28 +0100 (CET) Received: from mail-yb1-f179.google.com (mail-yb1-f179.google.com [209.85.219.179]) by mails.dpdk.org (Postfix) with ESMTP id 9F52540E03 for ; Wed, 3 Nov 2021 03:18:26 +0100 (CET) Received: by mail-yb1-f179.google.com with SMTP id s3so2785582ybs.9 for ; Tue, 02 Nov 2021 19:18:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=YR/2E6uExl5Fz3UHhnA2v2UBGIDUmk6L+4t9eH5gdG0=; b=crSV9GVLFHxYmHBkl7/UpQAStVsIM/D0h7tbuvGxMruw+2Lje6toyitv74SMpOJqaN ElKUKMjPP0TCue4zwzWCjWVSaK1Psdzz9xUynusqN2rl2Ci1srfN6B/ZkuphfUUHNdNP XidSLsXCpFHIux+BjS2nckP5wzAPNKG1LQGdU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=YR/2E6uExl5Fz3UHhnA2v2UBGIDUmk6L+4t9eH5gdG0=; b=1fI81x2wNmu6hXq6LoSJpye3fVaJEybcfZTngpA2JqKXxzJeHtUDoT3RsRy697g824 L6vHi3RkU4gJ8Z7+But6Ul8JpebkZeeKhpRB9reaKpYuVN4NJY/c9fb2Ib7Xe6SBtp0G Li6jpMpYa0Vtxh06c+svG1tZV6VPqW7kcr8AebnF6xU8gFSmJpX9uc6yNUhhjdsdYM6V /AmxJldAOaTcxnVk0R+e6hRiJgGcdZWuzF5pdCUI+HNNVXZqlAjeY9zvdsl4R7sJqE98 EPElZaWrpkUxrku5IAvAEPrmlwuDYJ/SKFgwTbtGZt08eUehmHQheQ6qwYNMJ2PkodY8 5Ugw== X-Gm-Message-State: AOAM531JNvqtGQRkC3wECxcjPDP6IPFG3iunraY/0/GlHlGmUkJbqqFD dEAD+qzgAHJH4Vyj8J1hKgldngr8HugWhywPcO+jmA== X-Google-Smtp-Source: ABdhPJwM/44fyPfCcRmZfnDoYTcsEYZNpGyhp5GF5IqWAWF8fWtnGtCCPw6a44nVTytdHsnTqdqJpVmTp20jjDskW4U= X-Received: by 2002:a25:74c8:: with SMTP id p191mr34465908ybc.157.1635905905939; Tue, 02 Nov 2021 19:18:25 -0700 (PDT) MIME-Version: 1.0 References: <20211102212744.295345-1-stephen@networkplumber.org> In-Reply-To: <20211102212744.295345-1-stephen@networkplumber.org> From: Somnath Kotur Date: Wed, 3 Nov 2021 07:48:14 +0530 Message-ID: To: Stephen Hemminger Cc: dev , Ajit Khaparde Content-Type: multipart/signed; protocol="application/pkcs7-signature"; micalg=sha-256; boundary="0000000000006d117805cfd9061a" X-Content-Filtered-By: Mailman/MimeDel 2.1.29 Subject: Re: [dpdk-dev] [PATCH] net/bnxt: fix undefined shift in vers_get X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" --0000000000006d117805cfd9061a Content-Type: text/plain; charset="UTF-8" On Wed, 3 Nov 2021, 02:57 Stephen Hemminger, 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 > --- > 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 > > --0000000000006d117805cfd9061a--