linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Artem Savkov <asavkov@redhat.com>
To: Alexei Starovoitov <ast@kernel.org>,
	Daniel Borkmann <daniel@iogearbox.net>,
	Andrii Nakryiko <andrii@kernel.org>,
	bpf@vger.kernel.org, netdev@vger.kernel.org
Cc: linux-kernel@vger.kernel.org,
	Andrea Arcangeli <aarcange@redhat.com>,
	Daniel Vacek <dvacek@redhat.com>, Jiri Olsa <olsajiri@gmail.com>,
	Song Liu <song@kernel.org>, Artem Savkov <asavkov@redhat.com>
Subject: [PATCH bpf-next 4/4] bpf: export crash_kexec() as destructive kfunc
Date: Wed, 20 Jul 2022 13:46:52 +0200	[thread overview]
Message-ID: <20220720114652.3020467-5-asavkov@redhat.com> (raw)
In-Reply-To: <20220720114652.3020467-1-asavkov@redhat.com>

Allow properly marked bpf programs to call crash_kexec().

Signed-off-by: Artem Savkov <asavkov@redhat.com>
---
 kernel/kexec_core.c | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

diff --git a/kernel/kexec_core.c b/kernel/kexec_core.c
index 4d34c78334ce4..a21fe8d326a8e 100644
--- a/kernel/kexec_core.c
+++ b/kernel/kexec_core.c
@@ -39,6 +39,8 @@
 #include <linux/hugetlb.h>
 #include <linux/objtool.h>
 #include <linux/kmsg_dump.h>
+#include <linux/btf.h>
+#include <linux/btf_ids.h>
 
 #include <asm/page.h>
 #include <asm/sections.h>
@@ -1238,3 +1240,23 @@ void __weak arch_kexec_protect_crashkres(void)
 
 void __weak arch_kexec_unprotect_crashkres(void)
 {}
+
+#ifdef CONFIG_DEBUG_INFO_BTF_MODULES
+BTF_SET_START(kexec_btf_ids)
+BTF_ID(func, crash_kexec)
+BTF_SET_END(kexec_btf_ids)
+
+static const struct btf_kfunc_id_set kexec_kfunc_set = {
+	.owner			= THIS_MODULE,
+	.check_set		= &kexec_btf_ids,
+	.destructive_set	= &kexec_btf_ids,
+};
+
+static int __init crash_kfunc_init(void)
+{
+	register_btf_kfunc_id_set(BPF_PROG_TYPE_TRACING, &kexec_kfunc_set);
+	return 0;
+}
+
+subsys_initcall(crash_kfunc_init);
+#endif
-- 
2.35.3


  parent reply	other threads:[~2022-07-20 11:47 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-20 11:46 [PATCH bpf-next 0/4] destructive bpf kfuncs (was: bpf_panic) Artem Savkov
2022-07-20 11:46 ` [PATCH bpf-next 1/4] bpf: add BPF_F_DESTRUCTIVE flag for BPF_PROG_LOAD Artem Savkov
2022-07-21 14:02   ` Alexei Starovoitov
2022-07-22  4:18     ` Artem Savkov
2022-07-22  4:32       ` Alexei Starovoitov
2022-07-25  9:27         ` Artem Savkov
2022-07-25 19:23         ` Daniel Xu
2022-07-20 11:46 ` [PATCH bpf-next 2/4] bpf: add destructive kfunc set Artem Savkov
2022-07-20 11:46 ` [PATCH bpf-next 3/4] selftests/bpf: add destructive kfunc tests Artem Savkov
2022-07-20 11:46 ` Artem Savkov [this message]
2022-07-21 13:00 ` [PATCH bpf-next 0/4] destructive bpf kfuncs (was: bpf_panic) Daniel Borkmann

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220720114652.3020467-5-asavkov@redhat.com \
    --to=asavkov@redhat.com \
    --cc=aarcange@redhat.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=dvacek@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=olsajiri@gmail.com \
    --cc=song@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).