{"id":"CVE-2025-40100","aliases":["CVE-2025-40100"],"related":[],"kind":"vulnerability","state":"published","title":"btrfs: do not assert we found block group item when creating free space tree","summary":"In the Linux kernel, the following vulnerability has been resolved:\n\nbtrfs: do not assert we found block group item when creating free space tree\n\nCurrently, when building a free space tree at populate_free_space_tree(),\nif we are not using the block group tree feature, we always expect to find\nblock group items (either extent items or a block group item with key type\nBTRFS_BLOCK_GROUP_ITEM_KEY) when we search the extent tree with\nbtrfs_search_slot_for_read(), so we assert that we found an item. However\nthis expectation is wrong since we can have a new block group created in\nthe current transaction which is still empty and for which we still have\nnot added the block group's item to the extent tree, in which case we do\nnot have any items in the extent tree associated to the block group.\n\nThe insertion of a new block group's block group item in the extent tree\nhappens at btrfs_create_pending_block_groups() when it calls the helper\ninsert_block_group_item(). This typically is done when a transaction\nhandle is released, committed or when running delayed refs (either as\npart of a transaction commit or when serving tickets for space reservation\nif we are low on free space).\n\nSo remove the assertion at populate_free_space_tree() even when the block\ngroup tree feature is not enabled and update the comment to mention this\ncase.\n\nSyzbot reported this with the following stack trace:\n\n  BTRFS info (device loop3 state M): rebuilding free space tree\n  assertion failed: ret == 0 :: 0, in fs/btrfs/free-space-tree.c:1115\n  ------------[ cut here ]------------\n  kernel BUG at fs/btrfs/free-space-tree.c:1115!\n  Oops: invalid opcode: 0000 [#1] SMP KASAN PTI\n  CPU: 1 UID: 0 PID: 6352 Comm: syz.3.25 Not tainted syzkaller #0 PREEMPT(full)\n  Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 08/18/2025\n  RIP: 0010:populate_free_space_tree+0x700/0x710 fs/btrfs/free-space-tree.c:1115\n  Code: ff ff e8 d3 (...)\n  RSP: 0018:ffffc9000430f780 EFLAGS: 00010246\n  RAX: 0000000000000043 RBX: ffff88805b709630 RCX: fea61d0e2e79d000\n  RDX: 0000000000000000 RSI: 0000000080000000 RDI: 0000000000000000\n  RBP: ffffc9000430f8b0 R08: ffffc9000430f4a7 R09: 1ffff92000861e94\n  R10: dffffc0000000000 R11: fffff52000861e95 R12: 0000000000000001\n  R13: 1ffff92000861f00 R14: dffffc0000000000 R15: 0000000000000000\n  FS:  00007f424d9fe6c0(0000) GS:ffff888125afc000(0000) knlGS:0000000000000000\n  CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033\n  CR2: 00007fd78ad212c0 CR3: 0000000076d68000 CR4: 00000000003526f0\n  Call Trace:\n   <TASK>\n   btrfs_rebuild_free_space_tree+0x1ba/0x6d0 fs/btrfs/free-space-tree.c:1364\n   btrfs_start_pre_rw_mount+0x128f/0x1bf0 fs/btrfs/disk-io.c:3062\n   btrfs_remount_rw fs/btrfs/super.c:1334 [inline]\n   btrfs_reconfigure+0xaed/0x2160 fs/btrfs/super.c:1559\n   reconfigure_super+0x227/0x890 fs/super.c:1076\n   do_remount fs/namespace.c:3279 [inline]\n   path_mount+0xd1a/0xfe0 fs/namespace.c:4027\n   do_mount fs/namespace.c:4048 [inline]\n   __do_sys_mount fs/namespace.c:4236 [inline]\n   __se_sys_mount+0x313/0x410 fs/namespace.c:4213\n   do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline]\n   do_syscall_64+0xfa/0xfa0 arch/x86/entry/syscall_64.c:94\n   entry_SYSCALL_64_after_hwframe+0x77/0x7f\n   RIP: 0033:0x7f424e39066a\n  Code: d8 64 89 02 (...)\n  RSP: 002b:00007f424d9fde68 EFLAGS: 00000246 ORIG_RAX: 00000000000000a5\n  RAX: ffffffffffffffda RBX: 00007f424d9fdef0 RCX: 00007f424e39066a\n  RDX: 0000200000000180 RSI: 0000200000000380 RDI: 0000000000000000\n  RBP: 0000200000000180 R08: 00007f424d9fdef0 R09: 0000000000000020\n  R10: 0000000000000020 R11: 0000000000000246 R12: 0000200000000380\n  R13: 00007f424d9fdeb0 R14: 0000000000000000 R15: 00002000000002c0\n   </TASK>\n  Modules linked in:\n  ---[ end trace 0000000000000000 ]---","summarySource":"cvelist","descriptions":[{"lang":"en","text":"In the Linux kernel, the following vulnerability has been resolved:\n\nbtrfs: do not assert we found block group item when creating free space tree\n\nCurrently, when building a free space tree at populate_free_space_tree(),\nif we are not using the block group tree feature, we always expect to find\nblock group items (either extent items or a block group item with key type\nBTRFS_BLOCK_GROUP_ITEM_KEY) when we search the extent tree with\nbtrfs_search_slot_for_read(), so we assert that we found an item. However\nthis expectation is wrong since we can have a new block group created in\nthe current transaction which is still empty and for which we still have\nnot added the block group's item to the extent tree, in which case we do\nnot have any items in the extent tree associated to the block group.\n\nThe insertion of a new block group's block group item in the extent tree\nhappens at btrfs_create_pending_block_groups() when it calls the helper\ninsert_block_group_item(). This typically is done when a transaction\nhandle is released, committed or when running delayed refs (either as\npart of a transaction commit or when serving tickets for space reservation\nif we are low on free space).\n\nSo remove the assertion at populate_free_space_tree() even when the block\ngroup tree feature is not enabled and update the comment to mention this\ncase.\n\nSyzbot reported this with the following stack trace:\n\n  BTRFS info (device loop3 state M): rebuilding free space tree\n  assertion failed: ret == 0 :: 0, in fs/btrfs/free-space-tree.c:1115\n  ------------[ cut here ]------------\n  kernel BUG at fs/btrfs/free-space-tree.c:1115!\n  Oops: invalid opcode: 0000 [#1] SMP KASAN PTI\n  CPU: 1 UID: 0 PID: 6352 Comm: syz.3.25 Not tainted syzkaller #0 PREEMPT(full)\n  Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 08/18/2025\n  RIP: 0010:populate_free_space_tree+0x700/0x710 fs/btrfs/free-space-tree.c:1115\n  Code: ff ff e8 d3 (...)\n  RSP: 0018:ffffc9000430f780 EFLAGS: 00010246\n  RAX: 0000000000000043 RBX: ffff88805b709630 RCX: fea61d0e2e79d000\n  RDX: 0000000000000000 RSI: 0000000080000000 RDI: 0000000000000000\n  RBP: ffffc9000430f8b0 R08: ffffc9000430f4a7 R09: 1ffff92000861e94\n  R10: dffffc0000000000 R11: fffff52000861e95 R12: 0000000000000001\n  R13: 1ffff92000861f00 R14: dffffc0000000000 R15: 0000000000000000\n  FS:  00007f424d9fe6c0(0000) GS:ffff888125afc000(0000) knlGS:0000000000000000\n  CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033\n  CR2: 00007fd78ad212c0 CR3: 0000000076d68000 CR4: 00000000003526f0\n  Call Trace:\n   <TASK>\n   btrfs_rebuild_free_space_tree+0x1ba/0x6d0 fs/btrfs/free-space-tree.c:1364\n   btrfs_start_pre_rw_mount+0x128f/0x1bf0 fs/btrfs/disk-io.c:3062\n   btrfs_remount_rw fs/btrfs/super.c:1334 [inline]\n   btrfs_reconfigure+0xaed/0x2160 fs/btrfs/super.c:1559\n   reconfigure_super+0x227/0x890 fs/super.c:1076\n   do_remount fs/namespace.c:3279 [inline]\n   path_mount+0xd1a/0xfe0 fs/namespace.c:4027\n   do_mount fs/namespace.c:4048 [inline]\n   __do_sys_mount fs/namespace.c:4236 [inline]\n   __se_sys_mount+0x313/0x410 fs/namespace.c:4213\n   do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline]\n   do_syscall_64+0xfa/0xfa0 arch/x86/entry/syscall_64.c:94\n   entry_SYSCALL_64_after_hwframe+0x77/0x7f\n   RIP: 0033:0x7f424e39066a\n  Code: d8 64 89 02 (...)\n  RSP: 002b:00007f424d9fde68 EFLAGS: 00000246 ORIG_RAX: 00000000000000a5\n  RAX: ffffffffffffffda RBX: 00007f424d9fdef0 RCX: 00007f424e39066a\n  RDX: 0000200000000180 RSI: 0000200000000380 RDI: 0000000000000000\n  RBP: 0000200000000180 R08: 00007f424d9fdef0 R09: 0000000000000020\n  R10: 0000000000000020 R11: 0000000000000246 R12: 0000200000000380\n  R13: 00007f424d9fdeb0 R14: 0000000000000000 R15: 00002000000002c0\n   </TASK>\n  Modules linked in:\n  ---[ end trace 0000000000000000 ]---","source":"cvelist"},{"lang":"es","text":"En el kernel de Linux, la siguiente vulnerabilidad ha sido resuelta:\n\nbtrfs: no afirmar que encontramos un elemento de grupo de bloques al crear el árbol de espacio libre\n\nActualmente, al construir un árbol de espacio libre en populate_free_space_tree(), si no estamos usando la característica del árbol de grupos de bloques, siempre esperamos encontrar elementos de grupo de bloques (ya sean elementos de extensión o un elemento de grupo de bloques con tipo de clave BTRFS_BLOCK_GROUP_ITEM_KEY) cuando buscamos en el árbol de extensiones con btrfs_search_slot_for_read(), por lo que afirmamos que encontramos un elemento. Sin embargo, esta expectativa es incorrecta ya que podemos tener un nuevo grupo de bloques creado en la transacción actual que aún está vacío y para el cual aún no hemos añadido el elemento del grupo de bloques al árbol de extensiones, en cuyo caso no tenemos ningún elemento en el árbol de extensiones asociado al grupo de bloques.\n\nLa inserción del elemento de grupo de bloques de un nuevo grupo de bloques en el árbol de extensiones ocurre en btrfs_create_pending_block_groups() cuando llama a la función auxiliar insert_block_group_item(). Esto se hace típicamente cuando un manejador de transacción es liberado, confirmado o cuando se ejecutan referencias retrasadas (ya sea como parte de una confirmación de transacción o al atender solicitudes de reserva de espacio si tenemos poco espacio libre).\n\nAsí que, eliminar la aserción en populate_free_space_tree() incluso cuando la característica del árbol de grupos de bloques no está habilitada y actualizar el comentario para mencionar este caso.\n\nSyzbot informó esto con el siguiente rastreo de pila:\n\n  BTRFS info (device loop3 state M): rebuilding free space tree\n  assertion failed: ret == 0 :: 0, in fs/btrfs/free-space-tree.c:1115\n  ------------[ cut here ]------------\n  kernel BUG at fs/btrfs/free-space-tree.c:1115!\n  Oops: invalid opcode: 0000 [#1] SMP KASAN PTI\n  CPU: 1 UID: 0 PID: 6352 Comm: syz.3.25 Not tainted syzkaller #0 PREEMPT(full)\n  Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 08/18/2025\n  RIP: 0010:populate_free_space_tree+0x700/0x710 fs/btrfs/free-space-tree.c:1115\n  Code: ff ff e8 d3 (...)\n  RSP: 0018:ffffc9000430f780 EFLAGS: 00010246\n  RAX: 0000000000000043 RBX: ffff88805b709630 RCX: fea61d0e2e79d000\n  RDX: 0000000000000000 RSI: 0000000080000000 RDI: 0000000000000000\n  RBP: ffffc9000430f8b0 R08: ffffc9000430f4a7 R09: 1ffff92000861e94\n  R10: dffffc0000000000 R11: fffff52000861e95 R12: 0000000000000001\n  R13: 1ffff92000861f00 R14: dffffc0000000000 R15: 0000000000000000\n  FS:  00007f424d9fe6c0(0000) GS:ffff888125afc000(0000) knlGS:0000000000000000\n  CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033\n  CR2: 00007fd78ad212c0 CR3: 0000000076d68000 CR4: 00000000003526f0\n  Call Trace:\n   <TASK>\n   btrfs_rebuild_free_space_tree+0x1ba/0x6d0 fs/btrfs/free-space-tree.c:1364\n   btrfs_start_pre_rw_mount+0x128f/0x1bf0 fs/btrfs/disk-io.c:3062\n   btrfs_remount_rw fs/btrfs/super.c:1334 [inline]\n   btrfs_reconfigure+0xaed/0x2160 fs/btrfs/super.c:1559\n   reconfigure_super+0x227/0x890 fs/super.c:1076\n   do_remount fs/namespace.c:3279 [inline]\n   path_mount+0xd1a/0xfe0 fs/namespace.c:4027\n   do_mount fs/namespace.c:4048 [inline]\n   __do_sys_mount fs/namespace.c:4236 [inline]\n   __se_sys_mount+0x313/0x410 fs/namespace.c:4213\n   do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline]\n   do_syscall_64+0xfa/0xfa0 arch/x86/entry/syscall_64.c:94\n   entry_SYSCALL_64_after_hwframe+0x77/0x7f\n   RIP: 0033:0x7f424e39066a\n  Code: d8 64 89 02 (...)\n  RSP: 002b:00007f424d9fde68 EFLAGS: 00000246 ORIG_RAX: 00000000000000a5\n  RAX: ffffffffffffffda RBX: 00007f424d9fdef0 RCX: 00007f424e39066a\n  RDX: 0000200000000180 RSI: 0000200000000380 RDI: 0000000000000000\n  RBP: 0000200000000180 R08: 00007f424d9fdef0 R09: 0000000000000020\n  R10: 0000000000000020 R11: 0000000000000246 R12: 0000200000000380\n  R13: 00007f424d9fdeb0 --TRUNCADO--","source":"nvd"}],"published":"2025-10-30T09:48:06.521Z","modified":"2026-10-19T21:10:00.160Z","severities":[],"cwes":[],"affected":[{"ranges":[{"type":"git","introduced":"a5ed91828518ab076209266c2bc510adabd078df","fixed":"4f4b9ca73f84130d9fbb0fc02306ce94ce8bdbe6","status":"affected"},{"type":"git","introduced":"a5ed91828518ab076209266c2bc510adabd078df","fixed":"289498da343b05c886f19b4269429606f86dd17b","status":"affected"},{"type":"git","introduced":"a5ed91828518ab076209266c2bc510adabd078df","fixed":"3fdcfd91b93f930d87843156c7c8cc5fbcf9b144","status":"affected"},{"type":"git","introduced":"a5ed91828518ab076209266c2bc510adabd078df","fixed":"eb145463f22d7d32d426b29fe9810de9e792b6ba","status":"affected"},{"type":"git","introduced":"a5ed91828518ab076209266c2bc510adabd078df","fixed":"a5a51bf4e9b7354ce7cd697e610d72c1b33fd949","status":"affected"}],"vendor":"Linux","product":"Linux","repo":"https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git","source":"cvelist"},{"ranges":[{"version":"4.5","status":"affected"},{"type":"semver","introduced":"0","fixed":"4.5","status":"unaffected"},{"type":"semver","introduced":"6.1.158","lastAffected":"6.1.*","status":"unaffected"},{"type":"semver","introduced":"6.6.114","lastAffected":"6.6.*","status":"unaffected"},{"type":"semver","introduced":"6.12.55","lastAffected":"6.12.*","status":"unaffected"},{"type":"semver","introduced":"6.17.5","lastAffected":"6.17.*","status":"unaffected"},{"type":"original_commit_for_fix","introduced":"6.18","lastAffected":"*","status":"unaffected"}],"vendor":"Linux","product":"Linux","repo":"https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git","source":"cvelist"}],"references":[{"url":"https://git.kernel.org/stable/c/4f4b9ca73f84130d9fbb0fc02306ce94ce8bdbe6","tags":[],"sources":["cvelist","nvd"]},{"url":"https://git.kernel.org/stable/c/289498da343b05c886f19b4269429606f86dd17b","tags":[],"sources":["cvelist","nvd"]},{"url":"https://git.kernel.org/stable/c/3fdcfd91b93f930d87843156c7c8cc5fbcf9b144","tags":[],"sources":["cvelist","nvd"]},{"url":"https://git.kernel.org/stable/c/eb145463f22d7d32d426b29fe9810de9e792b6ba","tags":[],"sources":["cvelist","nvd"]},{"url":"https://git.kernel.org/stable/c/a5a51bf4e9b7354ce7cd697e610d72c1b33fd949","tags":[],"sources":["cvelist","nvd"]}],"credits":[],"assigner":"Linux","sources":[{"source":"cvelist","name":"CVE List","id":"CVE-2025-40100","url":"https://www.cve.org/CVERecord?id=CVE-2025-40100","licence":"CVE Terms of Use","modified":"2026-05-11T21:42:30.966Z"},{"source":"nvd","name":"NVD","id":"CVE-2025-40100","url":"https://nvd.nist.gov/vuln/detail/CVE-2025-40100","licence":"Public domain","modified":"2026-10-19T21:10:00.160Z"}],"updatedAt":"2026-11-25T22:59:07.036Z","epss":{"score":0.00277,"percentile":0.12774,"date":"2026-11-30T12:00:22.000Z"}}