@@ -87,6 +87,12 @@ config BPF_SIG
Check BPF programs for valid signatures upon load: the signature
is passed via the bpf() syscall together with the instructions.
+config BPF_SIG_FORCE
+ bool "Require BPF to be validly signed"
+ depends on BPF_SIG
+ help
+ Reject unsigned BPF or signed BPF for which we don't have a key.
+
source "kernel/bpf/preload/Kconfig"
config BPF_LSM
@@ -2340,6 +2340,10 @@ static int bpf_prog_load(union bpf_attr *attr, bpfptr_t uattr)
prog->aux->name, ERR_PTR(err));
goto free_prog_sec;
}
+ } else if (IS_ENABLED(CONFIG_BPF_SIG_FORCE) && !uattr.is_kernel) {
+ pr_warn("Rejecting BPF '%s' with no signature\n", prog->aux->name);
+ err = -EKEYREJECTED;
+ goto free_prog_sec;
}
#endif