Skip to contentSkip to conversation

bpf: fix fds_example SIGSEGV error

PATCH In review Wenbo Zhang 2 participants 2 messages Jul 10, 2020

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 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.

---
 samples/bpf/fds_example.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
samples/bpf/fds_example.c +2 -1
index d5992f787232..59f45fef5110 100644
@@ -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;
 
Signature · 1 line
2.17.1