Eliminate UBSAN: array-index-out-of-bounds in map_runtime.h warnings The kernel's UBSAN array-index-out-of-bounds check needs the variable in the struct holding the size of the dynamically allocated array to be initialized before accessing the array. The code in _stp_map_init() has been reordered to allow the UBSAN check to work properly.
diff --git a/runtime/linux/map_runtime.h b/runtime/linux/map_runtime.h index 13a247c..e9ab8ae 100644 --- a/runtime/linux/map_runtime.h +++ b/runtime/linux/map_runtime.h
@@ -107,11 +107,10 @@ INIT_MLIST_HEAD(&m->head); m->hash_table_mask = hash_table_mask; - for (i = 0; i <= hash_table_mask; i++) - INIT_MHLIST_HEAD(&m->hashes[i]); - m->maxnum = max_entries; m->wrap = wrap; + for (i = 0; i <= hash_table_mask; i++) + INIT_MHLIST_HEAD(&m->hashes[i]); /* Since we're using _stp_map_vzalloc(), we can afford to * allocate the nodes in one big chunk. */