{"id":"CVE-2025-21658","aliases":["CVE-2025-21658"],"related":[],"kind":"vulnerability","state":"published","title":"btrfs: avoid NULL pointer dereference if no valid extent tree","summary":"In the Linux kernel, the following vulnerability has been resolved:\n\nbtrfs: avoid NULL pointer dereference if no valid extent tree\n\n[BUG]\nSyzbot reported a crash with the following call trace:\n\n  BTRFS info (device loop0): scrub: started on devid 1\n  BUG: kernel NULL pointer dereference, address: 0000000000000208\n  #PF: supervisor read access in kernel mode\n  #PF: error_code(0x0000) - not-present page\n  PGD 106e70067 P4D 106e70067 PUD 107143067 PMD 0\n  Oops: Oops: 0000 [#1] PREEMPT SMP NOPTI\n  CPU: 1 UID: 0 PID: 689 Comm: repro Kdump: loaded Tainted: G           O       6.13.0-rc4-custom+ #206\n  Tainted: [O]=OOT_MODULE\n  Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS unknown 02/02/2022\n  RIP: 0010:find_first_extent_item+0x26/0x1f0 [btrfs]\n  Call Trace:\n   <TASK>\n   scrub_find_fill_first_stripe+0x13d/0x3b0 [btrfs]\n   scrub_simple_mirror+0x175/0x260 [btrfs]\n   scrub_stripe+0x5d4/0x6c0 [btrfs]\n   scrub_chunk+0xbb/0x170 [btrfs]\n   scrub_enumerate_chunks+0x2f4/0x5f0 [btrfs]\n   btrfs_scrub_dev+0x240/0x600 [btrfs]\n   btrfs_ioctl+0x1dc8/0x2fa0 [btrfs]\n   ? do_sys_openat2+0xa5/0xf0\n   __x64_sys_ioctl+0x97/0xc0\n   do_syscall_64+0x4f/0x120\n   entry_SYSCALL_64_after_hwframe+0x76/0x7e\n   </TASK>\n\n[CAUSE]\nThe reproducer is using a corrupted image where extent tree root is\ncorrupted, thus forcing to use \"rescue=all,ro\" mount option to mount the\nimage.\n\nThen it triggered a scrub, but since scrub relies on extent tree to find\nwhere the data/metadata extents are, scrub_find_fill_first_stripe()\nrelies on an non-empty extent root.\n\nBut unfortunately scrub_find_fill_first_stripe() doesn't really expect\nan NULL pointer for extent root, it use extent_root to grab fs_info and\ntriggered a NULL pointer dereference.\n\n[FIX]\nAdd an extra check for a valid extent root at the beginning of\nscrub_find_fill_first_stripe().\n\nThe new error path is introduced by 42437a6386ff (\"btrfs: introduce\nmount option rescue=ignorebadroots\"), but that's pretty old, and later\ncommit b979547513ff (\"btrfs: scrub: introduce helper to find and fill\nsector info for a scrub_stripe\") changed how we do scrub.\n\nSo for kernels older than 6.6, the fix will need manual backport.","summarySource":"cvelist","descriptions":[{"lang":"en","text":"In the Linux kernel, the following vulnerability has been resolved:\n\nbtrfs: avoid NULL pointer dereference if no valid extent tree\n\n[BUG]\nSyzbot reported a crash with the following call trace:\n\n  BTRFS info (device loop0): scrub: started on devid 1\n  BUG: kernel NULL pointer dereference, address: 0000000000000208\n  #PF: supervisor read access in kernel mode\n  #PF: error_code(0x0000) - not-present page\n  PGD 106e70067 P4D 106e70067 PUD 107143067 PMD 0\n  Oops: Oops: 0000 [#1] PREEMPT SMP NOPTI\n  CPU: 1 UID: 0 PID: 689 Comm: repro Kdump: loaded Tainted: G           O       6.13.0-rc4-custom+ #206\n  Tainted: [O]=OOT_MODULE\n  Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS unknown 02/02/2022\n  RIP: 0010:find_first_extent_item+0x26/0x1f0 [btrfs]\n  Call Trace:\n   <TASK>\n   scrub_find_fill_first_stripe+0x13d/0x3b0 [btrfs]\n   scrub_simple_mirror+0x175/0x260 [btrfs]\n   scrub_stripe+0x5d4/0x6c0 [btrfs]\n   scrub_chunk+0xbb/0x170 [btrfs]\n   scrub_enumerate_chunks+0x2f4/0x5f0 [btrfs]\n   btrfs_scrub_dev+0x240/0x600 [btrfs]\n   btrfs_ioctl+0x1dc8/0x2fa0 [btrfs]\n   ? do_sys_openat2+0xa5/0xf0\n   __x64_sys_ioctl+0x97/0xc0\n   do_syscall_64+0x4f/0x120\n   entry_SYSCALL_64_after_hwframe+0x76/0x7e\n   </TASK>\n\n[CAUSE]\nThe reproducer is using a corrupted image where extent tree root is\ncorrupted, thus forcing to use \"rescue=all,ro\" mount option to mount the\nimage.\n\nThen it triggered a scrub, but since scrub relies on extent tree to find\nwhere the data/metadata extents are, scrub_find_fill_first_stripe()\nrelies on an non-empty extent root.\n\nBut unfortunately scrub_find_fill_first_stripe() doesn't really expect\nan NULL pointer for extent root, it use extent_root to grab fs_info and\ntriggered a NULL pointer dereference.\n\n[FIX]\nAdd an extra check for a valid extent root at the beginning of\nscrub_find_fill_first_stripe().\n\nThe new error path is introduced by 42437a6386ff (\"btrfs: introduce\nmount option rescue=ignorebadroots\"), but that's pretty old, and later\ncommit b979547513ff (\"btrfs: scrub: introduce helper to find and fill\nsector info for a scrub_stripe\") changed how we do scrub.\n\nSo for kernels older than 6.6, the fix will need manual backport.","source":"cvelist"},{"lang":"es","text":"En el kernel de Linux, se ha resuelto la siguiente vulnerabilidad: btrfs: evitar la desreferencia de puntero NULL si no hay un árbol de extensión válido [ERROR] Syzbot informó de un fallo con el siguiente seguimiento de llamada: Información de BTRFS (bucle de dispositivo 0): scrub: iniciado en devid 1 ERROR: desreferencia de puntero NULL del kernel, dirección: 0000000000000208 #PF: acceso de lectura de supervisor en modo kernel #PF: error_code(0x0000) - página no presente PGD 106e70067 P4D 106e70067 PUD 107143067 PMD 0 Oops: Oops: 0000 [#1] PREEMPT SMP NOPTI CPU: 1 UID: 0 PID: 689 Comm: repro Kdump: cargado Tainted: G O 6.13.0-rc4-custom+ #206 Tainted: [O]=OOT_MODULE Nombre de hardware: PC estándar QEMU (Q35 + ICH9, 2009), BIOS desconocido 02/02/2022 RIP: 0010:find_first_extent_item+0x26/0x1f0 [btrfs] Seguimiento de llamadas:  Scrub_find_fill_first_stripe+0x13d/0x3b0 [btrfs] Scrub_simple_mirror+0x175/0x260 [btrfs] Scrub_stripe+0x5d4/0x6c0 [btrfs] Scrub_chunk+0xbb/0x170 [btrfs] Scrub_enumerate_chunks+0x2f4/0x5f0 [btrfs] btrfs_scrub_dev+0x240/0x600 [btrfs] btrfs_ioctl+0x1dc8/0x2fa0 [btrfs] ? do_sys_openat2+0xa5/0xf0 __x64_sys_ioctl+0x97/0xc0 do_syscall_64+0x4f/0x120 entry_SYSCALL_64_after_hwframe+0x76/0x7e  [CAUSA] El reproductor está usando una imagen dañada donde la raíz del árbol de extensión está dañada, lo que obliga a usar la opción de montaje \"rescue=all,ro\" para montar la imagen. Luego, activó una limpieza, pero como la limpieza depende del árbol de extensión para encontrar dónde están las extensiones de datos/metadatos, scrub_find_fill_first_stripe() depende de una raíz de extensión no vacía. Pero desafortunadamente scrub_find_fill_first_stripe() no espera realmente un puntero NULL para la raíz de la extensión, usa extended_root para obtener fs_info y activa una desreferencia de puntero NULL. [SOLUCIÓN] Agregue una verificación adicional para una raíz de extensión válida al comienzo de scrub_find_fill_first_stripe(). La nueva ruta de error es introducida por 42437a6386ff (\"btrfs: introduce mount option rescue=ignorebadroots\"), pero eso es bastante antiguo, y el commit posterior b979547513ff (\"btrfs: scrub: introduce helper to find and fill sector info for a scrub_stripe\") cambió la forma en que realizamos el scrub. Entonces, para los kernels anteriores a 6.6, la solución necesitará una adaptación manual.","source":"nvd"}],"published":"2025-01-21T12:18:14.578Z","modified":"2026-10-30T13:17:51.060Z","severity":{"scorer":"CISA-ADP","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:N/I:N/A:H","score":5.5,"rating":"MEDIUM"},"severities":[{"scorer":"CISA-ADP","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:N/I:N/A:H","score":5.5,"rating":"MEDIUM"},{"scorer":"NVD","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:N/I:N/A:H","score":5.5,"rating":"MEDIUM"}],"cwes":["CWE-476"],"affected":[{"ranges":[{"type":"git","introduced":"42437a6386ffeaaf200731e73d723ea491f3fe7d","fixed":"1fb37b7840fdcbf69d062a79d14afbf566b11873","status":"affected"},{"type":"git","introduced":"42437a6386ffeaaf200731e73d723ea491f3fe7d","fixed":"24b85a8b0310e0144da9ab30be42e87e6476638a","status":"affected"},{"type":"git","introduced":"42437a6386ffeaaf200731e73d723ea491f3fe7d","fixed":"aee5f69f3e6cd82bfefaca1b70b40b6cd8f3f784","status":"affected"},{"type":"git","introduced":"42437a6386ffeaaf200731e73d723ea491f3fe7d","fixed":"6aecd91a5c5b68939cf4169e32bc49f3cd2dd329","status":"affected"}],"vendor":"Linux","product":"Linux","repo":"https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git","source":"cvelist"},{"ranges":[{"version":"5.11","status":"affected"},{"type":"semver","introduced":"0","fixed":"5.11","status":"unaffected"},{"type":"semver","introduced":"6.1.191","lastAffected":"6.1.*","status":"unaffected"},{"type":"semver","introduced":"6.6.72","lastAffected":"6.6.*","status":"unaffected"},{"type":"semver","introduced":"6.12.10","lastAffected":"6.12.*","status":"unaffected"},{"type":"original_commit_for_fix","introduced":"6.13","lastAffected":"*","status":"unaffected"}],"vendor":"Linux","product":"Linux","repo":"https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git","source":"cvelist"},{"ranges":[{"status":"affected","introduced":"5.11","fixed":"6.6.72"},{"status":"affected","introduced":"6.7","fixed":"6.12.10"},{"status":"affected","version":"6.13"},{"status":"affected","version":"6.13"},{"status":"affected","version":"6.13"},{"status":"affected","version":"6.13"},{"status":"affected","version":"6.13"},{"status":"affected","version":"6.13"}],"vendor":"linux","product":"linux_kernel","cpe":"cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*","source":"nvd"}],"references":[{"url":"https://git.kernel.org/stable/c/1fb37b7840fdcbf69d062a79d14afbf566b11873","tags":[],"sources":["cvelist","nvd"]},{"url":"https://git.kernel.org/stable/c/24b85a8b0310e0144da9ab30be42e87e6476638a","tags":["patch"],"sources":["cvelist","nvd"]},{"url":"https://git.kernel.org/stable/c/aee5f69f3e6cd82bfefaca1b70b40b6cd8f3f784","tags":["patch"],"sources":["cvelist","nvd"]},{"url":"https://git.kernel.org/stable/c/6aecd91a5c5b68939cf4169e32bc49f3cd2dd329","tags":["patch"],"sources":["cvelist","nvd"]}],"credits":[],"assigner":"Linux","ssvc":{"scorer":"CISA-ADP","exploitation":"none","automatable":"no","technicalImpact":"partial","date":"2025-10-01T19:52:37.080Z"},"sources":[{"source":"cvelist","name":"CVE List","id":"CVE-2025-21658","url":"https://www.cve.org/CVERecord?id=CVE-2025-21658","licence":"CVE Terms of Use","modified":"2026-10-30T12:20:41.665Z"},{"source":"nvd","name":"NVD","id":"CVE-2025-21658","url":"https://nvd.nist.gov/vuln/detail/CVE-2025-21658","licence":"Public domain","modified":"2026-10-30T13:17:51.060Z"}],"updatedAt":"2026-11-25T22:58:53.452Z","epss":{"score":0.00204,"percentile":0.10925,"date":"2026-12-01T12:00:22.000Z"}}