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 0D91BA0C53; Wed, 3 Nov 2021 05:14:52 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id E908740E0F; Wed, 3 Nov 2021 05:14:51 +0100 (CET) Received: from mail-il1-f175.google.com (mail-il1-f175.google.com [209.85.166.175]) by mails.dpdk.org (Postfix) with ESMTP id 4490540E03 for ; Wed, 3 Nov 2021 05:14:50 +0100 (CET) Received: by mail-il1-f175.google.com with SMTP id l19so1325666ilk.0 for ; Tue, 02 Nov 2021 21:14:50 -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=ZaBNbMTQhVZrzxqnJGrynWhSuyqSSlwOnaYS6qF7IwU=; b=h4xdovotCdYYaNpGjT8DsYzksCbRLKoGJZwDHdiY0ew2cCe9MPlTH79d/ceCI+r82C NoeeYcg2eu3pr62gMpPd0oKTQbVyBtFLAPZFvzZuQLkKe5UHL6NJ5vOq0CsTsR4GMWmg udiGdBu47yF6j5pgFibbk+b6pdWVvPubR2glk= 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=ZaBNbMTQhVZrzxqnJGrynWhSuyqSSlwOnaYS6qF7IwU=; b=3paKKo31YwGYWHc1QRqbK7AbWoao0uQs56OujIjjR7LXx0Ri/FtE6n8h+gnrT/pXIq VuYoaATiFj327fi+1npQwi8jyLoAbC1fHxS8DNetHbMql9g43CnLwPHXqJisSeLtCPyU yki2m+dIaooJ17fWIBcdaDtqzdjGETUn1wNtjvy/g46wdvQOUjfYdzcHlLfDziY/s62Q kkS9+HmVcYzr8KEO9ZxrLk18WLm9XaXYTkbiDEu0Jn49/e+hUb0qEWGh1/VkxTwwjaTV N/9FxFY8TVRTfauSNT6cwjqJKT/Vu9f7sH8t0pOt8nnlNT/osluBQIhLL4lCCqwfm3Ap U/XQ== X-Gm-Message-State: AOAM530eqkJqy+zKqIm9tYkB2Y9Nq4xj0AON5u3MvawDj7Mww59Z5FS3 T4kw0/0WzEZ5HPV61828kEu8RUcbTjvcKekRq4mAQg== X-Google-Smtp-Source: ABdhPJxAPLbKElm+nwY16TyIl60egz4IT9fEek3FpRhoo09hHSFkVpsfqz8AuNivASVcuxBK1gkc+CUW6QhicG4NPXg= X-Received: by 2002:a92:d5c1:: with SMTP id d1mr2531702ilq.311.1635912889702; Tue, 02 Nov 2021 21:14:49 -0700 (PDT) MIME-Version: 1.0 References: <20211102212744.295345-1-stephen@networkplumber.org> In-Reply-To: From: Ajit Khaparde Date: Tue, 2 Nov 2021 21:14:33 -0700 Message-ID: To: Somnath Kotur Cc: Stephen Hemminger , dev Content-Type: text/plain; charset="UTF-8" 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" On Tue, Nov 2, 2021 at 9:13 PM Ajit Khaparde wrote: > > On Tue, Nov 2, 2021 at 7:18 PM Somnath Kotur wrote: > > > > > > > > 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 > Acked-by: Ajit Khaparde > > 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 > > >> > >>