{"id":"CVE-2026-43118","aliases":["CVE-2026-43118"],"related":[],"kind":"vulnerability","state":"published","title":"btrfs: fix zero size inode with non-zero size after log replay","summary":"In the Linux kernel, the following vulnerability has been resolved:\n\nbtrfs: fix zero size inode with non-zero size after log replay\n\nWhen logging that an inode exists, as part of logging a new name or\nlogging new dir entries for a directory, we always set the generation of\nthe logged inode item to 0. This is to signal during log replay (in\noverwrite_item()), that we should not set the i_size since we only logged\nthat an inode exists, so the i_size of the inode in the subvolume tree\nmust be preserved (as when we log new names or that an inode exists, we\ndon't log extents).\n\nThis works fine except when we have already logged an inode in full mode\nor it's the first time we are logging an inode created in a past\ntransaction, that inode has a new i_size of 0 and then we log a new name\nfor the inode (due to a new hardlink or a rename), in which case we log\nan i_size of 0 for the inode and a generation of 0, which causes the log\nreplay code to not update the inode's i_size to 0 (in overwrite_item()).\n\nAn example scenario:\n\n  mkdir /mnt/dir\n  xfs_io -f -c \"pwrite 0 64K\" /mnt/dir/foo\n\n  sync\n\n  xfs_io -c \"truncate 0\" -c \"fsync\" /mnt/dir/foo\n\n  ln /mnt/dir/foo /mnt/dir/bar\n\n  xfs_io -c \"fsync\" /mnt/dir\n\n  <power fail>\n\nAfter log replay the file remains with a size of 64K. This is because when\nwe first log the inode, when we fsync file foo, we log its current i_size\nof 0, and then when we create a hard link we log again the inode in exists\nmode (LOG_INODE_EXISTS) but we set a generation of 0 for the inode item we\nadd to the log tree, so during log replay overwrite_item() sees that the\ngeneration is 0 and i_size is 0 so we skip updating the inode's i_size\nfrom 64K to 0.\n\nFix this by making sure at fill_inode_item() we always log the real\ngeneration of the inode if it was logged in the current transaction with\nthe i_size we logged before. Also if an inode created in a previous\ntransaction is logged in exists mode only, make sure we log the i_size\nstored in the inode item located from the commit root, so that if we log\nmultiple times that the inode exists we get the correct i_size.\n\nA test case for fstests will follow soon.","summarySource":"cvelist","descriptions":[{"lang":"en","text":"In the Linux kernel, the following vulnerability has been resolved:\n\nbtrfs: fix zero size inode with non-zero size after log replay\n\nWhen logging that an inode exists, as part of logging a new name or\nlogging new dir entries for a directory, we always set the generation of\nthe logged inode item to 0. This is to signal during log replay (in\noverwrite_item()), that we should not set the i_size since we only logged\nthat an inode exists, so the i_size of the inode in the subvolume tree\nmust be preserved (as when we log new names or that an inode exists, we\ndon't log extents).\n\nThis works fine except when we have already logged an inode in full mode\nor it's the first time we are logging an inode created in a past\ntransaction, that inode has a new i_size of 0 and then we log a new name\nfor the inode (due to a new hardlink or a rename), in which case we log\nan i_size of 0 for the inode and a generation of 0, which causes the log\nreplay code to not update the inode's i_size to 0 (in overwrite_item()).\n\nAn example scenario:\n\n  mkdir /mnt/dir\n  xfs_io -f -c \"pwrite 0 64K\" /mnt/dir/foo\n\n  sync\n\n  xfs_io -c \"truncate 0\" -c \"fsync\" /mnt/dir/foo\n\n  ln /mnt/dir/foo /mnt/dir/bar\n\n  xfs_io -c \"fsync\" /mnt/dir\n\n  <power fail>\n\nAfter log replay the file remains with a size of 64K. This is because when\nwe first log the inode, when we fsync file foo, we log its current i_size\nof 0, and then when we create a hard link we log again the inode in exists\nmode (LOG_INODE_EXISTS) but we set a generation of 0 for the inode item we\nadd to the log tree, so during log replay overwrite_item() sees that the\ngeneration is 0 and i_size is 0 so we skip updating the inode's i_size\nfrom 64K to 0.\n\nFix this by making sure at fill_inode_item() we always log the real\ngeneration of the inode if it was logged in the current transaction with\nthe i_size we logged before. Also if an inode created in a previous\ntransaction is logged in exists mode only, make sure we log the i_size\nstored in the inode item located from the commit root, so that if we log\nmultiple times that the inode exists we get the correct i_size.\n\nA test case for fstests will follow soon.","source":"cvelist"},{"lang":"es","text":"En el kernel de Linux, la siguiente vulnerabilidad ha sido resuelta:\n\nbtrfs: corrige inode de tamaño cero con tamaño no cero después de la reproducción del registro\n\nAl registrar que un inode existe, como parte de registrar un nuevo nombre o registrar nuevas entradas de directorio para un directorio, siempre establecemos la generación del elemento inode registrado en 0. Esto es para señalar durante la reproducción del registro (en overwrite_item()), que no debemos establecer el i_size ya que solo registramos que un inode existe, por lo que el i_size del inode en el árbol del subvolumen debe preservarse (ya que cuando registramos nuevos nombres o que un inode existe, no registramos extensiones).\n\nEsto funciona bien excepto cuando ya hemos registrado un inode en modo completo o es la primera vez que registramos un inode creado en una transacción pasada, ese inode tiene un nuevo i_size de 0 y luego registramos un nuevo nombre para el inode (debido a un nuevo enlace duro o un cambio de nombre), en cuyo caso registramos un i_size de 0 para el inode y una generación de 0, lo que hace que el código de reproducción del registro no actualice el i_size del inode a 0 (en overwrite_item()).\n\nUn escenario de ejemplo:\n\n  mkdir /mnt/dir\n  xfs_io -f -c ’pwrite 0 64K’ /mnt/dir/foo\n\n  sync\n\n  xfs_io -c ’truncate 0’ -c ’fsync’ /mnt/dir/foo\n\n  ln /mnt/dir/foo /mnt/dir/bar\n\n  xfs_io -c ’fsync’ /mnt/dir\n\n  <falla de energía>\n\nDespués de la reproducción del registro, el archivo permanece con un tamaño de 64K. Esto se debe a que cuando registramos el inode por primera vez, al hacer fsync del archivo foo, registramos su i_size actual de 0, y luego, cuando creamos un enlace duro, volvemos a registrar el inode en modo de existencia (LOG_INODE_EXISTS) pero establecemos una generación de 0 para el elemento inode que agregamos al árbol de registro, por lo que durante la reproducción del registro overwrite_item() ve que la generación es 0 y el i_size es 0, por lo que omitimos actualizar el i_size del inode de 64K a 0.\n\nEsto se corrige asegurándonos de que en fill_inode_item() siempre registramos la generación real del inode si fue registrado en la transacción actual con el i_size que registramos antes. Además, si un inode creado en una transacción anterior se registra solo en modo de existencia, nos aseguramos de registrar el i_size almacenado en el elemento inode ubicado desde la raíz de commit, de modo que si registramos varias veces que el inode existe, obtenemos el i_size correcto.\n\nPronto seguirá un caso de prueba para fstests.","source":"nvd"}],"published":"2026-05-06T07:40:42.598Z","modified":"2026-11-11T21:10:00.200Z","severity":{"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"},"severities":[{"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":[],"affected":[{"ranges":[{"type":"git","introduced":"12fcfd22fe5bf4fe74710232098bc101af497995","fixed":"126999610eddeb1de3b47680585f4bc9531dc7f4","status":"affected"},{"type":"git","introduced":"12fcfd22fe5bf4fe74710232098bc101af497995","fixed":"c939bfa67d221f75351a5bf2fc912e8125547b7e","status":"affected"},{"type":"git","introduced":"12fcfd22fe5bf4fe74710232098bc101af497995","fixed":"91990732ec4ce5c09361d498c6d621f5a76ee1f2","status":"affected"},{"type":"git","introduced":"12fcfd22fe5bf4fe74710232098bc101af497995","fixed":"fddb157536e67a055597f00a8b4922d5f5ed0826","status":"affected"},{"type":"git","introduced":"12fcfd22fe5bf4fe74710232098bc101af497995","fixed":"03e966b63df5b06790310c1faaf3e0cb43adea8b","status":"affected"},{"type":"git","introduced":"12fcfd22fe5bf4fe74710232098bc101af497995","fixed":"5254d4181add9dfaa5e3519edd71cc8f752b2f85","status":"affected"}],"vendor":"Linux","product":"Linux","repo":"https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git","source":"cvelist"},{"ranges":[{"version":"2.6.30","status":"affected"},{"type":"semver","introduced":"0","fixed":"2.6.30","status":"unaffected"},{"type":"semver","introduced":"6.1.191","lastAffected":"6.1.*","status":"unaffected"},{"type":"semver","introduced":"6.6.160","lastAffected":"6.6.*","status":"unaffected"},{"type":"semver","introduced":"6.12.114","lastAffected":"6.12.*","status":"unaffected"},{"type":"semver","introduced":"6.18.24","lastAffected":"6.18.*","status":"unaffected"},{"type":"semver","introduced":"6.19.14","lastAffected":"6.19.*","status":"unaffected"},{"type":"original_commit_for_fix","introduced":"7.0","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":"2.6.30","fixed":"6.18.24"},{"status":"affected","introduced":"6.19","fixed":"6.19.14"},{"status":"affected","version":"7.0"},{"status":"affected","version":"7.0"},{"status":"affected","version":"7.0"},{"status":"affected","version":"7.0"},{"status":"affected","version":"7.0"}],"vendor":"linux","product":"linux_kernel","cpe":"cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*","source":"nvd"}],"references":[{"url":"https://git.kernel.org/stable/c/126999610eddeb1de3b47680585f4bc9531dc7f4","tags":[],"sources":["cvelist","nvd"]},{"url":"https://git.kernel.org/stable/c/c939bfa67d221f75351a5bf2fc912e8125547b7e","tags":[],"sources":["cvelist","nvd"]},{"url":"https://git.kernel.org/stable/c/91990732ec4ce5c09361d498c6d621f5a76ee1f2","tags":[],"sources":["cvelist","nvd"]},{"url":"https://git.kernel.org/stable/c/fddb157536e67a055597f00a8b4922d5f5ed0826","tags":["patch"],"sources":["cvelist","nvd"]},{"url":"https://git.kernel.org/stable/c/03e966b63df5b06790310c1faaf3e0cb43adea8b","tags":["patch"],"sources":["cvelist","nvd"]},{"url":"https://git.kernel.org/stable/c/5254d4181add9dfaa5e3519edd71cc8f752b2f85","tags":["patch"],"sources":["cvelist","nvd"]}],"credits":[],"assigner":"Linux","sources":[{"source":"cvelist","name":"CVE List","id":"CVE-2026-43118","url":"https://www.cve.org/CVERecord?id=CVE-2026-43118","licence":"CVE Terms of Use","modified":"2026-10-30T12:24:59.447Z"},{"source":"nvd","name":"NVD","id":"CVE-2026-43118","url":"https://nvd.nist.gov/vuln/detail/CVE-2026-43118","licence":"Public domain","modified":"2026-11-11T21:10:00.200Z"}],"updatedAt":"2026-11-25T22:59:20.683Z","epss":{"score":0.00156,"percentile":0.05037,"date":"2026-12-01T12:00:22.000Z"}}