* [PATCH bpf v2] selftests/bpf: Bump path and command buffer sizes in bpftool_helpers.c
@ 2026-03-12 23:48 Ihor Solodrai
2026-03-16 21:20 ` patchwork-bot+netdevbpf
0 siblings, 1 reply; 2+ messages in thread
From: Ihor Solodrai @ 2026-03-12 23:48 UTC (permalink / raw)
To: Alexei Starovoitov, Andrii Nakryiko, Daniel Borkmann,
Eduard Zingerman
Cc: Alexis Lothoré, bpf, kernel-team
The path length of 64 is way too low in some envirnoments, which leads
to subtle failures due to truncation [1].
Replace BPFTOOL_PATH_MAX_LEN with PATH_MAX, and set
BPFTOOL_FULL_CMD_MAX_LEN to double of PATH_MAX.
[1] https://github.com/libbpf/libbpf/actions/runs/22980753016/job/66719800527
Signed-off-by: Ihor Solodrai <ihor.solodrai@linux.dev>
---
tools/testing/selftests/bpf/bpftool_helpers.c | 15 +++++++--------
1 file changed, 7 insertions(+), 8 deletions(-)
diff --git a/tools/testing/selftests/bpf/bpftool_helpers.c b/tools/testing/selftests/bpf/bpftool_helpers.c
index 929fc257f431..0a2a4f0a2794 100644
--- a/tools/testing/selftests/bpf/bpftool_helpers.c
+++ b/tools/testing/selftests/bpf/bpftool_helpers.c
@@ -2,18 +2,18 @@
#include <unistd.h>
#include <string.h>
#include <stdbool.h>
+#include <limits.h>
#include "bpf_util.h"
#include "bpftool_helpers.h"
-#define BPFTOOL_PATH_MAX_LEN 64
-#define BPFTOOL_FULL_CMD_MAX_LEN 512
+#define BPFTOOL_FULL_CMD_MAX_LEN (PATH_MAX * 2)
#define BPFTOOL_DEFAULT_PATH "tools/sbin/bpftool"
static int detect_bpftool_path(char *buffer, size_t size)
{
- char tmp[BPFTOOL_PATH_MAX_LEN];
+ char tmp[PATH_MAX];
const char *env_path;
/* First, check if BPFTOOL environment variable is set */
@@ -29,7 +29,7 @@ static int detect_bpftool_path(char *buffer, size_t size)
/* Check default bpftool location (will work if we are running the
* default flavor of test_progs)
*/
- snprintf(tmp, BPFTOOL_PATH_MAX_LEN, "./%s", BPFTOOL_DEFAULT_PATH);
+ snprintf(tmp, sizeof(tmp), "./%s", BPFTOOL_DEFAULT_PATH);
if (access(tmp, X_OK) == 0) {
strscpy(buffer, tmp, size);
return 0;
@@ -38,7 +38,7 @@ static int detect_bpftool_path(char *buffer, size_t size)
/* Check alternate bpftool location (will work if we are running a
* specific flavor of test_progs, e.g. cpuv4 or no_alu32)
*/
- snprintf(tmp, BPFTOOL_PATH_MAX_LEN, "../%s", BPFTOOL_DEFAULT_PATH);
+ snprintf(tmp, sizeof(tmp), "../%s", BPFTOOL_DEFAULT_PATH);
if (access(tmp, X_OK) == 0) {
strscpy(buffer, tmp, size);
return 0;
@@ -50,7 +50,7 @@ static int detect_bpftool_path(char *buffer, size_t size)
static int run_command(char *args, char *output_buf, size_t output_max_len)
{
- static char bpftool_path[BPFTOOL_PATH_MAX_LEN] = {0};
+ static char bpftool_path[PATH_MAX] = {};
bool suppress_output = !(output_buf && output_max_len);
char command[BPFTOOL_FULL_CMD_MAX_LEN];
FILE *f;
@@ -60,7 +60,7 @@ static int run_command(char *args, char *output_buf, size_t output_max_len)
if (bpftool_path[0] == 0 && detect_bpftool_path(bpftool_path, sizeof(bpftool_path)))
return 1;
- ret = snprintf(command, BPFTOOL_FULL_CMD_MAX_LEN, "%s %s%s",
+ ret = snprintf(command, sizeof(command), "%s %s%s",
bpftool_path, args,
suppress_output ? " > /dev/null 2>&1" : "");
@@ -84,4 +84,3 @@ int get_bpftool_command_output(char *args, char *output_buf, size_t output_max_l
{
return run_command(args, output_buf, output_max_len);
}
-
--
2.53.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH bpf v2] selftests/bpf: Bump path and command buffer sizes in bpftool_helpers.c
2026-03-12 23:48 [PATCH bpf v2] selftests/bpf: Bump path and command buffer sizes in bpftool_helpers.c Ihor Solodrai
@ 2026-03-16 21:20 ` patchwork-bot+netdevbpf
0 siblings, 0 replies; 2+ messages in thread
From: patchwork-bot+netdevbpf @ 2026-03-16 21:20 UTC (permalink / raw)
To: Ihor Solodrai
Cc: ast, andrii, daniel, eddyz87, alexis.lothore, bpf, kernel-team
Hello:
This patch was applied to bpf/bpf-next.git (master)
by Andrii Nakryiko <andrii@kernel.org>:
On Thu, 12 Mar 2026 16:48:20 -0700 you wrote:
> The path length of 64 is way too low in some envirnoments, which leads
> to subtle failures due to truncation [1].
>
> Replace BPFTOOL_PATH_MAX_LEN with PATH_MAX, and set
> BPFTOOL_FULL_CMD_MAX_LEN to double of PATH_MAX.
>
> [1] https://github.com/libbpf/libbpf/actions/runs/22980753016/job/66719800527
>
> [...]
Here is the summary with links:
- [bpf,v2] selftests/bpf: Bump path and command buffer sizes in bpftool_helpers.c
https://git.kernel.org/bpf/bpf-next/c/7e2f40ef0a75
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-03-16 21:20 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-12 23:48 [PATCH bpf v2] selftests/bpf: Bump path and command buffer sizes in bpftool_helpers.c Ihor Solodrai
2026-03-16 21:20 ` patchwork-bot+netdevbpf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox