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 69E1DA0C4B; Tue, 2 Nov 2021 22:27:51 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 288E64069F; Tue, 2 Nov 2021 22:27:51 +0100 (CET) Received: from mail-pl1-f173.google.com (mail-pl1-f173.google.com [209.85.214.173]) by mails.dpdk.org (Postfix) with ESMTP id A62E240689 for ; Tue, 2 Nov 2021 22:27:50 +0100 (CET) Received: by mail-pl1-f173.google.com with SMTP id k4so858855plx.8 for ; Tue, 02 Nov 2021 14:27:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=03Bli1MTItUlS6lQDc5QKIPfRsFGNTt4qaOQlrWKYic=; b=0s0icEpPSZ3GmBes1IsmcFzgtFIvFyifHKBWjAeYiLI9y5DK5LNslEjvRsuUvH8lQo bjyiTnFiJsN9aRBJJ2ipnNQUZZnOnXx8nXLSfoYZhz8wvN7wijCT+GymOvWcZYsEhN8R UKFTwMJ1ozfFYSvfxgRHDabih/Ev17zwvc+4vZZyGTRYzLQjZLF3NsWXo96YcyM31B7h 8t0nf1fUVGR9Y1AXHsB5aaEzaYipuFutuuBxPlyPc26JSt0leiRk/VOtg0NAWR8R38ZZ yo1GmE3rC1ZDLwlsi6Gp+CgJQCNWHktIPICbCxbY3HUX0GXm7rmjrj6VbD07YrpBtpIy iDHw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=03Bli1MTItUlS6lQDc5QKIPfRsFGNTt4qaOQlrWKYic=; b=AdlCE9xN8HycXpVGR5ngNPpP2LkZXm7H/H/X4fFYbDSOYMW9jhJwA//dDfNeEBXcyy JjHOyATqgTgFnhSx76er++vZYqvvtjvcVB2RQeLV5cFPo2zAmUVSOLyjjIol3p7ROR/T WGzMVph7w52kszvyGJX3DE1EFVuDQP5VFJ3/P7g7TS8Hq6pGqHD/n8TQo8bQHqcdlAUH vlNEEhpwgYmyWaYidg0VZutyLdlL4f1iFuZDrWzZqI9KAdhr4006xvchKzgEUlbLhl5M 1f2ItRXKnKXX6pwjqXBYpqMLcApnY5K+pu03nTRuGWVad5uWwPnf/sOnchciPsSXoNLJ QbSQ== X-Gm-Message-State: AOAM531cQ5rYTTOboEXQW31f8QetUom/MiFTe64RKA6rN6409SfMwfXE khJfF9fMISZW3ZuFTgrqZhjVku7CW4Jb9g== X-Google-Smtp-Source: ABdhPJyxC8EigNXo3JrPSt2AkZSWWGmiyVR75AFvuTvjzSqb4YunuJyhtvT6LYFSULfYGBoI/tnkLg== X-Received: by 2002:a17:90b:1a86:: with SMTP id ng6mr9165132pjb.142.1635888469318; Tue, 02 Nov 2021 14:27:49 -0700 (PDT) Received: from hermes.local (204-195-33-123.wavecable.com. [204.195.33.123]) by smtp.gmail.com with ESMTPSA id d10sm107672pfd.21.2021.11.02.14.27.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Nov 2021 14:27:48 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Ajit Khaparde , Somnath Kotur Date: Tue, 2 Nov 2021 14:27:44 -0700 Message-Id: <20211102212744.295345-1-stephen@networkplumber.org> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [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" 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