* [PATCH net-next 0/2] tools: bpf_jit_disasm: trivial fixes @ 2014-05-15 22:56 Alexei Starovoitov 2014-05-15 22:56 ` [PATCH net-next 1/2] tools: bpf_jit_disasm: ignore image address for disasm Alexei Starovoitov ` (2 more replies) 0 siblings, 3 replies; 6+ messages in thread From: Alexei Starovoitov @ 2014-05-15 22:56 UTC (permalink / raw) To: David S. Miller; +Cc: Daniel Borkmann, netdev Two trivial fixes for very useful bpf_jit_disasm tool Alexei Starovoitov (2): tools: bpf_jit_disasm: ignore image address for disasm tools: bpf_jit_disasm: increase image buffer size tools/net/bpf_jit_disasm.c | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) -- 1.7.9.5 ^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH net-next 1/2] tools: bpf_jit_disasm: ignore image address for disasm 2014-05-15 22:56 [PATCH net-next 0/2] tools: bpf_jit_disasm: trivial fixes Alexei Starovoitov @ 2014-05-15 22:56 ` Alexei Starovoitov 2014-05-16 9:34 ` Daniel Borkmann 2014-05-15 22:56 ` [PATCH net-next 2/2] tools: bpf_jit_disasm: increase image buffer size Alexei Starovoitov 2014-05-16 20:44 ` [PATCH net-next 0/2] tools: bpf_jit_disasm: trivial fixes David Miller 2 siblings, 1 reply; 6+ messages in thread From: Alexei Starovoitov @ 2014-05-15 22:56 UTC (permalink / raw) To: David S. Miller; +Cc: Daniel Borkmann, netdev seccomp filters use kernel JIT image addresses, so bpf_jit_enable=2 prints [ 20.146438] flen=3 proglen=82 pass=0 image=0000000000000000 [ 20.146442] JIT code: 00000000: 55 48 89 e5 48 81 ec 28 02 00 00 ... ignore image address, so that seccomp filters can be disassembled Signed-off-by: Alexei Starovoitov <ast@plumgrid.com> --- tools/net/bpf_jit_disasm.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/tools/net/bpf_jit_disasm.c b/tools/net/bpf_jit_disasm.c index cfe0cdcda3de..d9730c3319b9 100644 --- a/tools/net/bpf_jit_disasm.c +++ b/tools/net/bpf_jit_disasm.c @@ -43,8 +43,7 @@ static void get_exec_path(char *tpath, size_t size) free(path); } -static void get_asm_insns(uint8_t *image, size_t len, unsigned long base, - int opcodes) +static void get_asm_insns(uint8_t *image, size_t len, int opcodes) { int count, i, pc = 0; char tpath[256]; @@ -107,13 +106,13 @@ static void put_klog_buff(char *buff) } static int get_last_jit_image(char *haystack, size_t hlen, - uint8_t *image, size_t ilen, - unsigned long *base) + uint8_t *image, size_t ilen) { char *ptr, *pptr, *tmp; off_t off = 0; int ret, flen, proglen, pass, ulen = 0; regmatch_t pmatch[1]; + unsigned long base; regex_t regex; if (hlen == 0) @@ -136,7 +135,7 @@ static int get_last_jit_image(char *haystack, size_t hlen, ptr = haystack + off - (pmatch[0].rm_eo - pmatch[0].rm_so); ret = sscanf(ptr, "flen=%d proglen=%d pass=%d image=%lx", - &flen, &proglen, &pass, base); + &flen, &proglen, &pass, &base); if (ret != 4) return 0; @@ -162,7 +161,7 @@ static int get_last_jit_image(char *haystack, size_t hlen, assert(ulen == proglen); printf("%d bytes emitted from JIT compiler (pass:%d, flen:%d)\n", proglen, pass, flen); - printf("%lx + <x>:\n", *base); + printf("%lx + <x>:\n", base); regfree(®ex); return ulen; @@ -172,7 +171,6 @@ int main(int argc, char **argv) { int len, klen, opcodes = 0; char *kbuff; - unsigned long base; uint8_t image[4096]; if (argc > 1) { @@ -189,9 +187,9 @@ int main(int argc, char **argv) kbuff = get_klog_buff(&klen); - len = get_last_jit_image(kbuff, klen, image, sizeof(image), &base); - if (len > 0 && base > 0) - get_asm_insns(image, len, base, opcodes); + len = get_last_jit_image(kbuff, klen, image, sizeof(image)); + if (len > 0) + get_asm_insns(image, len, opcodes); put_klog_buff(kbuff); -- 1.7.9.5 ^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH net-next 1/2] tools: bpf_jit_disasm: ignore image address for disasm 2014-05-15 22:56 ` [PATCH net-next 1/2] tools: bpf_jit_disasm: ignore image address for disasm Alexei Starovoitov @ 2014-05-16 9:34 ` Daniel Borkmann 0 siblings, 0 replies; 6+ messages in thread From: Daniel Borkmann @ 2014-05-16 9:34 UTC (permalink / raw) To: Alexei Starovoitov; +Cc: David S. Miller, netdev On 05/16/2014 12:56 AM, Alexei Starovoitov wrote: > seccomp filters use kernel JIT image addresses, so bpf_jit_enable=2 prints > [ 20.146438] flen=3 proglen=82 pass=0 image=0000000000000000 > [ 20.146442] JIT code: 00000000: 55 48 89 e5 48 81 ec 28 02 00 00 ... > > ignore image address, so that seccomp filters can be disassembled > > Signed-off-by: Alexei Starovoitov <ast@plumgrid.com> Looks good to me! Thanks for using bpf_jit_disasm, hope it was of great help. ;) Acked-by: Daniel Borkmann <dborkman@redhat.com> ^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH net-next 2/2] tools: bpf_jit_disasm: increase image buffer size 2014-05-15 22:56 [PATCH net-next 0/2] tools: bpf_jit_disasm: trivial fixes Alexei Starovoitov 2014-05-15 22:56 ` [PATCH net-next 1/2] tools: bpf_jit_disasm: ignore image address for disasm Alexei Starovoitov @ 2014-05-15 22:56 ` Alexei Starovoitov 2014-05-16 9:35 ` Daniel Borkmann 2014-05-16 20:44 ` [PATCH net-next 0/2] tools: bpf_jit_disasm: trivial fixes David Miller 2 siblings, 1 reply; 6+ messages in thread From: Alexei Starovoitov @ 2014-05-15 22:56 UTC (permalink / raw) To: David S. Miller; +Cc: Daniel Borkmann, netdev JITed seccomp filters can be quite large if they check a lot of syscalls Simply increase buffer size Signed-off-by: Alexei Starovoitov <ast@plumgrid.com> --- tools/net/bpf_jit_disasm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/net/bpf_jit_disasm.c b/tools/net/bpf_jit_disasm.c index d9730c3319b9..c5baf9c591b7 100644 --- a/tools/net/bpf_jit_disasm.c +++ b/tools/net/bpf_jit_disasm.c @@ -171,7 +171,7 @@ int main(int argc, char **argv) { int len, klen, opcodes = 0; char *kbuff; - uint8_t image[4096]; + static uint8_t image[32768]; if (argc > 1) { if (!strncmp("-o", argv[argc - 1], 2)) { -- 1.7.9.5 ^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH net-next 2/2] tools: bpf_jit_disasm: increase image buffer size 2014-05-15 22:56 ` [PATCH net-next 2/2] tools: bpf_jit_disasm: increase image buffer size Alexei Starovoitov @ 2014-05-16 9:35 ` Daniel Borkmann 0 siblings, 0 replies; 6+ messages in thread From: Daniel Borkmann @ 2014-05-16 9:35 UTC (permalink / raw) To: Alexei Starovoitov; +Cc: David S. Miller, netdev On 05/16/2014 12:56 AM, Alexei Starovoitov wrote: > JITed seccomp filters can be quite large if they check a lot of syscalls > Simply increase buffer size > > Signed-off-by: Alexei Starovoitov <ast@plumgrid.com> Okay, fine by me. Acked-by: Daniel Borkmann <dborkman@redhat.com> ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH net-next 0/2] tools: bpf_jit_disasm: trivial fixes 2014-05-15 22:56 [PATCH net-next 0/2] tools: bpf_jit_disasm: trivial fixes Alexei Starovoitov 2014-05-15 22:56 ` [PATCH net-next 1/2] tools: bpf_jit_disasm: ignore image address for disasm Alexei Starovoitov 2014-05-15 22:56 ` [PATCH net-next 2/2] tools: bpf_jit_disasm: increase image buffer size Alexei Starovoitov @ 2014-05-16 20:44 ` David Miller 2 siblings, 0 replies; 6+ messages in thread From: David Miller @ 2014-05-16 20:44 UTC (permalink / raw) To: ast; +Cc: dborkman, netdev From: Alexei Starovoitov <ast@plumgrid.com> Date: Thu, 15 May 2014 15:56:37 -0700 > Two trivial fixes for very useful bpf_jit_disasm tool Series applied, thanks. ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2014-05-16 20:44 UTC | newest] Thread overview: 6+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2014-05-15 22:56 [PATCH net-next 0/2] tools: bpf_jit_disasm: trivial fixes Alexei Starovoitov 2014-05-15 22:56 ` [PATCH net-next 1/2] tools: bpf_jit_disasm: ignore image address for disasm Alexei Starovoitov 2014-05-16 9:34 ` Daniel Borkmann 2014-05-15 22:56 ` [PATCH net-next 2/2] tools: bpf_jit_disasm: increase image buffer size Alexei Starovoitov 2014-05-16 9:35 ` Daniel Borkmann 2014-05-16 20:44 ` [PATCH net-next 0/2] tools: bpf_jit_disasm: trivial fixes David Miller
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).