public inbox for linux-kernel@vger.kernel.org
 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>, Daniel Xu <dxu@dxuuu.xyz>,
	Artem Savkov <asavkov@redhat.com>
Subject: [PATCH bpf-next v3 2/3] bpf: export crash_kexec() as destructive kfunc
Date: Mon,  8 Aug 2022 11:46:22 +0200	[thread overview]
Message-ID: <20220808094623.387348-3-asavkov@redhat.com> (raw)
In-Reply-To: <20220808094623.387348-1-asavkov@redhat.com>

Allow properly marked bpf programs to call crash_kexec().

Signed-off-by: Artem Savkov <asavkov@redhat.com>
---
 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


  parent reply	other threads:[~2022-08-08  9:46 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-08  9:46 [PATCH bpf-next v3 0/3] destructive bpf_kfuncs Artem Savkov
2022-08-08  9:46 ` [PATCH bpf-next v3 1/3] bpf: add destructive kfunc flag Artem Savkov
2022-08-08 12:14   ` Kumar Kartikeya Dwivedi
2022-08-08 12:41     ` Artem Savkov
2022-08-08 13:32       ` Kumar Kartikeya Dwivedi
2022-08-09  0:37         ` Andrii Nakryiko
2022-08-09  0:48           ` Kumar Kartikeya Dwivedi
2022-08-08  9:46 ` Artem Savkov [this message]
2022-08-08  9:46 ` [PATCH bpf-next v3 3/3] selftests/bpf: add destructive kfunc test Artem Savkov

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=20220808094623.387348-3-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=dxu@dxuuu.xyz \
    --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