Skip to content

Commit 181740e

Browse files
ethercflowgregkh
authored andcommitted
bpf: Fix fds_example SIGSEGV error
[ Upstream commit eef8a42 ] 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 <ethercflow@gmail.com> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net> Acked-by: Andrii Nakryiko <andriin@fb.com> Link: https://lore.kernel.org/bpf/20200710092035.28919-1-ethercflow@gmail.com Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent e6132d0 commit 181740e

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

‎samples/bpf/fds_example.c‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@
3030
#define BPF_M_MAP 1
3131
#define BPF_M_PROG 2
3232

33+
char bpf_log_buf[BPF_LOG_BUF_SIZE];
34+
3335
static void usage(void)
3436
{
3537
printf("Usage: fds_example [...]\n");
@@ -57,7 +59,6 @@ static int bpf_prog_create(const char *object)
5759
BPF_EXIT_INSN(),
5860
};
5961
size_t insns_cnt = sizeof(insns) / sizeof(struct bpf_insn);
60-
char bpf_log_buf[BPF_LOG_BUF_SIZE];
6162
struct bpf_object *obj;
6263
int prog_fd;
6364

0 commit comments

Comments
 (0)