Skip to content

Commit

Permalink
bpf: Allow usage of BPF ringbuffer in sleepable programs
Browse files Browse the repository at this point in the history
The BPF ringbuffer map is pre-allocated and the implementation logic
does not rely on disabling preemption or per-cpu data structures. Using
the BPF ringbuffer sleepable LSM and tracing programs does not trigger
any warnings with DEBUG_ATOMIC_SLEEP, DEBUG_PREEMPT,
PROVE_RCU and PROVE_LOCKING and LOCKDEP enabled.

This allows helpers like bpf_copy_from_user and bpf_ima_inode_hash to
write to the BPF ring buffer from sleepable BPF programs.

Signed-off-by: KP Singh <kpsingh@kernel.org>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Acked-by: Andrii Nakryiko <andrii@kernel.org>
Link: https://lore.kernel.org/bpf/20210204193622.3367275-2-kpsingh@kernel.org
  • Loading branch information
KP Singh authored and Andrii Nakryiko committed Feb 5, 2021
1 parent ec45c5f commit ba90c2c
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion kernel/bpf/verifier.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down

0 comments on commit ba90c2c

Please sign in to comment.