• CVE-2025-22059

发布时间: 2025年4月17日

修改时间: 2025年4月23日

概要

In the Linux kernel, the following vulnerability has been resolved: udp: Fix multiple wraparounds of sk-&gt;sk_rmem_alloc. __udp_enqueue_schedule_skb() has the following condition: if (atomic_read(&amp;sk-&gt;sk_rmem_alloc) &gt; sk-&gt;sk_rcvbuf) goto drop; sk-&gt;sk_rcvbuf is initialised by net.core.rmem_default and later can be configured by SO_RCVBUF, which is limited by net.core.rmem_max, or SO_RCVBUFFORCE. If we set INT_MAX to sk-&gt;sk_rcvbuf, the condition is always false as sk-&gt;sk_rmem_alloc is also signed int. Then, the size of the incoming skb is added to sk-&gt;sk_rmem_alloc unconditionally. This results in integer overflow (possibly multiple times) on sk-&gt;sk_rmem_alloc and allows a single socket to have skb up to net.core.udp_mem[1]. For example, if we set a large value to udp_mem[1] and INT_MAX to sk-&gt;sk_rcvbuf 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 &gt; INT_MAX * 15 ^- PAGE_SHIFT # 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 INT_MAX, which was removed by commit 6a1f12dd85a8 ("udp: relax atomic operation on sk-&gt;sk_rmem_alloc"). A complete fix would be to revert it and cap the right operand by INT_MAX: rmem = atomic_add_return(size, &amp;sk-&gt;sk_rmem_alloc); if (rmem &gt; min(size + (unsigned int)sk-&gt;sk_rcvbuf, INT_MAX)) goto uncharge_drop; but we do not want to add the expensive atomic_add_return() 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 <-- (INT_MAX + 1) &gt;&gt; 12 # ss -uam State Recv-Q ... UNCONN -2147482816 ... <-- INT_MAX + 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-&gt;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-&gt;truesize for a small buffer as explained in commit 363dc73acacb ("udp: be less conservative with sock rmem accounting").

CVSS v3 指标

NVD openEuler
Confidentiality Low
Attack Vector Local
CVSS评分 N/A 3.9
Attack Complexity High
Privileges Required High
Scope Unchanged
Integrity Low
User Interaction None
Availability Low

安全公告

公告名 概要 发布时间
KylinSec-SA-2025-2411 In the Linux kernel, the following vulnerability has been resolved: udp: Fix multiple wraparounds of sk-&gt;sk_rmem_alloc. __udp_enqueue_schedule_skb() has the following condition: if (atomic_read(&amp;sk-&gt;sk_rmem_alloc) &gt; sk-&gt;sk_rcvbuf) goto drop; sk-&gt;sk_rcvbuf is initialised by net.core.rmem_default and later can be configured by SO_RCVBUF, which is limited by net.core.rmem_max, or SO_RCVBUFFORCE. If we set INT_MAX to sk-&gt;sk_rcvbuf, the condition is always false as sk-&gt;sk_rmem_alloc is also signed int. Then, the size of the incoming skb is added to sk-&gt;sk_rmem_alloc unconditionally. This results in integer overflow (possibly multiple times) on sk-&gt;sk_rmem_alloc and allows a single socket to have skb up to net.core.udp_mem[1]. For example, if we set a large value to udp_mem[1] and INT_MAX to sk-&gt;sk_rcvbuf 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 &gt; INT_MAX * 15 ^- PAGE_SHIFT # 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 INT_MAX, which was removed by commit 6a1f12dd85a8 ("udp: relax atomic operation on sk-&gt;sk_rmem_alloc"). A complete fix would be to revert it and cap the right operand by INT_MAX: rmem = atomic_add_return(size, &amp;sk-&gt;sk_rmem_alloc); if (rmem &gt; min(size + (unsigned int)sk-&gt;sk_rcvbuf, INT_MAX)) goto uncharge_drop; but we do not want to add the expensive atomic_add_return() 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 <-- (INT_MAX + 1) &gt;&gt; 12 # ss -uam State Recv-Q ... UNCONN -2147482816 ... <-- INT_MAX + 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-&gt;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-&gt;truesize for a small buffer as explained in commit 363dc73acacb ("udp: be less conservative with sock rmem accounting"). 2025年5月30日

影响产品

产品 状态
KY3.4-5A kernel Unaffected
KY3.5.3 kernel Unaffected
V6 kernel Unaffected