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 24624A0C53; Wed, 3 Nov 2021 05:13:39 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id E0A4840E0F; Wed, 3 Nov 2021 05:13:38 +0100 (CET) Received: from mail-il1-f171.google.com (mail-il1-f171.google.com [209.85.166.171]) by mails.dpdk.org (Postfix) with ESMTP id 4773A40E03 for ; Wed, 3 Nov 2021 05:13:37 +0100 (CET) Received: by mail-il1-f171.google.com with SMTP id w10so1224480ilc.13 for ; Tue, 02 Nov 2021 21:13:37 -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=HV9I5Dn1T1Q0NdWcgcri0bkp8/eVfgmbgvT5pZyp0p0=; b=HaGG+DKqR9nynbA2DD15IGfYSzDmt1hM0W158+St1h8tmqXUN5+DphWASaMCgpl3Vp Uu4qWKO6+xbd1W96UlWZqw6HsszEN7zpw1WvNcKLI+mre1YyDeMr0sk5pBdF92d+50wW +HqsC2n0/PgjvBieaGPmncTQLZbUVQ0K+oyjQ= 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=HV9I5Dn1T1Q0NdWcgcri0bkp8/eVfgmbgvT5pZyp0p0=; b=OxEfC2afj8MCazNMr+Xenejk3RWQCEIehzdWHcj2m0QVQAv1RnjIQlN/6aPeV/5Ei1 vNpcd2w2THg0/nHJCQZxL81KP/y5Ok+VaO60vdiOPYXHeiV8zqoBSB9QJfGbJXNYx14R pZlsdZO6AWbOQF4F98V00wGfqXuwaq6P74XTqeGnVZR5OA5FMhD8JS+hGhtKo6bP2dXx /2BQo9Ag55HsLiL5fPAhHwmQBOOqXUoplXA8biz5C3ZsvpbPDZvhFLdzRC5fiLBsT+KZ ebrxe9FfP4xyJ5CHOhQ4sy+KfVRSyFOY3lhd9xEpN0kUxgmFu2Qv6MYTdExqm8PZQbg6 vpEw== X-Gm-Message-State: AOAM532mfloWze8oUgIx/CfZr2D8yinmZL2QcbtfWuDMwUwAgNcStBhw jakcpsXJON8fGfgpZb9/eq2tk/NdamInxEsv774vRqFxfoZbfQ== X-Google-Smtp-Source: ABdhPJyy2GAbLvRErxlMKvp89CzsaxWCmL6VYEoaT10lM+4LfJdmDOhVncoGbMa8lFsTKRH+WcTHTNpUBn/AQSPM/J0= X-Received: by 2002:a05:6e02:1c2d:: with SMTP id m13mr14250327ilh.26.1635912816679; Tue, 02 Nov 2021 21:13:36 -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:13:20 -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 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 >> >>