aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Borkmann <daniel@iogearbox.net>2015-05-25 08:08:03 -0400
committerDavid S. Miller <davem@davemloft.net>2015-05-27 00:24:10 -0400
commit082739aa458a74add9a2362988e5aca0367bfa53 (patch)
tree7c24faf20b3215347b95b569437261c51b36ae46
parentb48732e4a48d80ed4a14812f0bab09560846514e (diff)
tools: bpf_jit_disasm: fix segfault on disabled debugging log output
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>
-rw-r--r--tools/net/bpf_jit_disasm.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/tools/net/bpf_jit_disasm.c b/tools/net/bpf_jit_disasm.c
index c5baf9c591b7..618c2bcd4eab 100644
--- a/tools/net/bpf_jit_disasm.c
+++ b/tools/net/bpf_jit_disasm.c
@@ -123,6 +123,8 @@ static int get_last_jit_image(char *haystack, size_t hlen,
123 assert(ret == 0); 123 assert(ret == 0);
124 124
125 ptr = haystack; 125 ptr = haystack;
126 memset(pmatch, 0, sizeof(pmatch));
127
126 while (1) { 128 while (1) {
127 ret = regexec(&regex, ptr, 1, pmatch, 0); 129 ret = regexec(&regex, ptr, 1, pmatch, 0);
128 if (ret == 0) { 130 if (ret == 0) {