* [PATCH net-next] tools: bpf: handle long path in jit disasm
@ 2017-11-02 8:09 Prashant Bhole
2017-11-02 11:25 ` David Miller
2017-11-02 21:19 ` Rustad, Mark D
0 siblings, 2 replies; 4+ messages in thread
From: Prashant Bhole @ 2017-11-02 8:09 UTC (permalink / raw)
To: David S . Miller
Cc: Prashant Bhole, netdev, Alexei Starovoitov, Daniel Borkmann
Use PATH_MAX instead of hardcoded array size 256
Signed-off-by: Prashant Bhole <bhole_prashant_q7@lab.ntt.co.jp>
---
tools/bpf/bpf_jit_disasm.c | 3 ++-
tools/bpf/bpftool/jit_disasm.c | 3 ++-
2 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/tools/bpf/bpf_jit_disasm.c b/tools/bpf/bpf_jit_disasm.c
index 422d9abd666a..75bf526a0168 100644
--- a/tools/bpf/bpf_jit_disasm.c
+++ b/tools/bpf/bpf_jit_disasm.c
@@ -27,6 +27,7 @@
#include <sys/klog.h>
#include <sys/types.h>
#include <sys/stat.h>
+#include <limits.h>
#define CMD_ACTION_SIZE_BUFFER 10
#define CMD_ACTION_READ_ALL 3
@@ -51,7 +52,7 @@ static void get_exec_path(char *tpath, size_t size)
static void get_asm_insns(uint8_t *image, size_t len, int opcodes)
{
int count, i, pc = 0;
- char tpath[256];
+ char tpath[PATH_MAX];
struct disassemble_info info;
disassembler_ftype disassemble;
bfd *bfdf;
diff --git a/tools/bpf/bpftool/jit_disasm.c b/tools/bpf/bpftool/jit_disasm.c
index 5937e134e408..1551d3918d4c 100644
--- a/tools/bpf/bpftool/jit_disasm.c
+++ b/tools/bpf/bpftool/jit_disasm.c
@@ -21,6 +21,7 @@
#include <dis-asm.h>
#include <sys/types.h>
#include <sys/stat.h>
+#include <limits.h>
#include "json_writer.h"
#include "main.h"
@@ -80,7 +81,7 @@ void disasm_print_insn(unsigned char *image, ssize_t len, int opcodes)
disassembler_ftype disassemble;
struct disassemble_info info;
int count, i, pc = 0;
- char tpath[256];
+ char tpath[PATH_MAX];
bfd *bfdf;
if (!len)
--
2.13.5
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH net-next] tools: bpf: handle long path in jit disasm
2017-11-02 8:09 [PATCH net-next] tools: bpf: handle long path in jit disasm Prashant Bhole
@ 2017-11-02 11:25 ` David Miller
2017-11-02 21:19 ` Rustad, Mark D
1 sibling, 0 replies; 4+ messages in thread
From: David Miller @ 2017-11-02 11:25 UTC (permalink / raw)
To: bhole_prashant_q7; +Cc: netdev, ast, daniel
From: Prashant Bhole <bhole_prashant_q7@lab.ntt.co.jp>
Date: Thu, 2 Nov 2017 17:09:45 +0900
> Use PATH_MAX instead of hardcoded array size 256
>
> Signed-off-by: Prashant Bhole <bhole_prashant_q7@lab.ntt.co.jp>
Applied, thank you.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH net-next] tools: bpf: handle long path in jit disasm
2017-11-02 8:09 [PATCH net-next] tools: bpf: handle long path in jit disasm Prashant Bhole
2017-11-02 11:25 ` David Miller
@ 2017-11-02 21:19 ` Rustad, Mark D
2017-11-03 0:51 ` David Miller
1 sibling, 1 reply; 4+ messages in thread
From: Rustad, Mark D @ 2017-11-02 21:19 UTC (permalink / raw)
To: Prashant Bhole
Cc: David S . Miller, netdev, Alexei Starovoitov, Daniel Borkmann
[-- Attachment #1: Type: text/plain, Size: 1831 bytes --]
> On Nov 2, 2017, at 1:09 AM, Prashant Bhole <bhole_prashant_q7@lab.ntt.co.jp> wrote:
>
> Use PATH_MAX instead of hardcoded array size 256
>
> Signed-off-by: Prashant Bhole <bhole_prashant_q7@lab.ntt.co.jp>
> ---
> tools/bpf/bpf_jit_disasm.c | 3 ++-
> tools/bpf/bpftool/jit_disasm.c | 3 ++-
> 2 files changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/tools/bpf/bpf_jit_disasm.c b/tools/bpf/bpf_jit_disasm.c
> index 422d9abd666a..75bf526a0168 100644
> --- a/tools/bpf/bpf_jit_disasm.c
> +++ b/tools/bpf/bpf_jit_disasm.c
> @@ -27,6 +27,7 @@
> #include <sys/klog.h>
> #include <sys/types.h>
> #include <sys/stat.h>
> +#include <limits.h>
>
> #define CMD_ACTION_SIZE_BUFFER 10
> #define CMD_ACTION_READ_ALL 3
> @@ -51,7 +52,7 @@ static void get_exec_path(char *tpath, size_t size)
> static void get_asm_insns(uint8_t *image, size_t len, int opcodes)
> {
> int count, i, pc = 0;
> - char tpath[256];
> + char tpath[PATH_MAX];
Seems like such a nice thing, *but* PATH_MAX is 4096. Can things really tolerate 4k on the stack here?
> struct disassemble_info info;
> disassembler_ftype disassemble;
> bfd *bfdf;
> diff --git a/tools/bpf/bpftool/jit_disasm.c b/tools/bpf/bpftool/jit_disasm.c
> index 5937e134e408..1551d3918d4c 100644
> --- a/tools/bpf/bpftool/jit_disasm.c
> +++ b/tools/bpf/bpftool/jit_disasm.c
> @@ -21,6 +21,7 @@
> #include <dis-asm.h>
> #include <sys/types.h>
> #include <sys/stat.h>
> +#include <limits.h>
>
> #include "json_writer.h"
> #include "main.h"
> @@ -80,7 +81,7 @@ void disasm_print_insn(unsigned char *image, ssize_t len, int opcodes)
> disassembler_ftype disassemble;
> struct disassemble_info info;
> int count, i, pc = 0;
> - char tpath[256];
> + char tpath[PATH_MAX];
Same comment here.
> bfd *bfdf;
>
> if (!len)
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH net-next] tools: bpf: handle long path in jit disasm
2017-11-02 21:19 ` Rustad, Mark D
@ 2017-11-03 0:51 ` David Miller
0 siblings, 0 replies; 4+ messages in thread
From: David Miller @ 2017-11-03 0:51 UTC (permalink / raw)
To: mark.d.rustad; +Cc: bhole_prashant_q7, netdev, ast, daniel
From: "Rustad, Mark D" <mark.d.rustad@intel.com>
Date: Thu, 2 Nov 2017 21:19:44 +0000
>
>> On Nov 2, 2017, at 1:09 AM, Prashant Bhole <bhole_prashant_q7@lab.ntt.co.jp> wrote:
>>
>> Use PATH_MAX instead of hardcoded array size 256
>>
>> Signed-off-by: Prashant Bhole <bhole_prashant_q7@lab.ntt.co.jp>
...
>> static void get_asm_insns(uint8_t *image, size_t len, int opcodes)
>> {
>> int count, i, pc = 0;
>> - char tpath[256];
>> + char tpath[PATH_MAX];
>
> Seems like such a nice thing, *but* PATH_MAX is 4096. Can things really tolerate 4k on the stack here?
This is userland code, why wouldn't it be able to handle 4K on the
stack?
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2017-11-03 0:51 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-11-02 8:09 [PATCH net-next] tools: bpf: handle long path in jit disasm Prashant Bhole
2017-11-02 11:25 ` David Miller
2017-11-02 21:19 ` Rustad, Mark D
2017-11-03 0:51 ` David Miller
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.