[PATCH 02/18] bpf-preload: Move bpf_preload.h to include/linux
Roberto Sassu
roberto.sassu at huawei.com
Mon Mar 28 17:50:17 UTC 2022
Move bpf_preload.h to include/linux, so that third-party providers can
develop out-of-tree kernel modules to preload eBPF programs.
Export the bpf_preload_ops global variable if CONFIG_BPF_SYSCALL is
defined.
Signed-off-by: Roberto Sassu <roberto.sassu at huawei.com>
---
{kernel/bpf/preload => include/linux}/bpf_preload.h | 4 ++++
kernel/bpf/inode.c | 2 +-
kernel/bpf/preload/bpf_preload_kern.c | 2 +-
3 files changed, 6 insertions(+), 2 deletions(-)
rename {kernel/bpf/preload => include/linux}/bpf_preload.h (85%)
diff --git a/kernel/bpf/preload/bpf_preload.h b/include/linux/bpf_preload.h
similarity index 85%
rename from kernel/bpf/preload/bpf_preload.h
rename to include/linux/bpf_preload.h
index f065c91213a0..09d55d9f1131 100644
--- a/kernel/bpf/preload/bpf_preload.h
+++ b/include/linux/bpf_preload.h
@@ -11,6 +11,10 @@ struct bpf_preload_ops {
int (*preload)(struct bpf_preload_info *);
struct module *owner;
};
+
+#ifdef CONFIG_BPF_SYSCALL
extern struct bpf_preload_ops *bpf_preload_ops;
+#endif /*CONFIG_BPF_SYSCALL*/
+
#define BPF_PRELOAD_LINKS 2
#endif
diff --git a/kernel/bpf/inode.c b/kernel/bpf/inode.c
index 4f841e16779e..1f2d468abf58 100644
--- a/kernel/bpf/inode.c
+++ b/kernel/bpf/inode.c
@@ -20,7 +20,7 @@
#include <linux/filter.h>
#include <linux/bpf.h>
#include <linux/bpf_trace.h>
-#include "preload/bpf_preload.h"
+#include <linux/bpf_preload.h>
enum bpf_type {
BPF_TYPE_UNSPEC = 0,
diff --git a/kernel/bpf/preload/bpf_preload_kern.c b/kernel/bpf/preload/bpf_preload_kern.c
index 5106b5372f0c..f43391d1c49c 100644
--- a/kernel/bpf/preload/bpf_preload_kern.c
+++ b/kernel/bpf/preload/bpf_preload_kern.c
@@ -2,7 +2,7 @@
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
#include <linux/init.h>
#include <linux/module.h>
-#include "bpf_preload.h"
+#include <linux/bpf_preload.h>
#include "iterators/iterators.lskel.h"
static struct bpf_link *maps_link, *progs_link;
--
2.32.0
More information about the Linux-security-module-archive
mailing list