diff options
| author | Andrii Nakryiko <andrii@kernel.org> | 2021-02-04 16:33:56 -0800 |
|---|---|---|
| committer | Andrii Nakryiko <andrii@kernel.org> | 2021-02-04 16:35:05 -0800 |
| commit | ecda49c522f693842d2832ebd5f59ea95064c9a3 (patch) | |
| tree | 160569736d54b2892fac30c99e004b52affebd3f /kernel | |
| parent | ec45c5faa2f4b3d53d6c04a334eb51d37d90cb56 (diff) | |
| parent | f446b570ac7e1e71ffd6d2a31ffbcc5f32330a6d (diff) | |
Merge branch 'BPF ring buffer + sleepable programs'
KP Singh says:
====================
- Use ring_buffer__consume without BPF_RB_FORCE_WAKEUP as suggested by
Andrii
- Use ASSERT_OK_PTR macro
Sleepable programs currently do not have access to any ringbuffer and
since the perf ring buffer is a per-cpu map, it would not be trivial to
enable for sleepable programs. Our specific use-case is to use the
bpf_ima_inode_hash helper and write the hash to a ring buffer from a
sleepable LSM hook.
This series allows the BPF ringbuffer to be used in sleepable programs
(tracing and lsm). Since the helper prototypes were already exposed
the only change required was have the verifier allow
BPF_MAP_TYPE_RINGBUF for sleepable programs. The ima test is also
modified to use the ringbuffer instead of global variables.
Based on dicussions we had over the BPF office hours and enabling all
the possible debug options, I could not find any issues or warnings when
using the ring buffer from sleepable programs.
====================
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Diffstat (limited to 'kernel')
| -rw-r--r-- | kernel/bpf/verifier.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c index 5e09632efddb..9749081bd26d 100644 --- a/kernel/bpf/verifier.c +++ b/kernel/bpf/verifier.c @@ -10024,9 +10024,11 @@ static int check_map_prog_compatibility(struct bpf_verifier_env *env, return -EINVAL; } break; + case BPF_MAP_TYPE_RINGBUF: + break; default: verbose(env, - "Sleepable programs can only use array and hash maps\n"); + "Sleepable programs can only use array, hash, and ringbuf maps\n"); return -EINVAL; } |
