You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
mbset: RemoveID returns early and leaks the followChildren ID (duplicate value, small programs) #5744
Suppose a matchBinaries selector with followChildren: true lists the same path twice.
Deleting that policy does not release its mbset ID. Only 64 IDs exist (mbset.MaxIDs),
so after 64 add/delete cycles no policy that uses followChildren can load until the
agent restarts.
Every add and delete in the loop succeeds, so the only sign of the problem is a warning in
the agent log.
Reproduce
Run a standalone agent built from main (no Kubernetes needed):
sudo ./tetragon --bpf-lib bpf/objs
Save a policy with a repeated followChildren value as dup.yaml:
Hi, I'd like to work on this. Two separate leaks as I read it:
Duplicate value: WriteMatchBinariesPath keeps duplicates, so in RemoveID the first copy deletes the tg_mbset_map key and the second Lookup returns ErrKeyNotExist, returning before delete(s.ids, id). Proposed fix: skip ErrKeyNotExist in the step 1 loop. Test: add a duplicate value to TestMatchBinariesFollowChildrenIDs, which already exhausts all 64 IDs across two add/delete rounds.
Small programs: SetMBSetUpdater is only called with large progs, so RemoveID hits if update == nil { return nil } and never releases the ID, while AllocID still succeeds. Releasing the ID there without clearing execve_map would let a reused ID match processes with the stale bit. Would you prefer rejecting followChildren at load time without large progs, or releasing the ID and accepting/clearing stale bits another way?
Happy to split these into two PRs if that's easier to review.
Hey everyone, I've opened PR #5907 to fix this issue. It handles path deduplication at write time, skips ErrKeyNotExist inside RemoveID, and correctly un-allocates slots when the execve updater is nil. Validated and unit-tested on Linux.
Activity
sayboras commentedon Oct 1, 2026
Added
good first issuelabel, however, I highly encourage to discuss the approach first to save development times/cycles.nicknikolakakis commentedon Oct 1, 2026
Hi, I'd like to work on this. Two separate leaks as I read it:
WriteMatchBinariesPathkeeps duplicates, so inRemoveIDthe first copy deletes thetg_mbset_mapkey and the secondLookupreturnsErrKeyNotExist, returning beforedelete(s.ids, id). Proposed fix: skipErrKeyNotExistin the step 1 loop. Test: add a duplicate value toTestMatchBinariesFollowChildrenIDs, which already exhausts all 64 IDs across two add/delete rounds.SetMBSetUpdateris only called with large progs, soRemoveIDhitsif update == nil { return nil }and never releases the ID, whileAllocIDstill succeeds. Releasing the ID there without clearingexecve_mapwould let a reused ID match processes with the stale bit. Would you prefer rejectingfollowChildrenat load time without large progs, or releasing the ID and accepting/clearing stale bits another way?Happy to split these into two PRs if that's easier to review.
abdullahhanif-001 commentedon Oct 23, 2026
Hey everyone, I've opened PR #5907 to fix this issue. It handles path deduplication at write time, skips ErrKeyNotExist inside RemoveID, and correctly un-allocates slots when the execve updater is nil. Validated and unit-tested on Linux.