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=1796078381; b=jVFr+kFw2AE/P0kODP/9x2wkVhe+jOzzxORqWLEM5/2op/JxRl3us7H7yapSq3fdFpc+ pruBxiT6iVFMt2imoZ7KFgurBUCrOZHBaUsU4gBJZnLJGUGOxakA12lEOziZM6Ey0HPCi SQU0+sGNBuV/Lul9aAUN4VqXHN5yOMfYzjkNvLNAW2VfZjZUTwjOrWwaXtB3IiDnKVM5+ J81xkUBLHT8oYUXzuSneoKvuxBlKRJp59c7xFOTQ0CEqehM7YuynBNArM5+jUjClqCoL5 JlSR4sl7TRqyaR4AtkHfW3o32Ck9QG0R+HggJQZ7aE1G2234B21Fwd3RFIs6evs5xEw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796078381; h=Received:DKIM-Signature:Subject:From:To:Cc:Date:Message-ID: In-Reply-To:References:X-sashiko-severity:Content-Type: Content-Transfer-Encoding:MIME-Version; bh=6PcLu4+RP38ttqs2angsxfb1hARM75Jwx2K89K7z3E0=; b=Xs8GQ7vu3vwOmS0oM3P/Xb4eaY1rcSTJA4YtPCS2nk3VFS/2jmIahIWMB3TuTPvZzVq1 2MhEVDbgqjtdCq8ikn2UBV0OFj1SIN2fwOwq1GZzQ5nEKVrAwOSKP+FuJCtbthApC/vhC DfO7EtQGKaD0WyL8Bn6+xf7GNAEd6LagndyvZD1SWlfeAezqqQun3PzTrEhJkqf4uHqQ7 k6GfgNQZdxt9VReQZ8SbGADQy2W41mwO9rPemHBIGkZxikEO8OssUm/O7FRVWArZjkQJO 1tLBx3NFOBoA3N2EA1xita/gPEJoH2k2hxsbDon5gMQmjgNhTMqUMlYW+5K659eddjQ== 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=f9Z8wdRs; 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 1500E606A320; Mon, 30 Nov 2026 22:39:40 +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=f9Z8wdRs Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8E3BA1F00899; Mon, 30 Nov 2026 22:39:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796078380; bh=6PcLu4+RP38ttqs2angsxfb1hARM75Jwx2K89K7z3E0=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=f9Z8wdRsPLlNpYSvdSnJK4sh7M0NvPHmdA4NJw5zxm/42ker/LSsFTWZ95HvhWBdD /r42+RuZsl0MoaadEq8X/RiROm6GyHH5rZ95SY/hqrvrLrP8dTBYGvK/9thN19GTvs ZUJ3vDYC1rsukQp2QuPYPdOrb77/P62kJ7urfYDyAKJB4mLu6DjR1LG0C2kNlv7can Rg2xUJ3eOplej7Fv2OycPpRKGNK0AUMdtJhx8Te6yRLVMEG8qS3A6eyTQU7rWlRJvh JgrY13iAZvFut8vPWeureT2c/IpbCuSauM40qC/SdWontEudB3YAkdZWXafaR/btG6 11sNG4+v7N4QA== Subject: Re: [PATCH net 3/3] selftests: net: test that RTM_GETLINK answers from the target netns 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 Date: Mon, 30 Nov 2026 22:39:39 +0000 Message-ID: <179607837909.3146.12869515913198207631@kernel.org> In-Reply-To: <20261129223628.2167924-4-kernel@cbannister.uk> References: <20261129223628.2167924-4-kernel@cbannister.uk> X-sashiko-severity: Medium Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit 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 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//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//wchan or /proc//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