aboutsummaryrefslogtreecommitdiffstats
path: root/include/uapi/linux/bpf.h
diff options
context:
space:
mode:
authorAndrey Ignatov <rdna@fb.com>2019-02-27 15:59:24 -0500
committerAlexei Starovoitov <ast@kernel.org>2019-04-12 16:54:58 -0400
commit7b146cebe30cb481b0f70d85779da938da818637 (patch)
tree11dbbeb42b32557d345e6dac2baf2881cbe5adb5 /include/uapi/linux/bpf.h
parentb1cd609d9b517f01867c211bd520cc805db3068a (diff)
bpf: Sysctl hook
Containerized applications may run as root and it may create problems for whole host. Specifically such applications may change a sysctl and affect applications in other containers. Furthermore in existing infrastructure it may not be possible to just completely disable writing to sysctl, instead such a process should be gradual with ability to log what sysctl are being changed by a container, investigate, limit the set of writable sysctl to currently used ones (so that new ones can not be changed) and eventually reduce this set to zero. The patch introduces new program type BPF_PROG_TYPE_CGROUP_SYSCTL and attach type BPF_CGROUP_SYSCTL to solve these problems on cgroup basis. New program type has access to following minimal context: struct bpf_sysctl { __u32 write; }; Where @write indicates whether sysctl is being read (= 0) or written (= 1). Helpers to access sysctl name and value will be introduced separately. BPF_CGROUP_SYSCTL attach point is added to sysctl code right before passing control to ctl_table->proc_handler so that BPF program can either allow or deny access to sysctl. Suggested-by: Roman Gushchin <guro@fb.com> Signed-off-by: Andrey Ignatov <rdna@fb.com> Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Diffstat (limited to 'include/uapi/linux/bpf.h')
-rw-r--r--include/uapi/linux/bpf.h9
1 files changed, 9 insertions, 0 deletions
diff --git a/include/uapi/linux/bpf.h b/include/uapi/linux/bpf.h
index 2e96d0b4bf65..cc2a2466d5f3 100644
--- a/include/uapi/linux/bpf.h
+++ b/include/uapi/linux/bpf.h
@@ -167,6 +167,7 @@ enum bpf_prog_type {
167 BPF_PROG_TYPE_LIRC_MODE2, 167 BPF_PROG_TYPE_LIRC_MODE2,
168 BPF_PROG_TYPE_SK_REUSEPORT, 168 BPF_PROG_TYPE_SK_REUSEPORT,
169 BPF_PROG_TYPE_FLOW_DISSECTOR, 169 BPF_PROG_TYPE_FLOW_DISSECTOR,
170 BPF_PROG_TYPE_CGROUP_SYSCTL,
170}; 171};
171 172
172enum bpf_attach_type { 173enum bpf_attach_type {
@@ -188,6 +189,7 @@ enum bpf_attach_type {
188 BPF_CGROUP_UDP6_SENDMSG, 189 BPF_CGROUP_UDP6_SENDMSG,
189 BPF_LIRC_MODE2, 190 BPF_LIRC_MODE2,
190 BPF_FLOW_DISSECTOR, 191 BPF_FLOW_DISSECTOR,
192 BPF_CGROUP_SYSCTL,
191 __MAX_BPF_ATTACH_TYPE 193 __MAX_BPF_ATTACH_TYPE
192}; 194};
193 195
@@ -3308,4 +3310,11 @@ struct bpf_line_info {
3308struct bpf_spin_lock { 3310struct bpf_spin_lock {
3309 __u32 val; 3311 __u32 val;
3310}; 3312};
3313
3314struct bpf_sysctl {
3315 __u32 write; /* Sysctl is being read (= 0) or written (= 1).
3316 * Allows 1,2,4-byte read, but no write.
3317 */
3318};
3319
3311#endif /* _UAPI__LINUX_BPF_H__ */ 3320#endif /* _UAPI__LINUX_BPF_H__ */