Allow properly marked bpf programs to call crash_kexec().
Signed-off-by: Artem Savkov <[email protected]>
---
kernel/bpf/helpers.c | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
diff --git a/kernel/bpf/helpers.c b/kernel/bpf/helpers.c
index 1f961f9982d2..103dbddff41f 100644
--- a/kernel/bpf/helpers.c
+++ b/kernel/bpf/helpers.c
@@ -1711,3 +1711,24 @@ 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)
+{
+ if (register_btf_kfunc_id_set(BPF_PROG_TYPE_TRACING, &tracing_kfunc_set))
+ pr_warn("failed to register kfunc id set for BPF_PROG_TYPE_TRACING\n");
+
+ return 0;
+}
+
+late_initcall(kfunc_init);
--
2.37.1
On Tue, Aug 9, 2022 at 3:53 AM Artem Savkov <[email protected]> wrote:
>
> Allow properly marked bpf programs to call crash_kexec().
>
> Signed-off-by: Artem Savkov <[email protected]>
> ---
> kernel/bpf/helpers.c | 21 +++++++++++++++++++++
> 1 file changed, 21 insertions(+)
>
> diff --git a/kernel/bpf/helpers.c b/kernel/bpf/helpers.c
> index 1f961f9982d2..103dbddff41f 100644
> --- a/kernel/bpf/helpers.c
> +++ b/kernel/bpf/helpers.c
> @@ -1711,3 +1711,24 @@ 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)
> +{
> + if (register_btf_kfunc_id_set(BPF_PROG_TYPE_TRACING, &tracing_kfunc_set))
> + pr_warn("failed to register kfunc id set for BPF_PROG_TYPE_TRACING\n");
Please drop pr_warn. We don't have it in all other
places where we do registration.