diff options
author | Artem Savkov <asavkov@redhat.com> | 2022-08-10 08:59:04 +0200 |
---|---|---|
committer | Alexei Starovoitov <ast@kernel.org> | 2022-08-10 09:22:18 -0700 |
commit | 133790596406ce2658f0864eb7eac64987c2b12f (patch) | |
tree | 1f6aee1573e122bd4fced269722c9dbd6e282065 | |
parent | 4dd48c6f1f83290d4bc61b43e61d86f8bc6c310e (diff) |
bpf: export crash_kexec() as destructive kfunc
Allow properly marked bpf programs to call crash_kexec().
Signed-off-by: Artem Savkov <asavkov@redhat.com>
Link: https://lore.kernel.org/r/20220810065905.475418-3-asavkov@redhat.com
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
-rw-r--r-- | kernel/bpf/helpers.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/kernel/bpf/helpers.c b/kernel/bpf/helpers.c index a95eb9fb01ff..3c1b9bbcf971 100644 --- a/kernel/bpf/helpers.c +++ b/kernel/bpf/helpers.c @@ -1725,3 +1725,21 @@ bpf_base_func_proto(enum bpf_func_id func_id) return NULL; } } + +BTF_SET8_START(tracing_btf_ids) +#ifdef CONFIG_KEXEC_CORE +BTF_ID_FLAGS(func, crash_kexec, KF_DESTRUCTIVE) +#endif +BTF_SET8_END(tracing_btf_ids) + +static const struct btf_kfunc_id_set tracing_kfunc_set = { + .owner = THIS_MODULE, + .set = &tracing_btf_ids, +}; + +static int __init kfunc_init(void) +{ + return register_btf_kfunc_id_set(BPF_PROG_TYPE_TRACING, &tracing_kfunc_set); +} + +late_initcall(kfunc_init); |