CVE-2025-22059: udp: Fix multiple wraparounds of sk->sk_rmem_alloc.

Published Apr 16, 2025
·
Updated

In the Linux kernel, the following vulnerability has been resolved:

udp: Fix multiple wraparounds of sk->skrmemalloc.

udpenqueuescheduleskb() has the following condition:

if (atomicread(&sk->skrmemalloc) > sk->skrcvbuf) goto drop;

sk->skrcvbuf is initialised by net.core.rmemdefault and later can be configured by SORCVBUF, which is limited by net.core.rmemmax, or SORCVBUFFORCE.

If we set INTMAX to sk->skrcvbuf, the condition is always false as sk->skrmemalloc is also signed int.

Then, the size of the incoming skb is added to sk->skrmemalloc unconditionally.

This results in integer overflow (possibly multiple times) on sk->skrmemalloc and allows a single socket to have skb up to net.core.udpmem[1].

For example, if we set a large value to udpmem[1] and INTMAX to sk->skrcvbuf and flood packets to the socket, we can see multiple overflows:

# cat /proc/net/sockstat | grep UDP: UDP: inuse 3 mem 7956736 <-- (7956736 << 12) bytes > INTMAX 15 ^- PAGESHIFT # ss -uam State Recv-Q ... UNCONN -1757018048 ... <-- flipping the sign repeatedly skmem:(r2537949248,rb2147483646,t0,tb212992,f1984,w0,o0,bl0,d0)

Previously, we had a boundary check for INTMAX, which was removed by commit 6a1f12dd85a8 ("udp: relax atomic operation on sk->skrmemalloc").

A complete fix would be to revert it and cap the right operand by INTMAX:

rmem = atomicaddreturn(size, &sk->skrmemalloc); if (rmem > min(size + (unsigned int)sk->skrcvbuf, INTMAX)) goto unchargedrop;

but we do not want to add the expensive atomicaddreturn() back just for the corner case.

Casting rmem to unsigned int prevents multiple wraparounds, but we still allow a single wraparound.

# cat /proc/net/sockstat | grep UDP: UDP: inuse 3 mem 524288 <-- (INTMAX + 1) >> 12

# ss -uam State Recv-Q ... UNCONN -2147482816 ... <-- INTMAX + 831 bytes skmem:(r2147484480,rb2147483646,t0,tb212992,f3264,w0,o0,bl0,d14468947)

So, let's define rmem and rcvbuf as unsigned int and check skb->truesize only when rcvbuf is large enough to lower the overflow possibility.

Note that we still have a small chance to see overflow if multiple skbs to the same socket are processed on different core at the same time and each size does not exceed the limit but the total size does.

Note also that we must ignore skb->truesize for a small buffer as explained in commit 363dc73acacb ("udp: be less conservative with sock rmem accounting").

Affected Software

4 affected components
Linux Linux kernel>=6.10<6.12.23
Linux Linux kernel>=6.13<6.13.11
Linux Linux kernel>=6.14<6.14.2
Linux Kernel

Remediation

Recommended actions to resolve this vulnerability, in priority order.

  1. Upgrade

    Upgrade to a fixed release to a version that resolves this vulnerability.

    Patch 6a1f12dd85a8
  2. Upgrade

    Upgrade to a fixed release to a version that resolves this vulnerability.

    Patch 363dc73acacb

Event History

Apr 16, 2025
CVE Published
via MITRE·02:12 PM
Data Sourced
via MITRE·02:12 PM
DescriptionSeverity
Data Sourced
via NVD·03:15 PM
RemedyDescriptionSeverityWeaknessAffected Software

Frequently Asked Questions

1

What is the severity of CVE-2025-22059?

CVE-2025-22059 has been classified as a moderate severity vulnerability in the Linux kernel.

2

How do I fix CVE-2025-22059?

To fix CVE-2025-22059, update your Linux kernel to a version above 6.14.2.

3

What versions of the Linux kernel are affected by CVE-2025-22059?

CVE-2025-22059 affects Linux kernel versions from 6.10 to 6.14.2 inclusive.

4

What type of vulnerability is CVE-2025-22059?

CVE-2025-22059 is a vulnerability related to memory management in the UDP implementation of the Linux kernel.

5

Is there any known exploit for CVE-2025-22059?

As of now, there are no publicly known exploits for CVE-2025-22059.

Contact

SecAlerts Pty Ltd.
132 Wickham Terrace
Fortitude Valley,
QLD 4006, Australia
info@secalerts.co
By using SecAlerts services, you agree to our services end-user license agreement. This website is safeguarded by reCAPTCHA and governed by the Google Privacy Policy and Terms of Service. All names, logos, and brands of products are owned by their respective owners, and any usage of these names, logos, and brands for identification purposes only does not imply endorsement. If you possess any content that requires removal, please get in touch with us.
© 2026 SecAlerts Pty Ltd.
ABN: 70 645 966 203, ACN: 645 966 203