From e03edfc99235b448bd577e4afb02fd3e8404b3cc Mon Sep 17 00:00:00 2001 From: Alan Maguire Date: Thu, 28 Nov 2024 17:32:03 +0000 Subject: [PATCH] libbpftune: fix bpftune_netns_info() checks when searching for netns cookie netns cookie check does not verify cookie is the one we are looking for; this means we match first cookie we find and misapply changes when multiple netns are in place. Reported-by: Roger Knobbe Signed-off-by: Alan Maguire --- src/libbpftune.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/libbpftune.c b/src/libbpftune.c index 7866b14..73414af 100644 --- a/src/libbpftune.c +++ b/src/libbpftune.c @@ -1487,7 +1487,8 @@ static int bpftune_netns_find(unsigned long cookie) mntfd = open(ent->mnt_dir, O_RDONLY); if (mntfd < 0) continue; - if (bpftune_netns_info(0, &mntfd, &netns_cookie)) { + if (bpftune_netns_info(0, &mntfd, &netns_cookie) || + (cookie && netns_cookie != cookie)) { close(mntfd); continue; }