[PATCH bpf-next] bpftool: Fix inverted tracefs validation when scanning /proc/mounts

From: chenyuan_fl

Date: Thu Oct 15 2026 - 21:54:09 EST


From: Yuan Chen <chenyuan@xxxxxxxxxx>

The /proc/mounts fallback in get_tracefs_pipe() accepts only
non-tracefs mount points, so a tracefs mounted outside the default
locations is ignored: bpftool prog tracelog then mounts a second
tracefs, or exits silently with --nomount. Negate the condition.

Fixes: be3245e22d22 ("tools: bpftool: attempt to mount tracefs if required for tracelog cmd")
Signed-off-by: Yuan Chen <chenyuan@xxxxxxxxxx>
---
tools/bpf/bpftool/tracelog.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/bpf/bpftool/tracelog.c b/tools/bpf/bpftool/tracelog.c
index 573a8d99f009..e104748c8350 100644
--- a/tools/bpf/bpftool/tracelog.c
+++ b/tools/bpf/bpftool/tracelog.c
@@ -86,7 +86,7 @@ static bool get_tracefs_pipe(char *mnt)
fclose(fp);

/* The string from fscanf() might be truncated, check mnt is valid */
- if (found && validate_tracefs_mnt(mnt, TRACEFS_MAGIC))
+ if (found && !validate_tracefs_mnt(mnt, TRACEFS_MAGIC))
goto exit_found;

if (block_mount)
--
2.54.0