Skip to content

Commit

Permalink
bug: support bpf_core_type_exists()
Browse files Browse the repository at this point in the history
In the previous version, when no target is found in BTF, coreCalculateFixups()
will mark its relocation as poison and cause failure when verified by Linux verifier.

This issue is fixed by using right fixup for "checksForExistence" type of relocations.

Signed-off-by: Shang-Wen Wang (Sam Wang) <sam_s_wang@trendmicro.com>
  • Loading branch information
holyspectral committed May 3, 2022
1 parent 5fd10f5 commit 328c0de
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions internal/btf/core.go
Expand Up @@ -313,10 +313,16 @@ func coreCalculateFixups(byteOrder binary.ByteOrder, local Type, targets []Type,

if bestFixups == nil {
// Nothing at all matched, probably because there are no suitable
// targets at all. Poison everything!
// targets at all.
//
// Poison everything except checksForExistence.
bestFixups = make([]COREFixup, len(relos))
for i, relo := range relos {
bestFixups[i] = COREFixup{kind: relo.kind, poison: true}
if relo.kind.checksForExistence() {
bestFixups[i] = COREFixup{kind: relo.kind, local: 1, target: 0}
} else {
bestFixups[i] = COREFixup{kind: relo.kind, poison: true}
}
}
}

Expand Down

0 comments on commit 328c0de

Please sign in to comment.