Bug 1289 - rte_table: lookup functions have UB for ctz
Summary: rte_table: lookup functions have UB for ctz
Status: UNCONFIRMED
Alias: None
Product: DPDK
Classification: Unclassified
Component: other (show other bugs)
Version: 23.11
Hardware: x86 Linux
: Normal normal
Target Milestone: ---
Assignee: dev
URL:
Depends on:
Blocks:
 
Reported: 2023-09-15 13:49 CEST by Dmitrii Loginov
Modified: 2023-09-15 13:49 CEST (History)
0 users



Attachments

Description Dmitrii Loginov 2023-09-15 13:49:01 CEST
Macros 'lookup2_stage0_with_odd_support' can call rte_ctz with zero value (pkt_mask), which is undefined behaviour based on the GCC manual:
 https://gcc.gnu.org/onlinedocs/gcc/Other-Builtins.html

Quote: "
Built-in Function: int __builtin_ctz (unsigned int x)
Returns the number of trailing 0-bits in x, starting at the least significant bit position. If x is 0, the result is undefined.
"

It is confirmed by checking this code in GCC-13 with ASAN.

Note You need to log in before you can comment on or make changes to this bug.