Use thread-safe function pointer in libbpf_print
PATCH 1/1 Use thread-safe function pointer in libbpf_print
From: Jonathan Wiepert <[email protected]>
This patch fixes a thread safety bug where libbpf_print uses the global variable storing the print function pointer rather than the local variable that had the print function set via __atomic_load_n.
--- tools/lib/bpf/libbpf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/lib/bpf/libbpf.c +1 -1
@@ -284,7 +284,7 @@ void libbpf_print(enum libbpf_print_level level, const char *format, ...) old_errno = errno;va_start (args, format); -__libbpf_pr (level, format, args); +print_fn (level, format, args);va_end (args); errno = old_errno;
Signature · 1 line
2.42.0
Quoted 16 lines · On 4/24/25 23:14, > wrote:
From: Jonathan Wiepert <[email protected]>
This patch fixes a thread safety bug where
libbpf_printuses the global variable storing the print function pointer rather than the local variable that had the print function set via__atomic_load_n.Signed-off-by Jonathan Wiepert <[email protected]>--- tools/lib/bpf/libbpf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)tools/lib/bpf/libbpf.c +0
-0
tools/lib/bpf/libbpf.c void libbpf_print(enum libbpf_print_level level, const char *format, ...) · line 290
Quoted 8 lines
tools/lib/bpf/libbpf.c +1
-1@@ -284,7 +284,7 @@ void libbpf_print(enum libbpf_print_level level, const char *format, ...) old_errno = errno;va_start (args, format); -__libbpf_pr (level, format, args); +print_fn (level, format, args);va_end (args); errno = old_errno;
Quoted 12 lines · On Thu, Apr 24, 2025 at 3:15 PM > <[email protected]> wrote:
From: Jonathan Wiepert <[email protected]>
This patch fixes a thread safety bug where
libbpf_printuses the global variable storing the print function pointer rather than the local variable that had the print function set via__atomic_load_n.Signed-off-by Jonathan Wiepert <[email protected]>--- tools/lib/bpf/libbpf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Added
and applied to bpf-next, thanks.
Quoted 16 lines
tools/lib/bpf/libbpf.c +1
-2@@ -284,7 +284,7 @@ void libbpf_print(enum libbpf_print_level level, const char *format, ...) old_errno = errno;va_start (args, format); -__libbpf_pr (level, format, args); +print_fn (level, format, args);va_end (args); errno = old_errno; --2.42.0