Skip to content

Commit

Permalink
tools: bpf_jit_disasm: fix segfault on disabled debugging log output
Browse files Browse the repository at this point in the history
With recent debugging, I noticed that bpf_jit_disasm segfaults when
there's no debugging output from the JIT compiler to the kernel log.

Reason is that when regexec(3) doesn't match on anything, start/end
offsets are not being filled out and contain some uninitialized garbage
from stack. Thus, we need zero out offsets first.

Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Daniel Borkmann authored and David S. Miller committed May 27, 2015
1 parent b48732e commit 082739a
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions tools/net/bpf_jit_disasm.c
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,8 @@ static int get_last_jit_image(char *haystack, size_t hlen,
assert(ret == 0);

ptr = haystack;
memset(pmatch, 0, sizeof(pmatch));

while (1) {
ret = regexec(&regex, ptr, 1, pmatch, 0);
if (ret == 0) {
Expand Down

0 comments on commit 082739a

Please sign in to comment.