]> Git Repo - linux.git/commitdiff
bpf: Fix fds_example SIGSEGV error
authorWenbo Zhang <[email protected]>
Fri, 10 Jul 2020 09:20:35 +0000 (05:20 -0400)
committerDaniel Borkmann <[email protected]>
Fri, 10 Jul 2020 21:25:25 +0000 (23:25 +0200)
The `BPF_LOG_BUF_SIZE`'s value is `UINT32_MAX >> 8`, so define an array
with it on stack caused an overflow.

Signed-off-by: Wenbo Zhang <[email protected]>
Signed-off-by: Daniel Borkmann <[email protected]>
Acked-by: Andrii Nakryiko <[email protected]>
Link: https://lore.kernel.org/bpf/[email protected]
samples/bpf/fds_example.c

index d5992f787232808691dbfe7da9445c7edfe902ba..59f45fef51109e808a16e02a8a3d013e52b63d43 100644 (file)
@@ -30,6 +30,8 @@
 #define BPF_M_MAP      1
 #define BPF_M_PROG     2
 
+char bpf_log_buf[BPF_LOG_BUF_SIZE];
+
 static void usage(void)
 {
        printf("Usage: fds_example [...]\n");
@@ -57,7 +59,6 @@ static int bpf_prog_create(const char *object)
                BPF_EXIT_INSN(),
        };
        size_t insns_cnt = sizeof(insns) / sizeof(struct bpf_insn);
-       char bpf_log_buf[BPF_LOG_BUF_SIZE];
        struct bpf_object *obj;
        int prog_fd;
 
This page took 0.067636 seconds and 4 git commands to generate.