From: netdev-bot+sashiko@kernel.org
To: kernel@cbannister.uk
Cc: edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com,
davem@davemloft.net, netdev@vger.kernel.org, willemb@google.com,
horms@kernel.org, kuniyu@google.com, shuah@kernel.org,
linux-kselftest@vger.kernel.org, regressions@lists.linux.dev,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH net 3/3] selftests: net: test that RTM_GETLINK answers from the target netns
Date: Mon, 30 Nov 2026 22:39:39 +0000 [thread overview]
Message-ID: <179607837909.3146.12869515913198207631@kernel.org> (raw)
In-Reply-To: <20261129223628.2167924-4-kernel@cbannister.uk>
Thank you for your contribution! Sashiko AI review found 6 potential
issue(s) to consider.
Critical: 0 · High: 0 · Medium: 1 · Low: 5
If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).
- [Medium] The test depends on a kernel behaviour that lets user space
hold the global RTNL for as long as it likes.
- [Low] The commit message contradicts itself about testing.
- [Low] The Testing paragraph says "v7.4-rc4 with 1/3 and 2/3 applied"
and never names the fix this selftest checks.
- [Low] The selftest only checks lookup by ifindex.
- [Low] wait_blocked() takes any 'D' state in /proc/self/task/<tid>/stat
as proof that the sender thread is on rtnl_mutex's wait list.
- [Low] The test holds the global rtnl_mutex, plus the per-netns lock
taken by rtnl_net_lock() in dev_ifconf(), while the gifconf thread…
--
selftests: net: test that RTM_GETLINK answers from the target netns
This adds a selftest that holds RTNL by stalling a SIOCGIFCONF ioctl on a
userfaultfd page. It then queues an RTM_SETLINK that moves a dummy device
to another netns, and an RTM_GETLINK by ifindex behind it, and expects the
GETLINK to fail with -ENODEV once the fault is resolved. CONFIG_USERFAULTFD=y
is added to the net selftests config.
> Testing: on vanilla kernel.org builds in a VM with CONFIG_USERFAULTFD=y,
> the test failed in each of 20 runs on that commit and on v7.4-rc4,
> and passed in each of 20 runs on its parent and on
> v7.4-rc4 with 1/3 and 2/3 applied. None of the 80 runs was skipped.
[Severity: Low]
Could the fix this test depends on be named by its subject rather than as
"1/3 and 2/3"? Once the series is merged, those positions mean nothing in
git history.
The test fails by design on any kernel without "rtnetlink: look the device
up under RTNL in full rtnl_getlink() requests". That includes e896e5c0734b
and the tree just before this series. Someone backporting only the selftest
has nothing in this commit that points to the commit it needs.
> AI assistance: this test and this commit message were produced by AI
> tools directed by the submitter: Claude Opus 5.5, Claude Fable 5.2 and
> Claude Sonnet 5.5 (Anthropic), and OpenAI gpt-6.2-sol and
> gpt-6.2-astra via Codex. Claude Fable 5.2 designed the test.
> The submitter read the test and follows its method, and has not run
> it.
[Severity: Low]
The Testing paragraph above gives exact results for 80 runs, but this
paragraph says the submitter "has not run it". Who ran those 80 runs, and
where?
The fix commit "rtnetlink: look the device up under RTNL in full
rtnl_getlink() requests" cites the same selftest numbers as evidence. From
the message alone, it isn't clear whether a person saw these results or an
AI tool reported them.
Documentation/process/generated-content.rst asks "How is the submission
tested and what tools were used to test the fix?". Item 8 of
Documentation/process/coding-assistants.rst asks submitters to say plainly
what could not be tested.
Could the message say who produced these results?
> diff --git a/tools/testing/selftests/net/rtnl_getlink.c b/tools/testing/selftests/net/rtnl_getlink.c
> new file mode 100644
> index 0000000000000..03d578870673c
> --- /dev/null
> +++ b/tools/testing/selftests/net/rtnl_getlink.c
> @@ -0,0 +1,356 @@
[ ... ]
> +static char task_state(pid_t tid)
> +{
> + char path[64], buf[512], *p;
> + int fd, len;
> +
> + snprintf(path, sizeof(path), "/proc/self/task/%d/stat", tid);
> + fd = open(path, O_RDONLY | O_CLOEXEC);
> + if (fd < 0)
> + return 0;
> + len = read(fd, buf, sizeof(buf) - 1);
> + close(fd);
> + if (len <= 0)
> + return 0;
> + buf[len] = 0;
> + p = strrchr(buf, ')');
> + return p && p[1] == ' ' ? p[2] : 0;
> +}
> +
> +/* Waits until the thread sleeps uninterruptibly, as a task waiting for RTNL
> + * does once the lock's owner is itself asleep.
> + */
> +static int wait_blocked(struct sender *s)
> +{
> + long start = now_ms();
> + pid_t tid;
> +
> + while (now_ms() - start < WAIT_MS) {
> + tid = __atomic_load_n(&s->tid, __ATOMIC_ACQUIRE);
> + if (tid && task_state(tid) == 'D')
> + return 0;
[Severity: Low]
Is a 'D' state enough to show that the sender is on the rtnl_mutex wait
list? task_state() reads only the one-letter state. A TASK_UNINTERRUPTIBLE
or TASK_KILLABLE sleep can also happen before rtnl_lock() is reached.
rtnl_setlink() and rtnl_getlink() are both called without RTNL and take it
themselves. Before that, the sender thread runs netlink_sendmsg(), which
allocates the skb with GFP_KERNEL and can enter direct reclaim or memcg
throttling. Copying the request from the main thread's stack may also need
a swap-in.
Suppose the GETLINK thread is caught in one of these sleeps before its RCU
lookup, on a kernel with e896e5c0734b. The fault is resolved, the move
completes, and the late lookup returns -ENODEV, so the test passes on a
broken kernel. That contradicts the commit message:
so a kernel that looks the device up before taking RTNL fails on every
run.
If the move thread is caught early instead, the GETLINK can reach
rtnl_mutex first, and the test skips on any kernel.
Could the test check /proc/<tid>/wchan or /proc/<tid>/stack for rtnl_lock
or __mutex_lock, so this assumption is checked and not just stated in the
commit message? Once the sleep really is on the mutex, the ordering holds:
__mutex_add_waiter() appends to the tail under wait_lock.
[ ... ]
> + /* Hold RTNL: the ioctl faults on the page in copy_to_user(), and
> + * sleeps there until the fault is resolved.
> + */
> + gifconf.ifc.ifc_len = page_size;
> + gifconf.ifc.ifc_buf = page;
> + ASSERT_EQ(0, pthread_create(&gifconf_t, NULL, gifconf_thread,
> + &gifconf));
[Severity: Medium]
This makes the test depend on dev_ifconf() holding the global RTNL across
a copy_to_user() into a user buffer:
net/core/dev_ioctl.c:dev_ifconf() {
...
rtnl_net_lock(net);
for_each_netdev(net, dev) {
...
done = inet_gifconf(dev, pos + total,
len - total, size);
...
}
net/ipv4/devinet.c:inet_gifconf() {
...
if (copy_to_user(buf + done, &ifr, size)) {
...
}
That behaviour predates this patch, but it lets a local user stall RTNL
for every netns on the host. sock_ioctl() requires no capability for
SIOCGIFCONF. The fault can be held open with userfaultfd (with privilege
or vm.unprivileged_userfaultfd=1), or with an mmap of a FUSE file whose
daemon never answers.
If dev_ifconf() is later changed to collect the ifreqs into a kernel buffer
and copy them out after rtnl_net_unlock(), the uffd fault still arrives
and poll() succeeds, but the move no longer blocks. wait_blocked(&move)
then polls for WAIT_MS and the ASSERT fails.
Should the test skip rather than fail in that case, so that fixing the
RTNL stall doesn't make this selftest fail?
> + pfd.fd = uffd;
> + ASSERT_EQ(1, poll(&pfd, 1, WAIT_MS));
> + ASSERT_EQ(sizeof(msg), read(uffd, &msg, sizeof(msg)));
> + ASSERT_EQ(UFFD_EVENT_PAGEFAULT, msg.event);
> +
> + /* Queue the move to the other netns, where the device gets another
> + * ifindex, as the first waiter for RTNL.
> + */
> + req_init(&move.req, RTM_SETLINK, NLM_F_ACK, 2, ifindex);
> + req_put(&move.req, IFLA_NET_NS_FD, &other_ns, sizeof(other_ns));
> + req_put(&move.req, IFLA_NEW_IFINDEX, &new_ifindex,
> + sizeof(new_ifindex));
> + ASSERT_EQ(0, pthread_create(&move_t, NULL, sender_thread, &move));
> + ASSERT_EQ(0, wait_blocked(&move)) {
> + TH_LOG("the move never waited for RTNL");
> + }
[Severity: Low]
At this point the gifconf thread holds RTNL, plus the per-netns lock from
rtnl_net_lock(), while it sleeps in the uffd fault. If this wait_blocked()
times out, does RTNL stay held for the full WAIT_MS, until the harness child
exits?
The only explicit release is the UFFDIO_COPY further down. On the failure
paths, the lock is dropped only when process exit makes the gifconf
thread's copy_to_user() fail. That is up to 10 s here, and up to about 20 s
if this check passes late and wait_blocked(&get) then times out.
During that time every rtnl_lock() user on the host sleeps in D state,
including linkwatch and other selftests running in parallel. This is not a
deadlock. Would resolving the fault before the ASSERT fails keep a failing
run from stalling RTNL for the whole machine?
> +
> + /* Queue the request behind it. The device is still in this netns,
> + * so a lookup done before taking RTNL finds it.
> + */
> + req_init(&get.req, RTM_GETLINK, 0, 3, ifindex);
[Severity: Low]
Should there also be a request by name? The file header comment claims the
property for any RTM_GETLINK request without RTEXT_FILTER_NAME_ONLY.
rtnl_getlink() makes the same promise for both kinds of lookup:
net/core/rtnetlink.c:rtnl_getlink() {
...
/* Look the device up under the lock the reply is built under:
* RTNL keeps it registered in tgt_net, with the requested
* ifindex or name, until the reply is complete.
*/
rtnl_lock();
if (ifm->ifi_index > 0)
dev = __dev_get_by_index(tgt_net, ifm->ifi_index);
else
dev = rtnl_dev_get(tgt_net, tb);
...
}
This test sends only a request by ifindex. If the rtnl_dev_get() lookup
moved back before RTNL, as the RTEXT_FILTER_NAME_ONLY path does with
rtnl_dev_get_rcu(), the test would still pass.
The fix commit says its reproducer found the netns bug with requests by
name. The device keeps the name getlink0 after the move, so an IFLA_IFNAME
request could be queued behind the move in the same way.
[ ... ]
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261129223628.2167924-1-kernel%40cbannister.uk
prev parent reply other threads:[~2026-11-30 22:39 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-29 22:36 [PATCH net 0/3] rtnetlink: build full rtnl_getlink() replies in one RTNL section again Chris Bannister
2026-11-29 22:36 ` [PATCH net 1/3] rtnetlink: look the device up under RTNL in full rtnl_getlink() requests Chris Bannister
2026-11-29 22:36 ` [PATCH net 2/3] rtnetlink: queue the rtnl_getlink() reply before releasing RTNL Chris Bannister
2026-11-29 22:36 ` [PATCH net 3/3] selftests: net: test that RTM_GETLINK answers from the target netns Chris Bannister
2026-11-30 22:39 ` netdev-bot+sashiko [this message]
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=179607837909.3146.12869515913198207631@kernel.org \
--to=netdev-bot+sashiko@kernel.org \
--cc=davem@davemloft.net \
--cc=edumazet@kernel.org \
--cc=horms@kernel.org \
--cc=kernel@cbannister.uk \
--cc=kuba@kernel.org \
--cc=kuniyu@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=regressions@lists.linux.dev \
--cc=shuah@kernel.org \
--cc=willemb@google.com \
/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®