Skip to content

Commit

Permalink
bpf: Fix fds_example SIGSEGV error
Browse files Browse the repository at this point in the history
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]
  • Loading branch information
ethercflow authored and borkmann committed Jul 10, 2020
1 parent 5c3320d commit eef8a42
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion samples/bpf/fds_example.c
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down Expand Up @@ -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;

Expand Down

0 comments on commit eef8a42

Please sign in to comment.