Commit acd143ee authored by Jean-Philippe Brucker's avatar Jean-Philippe Brucker Committed by Andrii Nakryiko

selftests/bpf: Fix segfault in bpf_tcp_ca

Since commit ad9a7f96 ("libbpf: Improve logging around BPF program
loading"), libbpf_debug_print() gets an additional prog_name parameter
but doesn't pass it to printf(). Since the format string now expects two
arguments, printf() may read uninitialized data and segfault. Pass
prog_name through.

Fixes: ad9a7f96 ("libbpf: Improve logging around BPF program loading")
Signed-off-by: default avatarJean-Philippe Brucker <jean-philippe@linaro.org>
Signed-off-by: default avatarAndrii Nakryiko <andrii@kernel.org>
Link: https://lore.kernel.org/bpf/20211213183058.346066-1-jean-philippe@linaro.org
parent c8064e5b
...@@ -217,7 +217,7 @@ static bool found; ...@@ -217,7 +217,7 @@ static bool found;
static int libbpf_debug_print(enum libbpf_print_level level, static int libbpf_debug_print(enum libbpf_print_level level,
const char *format, va_list args) const char *format, va_list args)
{ {
const char *log_buf; const char *prog_name, *log_buf;
if (level != LIBBPF_WARN || if (level != LIBBPF_WARN ||
!strstr(format, "-- BEGIN PROG LOAD LOG --")) { !strstr(format, "-- BEGIN PROG LOAD LOG --")) {
...@@ -225,15 +225,14 @@ static int libbpf_debug_print(enum libbpf_print_level level, ...@@ -225,15 +225,14 @@ static int libbpf_debug_print(enum libbpf_print_level level,
return 0; return 0;
} }
/* skip prog_name */ prog_name = va_arg(args, char *);
va_arg(args, char *);
log_buf = va_arg(args, char *); log_buf = va_arg(args, char *);
if (!log_buf) if (!log_buf)
goto out; goto out;
if (err_str && strstr(log_buf, err_str) != NULL) if (err_str && strstr(log_buf, err_str) != NULL)
found = true; found = true;
out: out:
printf(format, log_buf); printf(format, prog_name, log_buf);
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment