From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796312004; b=5DMkpkLjzMkJ0g+4KUFbUeziS5zMvTLVtSWsomLiqu/D8EJXqRMlDCY62LE4XUVV3fn9 2xLTFeKGxUTTEGFSlsD/KgiVXFEVRadIlMhFz/BC7ObS1kM5I9x99P0L9XiMZiSiTnC8f 8v10ZCa9v9G6fcUICgdFlZV6XFORgfehYegq8g8vNQBnEhCCm3NZIGEwKHQ+3RFGkRlfE GWEoD3yUlFpUVVGEeTso70cdi4DiJ3bXQ91ovd5ZsDuHdJj3OzIMeFDQyfszCqKM5zcbz cp/7rJ1SJ4FE4Dxs3nPgFSI1wMQKvnwQ1mBEzT6++K9XHfzAHbwTJORHB2Y9jk7f7jw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796312004; h=Received:DKIM-Signature:Content-Type:MIME-Version:Message-Id: In-Reply-To:References:Subject:From:To:Cc:Date; bh=D6r5YMA2xVYuLqdkmQG0NzPLpSa51k5KoPjWs+QFauI=; b=Cj3MJatJusA58qSujPRFBmqwHgs/G9wKFnwbQuwheLeaOtOPlqWixeEhRj9ic9mYStV3 0wB/iWJs0fSJJkV3cZmB3YcijAEXYdxMEsnzrJG66Q/CowGrS47BnecvL0NCXWnSPX+QY vpilJWdT7V9dJgcfhT2SfFKXrAYYYF/4tRD52pfptf3mcVfiXxyUT4rzOBpSCQQMAYzY/ agfdaEKGvCKvFBCAaLEp9G/sv/B3JbFXccT+PIWQziyZ+o27yAS5MnsfExp5bl3g1C8I/ x3oHWVD6N4xJmKCvZ98BaeNwXAcqWNs03vsl9ppRkQ+OEHtTtO4FOQwG7OiZ1i+a71g== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=doh5nHQe; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 41697606A322; Thu, 3 Dec 2026 15:33:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=doh5nHQe Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0A01D1F00896; Thu, 3 Dec 2026 15:33:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796312004; bh=D6r5YMA2xVYuLqdkmQG0NzPLpSa51k5KoPjWs+QFauI=; h=In-Reply-To:References:Subject:From:To:Cc:Date; b=doh5nHQewMUX9Z9EQNv8xvhtjqaD4y6PfKy+/4reor86yM5lGGI+8RsPv+NGAd/yl qRW9LphCWn1m6CDwkdA3c6vLxe3Bov7YyJtwjJJCojrL+XKGUcJh3Oi3u1utWpqZGo 0V6KLoTtKapOALxVDOnTWSw9Lkxzw8fbkOpvzTlMPGWuOMEa8Fist74i5Ul/ojdGPw YKQ21rJHENa5x15M8eo1JRpXxUflv+PqwOyMi8Vlp6epZr25nUjYGEywX9gzrDoudD GjloTkxRdiuKIcg3qMyXmDo6yHbvbYcsw5o6AdkXSO2N7HdnGZEX6lDZZMSZuuFvYB o3hUHhxg2l1hg== Content-Type: multipart/mixed; boundary="===============7650688439914283987==" X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Message-Id: <291a4a9daafdbd56768a4a64fbb633398875bd7c400072b79eb1ac32f0b2c294@mail.kernel.org> In-Reply-To: <20261203150338.2625598-4-cui.tao@linux.dev> References: <20261203150338.2625598-4-cui.tao@linux.dev> Subject: Re: [PATCH v15 3/4] selftests/bpf: add iocost cost model test From: bot+bpf-ci@kernel.org To: cui.tao@linux.dev,tj@kernel.org,josef@toxicopanda.com,axboe@kernel.dk,ast@kernel.org,alexei.starovoitov@gmail.com Cc: cgroups@vger.kernel.org,linux-block@vger.kernel.org,linux-kernel@vger.kernel.org,bpf@vger.kernel.org,andrii@kernel.org,eddyz87@gmail.com,daniel@iogearbox.net,linux-kselftest@vger.kernel.org,cui.tao@linux.dev,cuitao@kylinos.cn,ameryhung@gmail.com,ast@kernel.org,andrii@kernel.org,daniel@iogearbox.net,martin.lau@kernel.org,eddyz87@gmail.com,yonghong.song@linux.dev,mason@kernel.org,ihor.solodrai@linux.dev Date: Thu, 3 Dec 2026 15:33:21 +0000 (UTC) --===============7650688439914283987== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit > selftests/bpf: add iocost cost model test TL;DR: In iocost_model.c, iocost_test_env() may leave test_progs' cwd unreachable after unshare(), if fchdir() runs on success, possibly breaking later tests like test_sleepable_tracepoints, which expects getcwd() to start with '/'. > diff --git a/tools/testing/selftests/bpf/prog_tests/iocost_model.c b/tools/testing/selftests/bpf/prog_tests/iocost_model.c > new file mode 100644 > --- /dev/null > +++ b/tools/testing/selftests/bpf/prog_tests/iocost_model.c [ ... ] > +static bool iocost_test_env(void) > +{ > + static bool ready; > + struct statfs sf; > + int orig_ns = -1, orig_cwd = -1, supported; > + bool ok = false; [ ... ] > + if (!ready) { > + orig_cwd = open(".", O_RDONLY | O_DIRECTORY); > + orig_ns = open("/proc/self/ns/mnt", O_RDONLY); > + if (unshare(CLONE_NEWNS) || [ ... ] > +out: > + if (!ok) > + ready = false; > + if (orig_ns >= 0) { > + if (!ok) > + setns(orig_ns, CLONE_NEWNS); > + close(orig_ns); > + } > + if (orig_cwd >= 0) > + fchdir(orig_cwd); > + close(orig_cwd); > + return ok; > +} On the success path the process stays in the new private mount namespace, since setns(orig_ns) only runs when !ok. Yet fchdir(orig_cwd) runs unconditionally, pointing the cwd back at the vfsmount of the old namespace. Can this leave the cwd unreachable from the root for the rest of the test_progs process? If the old namespace was created by an earlier test's setup_cgroup_environment() and nothing else uses it, it is freed and the cwd mount is detached. Later unshare() calls would not move the cwd either, because copy_mnt_ns() only moves a pwd that lies in the namespace being copied. getcwd() would then return "(unreachable)/..." and realpath() on relative paths would fail with ENOENT. For example, in a non-parallel ./test_progs run, test_sleepable_tracepoints runs after the iocost tests and its sys_exit subtest checks: ASSERT_EQ(skel->bss->copied_byte, '/', "copied_byte"); That first byte of the getcwd() buffer would be '(' instead. Would it work to call fchdir(orig_cwd) only on the !ok path, right after setns(orig_ns, CLONE_NEWNS), and to close orig_cwd only when it is >= 0? --- AI reviewed your patch. Please fix the bug or email reply why it's not a bug. See: https://github.com/kernel-patches/vmtest/blob/master/ci/claude/README.md CI run summary: https://github.com/kernel-patches/bpf/actions/runs/47135984243 --===============7650688439914283987==--