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 0C777A0548; Wed, 15 Jun 2022 09:16:28 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id EE02E40221; Wed, 15 Jun 2022 09:16:27 +0200 (CEST) Received: from inbox.dpdk.org (inbox.dpdk.org [95.142.172.178]) by mails.dpdk.org (Postfix) with ESMTP id 244BE40220 for ; Wed, 15 Jun 2022 09:16:27 +0200 (CEST) Received: by inbox.dpdk.org (Postfix, from userid 33) id 0E65EA054A; Wed, 15 Jun 2022 09:16:27 +0200 (CEST) From: bugzilla@dpdk.org To: dev@dpdk.org Subject: [Bug 1035] __rte_raw_cksum() crash with misaligned pointer Date: Wed, 15 Jun 2022 07:16:26 +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: 21.11 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: emil.berg@ericsson.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 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 https://bugs.dpdk.org/show_bug.cgi?id=3D1035 Bug ID: 1035 Summary: __rte_raw_cksum() crash with misaligned pointer Product: DPDK Version: 21.11 Hardware: All OS: All Status: UNCONFIRMED Severity: normal Priority: Normal Component: ethdev Assignee: dev@dpdk.org Reporter: emil.berg@ericsson.com Target Milestone: --- See rte_raw_cksum() in rte_ip.h, which is part of the public API. See also = the subfunction __rte_raw_cksum(). _rte_raw_cksum assumes that the buffer over which the checksum is calculate= d is an even address (divisible by two). See for example this stack overflow pos= t: https://stackoverflow.com/questions/46790550/c-undefined-behavior-strict-al= iasing-rule-or-incorrect-alignment The post explains that there is undefined behavior in C11 when "conversion between two pointer types produces a result that is incorrectly aligned". W= hen the buf argument starts on an odd address we thus have undefined behavior, since a pointer is cast from void* to uint16_t*. In most cases (at least on x86) that isn't a problem, but with higher optimization levels it may break due to vector instructions. This new funct= ion seems to be easier to optimize by the compiler, resulting in a crash when t= he buf argument is odd. Please note that the undefined behavior is present in earlier versions of dpdk as well. Now you're probably thinking: "Just align your buffers". The problem is tha= t we have a packet buffer which is aligned. The checksum is calculated on a subs= et of that aligned packet buffer, and that sometimes lies on odd addresses. The question remains if this is an issue with dpdk or not. Maybe you do the assumption that odd addresses are never passed in when calculating the checksum, and that's all right. But perhaps a public API comment should be added in that case. Or perhaps you use it incorrectly as well, and in that = case something should be done about it. Triggering this bug seems to require high optimization levels as well as odd values of buf. Of interest may be that in older version of dpdk you added the a comment: /* workaround gcc strict-aliasing warning */ showing that you willfully ignored the warning. --=20 You are receiving this mail because: You are the assignee for the bug.=