History

bpf: add prog_digest and expose it via fdinfo/netlink

When loading a BPF program via bpf(2), calculate the digest over the program's instruction stream and store it in struct bpf_prog's digest member. This is done at a point in time before any instructions are rewritten by the verifier. Any unstable map file descriptor number part of the imm field will be zeroed for the hash. fdinfo example output for progs: # cat /proc/1590/fdinfo/5 pos: 0 flags: 02000002 mnt_id: 11 prog_type: 1 prog_jited: 1 prog_digest: b27e8b06da22707513aa97363dfb11c7c3675d28 memlock: 4096 When programs are pinned and retrieved by an ELF loader, the loader can check the program's digest through fdinfo and compare it against one that was generated over the ELF file's program section to see if the program needs to be reloaded. Furthermore, this can also be exposed through other means such as netlink in case of a tc cls/act dump (or xdp in future), but also through tracepoints or other facilities to identify the program. Other than that, the digest can also serve as a base name for the work in progress kallsyms support of programs. The digest doesn't depend/select the crypto layer, since we need to keep dependencies to a minimum. iproute2 will get support for this facility.

Daniel Borkmann committed 9 years ago

Commit 7bd509e1 parent 8d829bd9 files · +116 −2Browse files

Showing the changes to include/uapi (2 of 9 files). Show all

Unified · Split

2 files
  1. include/uapi/linux/pkt_cls.h +1 −0
  2. include/uapi/linux/tc_act/tc_bpf.h +1 −0
include/uapi/linux/pkt_cls.h+1−0
@@ -397,6 +397,7 @@ enum { · 396 unmodified lines
397 TCA_BPF_NAME,397 TCA_BPF_NAME,
398 TCA_BPF_FLAGS,398 TCA_BPF_FLAGS,
399 TCA_BPF_FLAGS_GEN,399 TCA_BPF_FLAGS_GEN,
400 TCA_BPF_DIGEST,
400 __TCA_BPF_MAX,401 __TCA_BPF_MAX,
401};402};
402 403
include/uapi/linux/tc_act/tc_bpf.h+1−0
@@ -27,6 +27,7 @@ enum { · 26 unmodified lines
27 TCA_ACT_BPF_FD,27 TCA_ACT_BPF_FD,
28 TCA_ACT_BPF_NAME,28 TCA_ACT_BPF_NAME,
29 TCA_ACT_BPF_PAD,29 TCA_ACT_BPF_PAD,
30 TCA_ACT_BPF_DIGEST,
30 __TCA_ACT_BPF_MAX,31 __TCA_ACT_BPF_MAX,
31};32};
32#define TCA_ACT_BPF_MAX (__TCA_ACT_BPF_MAX - 1)33#define TCA_ACT_BPF_MAX (__TCA_ACT_BPF_MAX - 1)

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