From 1b40174fd49e0a74c8f08577575bd850f0704b82 Mon Sep 17 00:00:00 2001 From: Eunseon Lee Date: Thu, 21 Nov 2024 11:53:45 +0900 Subject: [PATCH] libbpf_tools/profile: Support PID namespace mapping if available in the kernel Support PID namespace mapping only in kernels where bpf_get_ns_current_pid_tgid is available. --- libbpf-tools/profile.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/libbpf-tools/profile.c b/libbpf-tools/profile.c index dc27b400aa42..84d3bed57093 100644 --- a/libbpf-tools/profile.c +++ b/libbpf-tools/profile.c @@ -511,6 +511,9 @@ static int set_pidns(const struct profile_bpf *obj) { struct stat statbuf; + if (!probe_bpf_ns_current_pid_tgid()) + return -EPERM; + if (stat("/proc/self/ns/pid", &statbuf) == -1) return -errno;