Netdev List
 help / color / mirror / Atom feed
* [PATCH net 0/3] rtnetlink: build full rtnl_getlink() replies in one RTNL section again
@ 2026-11-29 22:36 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
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Chris Bannister @ 2026-11-29 22:36 UTC (permalink / raw)
  To: Eric Dumazet, Jakub Kicinski, Paolo Abeni, David S. Miller,
	netdev
  Cc: Willem de Bruijn, Simon Horman, Kuniyuki Iwashima, Shuah Khan,
	linux-kselftest, regressions, linux-kernel

Since commit e896e5c0734b ("rtnetlink: do not acquire RTNL in
rtnl_getlink() with RTEXT_FILTER_NAME_ONLY"), an RTM_GETLINK request
that still needs RTNL looks the device up before taking RTNL and sends
the reply after releasing it. Both gaps are reproduced on unmodified
kernels:

- A reply can be queued after a link notification built from newer
  state on the same socket. systemd-networkd applies such a reply as
  the current state, which is consistent with the VM boots where this
  was found: they lost carrier just after gaining it and got no DHCP
  lease. Reported in
  https://lore.kernel.org/all/20261129214529.4059732-1-kernel@cbannister.uk/.

- A request by ifindex that races a move of the device to another
  netns can be answered with the device's data from its new netns.
  Reported in https://lore.kernel.org/all/20261129215752.251291-1-kernel@cbannister.uk/.

1/3 looks the device up under RTNL again for requests that need RTNL.
2/3 sends the reply before releasing RTNL. 3/3 adds a deterministic
selftest for the netns case, which fails on that commit and on
v7.4-rc4 and passes with 1/3 and 2/3.
There is no deterministic selftest for the ordering. A single-patch
version of 1/3 and 2/3 is available if preferred.

One point on 3/3 needs a maintainer's judgement. The test holds RTNL
by making the copy_to_user() in SIOCGIFCONF fault on a userfaultfd
page, so it rests on dev_ifconf() copying out under RTNL. I cannot
judge whether a test that depends on that detail is acceptable; if it
is not, 1/3 and 2/3 stand without it.

Each patch states how its bug was found and how the fix was tested.
In short, on v7.4-rc4 against v7.4-rc4 with this series, with the
same config, host and binaries: the ordering reproducer nlrace.c [1]
saw 8 to 20 inversions in each of five 60-second runs, against none;
the netns reproducer counted 47 foreign replies in 20,000 iterations,
against none; and a lockdep, PROVE_RCU and KASAN build of the series
ran the reproducers with no report. The only modified kernels cited
here were diagnostic v7.3.6 builds with an inserted delay, used to
confirm the effect on systemd-networkd boots.

AI assistance: the investigation, the reproducers, the fix, the
selftest, the commit messages and this cover letter were produced by
AI tools directed by me: 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 fix and the selftest, and
gpt-6.2-astra reviewed the fix.

I personally reproduced both regressions on a bare-metal machine,
reviewed nlrace.c and the fix patches, read the selftest without
running it, and read rtnl_getlink() and __dev_change_net_namespace().

[1] https://github.com/zariel/linux-rtnetlink-getlink-regressions/blob/main/nlrace/c/nlrace.c

Chris Bannister

Chris Bannister (3):
  rtnetlink: look the device up under RTNL in full rtnl_getlink()
    requests
  rtnetlink: queue the rtnl_getlink() reply before releasing RTNL
  selftests: net: test that RTM_GETLINK answers from the target netns

 net/core/rtnetlink.c                       |  73 +++--
 tools/testing/selftests/net/.gitignore     |   1 +
 tools/testing/selftests/net/Makefile       |   2 +
 tools/testing/selftests/net/config         |   1 +
 tools/testing/selftests/net/rtnl_getlink.c | 356 +++++++++++++++++++++
 5 files changed, 405 insertions(+), 28 deletions(-)
 create mode 100644 tools/testing/selftests/net/rtnl_getlink.c


base-commit: fad0d57b12f6979bc0127f0a4f704c6d7177ca78
-- 
2.56.0


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-11-29 22:38 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox