deepin-kernel/net/netlink
Jakub Kicinski 17e83b78bf netlink: make sure we allow at least one dump skb
commit a215b5723922f8099078478122f02100e489cb80 upstream.

Commit under Fixes tightened up the memory accounting for Netlink
sockets. Looks like the accounting is too strict for some existing
use cases, Marek reported issues with nl80211 / WiFi iw CLI.

To reduce number of iterations Netlink dumps try to allocate
messages based on the size of the buffer passed to previous
recvmsg() calls. If user space uses a larger buffer in recvmsg()
than sk_rcvbuf we will allocate an skb we won't be able to queue.

Make sure we always allow at least one skb to be queued.
Same workaround is already present in netlink_attachskb().
Alternative would be to cap the allocation size to
  rcvbuf - rmem_alloc
but as I said, the workaround is already present in other places.

Reported-by: Marek Szyprowski <m.szyprowski@samsung.com>
Link: https://lore.kernel.org/9794af18-4905-46c6-b12c-365ea2f05858@samsung.com
Fixes: ae8f160e7eb2 ("netlink: Fix wraparounds of sk->sk_rmem_alloc.")
Tested-by: Marek Szyprowski <m.szyprowski@samsung.com>
Reviewed-by: Kuniyuki Iwashima <kuniyu@google.com>
Link: https://patch.msgid.link/20250711001121.3649033-1-kuba@kernel.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit c31ee1695b6d88042d7bd6b2a77babb70f941451)
2025-07-22 16:16:43 +08:00
..
Kconfig treewide: replace '---help---' in Kconfig files with 'help' 2020-06-14 01:57:21 +09:00
Makefile netlink: add infrastructure to expose policies to userspace 2020-04-30 17:51:42 -07:00
af_netlink.c netlink: make sure we allow at least one dump skb 2025-07-22 16:16:43 +08:00
af_netlink.h netlink: terminate outstanding dump on socket close 2024-12-10 20:43:52 +08:00
diag.c sock_diag: add module pointer to "struct sock_diag_handler" 2024-12-10 20:44:39 +08:00
genetlink.c genetlink: hold RCU in genlmsg_mcast() 2024-12-10 20:43:05 +08:00
policy.c net: genl: fix error path memory leak in policy dumping 2022-08-18 10:20:48 -07:00