« Volver al listado

CVE-2025-21942

Estado: AnalizadaMedia (5.5)—

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

btrfs: zoned: fix extent range end unlock in cow_file_range()

Running generic/751 on the for-next branch often results in a hang like below. They are both stack by locking an extent. This suggests someone forget to unlock an extent.

This happens because we have another success path for the zoned mode. When there is no active zone available, btrfs_reserve_extent() returns -EAGAIN. In this case, we have two reactions.

The commit 06f364284794 ("btrfs: do proper folio cleanup when cow_file_range() failed") moved the unlock code from the inside of the loop to the outside.

Leer descripción completaMostrar menos

So, previously, the allocated extents are unlocked just after the allocation and so before returning from the function. However, they are no longer unlocked on the case (2) above. That caused the hang issue.

Fix the issue by modifying the 'end' to the end of the allocated range. Then, we can exit the loop and the same unlock code can properly handle the case.

Detalles técnicos trazas, registros y código del informe original
  INFO: task kworker/u128:1:12 blocked for more than 323 seconds.
        Not tainted 6.13.0-BTRFS-ZNS+ #503
  "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
  task:kworker/u128:1  state:D stack:0     pid:12    tgid:12    ppid:2      flags:0x00004000
  Workqueue: btrfs-fixup btrfs_work_helper [btrfs]
  Call Trace:
   <TASK>
   __schedule+0x534/0xdd0
   schedule+0x39/0x140
   __lock_extent+0x31b/0x380 [btrfs]
   ? __pfx_autoremove_wake_function+0x10/0x10
   btrfs_writepage_fixup_worker+0xf1/0x3a0 [btrfs]
   btrfs_work_helper+0xff/0x480 [btrfs]
   ? lock_release+0x178/0x2c0
   process_one_work+0x1ee/0x570
   ? srso_return_thunk+0x5/0x5f
   worker_thread+0x1d1/0x3b0
   ? __pfx_worker_thread+0x10/0x10
   kthread+0x10b/0x230
   ? __pfx_kthread+0x10/0x10
   ret_from_fork+0x30/0x50
   ? __pfx_kthread+0x10/0x10
   ret_from_fork_asm+0x1a/0x30
   </TASK>
  INFO: task kworker/u134:0:184 blocked for more than 323 seconds.
        Not tainted 6.13.0-BTRFS-ZNS+ #503
  "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
  task:kworker/u134:0  state:D stack:0     pid:184   tgid:184   ppid:2      flags:0x00004000
  Workqueue: writeback wb_workfn (flush-btrfs-4)
  Call Trace:
   <TASK>
   __schedule+0x534/0xdd0
   schedule+0x39/0x140
   __lock_extent+0x31b/0x380 [btrfs]
   ? __pfx_autoremove_wake_function+0x10/0x10
   find_lock_delalloc_range+0xdb/0x260 [btrfs]
   writepage_delalloc+0x12f/0x500 [btrfs]
   ? srso_return_thunk+0x5/0x5f
   extent_write_cache_pages+0x232/0x840 [btrfs]
   btrfs_writepages+0x72/0x130 [btrfs]
   do_writepages+0xe7/0x260
   ? srso_return_thunk+0x5/0x5f
   ? lock_acquire+0xd2/0x300
   ? srso_return_thunk+0x5/0x5f
   ? find_held_lock+0x2b/0x80
   ? wbc_attach_and_unlock_inode.part.0+0x102/0x250
   ? wbc_attach_and_unlock_inode.part.0+0x102/0x250
   __writeback_single_inode+0x5c/0x4b0
   writeback_sb_inodes+0x22d/0x550
   __writeback_inodes_wb+0x4c/0xe0
   wb_writeback+0x2f6/0x3f0
   wb_workfn+0x32a/0x510
   process_one_work+0x1ee/0x570
   ? srso_return_thunk+0x5/0x5f
   worker_thread+0x1d1/0x3b0
   ? __pfx_worker_thread+0x10/0x10
   kthread+0x10b/0x230
   ? __pfx_kthread+0x10/0x10
   ret_from_fork+0x30/0x50
   ? __pfx_kthread+0x10/0x10
   ret_from_fork_asm+0x1a/0x30
   </TASK>

(1) If the given range is never allocated, we can only wait for someone
    to finish a zone, so wait on BTRFS_FS_NEED_ZONE_FINISH bit and retry
    afterward.

(2) Or, if some allocations are already done, we must bail out and let
    the caller to send IOs for the allocation. This is because these IOs
    may be necessary to finish a zone.

CVSS

Probabilidad de explotación (EPSS)

EPSS (Exploit Prediction Scoring System, de FIRST) estima la probabilidad de que una vulnerabilidad sea explotada en 30 días. Complementa a CVSS (impacto) y a CISA KEV (explotación confirmada).

Tecnologías afectadas (1)

CWE

Referencias

JSON original (NVD)

Mostrar
{
  "id": "CVE-2025-21942",
  "cveTags": [],
  "metrics": {
    "cvssMetricV31": [
      {
        "type": "Primary",
        "source": "nvd@nist.gov",
        "cvssData": {
          "scope": "UNCHANGED",
          "version": "3.1",
          "baseScore": 5.5,
          "attackVector": "LOCAL",
          "baseSeverity": "MEDIUM",
          "vectorString": "CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:N/I:N/A:H",
          "integrityImpact": "NONE",
          "userInteraction": "NONE",
          "attackComplexity": "LOW",
          "availabilityImpact": "HIGH",
          "privilegesRequired": "LOW",
          "confidentialityImpact": "NONE"
        },
        "impactScore": 3.6,
        "exploitabilityScore": 1.8
      }
    ]
  },
  "affected": [
    {
      "source": "416baaa9-dc9f-4396-8d5f-8c081fb06d67",
      "affectedData": [
        {
          "repo": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git",
          "vendor": "Linux",
          "product": "Linux",
          "versions": [
            {
              "status": "affected",
              "version": "10b3772292bf1be45604ba83fd9650eb94382e78",
              "lessThan": "5f4863cfb29a7b4fe7625ce148d0b9000b75b802",
              "versionType": "git"
            },
            {
              "status": "affected",
              "version": "692cf71173bb41395c855acbbbe197d3aedfa5d4",
              "lessThan": "3fcff2f55389306482ab049b4321bda49495e546",
              "versionType": "git"
            },
            {
              "status": "affected",
              "version": "06f364284794f149d2abc167c11d556cf20c954b",
              "lessThan": "5a4041f2c47247575a6c2e53ce14f7b0ac946c33",
              "versionType": "git"
            }
          ],
          "programFiles": [
            "fs/btrfs/inode.c"
          ],
          "defaultStatus": "unaffected"
        },
        {
          "repo": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git",
          "vendor": "Linux",
          "product": "Linux",
          "versions": [
            {
              "status": "affected",
              "version": "6.13.2",
              "lessThan": "6.13.7",
              "versionType": "semver"
            }
          ],
          "programFiles": [
            "fs/btrfs/inode.c"
          ],
          "defaultStatus": "unaffected"
        }
      ]
    }
  ],
  "published": "2025-04-01T16:15:25.100",
  "references": [
    {
      "url": "https://git.kernel.org/stable/c/3fcff2f55389306482ab049b4321bda49495e546",
      "tags": [
        "Patch"
      ],
      "source": "416baaa9-dc9f-4396-8d5f-8c081fb06d67"
    },
    {
      "url": "https://git.kernel.org/stable/c/5a4041f2c47247575a6c2e53ce14f7b0ac946c33",
      "tags": [
        "Patch"
      ],
      "source": "416baaa9-dc9f-4396-8d5f-8c081fb06d67"
    },
    {
      "url": "https://git.kernel.org/stable/c/5f4863cfb29a7b4fe7625ce148d0b9000b75b802",
      "tags": [
        "Patch"
      ],
      "source": "416baaa9-dc9f-4396-8d5f-8c081fb06d67"
    }
  ],
  "vulnStatus": "Analyzed",
  "weaknesses": [
    {
      "type": "Primary",
      "source": "nvd@nist.gov",
      "description": [
        {
          "lang": "en",
          "value": "CWE-835"
        }
      ]
    }
  ],
  "descriptions": [
    {
      "lang": "en",
      "value": "In the Linux kernel, the following vulnerability has been resolved:\n\nbtrfs: zoned: fix extent range end unlock in cow_file_range()\n\nRunning generic/751 on the for-next branch often results in a hang like\nbelow. They are both stack by locking an extent. This suggests someone\nforget to unlock an extent.\n\n  INFO: task kworker/u128:1:12 blocked for more than 323 seconds.\n        Not tainted 6.13.0-BTRFS-ZNS+ #503\n  \"echo 0 > /proc/sys/kernel/hung_task_timeout_secs\" disables this message.\n  task:kworker/u128:1  state:D stack:0     pid:12    tgid:12    ppid:2      flags:0x00004000\n  Workqueue: btrfs-fixup btrfs_work_helper [btrfs]\n  Call Trace:\n   <TASK>\n   __schedule+0x534/0xdd0\n   schedule+0x39/0x140\n   __lock_extent+0x31b/0x380 [btrfs]\n   ? __pfx_autoremove_wake_function+0x10/0x10\n   btrfs_writepage_fixup_worker+0xf1/0x3a0 [btrfs]\n   btrfs_work_helper+0xff/0x480 [btrfs]\n   ? lock_release+0x178/0x2c0\n   process_one_work+0x1ee/0x570\n   ? srso_return_thunk+0x5/0x5f\n   worker_thread+0x1d1/0x3b0\n   ? __pfx_worker_thread+0x10/0x10\n   kthread+0x10b/0x230\n   ? __pfx_kthread+0x10/0x10\n   ret_from_fork+0x30/0x50\n   ? __pfx_kthread+0x10/0x10\n   ret_from_fork_asm+0x1a/0x30\n   </TASK>\n  INFO: task kworker/u134:0:184 blocked for more than 323 seconds.\n        Not tainted 6.13.0-BTRFS-ZNS+ #503\n  \"echo 0 > /proc/sys/kernel/hung_task_timeout_secs\" disables this message.\n  task:kworker/u134:0  state:D stack:0     pid:184   tgid:184   ppid:2      flags:0x00004000\n  Workqueue: writeback wb_workfn (flush-btrfs-4)\n  Call Trace:\n   <TASK>\n   __schedule+0x534/0xdd0\n   schedule+0x39/0x140\n   __lock_extent+0x31b/0x380 [btrfs]\n   ? __pfx_autoremove_wake_function+0x10/0x10\n   find_lock_delalloc_range+0xdb/0x260 [btrfs]\n   writepage_delalloc+0x12f/0x500 [btrfs]\n   ? srso_return_thunk+0x5/0x5f\n   extent_write_cache_pages+0x232/0x840 [btrfs]\n   btrfs_writepages+0x72/0x130 [btrfs]\n   do_writepages+0xe7/0x260\n   ? srso_return_thunk+0x5/0x5f\n   ? lock_acquire+0xd2/0x300\n   ? srso_return_thunk+0x5/0x5f\n   ? find_held_lock+0x2b/0x80\n   ? wbc_attach_and_unlock_inode.part.0+0x102/0x250\n   ? wbc_attach_and_unlock_inode.part.0+0x102/0x250\n   __writeback_single_inode+0x5c/0x4b0\n   writeback_sb_inodes+0x22d/0x550\n   __writeback_inodes_wb+0x4c/0xe0\n   wb_writeback+0x2f6/0x3f0\n   wb_workfn+0x32a/0x510\n   process_one_work+0x1ee/0x570\n   ? srso_return_thunk+0x5/0x5f\n   worker_thread+0x1d1/0x3b0\n   ? __pfx_worker_thread+0x10/0x10\n   kthread+0x10b/0x230\n   ? __pfx_kthread+0x10/0x10\n   ret_from_fork+0x30/0x50\n   ? __pfx_kthread+0x10/0x10\n   ret_from_fork_asm+0x1a/0x30\n   </TASK>\n\nThis happens because we have another success path for the zoned mode. When\nthere is no active zone available, btrfs_reserve_extent() returns\n-EAGAIN. In this case, we have two reactions.\n\n(1) If the given range is never allocated, we can only wait for someone\n    to finish a zone, so wait on BTRFS_FS_NEED_ZONE_FINISH bit and retry\n    afterward.\n\n(2) Or, if some allocations are already done, we must bail out and let\n    the caller to send IOs for the allocation. This is because these IOs\n    may be necessary to finish a zone.\n\nThe commit 06f364284794 (\"btrfs: do proper folio cleanup when\ncow_file_range() failed\") moved the unlock code from the inside of the\nloop to the outside. So, previously, the allocated extents are unlocked\njust after the allocation and so before returning from the function.\nHowever, they are no longer unlocked on the case (2) above. That caused\nthe hang issue.\n\nFix the issue by modifying the 'end' to the end of the allocated\nrange. Then, we can exit the loop and the same unlock code can properly\nhandle the case."
    },
    {
      "lang": "es",
      "value": "En el kernel de Linux, se ha resuelto la siguiente vulnerabilidad: btrfs: zoned: fix extent range end unlock in cow_file_range(). Ejecutar generic/751 en la rama for-next suele provocar un bloqueo como el que se muestra a continuación. Ambas se acumulan bloqueando una extensión. Esto sugiere que alguien olvidó desbloquear una extensión. INFORMACIÓN: La tarea kworker/u128:1:12 se bloqueó durante más de 323 segundos. No contaminada. 6.13.0-BTRFS-ZNS+ #503 \"echo 0 &gt; /proc/sys/kernel/hung_task_timeout_secs\" desactiva este mensaje. tarea:kworker/u128:1 estado:D pila:0 pid:12 tgid:12 ppid:2 indicadores:0x00004000 Cola de trabajo: btrfs-fixup btrfs_work_helper [btrfs] Rastreo de llamadas:  __schedule+0x534/0xdd0 schedule+0x39/0x140 __lock_extent+0x31b/0x380 [btrfs] ? __pfx_autoremove_wake_function+0x10/0x10 btrfs_writepage_fixup_worker+0xf1/0x3a0 [btrfs] btrfs_work_helper+0xff/0x480 [btrfs] ? lock_release+0x178/0x2c0 process_one_work+0x1ee/0x570 ? srso_return_thunk+0x5/0x5f worker_thread+0x1d1/0x3b0 ? __pfx_worker_thread+0x10/0x10 kthread+0x10b/0x230 ? __pfx_kthread+0x10/0x10 ret_from_fork+0x30/0x50 ? __pfx_kthread+0x10/0x10 ret_from_fork_asm+0x1a/0x30  INFO: task kworker/u134:0:184 blocked for more than 323 seconds. Not tainted 6.13.0-BTRFS-ZNS+ #503 \"echo 0 &gt; /proc/sys/kernel/hung_task_timeout_secs\" disables this message. task:kworker/u134:0 state:D stack:0 pid:184 tgid:184 ppid:2 flags:0x00004000 Workqueue: writeback wb_workfn (flush-btrfs-4) Call Trace:  __schedule+0x534/0xdd0 schedule+0x39/0x140 __lock_extent+0x31b/0x380 [btrfs] ? __pfx_autoremove_wake_function+0x10/0x10 find_lock_delalloc_range+0xdb/0x260 [btrfs] writepage_delalloc+0x12f/0x500 [btrfs] ? srso_return_thunk+0x5/0x5f extent_write_cache_pages+0x232/0x840 [btrfs] btrfs_writepages+0x72/0x130 [btrfs] do_writepages+0xe7/0x260 ? srso_return_thunk+0x5/0x5f ? lock_acquire+0xd2/0x300 ? srso_return_thunk+0x5/0x5f ? find_held_lock+0x2b/0x80 ? wbc_attach_and_unlock_inode.part.0+0x102/0x250 ? wbc_attach_and_unlock_inode.part.0+0x102/0x250 __writeback_single_inode+0x5c/0x4b0 writeback_sb_inodes+0x22d/0x550 __writeback_inodes_wb+0x4c/0xe0 wb_writeback+0x2f6/0x3f0 wb_workfn+0x32a/0x510 process_one_work+0x1ee/0x570 ? srso_return_thunk+0x5/0x5f worker_thread+0x1d1/0x3b0 ? __pfx_worker_thread+0x10/0x10 kthread+0x10b/0x230 ? __pfx_kthread+0x10/0x10 ret_from_fork+0x30/0x50 ? __pfx_kthread+0x10/0x10 ret_from_fork_asm+0x1a/0x30  Esto sucede porque tenemos otra ruta de éxito para el modo zonificado. Cuando no hay ninguna zona activa disponible, btrfs_reserve_extent() devuelve -EAGAIN. En este caso, tenemos dos reacciones. (1) Si el rango dado nunca se asigna, solo podemos esperar a que alguien complete una zona, por lo que esperamos el bit BTRFS_FS_NEED_ZONE_FINISH y reintentamos después. (2) O bien, si ya se han realizado algunas asignaciones, debemos abandonar y dejar que el llamador envíe E/S para la asignación. Esto se debe a que estas E/S pueden ser necesarias para completar una zona. El commit 06f364284794 (\"btrfs: realizar la limpieza de folio correcta cuando cow_file_range() falla\") movió el código de desbloqueo del interior del bucle al exterior. Por lo tanto, antes, las extensiones asignadas se desbloqueaban justo después de la asignación y, por lo tanto, antes de regresar de la función. Sin embargo, ya no se desbloquean en el caso (2) mencionado. Esto causó el bloqueo. Para solucionar el problema, modifique \"end\" al final del rango asignado. De esta manera, podemos salir del bucle y el mismo código de desbloqueo puede gestionar el caso correctamente."
    }
  ],
  "lastModified": "2026-06-17T08:44:40.193",
  "configurations": [
    {
      "nodes": [
        {
          "negate": false,
          "cpeMatch": [
            {
              "criteria": "cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*",
              "vulnerable": true,
              "matchCriteriaId": "29216D30-0F8D-48B2-8F91-77DB6C23D506",
              "versionEndExcluding": "6.13.7",
              "versionStartIncluding": "6.13.2"
            },
            {
              "criteria": "cpe:2.3:o:linux:linux_kernel:6.14:rc1:*:*:*:*:*:*",
              "vulnerable": true,
              "matchCriteriaId": "186716B6-2B66-4BD0-852E-D48E71C0C85F"
            },
            {
              "criteria": "cpe:2.3:o:linux:linux_kernel:6.14:rc2:*:*:*:*:*:*",
              "vulnerable": true,
              "matchCriteriaId": "0D3E781C-403A-498F-9DA9-ECEE50F41E75"
            },
            {
              "criteria": "cpe:2.3:o:linux:linux_kernel:6.14:rc3:*:*:*:*:*:*",
              "vulnerable": true,
              "matchCriteriaId": "66619FB8-0AAF-4166-B2CF-67B24143261D"
            },
            {
              "criteria": "cpe:2.3:o:linux:linux_kernel:6.14:rc4:*:*:*:*:*:*",
              "vulnerable": true,
              "matchCriteriaId": "D3D6550E-6679-4560-902D-AF52DCFE905B"
            },
            {
              "criteria": "cpe:2.3:o:linux:linux_kernel:6.14:rc5:*:*:*:*:*:*",
              "vulnerable": true,
              "matchCriteriaId": "45B90F6B-BEC7-4D4E-883A-9DBADE021750"
            }
          ],
          "operator": "OR"
        }
      ]
    }
  ],
  "sourceIdentifier": "416baaa9-dc9f-4396-8d5f-8c081fb06d67"
}