History

bpf: get kernel symbol addresses via syscall

This adds new two new fields to struct bpf_prog_info. For multi-function programs, these fields can be used to pass a list of kernel symbol addresses for all functions in a given program to userspace using the bpf system call with the BPF_OBJ_GET_INFO_BY_FD command. When bpf_jit_kallsyms is enabled, we can get the address of the corresponding kernel symbol for a callee function and resolve the symbol's name. The address is determined by adding the value of the call instruction's imm field to __bpf_call_base. This offset gets assigned to the imm field by the verifier. For some architectures, such as powerpc64, the imm field is not large enough to hold this offset. We resolve this by: [1] Assigning the subprog id to the imm field of a call instruction in the verifier instead of the offset of the callee's symbol's address from __bpf_call_base. [2] Determining the address of a callee's corresponding symbol by using the imm field as an index for the list of kernel symbol addresses now available from the program info.

Sandipan Das committed 8 years ago

Commit dbecd731 parent 8484ce83 files · +28 −6Browse files

Showing the changes to include/uapi/linux (1 of 3 files). Show all

Unified · Split

include/uapi/linux/bpf.h+2−0
@@ -2205,6 +2205,8 @@ struct bpf_prog_info { · 2204 unmodified lines
22052205 __u32 gpl_compatible:1;
22062206 __u64 netns_dev;
22072207 __u64 netns_ino;
2208+ __u32 nr_jited_ksyms;
2209+ __aligned_u64 jited_ksyms;
22082210 } __attribute__((aligned(8)));
22092211
22102212 struct bpf_map_info {

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t