[RFC,bpf-next,1/9] bpf: allow more maps in sleepable bpf programs

Message ID 20240209-hid-bpf-sleepable-v1-1-4cc895b5adbd@kernel.org
State New
Headers
Series allow HID-BPF to do device IOs |

Commit Message

Benjamin Tissoires Feb. 9, 2024, 1:26 p.m. UTC
  These 3 maps types are required for HID-BPF when a user wants to do
IO with a device from a sleepable tracing point.

HID-BPF relies on `bpf_tail_call()` to selectively call the BPF programs
attached to a device, thus we need BPF_MAP_TYPE_PROG_ARRAY access.

Allowing BPF_MAP_TYPE_QUEUE (and therefore BPF_MAP_TYPE_STACK) allows
for a BPF program to prepare from an IRQ the list of HID commands to send
back to the device and then these commands can be retrieved from the
sleepable trace point.

Signed-off-by: Benjamin Tissoires <bentiss@kernel.org>
---
 kernel/bpf/verifier.c | 3 +++
 1 file changed, 3 insertions(+)
  

Patch

diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c
index 64fa188d00ad..3cc880ecd3e4 100644
--- a/kernel/bpf/verifier.c
+++ b/kernel/bpf/verifier.c
@@ -18028,6 +18028,9 @@  static int check_map_prog_compatibility(struct bpf_verifier_env *env,
 		case BPF_MAP_TYPE_SK_STORAGE:
 		case BPF_MAP_TYPE_TASK_STORAGE:
 		case BPF_MAP_TYPE_CGRP_STORAGE:
+		case BPF_MAP_TYPE_PROG_ARRAY:
+		case BPF_MAP_TYPE_QUEUE:
+		case BPF_MAP_TYPE_STACK:
 			break;
 		default:
 			verbose(env,