Skip to content

bpf/unused_maps.go: Fix unused map verification

The verifyUnusedMaps function takes in a set of map names which it should ignore. This list is meant for maps which are intentionally unused in the bytecode such as maps for global variables or inner maps.

We need this same list inside removeUnusedMaps to avoid removing maps which are intentionally unused. So our solution is to generate the list in removeUnusedMaps and return it to the caller so it can be passed to verifyUnusedMaps.

The flaw is that we were internally also adding the names for maps which are reachable from programs. An error likely introduced during a refactor and missed during code review.

This effectively disables the unused map verification. Since any map we believe to be reachable is ignored and thus no error reported if the reachability analysis is incorrect.

This commit fixes the issue by making a copy of the keep set before adding maps from the reachability analysis to it, and returning that copy instead.

Merge request reports

Loading