CVE-2025-22059 (GCVE-0-2025-22059)
Vulnerability from cvelistv5
Published
2025-04-16 14:12
Modified
2025-05-26 05:17
Severity ?
Summary
In the Linux kernel, the following vulnerability has been resolved: udp: Fix multiple wraparounds of sk->sk_rmem_alloc. __udp_enqueue_schedule_skb() has the following condition: if (atomic_read(&sk->sk_rmem_alloc) > sk->sk_rcvbuf) goto drop; sk->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->sk_rcvbuf, the condition is always false as sk->sk_rmem_alloc is also signed int. Then, the size of the incoming skb is added to sk->sk_rmem_alloc unconditionally. This results in integer overflow (possibly multiple times) on sk->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->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 > 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->sk_rmem_alloc"). A complete fix would be to revert it and cap the right operand by INT_MAX: rmem = atomic_add_return(size, &sk->sk_rmem_alloc); if (rmem > min(size + (unsigned int)sk->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) >> 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->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").
Impacted products
Vendor Product Version
Linux Linux Version: 6a1f12dd85a8b24f871dfcf467378660af9c064d
Version: 6a1f12dd85a8b24f871dfcf467378660af9c064d
Version: 6a1f12dd85a8b24f871dfcf467378660af9c064d
Version: 6a1f12dd85a8b24f871dfcf467378660af9c064d
Create a notification for this product.
Show details on NVD website


{
  "containers": {
    "cna": {
      "affected": [
        {
          "defaultStatus": "unaffected",
          "product": "Linux",
          "programFiles": [
            "net/ipv4/udp.c"
          ],
          "repo": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git",
          "vendor": "Linux",
          "versions": [
            {
              "lessThan": "94d5ad7b41122be33ebc2a6830fe710cba1ecd75",
              "status": "affected",
              "version": "6a1f12dd85a8b24f871dfcf467378660af9c064d",
              "versionType": "git"
            },
            {
              "lessThan": "1f529988efe9870db802cb79d01d8f473099b4d7",
              "status": "affected",
              "version": "6a1f12dd85a8b24f871dfcf467378660af9c064d",
              "versionType": "git"
            },
            {
              "lessThan": "7571aadd20289e9ea10ebfed0986f39ed8b3c16b",
              "status": "affected",
              "version": "6a1f12dd85a8b24f871dfcf467378660af9c064d",
              "versionType": "git"
            },
            {
              "lessThan": "5a465a0da13ee9fbd7d3cd0b2893309b0fe4b7e3",
              "status": "affected",
              "version": "6a1f12dd85a8b24f871dfcf467378660af9c064d",
              "versionType": "git"
            }
          ]
        },
        {
          "defaultStatus": "affected",
          "product": "Linux",
          "programFiles": [
            "net/ipv4/udp.c"
          ],
          "repo": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git",
          "vendor": "Linux",
          "versions": [
            {
              "status": "affected",
              "version": "6.10"
            },
            {
              "lessThan": "6.10",
              "status": "unaffected",
              "version": "0",
              "versionType": "semver"
            },
            {
              "lessThanOrEqual": "6.12.*",
              "status": "unaffected",
              "version": "6.12.23",
              "versionType": "semver"
            },
            {
              "lessThanOrEqual": "6.13.*",
              "status": "unaffected",
              "version": "6.13.11",
              "versionType": "semver"
            },
            {
              "lessThanOrEqual": "6.14.*",
              "status": "unaffected",
              "version": "6.14.2",
              "versionType": "semver"
            },
            {
              "lessThanOrEqual": "*",
              "status": "unaffected",
              "version": "6.15",
              "versionType": "original_commit_for_fix"
            }
          ]
        }
      ],
      "cpeApplicability": [
        {
          "nodes": [
            {
              "cpeMatch": [
                {
                  "criteria": "cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*",
                  "versionEndExcluding": "6.12.23",
                  "versionStartIncluding": "6.10",
                  "vulnerable": true
                },
                {
                  "criteria": "cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*",
                  "versionEndExcluding": "6.13.11",
                  "versionStartIncluding": "6.10",
                  "vulnerable": true
                },
                {
                  "criteria": "cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*",
                  "versionEndExcluding": "6.14.2",
                  "versionStartIncluding": "6.10",
                  "vulnerable": true
                },
                {
                  "criteria": "cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*",
                  "versionEndExcluding": "6.15",
                  "versionStartIncluding": "6.10",
                  "vulnerable": true
                }
              ],
              "negate": false,
              "operator": "OR"
            }
          ]
        }
      ],
      "descriptions": [
        {
          "lang": "en",
          "value": "In the Linux kernel, the following vulnerability has been resolved:\n\nudp: Fix multiple wraparounds of sk-\u003esk_rmem_alloc.\n\n__udp_enqueue_schedule_skb() has the following condition:\n\n  if (atomic_read(\u0026sk-\u003esk_rmem_alloc) \u003e sk-\u003esk_rcvbuf)\n          goto drop;\n\nsk-\u003esk_rcvbuf is initialised by net.core.rmem_default and later can\nbe configured by SO_RCVBUF, which is limited by net.core.rmem_max,\nor SO_RCVBUFFORCE.\n\nIf we set INT_MAX to sk-\u003esk_rcvbuf, the condition is always false\nas sk-\u003esk_rmem_alloc is also signed int.\n\nThen, the size of the incoming skb is added to sk-\u003esk_rmem_alloc\nunconditionally.\n\nThis results in integer overflow (possibly multiple times) on\nsk-\u003esk_rmem_alloc and allows a single socket to have skb up to\nnet.core.udp_mem[1].\n\nFor example, if we set a large value to udp_mem[1] and INT_MAX to\nsk-\u003esk_rcvbuf and flood packets to the socket, we can see multiple\noverflows:\n\n  # cat /proc/net/sockstat | grep UDP:\n  UDP: inuse 3 mem 7956736  \u003c-- (7956736 \u003c\u003c 12) bytes \u003e INT_MAX * 15\n                                             ^- PAGE_SHIFT\n  # ss -uam\n  State  Recv-Q      ...\n  UNCONN -1757018048 ...    \u003c-- flipping the sign repeatedly\n         skmem:(r2537949248,rb2147483646,t0,tb212992,f1984,w0,o0,bl0,d0)\n\nPreviously, we had a boundary check for INT_MAX, which was removed by\ncommit 6a1f12dd85a8 (\"udp: relax atomic operation on sk-\u003esk_rmem_alloc\").\n\nA complete fix would be to revert it and cap the right operand by\nINT_MAX:\n\n  rmem = atomic_add_return(size, \u0026sk-\u003esk_rmem_alloc);\n  if (rmem \u003e min(size + (unsigned int)sk-\u003esk_rcvbuf, INT_MAX))\n          goto uncharge_drop;\n\nbut we do not want to add the expensive atomic_add_return() back just\nfor the corner case.\n\nCasting rmem to unsigned int prevents multiple wraparounds, but we still\nallow a single wraparound.\n\n  # cat /proc/net/sockstat | grep UDP:\n  UDP: inuse 3 mem 524288  \u003c-- (INT_MAX + 1) \u003e\u003e 12\n\n  # ss -uam\n  State  Recv-Q      ...\n  UNCONN -2147482816 ...   \u003c-- INT_MAX + 831 bytes\n         skmem:(r2147484480,rb2147483646,t0,tb212992,f3264,w0,o0,bl0,d14468947)\n\nSo, let\u0027s define rmem and rcvbuf as unsigned int and check skb-\u003etruesize\nonly when rcvbuf is large enough to lower the overflow possibility.\n\nNote that we still have a small chance to see overflow if multiple skbs\nto the same socket are processed on different core at the same time and\neach size does not exceed the limit but the total size does.\n\nNote also that we must ignore skb-\u003etruesize for a small buffer as\nexplained in commit 363dc73acacb (\"udp: be less conservative with\nsock rmem accounting\")."
        }
      ],
      "providerMetadata": {
        "dateUpdated": "2025-05-26T05:17:34.456Z",
        "orgId": "416baaa9-dc9f-4396-8d5f-8c081fb06d67",
        "shortName": "Linux"
      },
      "references": [
        {
          "url": "https://git.kernel.org/stable/c/94d5ad7b41122be33ebc2a6830fe710cba1ecd75"
        },
        {
          "url": "https://git.kernel.org/stable/c/1f529988efe9870db802cb79d01d8f473099b4d7"
        },
        {
          "url": "https://git.kernel.org/stable/c/7571aadd20289e9ea10ebfed0986f39ed8b3c16b"
        },
        {
          "url": "https://git.kernel.org/stable/c/5a465a0da13ee9fbd7d3cd0b2893309b0fe4b7e3"
        }
      ],
      "title": "udp: Fix multiple wraparounds of sk-\u003esk_rmem_alloc.",
      "x_generator": {
        "engine": "bippy-1.2.0"
      }
    }
  },
  "cveMetadata": {
    "assignerOrgId": "416baaa9-dc9f-4396-8d5f-8c081fb06d67",
    "assignerShortName": "Linux",
    "cveId": "CVE-2025-22059",
    "datePublished": "2025-04-16T14:12:15.505Z",
    "dateReserved": "2024-12-29T08:45:45.812Z",
    "dateUpdated": "2025-05-26T05:17:34.456Z",
    "state": "PUBLISHED"
  },
  "dataType": "CVE_RECORD",
  "dataVersion": "5.1",
  "vulnerability-lookup:meta": {
    "nvd": "{\"cve\":{\"id\":\"CVE-2025-22059\",\"sourceIdentifier\":\"416baaa9-dc9f-4396-8d5f-8c081fb06d67\",\"published\":\"2025-04-16T15:15:59.380\",\"lastModified\":\"2025-05-06T16:41:21.620\",\"vulnStatus\":\"Analyzed\",\"cveTags\":[],\"descriptions\":[{\"lang\":\"en\",\"value\":\"In the Linux kernel, the following vulnerability has been resolved:\\n\\nudp: Fix multiple wraparounds of sk-\u003esk_rmem_alloc.\\n\\n__udp_enqueue_schedule_skb() has the following condition:\\n\\n  if (atomic_read(\u0026sk-\u003esk_rmem_alloc) \u003e sk-\u003esk_rcvbuf)\\n          goto drop;\\n\\nsk-\u003esk_rcvbuf is initialised by net.core.rmem_default and later can\\nbe configured by SO_RCVBUF, which is limited by net.core.rmem_max,\\nor SO_RCVBUFFORCE.\\n\\nIf we set INT_MAX to sk-\u003esk_rcvbuf, the condition is always false\\nas sk-\u003esk_rmem_alloc is also signed int.\\n\\nThen, the size of the incoming skb is added to sk-\u003esk_rmem_alloc\\nunconditionally.\\n\\nThis results in integer overflow (possibly multiple times) on\\nsk-\u003esk_rmem_alloc and allows a single socket to have skb up to\\nnet.core.udp_mem[1].\\n\\nFor example, if we set a large value to udp_mem[1] and INT_MAX to\\nsk-\u003esk_rcvbuf and flood packets to the socket, we can see multiple\\noverflows:\\n\\n  # cat /proc/net/sockstat | grep UDP:\\n  UDP: inuse 3 mem 7956736  \u003c-- (7956736 \u003c\u003c 12) bytes \u003e INT_MAX * 15\\n                                             ^- PAGE_SHIFT\\n  # ss -uam\\n  State  Recv-Q      ...\\n  UNCONN -1757018048 ...    \u003c-- flipping the sign repeatedly\\n         skmem:(r2537949248,rb2147483646,t0,tb212992,f1984,w0,o0,bl0,d0)\\n\\nPreviously, we had a boundary check for INT_MAX, which was removed by\\ncommit 6a1f12dd85a8 (\\\"udp: relax atomic operation on sk-\u003esk_rmem_alloc\\\").\\n\\nA complete fix would be to revert it and cap the right operand by\\nINT_MAX:\\n\\n  rmem = atomic_add_return(size, \u0026sk-\u003esk_rmem_alloc);\\n  if (rmem \u003e min(size + (unsigned int)sk-\u003esk_rcvbuf, INT_MAX))\\n          goto uncharge_drop;\\n\\nbut we do not want to add the expensive atomic_add_return() back just\\nfor the corner case.\\n\\nCasting rmem to unsigned int prevents multiple wraparounds, but we still\\nallow a single wraparound.\\n\\n  # cat /proc/net/sockstat | grep UDP:\\n  UDP: inuse 3 mem 524288  \u003c-- (INT_MAX + 1) \u003e\u003e 12\\n\\n  # ss -uam\\n  State  Recv-Q      ...\\n  UNCONN -2147482816 ...   \u003c-- INT_MAX + 831 bytes\\n         skmem:(r2147484480,rb2147483646,t0,tb212992,f3264,w0,o0,bl0,d14468947)\\n\\nSo, let\u0027s define rmem and rcvbuf as unsigned int and check skb-\u003etruesize\\nonly when rcvbuf is large enough to lower the overflow possibility.\\n\\nNote that we still have a small chance to see overflow if multiple skbs\\nto the same socket are processed on different core at the same time and\\neach size does not exceed the limit but the total size does.\\n\\nNote also that we must ignore skb-\u003etruesize for a small buffer as\\nexplained in commit 363dc73acacb (\\\"udp: be less conservative with\\nsock rmem accounting\\\").\"},{\"lang\":\"es\",\"value\":\"En el kernel de Linux, se ha resuelto la siguiente vulnerabilidad: udp: Se corrigen m\u00faltiples encapsulamientos de sk-\u0026gt;sk_rmem_alloc. __udp_enqueue_schedule_skb() tiene la siguiente condici\u00f3n: if (atomic_read(\u0026amp;sk-\u0026gt;sk_rmem_alloc) \u0026gt; sk-\u0026gt;sk_rcvbuf) goto drop; sk-\u0026gt;sk_rcvbuf se inicializa con net.core.rmem_default y posteriormente se puede configurar con SO_RCVBUF, que est\u00e1 limitado por net.core.rmem_max o SO_RCVBUFFORCE. Si se establece INT_MAX en sk-\u0026gt;sk_rcvbuf, la condici\u00f3n siempre es falsa, ya que sk-\u0026gt;sk_rmem_alloc tambi\u00e9n es un entero con signo. En ese caso, el tama\u00f1o del skb entrante se a\u00f1ade a sk-\u0026gt;sk_rmem_alloc incondicionalmente. Esto provoca un desbordamiento de enteros (posiblemente varias veces) en sk-\u0026gt;sk_rmem_alloc y permite que un \u00fanico socket tenga skb hasta net.core.udp_mem[1]. Por ejemplo, si establecemos un valor grande en udp_mem[1] e INT_MAX en sk-\u0026gt;sk_rcvbuf e inundamos el socket con paquetes, podemos ver m\u00faltiples desbordamientos: # cat /proc/net/sockstat | grep UDP: UDP: inuse 3 mem 7956736 \u0026lt;-- (7956736 \u0026lt;\u0026lt; 12) bytes \u0026gt; INT_MAX * 15 ^- PAGE_SHIFT # ss -uam State Recv-Q ... UNCONN -1757018048 ... \u0026lt;-- invirtiendo el signo repetidamente skmem:(r2537949248,rb2147483646,t0,tb212992,f1984,w0,o0,bl0,d0) Anteriormente, ten\u00edamos una verificaci\u00f3n de l\u00edmite para INT_MAX, que se elimin\u00f3 mediante el commit 6a1f12dd85a8 (\\\"udp: relajar la operaci\u00f3n at\u00f3mica en sk-\u0026gt;sk_rmem_alloc\\\"). Una soluci\u00f3n completa ser\u00eda revertirlo y limitar el operando derecho con INT_MAX: rmem = atomic_add_return(size, \u0026amp;sk-\u0026gt;sk_rmem_alloc); if (rmem \u0026gt; min(size + (unsigned int)sk-\u0026gt;sk_rcvbuf, INT_MAX)) goto uncharge_drop; pero no queremos a\u00f1adir el costoso atomic_add_return() solo para casos excepcionales. Convertir rmem a unsigned int evita m\u00faltiples encapsulamientos, pero a\u00fan permite un \u00fanico encapsulamiento. # cat /proc/net/sockstat | grep UDP: UDP: inuse 3 mem 524288 \u0026lt;-- (INT_MAX + 1) \u0026gt;\u0026gt; 12 # ss -uam State Recv-Q ... UNCONN -2147482816 ... \u0026lt;-- INT_MAX + 831 bytes skmem:(r2147484480,rb2147483646,t0,tb212992,f3264,w0,o0,bl0,d14468947) Por lo tanto, definamos rmem y rcvbuf como unsigned int y verifiquemos skb-\u0026gt;truesize solo cuando rcvbuf sea lo suficientemente grande como para reducir la posibilidad de desbordamiento. Tenga en cuenta que a\u00fan existe una peque\u00f1a probabilidad de ver un desbordamiento si se procesan m\u00faltiples skbs al mismo socket en diferentes n\u00facleos al mismo tiempo y cada tama\u00f1o no excede el l\u00edmite, pero el tama\u00f1o total s\u00ed. Tenga en cuenta tambi\u00e9n que debemos ignorar skb-\u0026gt;truesize para un buffer peque\u00f1o como se explica en el commit 363dc73acacb (\\\"udp: sea menos conservador con la contabilidad de sock rmem\\\").\"}],\"metrics\":{\"cvssMetricV31\":[{\"source\":\"nvd@nist.gov\",\"type\":\"Primary\",\"cvssData\":{\"version\":\"3.1\",\"vectorString\":\"CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:N/I:N/A:H\",\"baseScore\":5.5,\"baseSeverity\":\"MEDIUM\",\"attackVector\":\"LOCAL\",\"attackComplexity\":\"LOW\",\"privilegesRequired\":\"LOW\",\"userInteraction\":\"NONE\",\"scope\":\"UNCHANGED\",\"confidentialityImpact\":\"NONE\",\"integrityImpact\":\"NONE\",\"availabilityImpact\":\"HIGH\"},\"exploitabilityScore\":1.8,\"impactScore\":3.6}]},\"weaknesses\":[{\"source\":\"nvd@nist.gov\",\"type\":\"Primary\",\"description\":[{\"lang\":\"en\",\"value\":\"CWE-190\"}]}],\"configurations\":[{\"nodes\":[{\"operator\":\"OR\",\"negate\":false,\"cpeMatch\":[{\"vulnerable\":true,\"criteria\":\"cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*\",\"versionStartIncluding\":\"6.10\",\"versionEndExcluding\":\"6.12.23\",\"matchCriteriaId\":\"CD08468B-6C62-4470-90F6-7F16F10CF3B4\"},{\"vulnerable\":true,\"criteria\":\"cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*\",\"versionStartIncluding\":\"6.13\",\"versionEndExcluding\":\"6.13.11\",\"matchCriteriaId\":\"E7E864B0-8C00-4679-BA55-659B4C9C3AD3\"},{\"vulnerable\":true,\"criteria\":\"cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*\",\"versionStartIncluding\":\"6.14\",\"versionEndExcluding\":\"6.14.2\",\"matchCriteriaId\":\"FADAE5D8-4808-442C-B218-77B2CE8780A0\"}]}]}],\"references\":[{\"url\":\"https://git.kernel.org/stable/c/1f529988efe9870db802cb79d01d8f473099b4d7\",\"source\":\"416baaa9-dc9f-4396-8d5f-8c081fb06d67\",\"tags\":[\"Patch\"]},{\"url\":\"https://git.kernel.org/stable/c/5a465a0da13ee9fbd7d3cd0b2893309b0fe4b7e3\",\"source\":\"416baaa9-dc9f-4396-8d5f-8c081fb06d67\",\"tags\":[\"Patch\"]},{\"url\":\"https://git.kernel.org/stable/c/7571aadd20289e9ea10ebfed0986f39ed8b3c16b\",\"source\":\"416baaa9-dc9f-4396-8d5f-8c081fb06d67\",\"tags\":[\"Patch\"]},{\"url\":\"https://git.kernel.org/stable/c/94d5ad7b41122be33ebc2a6830fe710cba1ecd75\",\"source\":\"416baaa9-dc9f-4396-8d5f-8c081fb06d67\",\"tags\":[\"Patch\"]}]}}"
  }
}


Log in or create an account to share your comment.




Tags
Taxonomy of the tags.


Loading…

Loading…

Loading…

Sightings

Author Source Type Date

Nomenclature

  • Seen: The vulnerability was mentioned, discussed, or seen somewhere by the user.
  • Confirmed: The vulnerability is confirmed from an analyst perspective.
  • Exploited: This vulnerability was exploited and seen by the user reporting the sighting.
  • Patched: This vulnerability was successfully patched by the user reporting the sighting.
  • Not exploited: This vulnerability was not exploited or seen by the user reporting the sighting.
  • Not confirmed: The user expresses doubt about the veracity of the vulnerability.
  • Not patched: This vulnerability was not successfully patched by the user reporting the sighting.


Loading…

Loading…