From: Yohei Kojima <yk@y-koj.net>
To: Christian Brauner <brauner@kernel.org>, Shuah Khan <shuah@kernel.org>
Cc: Yohei Kojima <yk@y-koj.net>,
linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org
Subject: [PATCH 0/4] nstree: Fix spurious ENOENT in listns pagination during grace period
Date: Mon, 6 Apr 2026 01:50:36 +0900 [thread overview]
Message-ID: <cover.1775404451.git.yk@y-koj.net> (raw)
This series fixes the spurious ENOENT set by listns when (1) pagination
is used and (2) listns tries to start enumeration from a destroyed or
inactive namespace.
The Cause of the Bug
====================
This bug was caused by lookup_ns_id_at(kls->last_ns_id + 1, ...), which
is called by do_listns(). This function returned NULL if the first
namespace after the given ns id was destroyed or inactivated before this
function is called:
A: active namespace
D: destroyed (or inactive) namespace
+-----+-----+-----+-----+-----+-----+-----+-----+
state: | A | A | A | D | D | A | A | A |
ns_id: | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 |
+-----+-----+-----+-----+-----+-----+-----+-----+
| |
| +-- (kls->last_ns_id + 1)
+-- req.ns_id = 3
For listns(), there is no way to distinguish this case with the case
nstree is empty, therefore it returns -ENOENT although three namespaces
remains in the tree.
Solution
========
The bug is fixed by iterating over the nstree's internal list until it
reaches the first active namespace.
Patches Sequence
================
Patches 1 and Patch 2 fix the existing issues in namespace selftests.
Patch 3 fixes the spurious ENOENT bug. Patch 4 adds a regression test
for this bug.
Disclaimer on Reproduction
==========================
Unfortunately I couldn't reproduce this bug on VM environment, perhaps
because the test I added relies on timing-sensitive RCU behavior. At
least, I confirmed that this bug reproduces on my bare-metal machine
equipped with i7-14700K. Also, I confirmed that all namespaces tests
pass after applying this series.
Yohei Kojima (4):
selftests/namespace: fix selftest hang-up caused by zombie processes
selftests/namespace: fix unintentional skip in ns_active_ref_test.c
nstree: Fix spurious ENOENT in listns pagination during grace period
selftests/namespace: test spurious ENOENT bug in listns pagination
kernel/nstree.c | 68 ++++--
.../namespaces/listns_pagination_bug.c | 200 ++++++++++++++++++
.../selftests/namespaces/ns_active_ref_test.c | 4 +
.../testing/selftests/namespaces/nsid_test.c | 8 +
4 files changed, 258 insertions(+), 22 deletions(-)
--
2.52.0
next reply other threads:[~2026-04-05 16:53 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-05 16:50 Yohei Kojima [this message]
2026-04-05 16:50 ` [PATCH 1/4] selftests/namespace: fix selftest hang-up caused by zombie processes Yohei Kojima
2026-04-05 16:50 ` [PATCH 2/4] selftests/namespace: fix unintentional skip in ns_active_ref_test.c Yohei Kojima
2026-04-05 16:50 ` [PATCH 3/4] nstree: Fix spurious ENOENT in listns pagination during grace period Yohei Kojima
2026-04-05 16:50 ` [PATCH 4/4] selftests/namespace: test spurious ENOENT bug in listns pagination Yohei Kojima
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=cover.1775404451.git.yk@y-koj.net \
--to=yk@y-koj.net \
--cc=brauner@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=shuah@kernel.org \
/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