info: Return dedicated error when program info is restricted #1858
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
On systems where the
kernel.kptr_restrict
andnet.core.bpf_jit_harden
sysctls are enabled, certain fields in the program info may be restricted. When this is the case xlated and jitted instruction, line info, and function info are unavailable.When such fields are unavailable, we do get ..len fields set to non-zero values, but the kernel will have not written any data to the pointers provided. Link
At present when this happens we don't recognize this and attempt to parse the empty buffers resulting in a
parse func info: offset 0: type ID 0 is a *btf.Void, but expected a Func
error.The only clue we have that this is happening is that the kernel will zero out the insns pointer. This commit adds logic to detect when this happens and then returns a dedicated
ErrInfoRestricted
error so this case can be handled gracefully.This is similar to / based on the approach bpftool has taken to handle this.