diff options
author | Daniel Borkmann <dborkman@redhat.com> | 2014-09-08 02:04:49 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2014-09-09 19:58:56 -0400 |
commit | 286aad3c4014ca825c447e07e24f8929e6d266d2 (patch) | |
tree | 50f1a085ddd7923b2b3c2764c850d0c02447d32a | |
parent | 55309dd3d4cd7420376a3de0526d6ed24ff8fa76 (diff) |
net: bpf: be friendly to kmemcheck
Reported by Mikulas Patocka, kmemcheck currently barks out a
false positive since we don't have special kmemcheck annotation
for bitfields used in bpf_prog structure.
We currently have jited:1, len:31 and thus when accessing len
while CONFIG_KMEMCHECK enabled, kmemcheck throws a warning that
we're reading uninitialized memory.
As we don't need the whole bit universe for pages member, we
can just split it to u16 and use a bool flag for jited instead
of a bitfield.
Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
Signed-off-by: Daniel Borkmann <dborkman@redhat.com>
Acked-by: Alexei Starovoitov <ast@plumgrid.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | arch/arm/net/bpf_jit_32.c | 2 | ||||
-rw-r--r-- | arch/mips/net/bpf_jit.c | 2 | ||||
-rw-r--r-- | arch/powerpc/net/bpf_jit_comp.c | 2 | ||||
-rw-r--r-- | arch/s390/net/bpf_jit_comp.c | 2 | ||||
-rw-r--r-- | arch/sparc/net/bpf_jit_comp.c | 2 | ||||
-rw-r--r-- | arch/x86/net/bpf_jit_comp.c | 2 | ||||
-rw-r--r-- | include/linux/filter.h | 6 | ||||
-rw-r--r-- | net/core/filter.c | 2 |
8 files changed, 10 insertions, 10 deletions
diff --git a/arch/arm/net/bpf_jit_32.c b/arch/arm/net/bpf_jit_32.c index 2d1a5b93d91c..6b45f649eff0 100644 --- a/arch/arm/net/bpf_jit_32.c +++ b/arch/arm/net/bpf_jit_32.c | |||
@@ -933,7 +933,7 @@ void bpf_jit_compile(struct bpf_prog *fp) | |||
933 | 933 | ||
934 | set_memory_ro((unsigned long)header, header->pages); | 934 | set_memory_ro((unsigned long)header, header->pages); |
935 | fp->bpf_func = (void *)ctx.target; | 935 | fp->bpf_func = (void *)ctx.target; |
936 | fp->jited = 1; | 936 | fp->jited = true; |
937 | out: | 937 | out: |
938 | kfree(ctx.offsets); | 938 | kfree(ctx.offsets); |
939 | return; | 939 | return; |
diff --git a/arch/mips/net/bpf_jit.c b/arch/mips/net/bpf_jit.c index cfa83cf2447d..0e97ccd29fe3 100644 --- a/arch/mips/net/bpf_jit.c +++ b/arch/mips/net/bpf_jit.c | |||
@@ -1417,7 +1417,7 @@ void bpf_jit_compile(struct bpf_prog *fp) | |||
1417 | bpf_jit_dump(fp->len, alloc_size, 2, ctx.target); | 1417 | bpf_jit_dump(fp->len, alloc_size, 2, ctx.target); |
1418 | 1418 | ||
1419 | fp->bpf_func = (void *)ctx.target; | 1419 | fp->bpf_func = (void *)ctx.target; |
1420 | fp->jited = 1; | 1420 | fp->jited = true; |
1421 | 1421 | ||
1422 | out: | 1422 | out: |
1423 | kfree(ctx.offsets); | 1423 | kfree(ctx.offsets); |
diff --git a/arch/powerpc/net/bpf_jit_comp.c b/arch/powerpc/net/bpf_jit_comp.c index 40c53ff59124..cbae2dfd053c 100644 --- a/arch/powerpc/net/bpf_jit_comp.c +++ b/arch/powerpc/net/bpf_jit_comp.c | |||
@@ -686,7 +686,7 @@ void bpf_jit_compile(struct bpf_prog *fp) | |||
686 | ((u64 *)image)[0] = (u64)code_base; | 686 | ((u64 *)image)[0] = (u64)code_base; |
687 | ((u64 *)image)[1] = local_paca->kernel_toc; | 687 | ((u64 *)image)[1] = local_paca->kernel_toc; |
688 | fp->bpf_func = (void *)image; | 688 | fp->bpf_func = (void *)image; |
689 | fp->jited = 1; | 689 | fp->jited = true; |
690 | } | 690 | } |
691 | out: | 691 | out: |
692 | kfree(addrs); | 692 | kfree(addrs); |
diff --git a/arch/s390/net/bpf_jit_comp.c b/arch/s390/net/bpf_jit_comp.c index b734f975c22e..555f5c7e83ab 100644 --- a/arch/s390/net/bpf_jit_comp.c +++ b/arch/s390/net/bpf_jit_comp.c | |||
@@ -842,7 +842,7 @@ void bpf_jit_compile(struct bpf_prog *fp) | |||
842 | if (jit.start) { | 842 | if (jit.start) { |
843 | set_memory_ro((unsigned long)header, header->pages); | 843 | set_memory_ro((unsigned long)header, header->pages); |
844 | fp->bpf_func = (void *) jit.start; | 844 | fp->bpf_func = (void *) jit.start; |
845 | fp->jited = 1; | 845 | fp->jited = true; |
846 | } | 846 | } |
847 | out: | 847 | out: |
848 | kfree(addrs); | 848 | kfree(addrs); |
diff --git a/arch/sparc/net/bpf_jit_comp.c b/arch/sparc/net/bpf_jit_comp.c index f7a736b645e8..b2ad9dc5425e 100644 --- a/arch/sparc/net/bpf_jit_comp.c +++ b/arch/sparc/net/bpf_jit_comp.c | |||
@@ -801,7 +801,7 @@ cond_branch: f_offset = addrs[i + filter[i].jf]; | |||
801 | if (image) { | 801 | if (image) { |
802 | bpf_flush_icache(image, image + proglen); | 802 | bpf_flush_icache(image, image + proglen); |
803 | fp->bpf_func = (void *)image; | 803 | fp->bpf_func = (void *)image; |
804 | fp->jited = 1; | 804 | fp->jited = true; |
805 | } | 805 | } |
806 | out: | 806 | out: |
807 | kfree(addrs); | 807 | kfree(addrs); |
diff --git a/arch/x86/net/bpf_jit_comp.c b/arch/x86/net/bpf_jit_comp.c index 9de0b5476b0c..d56cd1f515bd 100644 --- a/arch/x86/net/bpf_jit_comp.c +++ b/arch/x86/net/bpf_jit_comp.c | |||
@@ -955,7 +955,7 @@ void bpf_int_jit_compile(struct bpf_prog *prog) | |||
955 | bpf_flush_icache(header, image + proglen); | 955 | bpf_flush_icache(header, image + proglen); |
956 | set_memory_ro((unsigned long)header, header->pages); | 956 | set_memory_ro((unsigned long)header, header->pages); |
957 | prog->bpf_func = (void *)image; | 957 | prog->bpf_func = (void *)image; |
958 | prog->jited = 1; | 958 | prog->jited = true; |
959 | } | 959 | } |
960 | out: | 960 | out: |
961 | kfree(addrs); | 961 | kfree(addrs); |
diff --git a/include/linux/filter.h b/include/linux/filter.h index 868764fcffb8..4b59edead908 100644 --- a/include/linux/filter.h +++ b/include/linux/filter.h | |||
@@ -300,9 +300,9 @@ struct bpf_work_struct { | |||
300 | }; | 300 | }; |
301 | 301 | ||
302 | struct bpf_prog { | 302 | struct bpf_prog { |
303 | u32 pages; /* Number of allocated pages */ | 303 | u16 pages; /* Number of allocated pages */ |
304 | u32 jited:1, /* Is our filter JIT'ed? */ | 304 | bool jited; /* Is our filter JIT'ed? */ |
305 | len:31; /* Number of filter blocks */ | 305 | u32 len; /* Number of filter blocks */ |
306 | struct sock_fprog_kern *orig_prog; /* Original BPF program */ | 306 | struct sock_fprog_kern *orig_prog; /* Original BPF program */ |
307 | struct bpf_work_struct *work; /* Deferred free work struct */ | 307 | struct bpf_work_struct *work; /* Deferred free work struct */ |
308 | unsigned int (*bpf_func)(const struct sk_buff *skb, | 308 | unsigned int (*bpf_func)(const struct sk_buff *skb, |
diff --git a/net/core/filter.c b/net/core/filter.c index fa5b7d0f77ac..dfc716ffa44b 100644 --- a/net/core/filter.c +++ b/net/core/filter.c | |||
@@ -972,7 +972,7 @@ static struct bpf_prog *bpf_prepare_filter(struct bpf_prog *fp) | |||
972 | int err; | 972 | int err; |
973 | 973 | ||
974 | fp->bpf_func = NULL; | 974 | fp->bpf_func = NULL; |
975 | fp->jited = 0; | 975 | fp->jited = false; |
976 | 976 | ||
977 | err = bpf_check_classic(fp->insns, fp->len); | 977 | err = bpf_check_classic(fp->insns, fp->len); |
978 | if (err) { | 978 | if (err) { |