From: Jakub Kicinski Date: Thu, 23 Nov 2017 01:00:53 +0000 (-0800) Subject: bpf: initialize the verifier log X-Git-Tag: v4.16.0~124 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f6a54d72a51ec563a577fde21d1ae53cb4aa3f44;p=thirdparty%2Fiproute2.git bpf: initialize the verifier log If program loading fails before verifier prints its first message, the verifier log will not be initialized. Always set the first character of the log buffer to zero to make sure we don't dump non-printable characters to the terminal. Signed-off-by: Jakub Kicinski Reviewed-by: Quentin Monnet Acked-by: Daniel Borkmann --- diff --git a/lib/bpf.c b/lib/bpf.c index 10ea23a47..fdc28772f 100644 --- a/lib/bpf.c +++ b/lib/bpf.c @@ -1153,7 +1153,7 @@ static int bpf_log_realloc(struct bpf_elf_ctx *ctx) { const size_t log_max = UINT_MAX >> 8; size_t log_size = ctx->log_size; - void *ptr; + char *ptr; if (!ctx->log) { log_size = 65536; @@ -1169,6 +1169,7 @@ static int bpf_log_realloc(struct bpf_elf_ctx *ctx) if (!ptr) return -ENOMEM; + ptr[0] = 0; ctx->log = ptr; ctx->log_size = log_size;