summaryrefslogtreecommitdiffstats
path: root/samples
diff options
context:
space:
mode:
authorWenbo Zhang <ethercflow@gmail.com>2020-07-10 05:20:35 -0400
committerDaniel Borkmann <daniel@iogearbox.net>2020-07-10 23:25:25 +0200
commiteef8a42d6ce087d1c81c960ae0d14f955b742feb (patch)
treecb2deede30a7bd2f068726f62d7678c319a62366 /samples
parent5c3320d7fece4612d4a413aa3c8e82cdb5b49fcb (diff)
downloadlinux-stable-eef8a42d6ce087d1c81c960ae0d14f955b742feb.tar.gz
linux-stable-eef8a42d6ce087d1c81c960ae0d14f955b742feb.tar.bz2
linux-stable-eef8a42d6ce087d1c81c960ae0d14f955b742feb.zip
bpf: Fix fds_example SIGSEGV error
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
Diffstat (limited to 'samples')
-rw-r--r--samples/bpf/fds_example.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/samples/bpf/fds_example.c b/samples/bpf/fds_example.c
index d5992f787232..59f45fef5110 100644
--- a/samples/bpf/fds_example.c
+++ b/samples/bpf/fds_example.c
@@ -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;