diff options
-rw-r--r-- | net/bpfilter/Makefile | 17 | ||||
-rw-r--r-- | net/bpfilter/bpfilter_kern.c | 11 | ||||
-rw-r--r-- | net/bpfilter/bpfilter_umh_blob.S | 7 |
3 files changed, 14 insertions, 21 deletions
diff --git a/net/bpfilter/Makefile b/net/bpfilter/Makefile index 051dc18b8ccb..39c6980b5d99 100644 --- a/net/bpfilter/Makefile +++ b/net/bpfilter/Makefile | |||
@@ -15,20 +15,7 @@ ifeq ($(CONFIG_BPFILTER_UMH), y) | |||
15 | HOSTLDFLAGS += -static | 15 | HOSTLDFLAGS += -static |
16 | endif | 16 | endif |
17 | 17 | ||
18 | # a bit of elf magic to convert bpfilter_umh binary into a binary blob | 18 | $(obj)/bpfilter_umh_blob.o: $(obj)/bpfilter_umh |
19 | # inside bpfilter_umh.o elf file referenced by | ||
20 | # _binary_net_bpfilter_bpfilter_umh_start symbol | ||
21 | # which bpfilter_kern.c passes further into umh blob loader at run-time | ||
22 | quiet_cmd_copy_umh = GEN $@ | ||
23 | cmd_copy_umh = echo ':' > $(obj)/.bpfilter_umh.o.cmd; \ | ||
24 | $(OBJCOPY) -I binary \ | ||
25 | `LC_ALL=C $(OBJDUMP) -f net/bpfilter/bpfilter_umh \ | ||
26 | |awk -F' |,' '/file format/{print "-O",$$NF} \ | ||
27 | /^architecture:/{print "-B",$$2}'` \ | ||
28 | --rename-section .data=.init.rodata $< $@ | ||
29 | |||
30 | $(obj)/bpfilter_umh.o: $(obj)/bpfilter_umh | ||
31 | $(call cmd,copy_umh) | ||
32 | 19 | ||
33 | obj-$(CONFIG_BPFILTER_UMH) += bpfilter.o | 20 | obj-$(CONFIG_BPFILTER_UMH) += bpfilter.o |
34 | bpfilter-objs += bpfilter_kern.o bpfilter_umh.o | 21 | bpfilter-objs += bpfilter_kern.o bpfilter_umh_blob.o |
diff --git a/net/bpfilter/bpfilter_kern.c b/net/bpfilter/bpfilter_kern.c index 09522573f611..f0fc182d3db7 100644 --- a/net/bpfilter/bpfilter_kern.c +++ b/net/bpfilter/bpfilter_kern.c | |||
@@ -10,11 +10,8 @@ | |||
10 | #include <linux/file.h> | 10 | #include <linux/file.h> |
11 | #include "msgfmt.h" | 11 | #include "msgfmt.h" |
12 | 12 | ||
13 | #define UMH_start _binary_net_bpfilter_bpfilter_umh_start | 13 | extern char bpfilter_umh_start; |
14 | #define UMH_end _binary_net_bpfilter_bpfilter_umh_end | 14 | extern char bpfilter_umh_end; |
15 | |||
16 | extern char UMH_start; | ||
17 | extern char UMH_end; | ||
18 | 15 | ||
19 | static struct umh_info info; | 16 | static struct umh_info info; |
20 | /* since ip_getsockopt() can run in parallel, serialize access to umh */ | 17 | /* since ip_getsockopt() can run in parallel, serialize access to umh */ |
@@ -93,7 +90,9 @@ static int __init load_umh(void) | |||
93 | int err; | 90 | int err; |
94 | 91 | ||
95 | /* fork usermode process */ | 92 | /* fork usermode process */ |
96 | err = fork_usermode_blob(&UMH_start, &UMH_end - &UMH_start, &info); | 93 | err = fork_usermode_blob(&bpfilter_umh_start, |
94 | &bpfilter_umh_end - &bpfilter_umh_start, | ||
95 | &info); | ||
97 | if (err) | 96 | if (err) |
98 | return err; | 97 | return err; |
99 | pr_info("Loaded bpfilter_umh pid %d\n", info.pid); | 98 | pr_info("Loaded bpfilter_umh pid %d\n", info.pid); |
diff --git a/net/bpfilter/bpfilter_umh_blob.S b/net/bpfilter/bpfilter_umh_blob.S new file mode 100644 index 000000000000..40311d10d2f2 --- /dev/null +++ b/net/bpfilter/bpfilter_umh_blob.S | |||
@@ -0,0 +1,7 @@ | |||
1 | /* SPDX-License-Identifier: GPL-2.0 */ | ||
2 | .section .init.rodata, "a" | ||
3 | .global bpfilter_umh_start | ||
4 | bpfilter_umh_start: | ||
5 | .incbin "net/bpfilter/bpfilter_umh" | ||
6 | .global bpfilter_umh_end | ||
7 | bpfilter_umh_end: | ||