Repository navigation
Tags
Tags
program: don't return error when kmod BTF is disabled In kernels where the flag CONFIG_DEBUG_INFO_BTF_MODULES is not set, including kernels 5.10 and below (because the flag was introduced in 5.11), loading a program that attaches to kernel module functions and relied on CORE failed because the module's BTF is not available. This fix allows the program to run, obviously only as long as it only relies on the kernel's BTF and not on the specific module's BTF. Fixes: cilium#1436 Signed-off-by: Ori Shussman <orishuss@gmail.com>
btf: fix race in mutableTypes.copy We reference mt.copiedTypeIDs during copy to be able to figure out the correct ID for a copied type. This access can currently race with mutableTypes.add since we don't protect mt.copiedTypeIDs. Take a read lock to prevent modification. Signed-off-by: Lorenz Bauer <lmb@isovalent.com>
btf: fix race due to concurrent read access Up until the introduction of lazy copying, reading from a Spec concurrently was safe. Now a read may trigger a copy and a write into the Spec, therefore causing a race on mutableTypes. Fix this by introducing a mutex which protects access to the mutable state. We need to be a bit careful here: copying in mutableTypes.add happens piecemeal, so we need to take a lock for the whole duration of modifyGraph. Signed-off-by: Lorenz Bauer <lmb@isovalent.com>
btf: Replace `binary.Read` with manual parsing in `readAndInflateTypes`
During profiling `binary.Read` uses up a significant amount of CPU time.
This seems to be due to it using reflection to calculate the amount of
bytes to read at runtime and not caching these results.
By doing manual `io.ReadFull` calls, pre-calculating struct sizes and
reusing types and buffers where possible, we can reduce the CPU time
spent in `readAndInflateTypes` by almost 25%.
```
goos: linux
goarch: amd64
pkg: github.com/cilium/ebpf/btf
cpu: 11th Gen Intel(R) Core(TM) i7-11800H @ 2.30GHz
│ before.txt │ after.txt │
│ sec/op │ sec/op vs base │
ParseVmlinux-16 46.08m ± 1% 34.59m ± 2% -24.93% (n=100)
│ before.txt │ after.txt │
│ B/op │ B/op vs base │
ParseVmlinux-16 26.65Mi ± 0% 23.49Mi ± 0% -11.87% (n=100)
│ before.txt │ after.txt │
│ allocs/op │ allocs/op vs base │
ParseVmlinux-16 467.5k ± 0% 267.7k ± 0% -42.73% (n=100)
```
Signed-off-by: Dylan Reimerink <dylan.reimerink@isovalent.com>
sysenc: refuse to unmarshal into undersized dst Unmarshal currently doesn't check that unmarshaling actually consumes to full buffer. This means that looking uint16 from an uint32 value doesn't return an error. Fixes cilium#1157 Signed-off-by: Lorenz Bauer <lmb@isovalent.com>
btf,info: Fix bad instruction offset when parsing infos from kernel When BTF ext info is encoded in ELF the instruction offsets are in bytes, but when you pass them to the kernel they must be instruction indices. Therefore we divide the offset by the instruction size in the parsing logic for ELF. This was missed during the initial implementation of reading back BTF ext info from the kernel. This would cause an error when loading back ext info which was not a multiple of the instruction size or a bad instruction offset if it was. Fix this by making LoadLineInfos and LoadFuncInfos work on the kernel format which contains instruction offsets while the ELF parser uses bytes instead. Signed-off-by: Dylan Reimerink <dylan.reimerink@isovalent.com> Co-developed-by: Lorenz Bauer <lmb@isovalent.com>
features: fix unsupported progtype/helper probes By enabling feature probes for the program types Tracing, Extension, LSM and StructOps within the HaveProgramType API, we overlooked that this would cause false negative results when using these types with the HaveProgramHelper API. To probe for these program types we craft specialized ProgramSpecs, but don't do the same when probing for these types in combination with an arbitrary helper. For now we should return an inconclusive error from the HaveProgramHelper API until we find a better way to probe for helpers with these program types. Fixes: cilium#1082 Signed-off-by: Robin Gögge <r.goegge@isovalent.com>
PreviousNext