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/bpf_jit.c2
-rw-r--r--arch/powerpc/net/bpf_jit_comp.c2
-rw-r--r--arch/s390/net/bpf_jit_comp.c2
-rw-r--r--arch/sparc/net/bpf_jit_comp.c2
-rw-r--r--arch/x86/net/bpf_jit_comp.c2
-rw-r--r--include/linux/filter.h6
-rw-r--r--kernel/bpf/core.c4
-rw-r--r--kernel/bpf/syscall.c4
-rw-r--r--net/core/filter.c2
11 files changed, 18 insertions, 12 deletions
diff --git a/arch/arm/net/bpf_jit_32.c b/arch/arm/net/bpf_jit_32.c
index 876060bcceeb..0df5fd561513 100644
--- a/arch/arm/net/bpf_jit_32.c
+++ b/arch/arm/net/bpf_jit_32.c
@@ -1047,7 +1047,7 @@ void bpf_jit_compile(struct bpf_prog *fp)
1047 1047
1048 set_memory_ro((unsigned long)header, header->pages); 1048 set_memory_ro((unsigned long)header, header->pages);
1049 fp->bpf_func = (void *)ctx.target; 1049 fp->bpf_func = (void *)ctx.target;
1050 fp->jited = true; 1050 fp->jited = 1;
1051out: 1051out:
1052 kfree(ctx.offsets); 1052 kfree(ctx.offsets);
1053 return; 1053 return;
diff --git a/arch/arm64/net/bpf_jit_comp.c b/arch/arm64/net/bpf_jit_comp.c
index c047598b09e0..a44e5293c6f5 100644
--- a/arch/arm64/net/bpf_jit_comp.c
+++ b/arch/arm64/net/bpf_jit_comp.c
@@ -744,7 +744,7 @@ void bpf_int_jit_compile(struct bpf_prog *prog)
744 744
745 set_memory_ro((unsigned long)header, header->pages); 745 set_memory_ro((unsigned long)header, header->pages);
746 prog->bpf_func = (void *)ctx.image; 746 prog->bpf_func = (void *)ctx.image;
747 prog->jited = true; 747 prog->jited = 1;
748out: 748out:
749 kfree(ctx.offset); 749 kfree(ctx.offset);
750} 750}
diff --git a/arch/mips/net/bpf_jit.c b/arch/mips/net/bpf_jit.c
index 0c4a133f6216..77cb27309db2 100644
--- a/arch/mips/net/bpf_jit.c
+++ b/arch/mips/net/bpf_jit.c
@@ -1251,7 +1251,7 @@ void bpf_jit_compile(struct bpf_prog *fp)
1251 bpf_jit_dump(fp->len, alloc_size, 2, ctx.target); 1251 bpf_jit_dump(fp->len, alloc_size, 2, ctx.target);
1252 1252
1253 fp->bpf_func = (void *)ctx.target; 1253 fp->bpf_func = (void *)ctx.target;
1254 fp->jited = true; 1254 fp->jited = 1;
1255 1255
1256out: 1256out:
1257 kfree(ctx.offsets); 1257 kfree(ctx.offsets);
diff --git a/arch/powerpc/net/bpf_jit_comp.c b/arch/powerpc/net/bpf_jit_comp.c
index 17cea18a09d3..04782164ee67 100644
--- a/arch/powerpc/net/bpf_jit_comp.c
+++ b/arch/powerpc/net/bpf_jit_comp.c
@@ -679,7 +679,7 @@ void bpf_jit_compile(struct bpf_prog *fp)
679 ((u64 *)image)[1] = local_paca->kernel_toc; 679 ((u64 *)image)[1] = local_paca->kernel_toc;
680#endif 680#endif
681 fp->bpf_func = (void *)image; 681 fp->bpf_func = (void *)image;
682 fp->jited = true; 682 fp->jited = 1;
683 } 683 }
684out: 684out:
685 kfree(addrs); 685 kfree(addrs);
diff --git a/arch/s390/net/bpf_jit_comp.c b/arch/s390/net/bpf_jit_comp.c
index eeda051442c3..9a0c4c22e536 100644
--- a/arch/s390/net/bpf_jit_comp.c
+++ b/arch/s390/net/bpf_jit_comp.c
@@ -1310,7 +1310,7 @@ void bpf_int_jit_compile(struct bpf_prog *fp)
1310 if (jit.prg_buf) { 1310 if (jit.prg_buf) {
1311 set_memory_ro((unsigned long)header, header->pages); 1311 set_memory_ro((unsigned long)header, header->pages);
1312 fp->bpf_func = (void *) jit.prg_buf; 1312 fp->bpf_func = (void *) jit.prg_buf;
1313 fp->jited = true; 1313 fp->jited = 1;
1314 } 1314 }
1315free_addrs: 1315free_addrs:
1316 kfree(jit.addrs); 1316 kfree(jit.addrs);
diff --git a/arch/sparc/net/bpf_jit_comp.c b/arch/sparc/net/bpf_jit_comp.c
index f8b9f71b9a2b..22564f5f2364 100644
--- a/arch/sparc/net/bpf_jit_comp.c
+++ b/arch/sparc/net/bpf_jit_comp.c
@@ -812,7 +812,7 @@ cond_branch: f_offset = addrs[i + filter[i].jf];
812 if (image) { 812 if (image) {
813 bpf_flush_icache(image, image + proglen); 813 bpf_flush_icache(image, image + proglen);
814 fp->bpf_func = (void *)image; 814 fp->bpf_func = (void *)image;
815 fp->jited = true; 815 fp->jited = 1;
816 } 816 }
817out: 817out:
818 kfree(addrs); 818 kfree(addrs);
diff --git a/arch/x86/net/bpf_jit_comp.c b/arch/x86/net/bpf_jit_comp.c
index 70efcd0940f9..75991979f667 100644
--- a/arch/x86/net/bpf_jit_comp.c
+++ b/arch/x86/net/bpf_jit_comp.c
@@ -1109,7 +1109,7 @@ void bpf_int_jit_compile(struct bpf_prog *prog)
1109 bpf_flush_icache(header, image + proglen); 1109 bpf_flush_icache(header, image + proglen);
1110 set_memory_ro((unsigned long)header, header->pages); 1110 set_memory_ro((unsigned long)header, header->pages);
1111 prog->bpf_func = (void *)image; 1111 prog->bpf_func = (void *)image;
1112 prog->jited = true; 1112 prog->jited = 1;
1113 } 1113 }
1114out: 1114out:
1115 kfree(addrs); 1115 kfree(addrs);
diff --git a/include/linux/filter.h b/include/linux/filter.h
index fa2cab985e57..bad618f316d7 100644
--- a/include/linux/filter.h
+++ b/include/linux/filter.h
@@ -326,8 +326,10 @@ struct bpf_binary_header {
326 326
327struct bpf_prog { 327struct bpf_prog {
328 u16 pages; /* Number of allocated pages */ 328 u16 pages; /* Number of allocated pages */
329 bool jited; /* Is our filter JIT'ed? */ 329 kmemcheck_bitfield_begin(meta);
330 bool gpl_compatible; /* Is our filter GPL compatible? */ 330 u16 jited:1, /* Is our filter JIT'ed? */
331 gpl_compatible:1; /* Is filter GPL compatible? */
332 kmemcheck_bitfield_end(meta);
331 u32 len; /* Number of filter blocks */ 333 u32 len; /* Number of filter blocks */
332 enum bpf_prog_type type; /* Type of BPF program */ 334 enum bpf_prog_type type; /* Type of BPF program */
333 struct bpf_prog_aux *aux; /* Auxiliary fields */ 335 struct bpf_prog_aux *aux; /* Auxiliary fields */
diff --git a/kernel/bpf/core.c b/kernel/bpf/core.c
index 67c380cfa9ca..c8855c2a7a48 100644
--- a/kernel/bpf/core.c
+++ b/kernel/bpf/core.c
@@ -82,6 +82,8 @@ struct bpf_prog *bpf_prog_alloc(unsigned int size, gfp_t gfp_extra_flags)
82 if (fp == NULL) 82 if (fp == NULL)
83 return NULL; 83 return NULL;
84 84
85 kmemcheck_annotate_bitfield(fp, meta);
86
85 aux = kzalloc(sizeof(*aux), GFP_KERNEL | gfp_extra_flags); 87 aux = kzalloc(sizeof(*aux), GFP_KERNEL | gfp_extra_flags);
86 if (aux == NULL) { 88 if (aux == NULL) {
87 vfree(fp); 89 vfree(fp);
@@ -110,6 +112,8 @@ struct bpf_prog *bpf_prog_realloc(struct bpf_prog *fp_old, unsigned int size,
110 112
111 fp = __vmalloc(size, gfp_flags, PAGE_KERNEL); 113 fp = __vmalloc(size, gfp_flags, PAGE_KERNEL);
112 if (fp != NULL) { 114 if (fp != NULL) {
115 kmemcheck_annotate_bitfield(fp, meta);
116
113 memcpy(fp, fp_old, fp_old->pages * PAGE_SIZE); 117 memcpy(fp, fp_old, fp_old->pages * PAGE_SIZE);
114 fp->pages = size / PAGE_SIZE; 118 fp->pages = size / PAGE_SIZE;
115 119
diff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c
index 35bac8e8b071..2190ab14b763 100644
--- a/kernel/bpf/syscall.c
+++ b/kernel/bpf/syscall.c
@@ -553,10 +553,10 @@ static int bpf_prog_load(union bpf_attr *attr)
553 goto free_prog; 553 goto free_prog;
554 554
555 prog->orig_prog = NULL; 555 prog->orig_prog = NULL;
556 prog->jited = false; 556 prog->jited = 0;
557 557
558 atomic_set(&prog->aux->refcnt, 1); 558 atomic_set(&prog->aux->refcnt, 1);
559 prog->gpl_compatible = is_gpl; 559 prog->gpl_compatible = is_gpl ? 1 : 0;
560 560
561 /* find program type: socket_filter vs tracing_filter */ 561 /* find program type: socket_filter vs tracing_filter */
562 err = find_prog_type(type, prog); 562 err = find_prog_type(type, prog);
diff --git a/net/core/filter.c b/net/core/filter.c
index 60e3fe7c59c0..04664acb86ce 100644
--- a/net/core/filter.c
+++ b/net/core/filter.c
@@ -1001,7 +1001,7 @@ static struct bpf_prog *bpf_prepare_filter(struct bpf_prog *fp,
1001 int err; 1001 int err;
1002 1002
1003 fp->bpf_func = NULL; 1003 fp->bpf_func = NULL;
1004 fp->jited = false; 1004 fp->jited = 0;
1005 1005
1006 err = bpf_check_classic(fp->insns, fp->len); 1006 err = bpf_check_classic(fp->insns, fp->len);
1007 if (err) { 1007 if (err) {