Skip to content

Commit baa1e8a

Browse files
Sanjay ChitrodaKernel Patches Daemon
authored andcommitted
libbpf: increase probe_name buffer size to avoid format-truncation
This patch increases the size of the `probe_name` buffer in `probe_kern_syscall_wrapper()` from `MAX_EVENT_NAME_LEN` to `MAX_EVENT_NAME_LEN * 2`. The change addresses a build failure in perf builds caused by GCC's -Werror=format-truncation warning: libbpf.c:11052:45: error: '%s' directive output may be truncated writing up to 63 bytes into a region of size between 34 and 53 [-Werror=format-truncation] The warning is triggered by a `snprintf()` call that formats a string using syscall names and other identifiers. In some cases, the buffer size is insufficient, leading to potential truncation. Debug builds pass because they do not treat warnings as errors, but perf builds fail due to `-Werror`. Increasing the buffer size ensures that the formatted string fits safely, resolving the issue without affecting functionality. Signed-off-by: Sanjay Chitroda <[email protected]>
1 parent 2b3c471 commit baa1e8a

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

tools/lib/bpf/libbpf.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11300,7 +11300,7 @@ int probe_kern_syscall_wrapper(int token_fd)
1130011300

1130111301
return pfd >= 0 ? 1 : 0;
1130211302
} else { /* legacy mode */
11303-
char probe_name[MAX_EVENT_NAME_LEN];
11303+
char probe_name[MAX_EVENT_NAME_LEN * 2];
1130411304

1130511305
gen_probe_legacy_event_name(probe_name, sizeof(probe_name), syscall_name, 0);
1130611306
if (add_kprobe_event_legacy(probe_name, false, syscall_name, 0) < 0)

0 commit comments

Comments
 (0)