aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--arch/arm/net/bpf_jit_32.c2
-rw-r--r--arch/arm64/net/bpf_jit_comp.c2
-rw-r--r--arch/mips/net/ebpf_jit.c2
-rw-r--r--arch/powerpc/net/bpf_jit_comp64.c2
-rw-r--r--arch/s390/net/bpf_jit_comp.c2
-rw-r--r--arch/sparc/net/bpf_jit_comp_64.c2
-rw-r--r--arch/x86/net/bpf_jit_comp.c2
-rw-r--r--include/linux/filter.h5
-rw-r--r--kernel/bpf/core.c3
-rw-r--r--kernel/bpf/verifier.c2
10 files changed, 13 insertions, 11 deletions
diff --git a/arch/arm/net/bpf_jit_32.c b/arch/arm/net/bpf_jit_32.c
index c199990e12b6..4425189bb24c 100644
--- a/arch/arm/net/bpf_jit_32.c
+++ b/arch/arm/net/bpf_jit_32.c
@@ -1824,7 +1824,7 @@ struct bpf_prog *bpf_int_jit_compile(struct bpf_prog *prog)
1824 /* If BPF JIT was not enabled then we must fall back to 1824 /* If BPF JIT was not enabled then we must fall back to
1825 * the interpreter. 1825 * the interpreter.
1826 */ 1826 */
1827 if (!bpf_jit_enable) 1827 if (!prog->jit_requested)
1828 return orig_prog; 1828 return orig_prog;
1829 1829
1830 /* If constant blinding was enabled and we failed during blinding 1830 /* If constant blinding was enabled and we failed during blinding
diff --git a/arch/arm64/net/bpf_jit_comp.c b/arch/arm64/net/bpf_jit_comp.c
index ba38d403abb2..288137cb0871 100644
--- a/arch/arm64/net/bpf_jit_comp.c
+++ b/arch/arm64/net/bpf_jit_comp.c
@@ -844,7 +844,7 @@ struct bpf_prog *bpf_int_jit_compile(struct bpf_prog *prog)
844 int image_size; 844 int image_size;
845 u8 *image_ptr; 845 u8 *image_ptr;
846 846
847 if (!bpf_jit_enable) 847 if (!prog->jit_requested)
848 return orig_prog; 848 return orig_prog;
849 849
850 tmp = bpf_jit_blind_constants(prog); 850 tmp = bpf_jit_blind_constants(prog);
diff --git a/arch/mips/net/ebpf_jit.c b/arch/mips/net/ebpf_jit.c
index 962b0259b4b6..97069a1b6f43 100644
--- a/arch/mips/net/ebpf_jit.c
+++ b/arch/mips/net/ebpf_jit.c
@@ -1869,7 +1869,7 @@ struct bpf_prog *bpf_int_jit_compile(struct bpf_prog *prog)
1869 unsigned int image_size; 1869 unsigned int image_size;
1870 u8 *image_ptr; 1870 u8 *image_ptr;
1871 1871
1872 if (!bpf_jit_enable || !cpu_has_mips64r2) 1872 if (!prog->jit_requested || !cpu_has_mips64r2)
1873 return prog; 1873 return prog;
1874 1874
1875 tmp = bpf_jit_blind_constants(prog); 1875 tmp = bpf_jit_blind_constants(prog);
diff --git a/arch/powerpc/net/bpf_jit_comp64.c b/arch/powerpc/net/bpf_jit_comp64.c
index 46d74e81aff1..d5a5bc43cf8f 100644
--- a/arch/powerpc/net/bpf_jit_comp64.c
+++ b/arch/powerpc/net/bpf_jit_comp64.c
@@ -993,7 +993,7 @@ struct bpf_prog *bpf_int_jit_compile(struct bpf_prog *fp)
993 struct bpf_prog *tmp_fp; 993 struct bpf_prog *tmp_fp;
994 bool bpf_blinded = false; 994 bool bpf_blinded = false;
995 995
996 if (!bpf_jit_enable) 996 if (!fp->jit_requested)
997 return org_fp; 997 return org_fp;
998 998
999 tmp_fp = bpf_jit_blind_constants(org_fp); 999 tmp_fp = bpf_jit_blind_constants(org_fp);
diff --git a/arch/s390/net/bpf_jit_comp.c b/arch/s390/net/bpf_jit_comp.c
index e81c16838b90..f4baa8c514d3 100644
--- a/arch/s390/net/bpf_jit_comp.c
+++ b/arch/s390/net/bpf_jit_comp.c
@@ -1300,7 +1300,7 @@ struct bpf_prog *bpf_int_jit_compile(struct bpf_prog *fp)
1300 struct bpf_jit jit; 1300 struct bpf_jit jit;
1301 int pass; 1301 int pass;
1302 1302
1303 if (!bpf_jit_enable) 1303 if (!fp->jit_requested)
1304 return orig_fp; 1304 return orig_fp;
1305 1305
1306 tmp = bpf_jit_blind_constants(fp); 1306 tmp = bpf_jit_blind_constants(fp);
diff --git a/arch/sparc/net/bpf_jit_comp_64.c b/arch/sparc/net/bpf_jit_comp_64.c
index 5765e7e711f7..a2f1b5e774a7 100644
--- a/arch/sparc/net/bpf_jit_comp_64.c
+++ b/arch/sparc/net/bpf_jit_comp_64.c
@@ -1517,7 +1517,7 @@ struct bpf_prog *bpf_int_jit_compile(struct bpf_prog *prog)
1517 u8 *image_ptr; 1517 u8 *image_ptr;
1518 int pass; 1518 int pass;
1519 1519
1520 if (!bpf_jit_enable) 1520 if (!prog->jit_requested)
1521 return orig_prog; 1521 return orig_prog;
1522 1522
1523 tmp = bpf_jit_blind_constants(prog); 1523 tmp = bpf_jit_blind_constants(prog);
diff --git a/arch/x86/net/bpf_jit_comp.c b/arch/x86/net/bpf_jit_comp.c
index 0554e8aef4d5..68859b58ab84 100644
--- a/arch/x86/net/bpf_jit_comp.c
+++ b/arch/x86/net/bpf_jit_comp.c
@@ -1121,7 +1121,7 @@ struct bpf_prog *bpf_int_jit_compile(struct bpf_prog *prog)
1121 int pass; 1121 int pass;
1122 int i; 1122 int i;
1123 1123
1124 if (!bpf_jit_enable) 1124 if (!prog->jit_requested)
1125 return orig_prog; 1125 return orig_prog;
1126 1126
1127 tmp = bpf_jit_blind_constants(prog); 1127 tmp = bpf_jit_blind_constants(prog);
diff --git a/include/linux/filter.h b/include/linux/filter.h
index f26e6da1007b..3d6edc34932c 100644
--- a/include/linux/filter.h
+++ b/include/linux/filter.h
@@ -458,6 +458,7 @@ struct bpf_binary_header {
458struct bpf_prog { 458struct bpf_prog {
459 u16 pages; /* Number of allocated pages */ 459 u16 pages; /* Number of allocated pages */
460 u16 jited:1, /* Is our filter JIT'ed? */ 460 u16 jited:1, /* Is our filter JIT'ed? */
461 jit_requested:1,/* archs need to JIT the prog */
461 locked:1, /* Program image locked? */ 462 locked:1, /* Program image locked? */
462 gpl_compatible:1, /* Is filter GPL compatible? */ 463 gpl_compatible:1, /* Is filter GPL compatible? */
463 cb_access:1, /* Is control block accessed? */ 464 cb_access:1, /* Is control block accessed? */
@@ -804,7 +805,7 @@ static inline bool bpf_prog_ebpf_jited(const struct bpf_prog *fp)
804 return fp->jited && bpf_jit_is_ebpf(); 805 return fp->jited && bpf_jit_is_ebpf();
805} 806}
806 807
807static inline bool bpf_jit_blinding_enabled(void) 808static inline bool bpf_jit_blinding_enabled(struct bpf_prog *prog)
808{ 809{
809 /* These are the prerequisites, should someone ever have the 810 /* These are the prerequisites, should someone ever have the
810 * idea to call blinding outside of them, we make sure to 811 * idea to call blinding outside of them, we make sure to
@@ -812,7 +813,7 @@ static inline bool bpf_jit_blinding_enabled(void)
812 */ 813 */
813 if (!bpf_jit_is_ebpf()) 814 if (!bpf_jit_is_ebpf())
814 return false; 815 return false;
815 if (!bpf_jit_enable) 816 if (!prog->jit_requested)
816 return false; 817 return false;
817 if (!bpf_jit_harden) 818 if (!bpf_jit_harden)
818 return false; 819 return false;
diff --git a/kernel/bpf/core.c b/kernel/bpf/core.c
index dc12c4fd006e..bda911644b1c 100644
--- a/kernel/bpf/core.c
+++ b/kernel/bpf/core.c
@@ -94,6 +94,7 @@ struct bpf_prog *bpf_prog_alloc(unsigned int size, gfp_t gfp_extra_flags)
94 fp->pages = size / PAGE_SIZE; 94 fp->pages = size / PAGE_SIZE;
95 fp->aux = aux; 95 fp->aux = aux;
96 fp->aux->prog = fp; 96 fp->aux->prog = fp;
97 fp->jit_requested = ebpf_jit_enabled();
97 98
98 INIT_LIST_HEAD_RCU(&fp->aux->ksym_lnode); 99 INIT_LIST_HEAD_RCU(&fp->aux->ksym_lnode);
99 100
@@ -721,7 +722,7 @@ struct bpf_prog *bpf_jit_blind_constants(struct bpf_prog *prog)
721 struct bpf_insn *insn; 722 struct bpf_insn *insn;
722 int i, rewritten; 723 int i, rewritten;
723 724
724 if (!bpf_jit_blinding_enabled()) 725 if (!bpf_jit_blinding_enabled(prog))
725 return prog; 726 return prog;
726 727
727 clone = bpf_prog_clone_create(prog, GFP_USER); 728 clone = bpf_prog_clone_create(prog, GFP_USER);
diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c
index cdc1f043c69b..8e0e4cd0d5e4 100644
--- a/kernel/bpf/verifier.c
+++ b/kernel/bpf/verifier.c
@@ -5080,7 +5080,7 @@ static int fixup_bpf_calls(struct bpf_verifier_env *env)
5080 /* BPF_EMIT_CALL() assumptions in some of the map_gen_lookup 5080 /* BPF_EMIT_CALL() assumptions in some of the map_gen_lookup
5081 * handlers are currently limited to 64 bit only. 5081 * handlers are currently limited to 64 bit only.
5082 */ 5082 */
5083 if (ebpf_jit_enabled() && BITS_PER_LONG == 64 && 5083 if (prog->jit_requested && BITS_PER_LONG == 64 &&
5084 insn->imm == BPF_FUNC_map_lookup_elem) { 5084 insn->imm == BPF_FUNC_map_lookup_elem) {
5085 map_ptr = env->insn_aux_data[i + delta].map_ptr; 5085 map_ptr = env->insn_aux_data[i + delta].map_ptr;
5086 if (map_ptr == BPF_MAP_PTR_POISON || 5086 if (map_ptr == BPF_MAP_PTR_POISON ||