bpftool: Fix inverted tracefs validation when scanning /proc/mounts

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: be3245e22d ("tools: bpftool: attempt to mount tracefs if required for tracelog cmd")
Signed-off-by: Yuan Chen <chenyuan@kylinos.cn>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Link: https://lore.kernel.org/bpf/20261016015057.127061-1-chenyuan_fl@163.com
This commit is contained in:
Yuan Chen 2026-10-16 09:50:57 +08:00 committed by Daniel Borkmann
parent 34d527e513
commit 21c755efaa

View File

@ -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)