Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 286aad3c authored by Daniel Borkmann's avatar Daniel Borkmann Committed by David S. Miller
Browse files

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: default avatarMikulas Patocka <mpatocka@redhat.com>
Signed-off-by: default avatarDaniel Borkmann <dborkman@redhat.com>
Acked-by: default avatarAlexei Starovoitov <ast@plumgrid.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 55309dd3
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -933,7 +933,7 @@ void bpf_jit_compile(struct bpf_prog *fp)

	set_memory_ro((unsigned long)header, header->pages);
	fp->bpf_func = (void *)ctx.target;
	fp->jited = 1;
	fp->jited = true;
out:
	kfree(ctx.offsets);
	return;
+1 −1
Original line number Diff line number Diff line
@@ -1417,7 +1417,7 @@ void bpf_jit_compile(struct bpf_prog *fp)
		bpf_jit_dump(fp->len, alloc_size, 2, ctx.target);

	fp->bpf_func = (void *)ctx.target;
	fp->jited = 1;
	fp->jited = true;

out:
	kfree(ctx.offsets);
+1 −1
Original line number Diff line number Diff line
@@ -686,7 +686,7 @@ void bpf_jit_compile(struct bpf_prog *fp)
		((u64 *)image)[0] = (u64)code_base;
		((u64 *)image)[1] = local_paca->kernel_toc;
		fp->bpf_func = (void *)image;
		fp->jited = 1;
		fp->jited = true;
	}
out:
	kfree(addrs);
+1 −1
Original line number Diff line number Diff line
@@ -842,7 +842,7 @@ void bpf_jit_compile(struct bpf_prog *fp)
	if (jit.start) {
		set_memory_ro((unsigned long)header, header->pages);
		fp->bpf_func = (void *) jit.start;
		fp->jited = 1;
		fp->jited = true;
	}
out:
	kfree(addrs);
+1 −1
Original line number Diff line number Diff line
@@ -801,7 +801,7 @@ cond_branch: f_offset = addrs[i + filter[i].jf];
	if (image) {
		bpf_flush_icache(image, image + proglen);
		fp->bpf_func = (void *)image;
		fp->jited = 1;
		fp->jited = true;
	}
out:
	kfree(addrs);
Loading