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
Subject: Re: [PATCH v15 3/4] selftests/bpf: add iocost cost model test
Date: Thu, 3 Dec 2026 15:33:21 +0000 (UTC) [thread overview]
Message-ID: <291a4a9daafdbd56768a4a64fbb633398875bd7c400072b79eb1ac32f0b2c294@mail.kernel.org> (raw)
In-Reply-To: <20261203150338.2625598-4-cui.tao@linux.dev>
[-- Attachment #1: Type: text/plain, Size: 2421 bytes --]
> 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
next prev parent reply other threads:[~2026-12-03 15:33 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-03 15:03 [PATCH v15 0/4] blk-iocost: BPF struct_ops cost model Tao Cui
2026-12-03 15:03 ` [PATCH v15 1/4] blk-iocost: add BPF struct_ops cost model support Tao Cui
2026-12-03 15:44 ` bot+bpf-ci
2026-12-03 15:03 ` [PATCH v15 2/4] blk-iocost: add iocost_ioc_tick tracepoint for per-period device summary Tao Cui
2026-12-03 15:03 ` [PATCH v15 3/4] selftests/bpf: add iocost cost model test Tao Cui
2026-12-03 15:33 ` bot+bpf-ci [this message]
2026-12-03 15:03 ` [PATCH v15 4/4] docs: cgroup-v2: document the iocost BPF cost model attachment Tao Cui
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=291a4a9daafdbd56768a4a64fbb633398875bd7c400072b79eb1ac32f0b2c294@mail.kernel.org \
--to=bot+bpf-ci@kernel.org \
--cc=alexei.starovoitov@gmail.com \
--cc=ameryhung@gmail.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=axboe@kernel.dk \
--cc=bpf@vger.kernel.org \
--cc=cgroups@vger.kernel.org \
--cc=cui.tao@linux.dev \
--cc=cuitao@kylinos.cn \
--cc=daniel@iogearbox.net \
--cc=eddyz87@gmail.com \
--cc=ihor.solodrai@linux.dev \
--cc=josef@toxicopanda.com \
--cc=linux-block@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=martin.lau@kernel.org \
--cc=mason@kernel.org \
--cc=tj@kernel.org \
--cc=yonghong.song@linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®