Tags: cilium/ebpf
Tags
Fix ksym buffer overrun on 32 bit platforms Commit 78074c5 ("info: expose more prog jited info"), which made its way into v0.17.0, resulted in random runc CI failures when running i386 binary on an amd64 kernel (see [1]). Apparently [2], the kernel always returns 64-bit pointers, so uint64 (rather than uintptr) should be used for ksyms slice regardless of the platform to avoid the buffer overrun. Now, to keep the public API of (*ProgramInfo).JitedKsymAddrs intact, convert those addresses back to uintptr, as it was done before commit 78074c5. Except, if the kernel address won't fit into an uintptr (as it is the case when running i386 binary on an amd64 kernel), return an empty slice and a false, rather than incorrect addresses. [1]: opencontainers/runc#4594 [2]: https://github.com/torvalds/linux/blob/2014c95afecee3e76ca4a56956a936e23283f05b/kernel/bpf/syscall.c#L4840-L4846 Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
internal: add OnLinux constant Add a constant which indicates whether we are building for Linux. This is so that we can write if !internal.OnLinux { instead of if runtime.GOOS != "linux" { This makes it easy to remove platform dependent code by removing the constant and then fixing the breakage. Signed-off-by: Lorenz Bauer <lmb@isovalent.com>
prog: fix shadowing log size variable in verifier log retry loop When ProgramOptions.LogSize was removed in 0.16, the tests weren't updated to exercise the retry loop, since a minimum log size was chosen that was larger than what the test program could generate. With the addition of LogSizeStart, this notoriously fragile code broke when logSize was again tracked as a separate variable, while being accidentally shadowed within the scope of the for loop. This resulted in an endless loop on kernels without the LogTrueSize field. Remove the shadowing and fix the tests. Signed-off-by: Timo Beckers <timo@isovalent.com>
examples: tcx: use Variable API This commit updates the `example/tcx` program to use the new Variable API rather than traditional bpf maps. The example already depends on `bpf_link`, which requires kernel >= v6.6, therefore the Variable API is already supported and working (since v5.5). Signed-off-by: Simone Magnani <simone.magnani@isovalent.com>
map: remove misleading error message when creating without BTF Time and time again people misunderstand errors like the following: map create: cannot allocate memory (without BTF k/v) Instead of focusing on the ENOMEM they assume that it has something to do with BTF. In reality it just means that creating a map has failed, and we didn't supply any BTF during creation. Avoid this confusion by removing the "without BTF k/v" part. Signed-off-by: Lorenz Bauer <lmb@isovalent.com>
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: #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>
PreviousNext