Skip to content

netlink: fix a dump livelock with a notification queued

Jhonata Poma-Hansen b4-sent linux-kselftest lkml netdev 2 versions – Applied

Status from this message: This series was applied to netdev/net.git (main)

Get series with b4
b4 am [email protected] change-id 20261023-netlink-dump-livelock-e83cf13f977a

Versions newest first

  1. v2 Latest2 patches 2 repliesApplied 2/2
  2. v12 patches 1 replySuperseded

Changes in v2 from the cover letter

- Patch 1: check sk_rcvbuf before charging instead of retrying with
the minimum skb size, which could still be rejected (Sashiko), and
refuse a skb that would take sk_rmem_alloc past INT_MAX.
- Patch 1: say how the bug was found and how the fix was tested.
- Patch 2: use SO_RCVBUF 2048, which also fails with v1, check the
NLMSG_DONE status and that a link was dumped, and skip without
privileges (Sashiko).
- Link to v1: https://patch.msgid.link/[email protected]

Patches in v2 All 2 applied

#Subject and filesSizeRepliesApplied
1/2netlink: check sk_rcvbuf before charging the dump skbnet/netlink/af_netlink.c+5 -12 repliesApplied
2/2selftests: net: netlink-dumps: start a dump with a notification queuedtools/testing/selftests/net/netlink-dumps.c+102 -00 repliesApplied

Reviews trailers per patch

1 of 2 patches has a Reviewed-by or Acked-by.

PatchEric Dumazet
1/2R-b
2/2

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v2 thread

Cover letter [PATCH net v2 0/2] netlink: fix a dump livelock with a notification queued

A netlink dump that starts while a notification is still charged to a socket with a small receive buffer fails with ENOBUFS, and every retry from recvmsg() fails the same way. A reader that peeks before reading, as libnl does, never consumes the message at the head of the queue and spins forever. I hit this with "iw dev wlan0 scan" on an arm64 board.

Patch 1 goes back to checking sk_rcvbuf before charging the dump skb, as before commit ae8f160e7eb2. Patch 2 adds a selftest; it fails without patch 1 and is skipped without the privileges to create a netns.

---
Changes in v2:
- Patch 1: check sk_rcvbuf before charging instead of retrying with
the minimum skb size, which could still be rejected (Sashiko), and
refuse a skb that would take sk_rmem_alloc past INT_MAX.
- Patch 1: say how the bug was found and how the fix was tested.
- Patch 2: use SO_RCVBUF 2048, which also fails with v1, check the
NLMSG_DONE status and that a link was dumped, and skip without
privileges (Sashiko).
- Link to v1: https://patch.msgid.link/[email protected]

To: "David S. Miller" <[email protected]>
To: Eric Dumazet <[email protected]>
To: Jakub Kicinski <[email protected]>
To: Paolo Abeni <[email protected]>
To: Simon Horman <[email protected]>
To: Kuniyuki Iwashima <[email protected]>
To: Shuah Khan <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]

---
Jhonata Poma-Hansen (2):
netlink: check sk_rcvbuf before charging the dump skb
selftests: net: netlink-dumps: start a dump with a notification queued

 net/netlink/af_netlink.c                    |   6 +-
 tools/testing/selftests/net/netlink-dumps.c | 102 ++++++++++++++++++++++++++++
 2 files changed, 107 insertions(+), 1 deletion(-)

---
base-commit: 734bef548a96e8774d6eef5dfa2026c6edc4e80b
change-id: 20261023-netlink-dump-livelock-e83cf13f977a

Best regards,

Signature · 1 line
Jhonata Poma-Hansen <[email protected]>