Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Daniel Borkmann and committed by
David S. Miller
082739aa b48732e4

+2
+2
tools/net/bpf_jit_disasm.c
··· 123 123 assert(ret == 0); 124 124 125 125 ptr = haystack; 126 + memset(pmatch, 0, sizeof(pmatch)); 127 + 126 128 while (1) { 127 129 ret = regexec(&regex, ptr, 1, pmatch, 0); 128 130 if (ret == 0) {