bpf.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] bpf: fix fds_example SIGSEGV error
@ 2020-07-10  9:20 Wenbo Zhang
  2020-07-10 18:46 ` Andrii Nakryiko
  0 siblings, 1 reply; 2+ messages in thread
From: Wenbo Zhang @ 2020-07-10  9:20 UTC (permalink / raw)
  To: ast, daniel; +Cc: netdev, bpf, linux-kernel, ethercflow

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>
---
 samples/bpf/fds_example.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

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;
 
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] bpf: fix fds_example SIGSEGV error
  2020-07-10  9:20 [PATCH] bpf: fix fds_example SIGSEGV error Wenbo Zhang
@ 2020-07-10 18:46 ` Andrii Nakryiko
  0 siblings, 0 replies; 2+ messages in thread
From: Andrii Nakryiko @ 2020-07-10 18:46 UTC (permalink / raw)
  To: Wenbo Zhang
  Cc: Alexei Starovoitov, Daniel Borkmann, Networking, bpf, open list

On Fri, Jul 10, 2020 at 2:21 AM Wenbo Zhang <ethercflow@gmail.com> wrote:
>
> 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>
> ---

Acked-by: Andrii Nakryiko <andriin@fb.com>

>  samples/bpf/fds_example.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>

[...]

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-07-10 18:46 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-10  9:20 [PATCH] bpf: fix fds_example SIGSEGV error Wenbo Zhang
2020-07-10 18:46 ` Andrii Nakryiko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).