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 12448A0C47; Tue, 26 Oct 2021 11:47:41 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 025AF410D5; Tue, 26 Oct 2021 11:47:41 +0200 (CEST) Received: from inbox.dpdk.org (inbox.dpdk.org [95.142.172.178]) by mails.dpdk.org (Postfix) with ESMTP id 3F8F4407FF for ; Tue, 26 Oct 2021 11:47:40 +0200 (CEST) Received: by inbox.dpdk.org (Postfix, from userid 33) id 27F54A0C4B; Tue, 26 Oct 2021 11:47:40 +0200 (CEST) From: bugzilla@dpdk.org To: dev@dpdk.org Date: Tue, 26 Oct 2021 09:47:40 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: DPDK X-Bugzilla-Component: ethdev X-Bugzilla-Version: unspecified X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: burner-email@caramail.com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: Normal X-Bugzilla-Assigned-To: dev@dpdk.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version rep_platform op_sys bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://bugs.dpdk.org/ Auto-Submitted: auto-generated X-Auto-Response-Suppress: All MIME-Version: 1.0 Subject: [dpdk-dev] [Bug 838] [ubsan] bnxt: left shift cannot be represented in bnxt_hwrm_ver_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" https://bugs.dpdk.org/show_bug.cgi?id=3D838 Bug ID: 838 Summary: [ubsan] bnxt: left shift cannot be represented in bnxt_hwrm_ver_get() Product: DPDK Version: unspecified Hardware: All OS: All Status: UNCONFIRMED Severity: normal Priority: Normal Component: ethdev Assignee: dev@dpdk.org Reporter: burner-email@caramail.com Target Milestone: --- Hello, An issue found by UBSan: DPDK/drivers/net/bnxt/bnxt_hwrm.c:X:Y: runtime error: left shift of 216 by = 24 places cannot be represented in type 'int'. The offending code is in bnxt_hwrm_ver_get(): bp->fw_ver =3D (resp->hwrm_fw_maj_8b << 24) | <--- HERE (resp->hwrm_fw_min_8b << 16) | (resp->hwrm_fw_bld_8b << 8) | resp->hwrm_fw_rsvd_8b; The left shifts here are of type 'int', and the first one cannot be represented. This is an undefined behavior. The first shift should be explicitly cast to uint32_t, ie: bp->fw_ver =3D ((uint32_t)resp->hwrm_fw_maj_8b << 24) | (resp->hwrm_fw_min_8b << 16) | (resp->hwrm_fw_bld_8b << 8) | resp->hwrm_fw_rsvd_8b; I have tested this patch, and could confirm with UBSan that there is no undefined behavior anymore. Thanks! --=20 You are receiving this mail because: You are the assignee for the bug.=