netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next v2 0/3] Fix netlink rcvbuf wraparound
@ 2025-06-18 23:13 Jason Baron
  2025-06-18 23:13 ` [PATCH net-next v2 1/3] net: add sock_rcvbuf_has_space() helper Jason Baron
                   ` (2 more replies)
  0 siblings, 3 replies; 12+ messages in thread
From: Jason Baron @ 2025-06-18 23:13 UTC (permalink / raw)
  To: netdev; +Cc: davem, edumazet, kuba, pabeni, horms, kuniyu

The sk->sk_rmem_alloc field of a netlink socket can wraparound as a
signed int when comparing to sk->sk_rcvbuf, when sk->sk_rcvbuf approaches
INT_MAX. This can be reproduced by forcing sk->sk_rcvbuf to INT_MAX and
this can exhaust all of memory.

I've added a sock_rcvbuf_has_space() helper function to generalize the
fix as a similar approach has already been implemented for udp sockets.

v2:
-add Fixes:
-add sock_rcvbuf_has_space() helper
-use helper functions for udp netlink
-remove excessive parentheses

Jason Baron (3):
  net: add sock_rcvbuf_has_space() helper
  udp: use __sock_rcvbuf_has_space() helper
  netlink: Fix wraparound of sk->sk_rmem_alloc

 include/net/sock.h       | 38 ++++++++++++++++++++++++++++++++++++++
 net/ipv4/udp.c           | 13 ++-----------
 net/netlink/af_netlink.c | 35 +++++++++++++++++++++--------------
 3 files changed, 61 insertions(+), 25 deletions(-)

-- 
2.25.1


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

end of thread, other threads:[~2025-06-25 16:56 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-06-18 23:13 [PATCH net-next v2 0/3] Fix netlink rcvbuf wraparound Jason Baron
2025-06-18 23:13 ` [PATCH net-next v2 1/3] net: add sock_rcvbuf_has_space() helper Jason Baron
2025-06-18 23:13 ` [PATCH net-next v2 2/3] udp: use __sock_rcvbuf_has_space() helper Jason Baron
2025-06-18 23:13 ` [PATCH net-next v2 3/3] netlink: Fix wraparound of sk->sk_rmem_alloc Jason Baron
2025-06-19  6:13   ` Kuniyuki Iwashima
2025-06-23 23:35     ` Jakub Kicinski
2025-06-24  7:55       ` Paolo Abeni
2025-06-24 13:57         ` Jason Baron
2025-06-24 14:11         ` Jakub Kicinski
2025-06-24 17:08           ` Kuniyuki Iwashima
2025-06-24 22:03             ` Jakub Kicinski
2025-06-25 16:56               ` Kuniyuki Iwashima

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).