diff options
| author | Yonghong Song <yhs@fb.com> | 2018-06-04 11:53:41 -0400 |
|---|---|---|
| committer | Daniel Borkmann <daniel@iogearbox.net> | 2018-06-04 15:52:26 -0400 |
| commit | 34ea38ca27991466a8fff849514b4181b42ae2eb (patch) | |
| tree | 82a6a5c2b288e9d1011c4a24e71825cce3b37792 | |
| parent | 649953628ee241188af0afb55a5bc4b8c0a9d603 (diff) | |
bpf: guard bpf_get_current_cgroup_id() with CONFIG_CGROUPS
Commit bf6fa2c893c5 ("bpf: implement bpf_get_current_cgroup_id()
helper") introduced a new helper bpf_get_current_cgroup_id().
The helper has a dependency on CONFIG_CGROUPS.
When CONFIG_CGROUPS is not defined, using the helper will result
the following verifier error:
kernel subsystem misconfigured func bpf_get_current_cgroup_id#80
which is hard for users to interpret.
Guarding the reference to bpf_get_current_cgroup_id_proto with
CONFIG_CGROUPS will result in below better message:
unknown func bpf_get_current_cgroup_id#80
Fixes: bf6fa2c893c5 ("bpf: implement bpf_get_current_cgroup_id() helper")
Suggested-by: Daniel Borkmann <daniel@iogearbox.net>
Signed-off-by: Yonghong Song <yhs@fb.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
| -rw-r--r-- | kernel/trace/bpf_trace.c | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/kernel/trace/bpf_trace.c b/kernel/trace/bpf_trace.c index e2ab5b7f29d2..0ae6829804bc 100644 --- a/kernel/trace/bpf_trace.c +++ b/kernel/trace/bpf_trace.c | |||
| @@ -564,8 +564,10 @@ tracing_func_proto(enum bpf_func_id func_id, const struct bpf_prog *prog) | |||
| 564 | return &bpf_get_prandom_u32_proto; | 564 | return &bpf_get_prandom_u32_proto; |
| 565 | case BPF_FUNC_probe_read_str: | 565 | case BPF_FUNC_probe_read_str: |
| 566 | return &bpf_probe_read_str_proto; | 566 | return &bpf_probe_read_str_proto; |
| 567 | #ifdef CONFIG_CGROUPS | ||
| 567 | case BPF_FUNC_get_current_cgroup_id: | 568 | case BPF_FUNC_get_current_cgroup_id: |
| 568 | return &bpf_get_current_cgroup_id_proto; | 569 | return &bpf_get_current_cgroup_id_proto; |
| 570 | #endif | ||
| 569 | default: | 571 | default: |
| 570 | return NULL; | 572 | return NULL; |
| 571 | } | 573 | } |
