Skip to content

Commit

Permalink
Update Capabilities (CAP_PERFMON, CAP_BPF) (#17)
Browse files Browse the repository at this point in the history
  • Loading branch information
k1LoW authored Aug 15, 2020
1 parent d983527 commit ce1475b
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 1 deletion.
37 changes: 36 additions & 1 deletion capability/enum.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ const (
// arbitrary SCSI commands
// Allow setting encryption key on loopback filesystem
// Allow setting zone reclaim policy
// Allow everything under CAP_BPF and CAP_PERFMON for backward compatibility
CAP_SYS_ADMIN = Cap(21)

// Allow use of reboot()
Expand All @@ -211,6 +212,7 @@ const (
// Allow more than 64hz interrupts from the real-time clock
// Override max number of consoles on console allocation
// Override max number of keymaps
// Control memory reclaim behavior
CAP_SYS_RESOURCE = Cap(24)

// Allow manipulation of system clock
Expand Down Expand Up @@ -256,8 +258,41 @@ const (
// Allow preventing system suspends
CAP_BLOCK_SUSPEND = Cap(36)

// Allow reading audit messages from the kernel
// Allow reading the audit log via multicast netlink socket
CAP_AUDIT_READ = Cap(37)

// Allow system performance and observability privileged operations
// using perf_events, i915_perf and other kernel subsystems
CAP_PERFMON = Cap(38)

// CAP_BPF allows the following BPF operations:
// - Creating all types of BPF maps
// - Advanced verifier features
// - Indirect variable access
// - Bounded loops
// - BPF to BPF function calls
// - Scalar precision tracking
// - Larger complexity limits
// - Dead code elimination
// - And potentially other features
// - Loading BPF Type Format (BTF) data
// - Retrieve xlated and JITed code of BPF programs
// - Use bpf_spin_lock() helper
//
// CAP_PERFMON relaxes the verifier checks further:
// - BPF progs can use of pointer-to-integer conversions
// - speculation attack hardening measures are bypassed
// - bpf_probe_read to read arbitrary kernel memory is allowed
// - bpf_trace_printk to print kernel memory is allowed
//
// CAP_SYS_ADMIN is required to use bpf_probe_write_user.
//
// CAP_SYS_ADMIN is required to iterate system wide loaded
// programs, maps, links, BTFs and convert their IDs to file descriptors.
//
// CAP_PERFMON and CAP_BPF are required to load tracing programs.
// CAP_NET_ADMIN and CAP_BPF are required to load networking programs.
CAP_BPF = Cap(39)
)

var (
Expand Down
6 changes: 6 additions & 0 deletions capability/enum_gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,10 @@ func (c Cap) String() string {
return "block_suspend"
case CAP_AUDIT_READ:
return "audit_read"
case CAP_PERFMON:
return "perfmon"
case CAP_BPF:
return "bpf"
}
return "unknown"
}
Expand Down Expand Up @@ -125,5 +129,7 @@ func List() []Cap {
CAP_WAKE_ALARM,
CAP_BLOCK_SUSPEND,
CAP_AUDIT_READ,
CAP_PERFMON,
CAP_BPF,
}
}

0 comments on commit ce1475b

Please sign in to comment.