bpf: Keep BPF_PROG_LOAD permission checks clear of validations
authorAndrii Nakryiko <andrii@kernel.org>
Tue, 13 Jun 2023 22:35:33 +0000 (15:35 -0700)
committerDaniel Borkmann <daniel@iogearbox.net>
Mon, 19 Jun 2023 12:04:04 +0000 (14:04 +0200)
commit7f6719f7a8662a40afed367a685516f9f34e7bc2
treecaa644c43993c20faef1d7446b79625e9ed2c941
parent6c3eba1c5e283fd2bb1c076dbfcb47f569c3bfde
bpf: Keep BPF_PROG_LOAD permission checks clear of validations

Move out flags validation and license checks out of the permission
checks. They were intermingled, which makes subsequent changes harder.
Clean this up: perform straightforward flag validation upfront, and
fetch and check license later, right where we use it. Also consolidate
capabilities check in one block, right after basic attribute sanity
checks.

Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Stanislav Fomichev <sdf@google.com>
Link: https://lore.kernel.org/bpf/20230613223533.3689589-5-andrii@kernel.org
kernel/bpf/syscall.c