{"id":"CVE-2026-43158","aliases":["CVE-2026-43158"],"related":[],"kind":"vulnerability","state":"published","title":"xfs: fix freemap adjustments when adding xattrs to leaf blocks","summary":"In the Linux kernel, the following vulnerability has been resolved:\n\nxfs: fix freemap adjustments when adding xattrs to leaf blocks\n\nxfs/592 and xfs/794 both trip this assertion in the leaf block freemap\nadjustment code after ~20 minutes of running on my test VMs:\n\n ASSERT(ichdr->firstused >= ichdr->count * sizeof(xfs_attr_leaf_entry_t)\n\t\t\t\t\t+ xfs_attr3_leaf_hdr_size(leaf));\n\nUpon enabling quite a lot more debugging code, I narrowed this down to\nfsstress trying to set a local extended attribute with namelen=3 and\nvaluelen=71.  This results in an entry size of 80 bytes.\n\nAt the start of xfs_attr3_leaf_add_work, the freemap looks like this:\n\ni 0 base 448 size 0 rhs 448 count 46\ni 1 base 388 size 132 rhs 448 count 46\ni 2 base 2120 size 4 rhs 448 count 46\nfirstused = 520\n\nwhere \"rhs\" is the first byte past the end of the leaf entry array.\nThis is inconsistent -- the entries array ends at byte 448, but\nfreemap[1] says there's free space starting at byte 388!\n\nBy the end of the function, the freemap is in worse shape:\n\ni 0 base 456 size 0 rhs 456 count 47\ni 1 base 388 size 52 rhs 456 count 47\ni 2 base 2120 size 4 rhs 456 count 47\nfirstused = 440\n\nImportant note: 388 is not aligned with the entries array element size\nof 8 bytes.\n\nBased on the incorrect freemap, the name area starts at byte 440, which\nis below the end of the entries array!  That's why the assertion\ntriggers and the filesystem shuts down.\n\nHow did we end up here?  First, recall from the previous patch that the\nfreemap array in an xattr leaf block is not intended to be a\ncomprehensive map of all free space in the leaf block.  In other words,\nit's perfectly legal to have a leaf block with:\n\n * 376 bytes in use by the entries array\n * freemap[0] has [base = 376, size = 8]\n * freemap[1] has [base = 388, size = 1500]\n * the space between 376 and 388 is free, but the freemap stopped\n   tracking that some time ago\n\nIf we add one xattr, the entries array grows to 384 bytes, and\nfreemap[0] becomes [base = 384, size = 0].  So far, so good.  But if we\nadd a second xattr, the entries array grows to 392 bytes, and freemap[0]\ngets pushed up to [base = 392, size = 0].  This is bad, because\nfreemap[1] hasn't been updated, and now the entries array and the free\nspace claim the same space.\n\nThe fix here is to adjust all freemap entries so that none of them\ncollide with the entries array.  Note that this fix relies on commit\n2a2b5932db6758 (\"xfs: fix attr leaf header freemap.size underflow\") and\nthe previous patch that resets zero length freemap entries to have\nbase = 0.","summarySource":"cvelist","descriptions":[{"lang":"en","text":"In the Linux kernel, the following vulnerability has been resolved:\n\nxfs: fix freemap adjustments when adding xattrs to leaf blocks\n\nxfs/592 and xfs/794 both trip this assertion in the leaf block freemap\nadjustment code after ~20 minutes of running on my test VMs:\n\n ASSERT(ichdr->firstused >= ichdr->count * sizeof(xfs_attr_leaf_entry_t)\n\t\t\t\t\t+ xfs_attr3_leaf_hdr_size(leaf));\n\nUpon enabling quite a lot more debugging code, I narrowed this down to\nfsstress trying to set a local extended attribute with namelen=3 and\nvaluelen=71.  This results in an entry size of 80 bytes.\n\nAt the start of xfs_attr3_leaf_add_work, the freemap looks like this:\n\ni 0 base 448 size 0 rhs 448 count 46\ni 1 base 388 size 132 rhs 448 count 46\ni 2 base 2120 size 4 rhs 448 count 46\nfirstused = 520\n\nwhere \"rhs\" is the first byte past the end of the leaf entry array.\nThis is inconsistent -- the entries array ends at byte 448, but\nfreemap[1] says there's free space starting at byte 388!\n\nBy the end of the function, the freemap is in worse shape:\n\ni 0 base 456 size 0 rhs 456 count 47\ni 1 base 388 size 52 rhs 456 count 47\ni 2 base 2120 size 4 rhs 456 count 47\nfirstused = 440\n\nImportant note: 388 is not aligned with the entries array element size\nof 8 bytes.\n\nBased on the incorrect freemap, the name area starts at byte 440, which\nis below the end of the entries array!  That's why the assertion\ntriggers and the filesystem shuts down.\n\nHow did we end up here?  First, recall from the previous patch that the\nfreemap array in an xattr leaf block is not intended to be a\ncomprehensive map of all free space in the leaf block.  In other words,\nit's perfectly legal to have a leaf block with:\n\n * 376 bytes in use by the entries array\n * freemap[0] has [base = 376, size = 8]\n * freemap[1] has [base = 388, size = 1500]\n * the space between 376 and 388 is free, but the freemap stopped\n   tracking that some time ago\n\nIf we add one xattr, the entries array grows to 384 bytes, and\nfreemap[0] becomes [base = 384, size = 0].  So far, so good.  But if we\nadd a second xattr, the entries array grows to 392 bytes, and freemap[0]\ngets pushed up to [base = 392, size = 0].  This is bad, because\nfreemap[1] hasn't been updated, and now the entries array and the free\nspace claim the same space.\n\nThe fix here is to adjust all freemap entries so that none of them\ncollide with the entries array.  Note that this fix relies on commit\n2a2b5932db6758 (\"xfs: fix attr leaf header freemap.size underflow\") and\nthe previous patch that resets zero length freemap entries to have\nbase = 0.","source":"cvelist"},{"lang":"es","text":"En el kernel de Linux, la siguiente vulnerabilidad ha sido resuelta:\n\nxfs: soluciona los ajustes del freemap al añadir xattrs a bloques hoja\n\nxfs/592 y xfs/794 ambos activan esta aserción en el código de ajuste del freemap del bloque hoja después de ~20 minutos de ejecución en mis máquinas virtuales de prueba:\n\n ASSERT(ichdr  ->  firstused >= ichdr  ->  count * sizeof(xfs_attr_leaf_entry_t)\n\t\t\t\t\t+ xfs_attr3_leaf_hdr_size(leaf));\n\nAl habilitar mucho más código de depuración, lo reduje a fsstress intentando establecer un atributo extendido local con namelen=3 y valuelen=71. Esto resulta en un tamaño de entrada de 80 bytes.\n\nAl inicio de xfs_attr3_leaf_add_work, el freemap se ve así:\n\ni 0 base 448 size 0 rhs 448 count 46\ni 1 base 388 size 132 rhs 448 count 46\ni 2 base 2120 size 4 rhs 448 count 46\nfirstused = 520\n\ndonde ’rhs’ es el primer byte después del final del array de entradas de la hoja. Esto es inconsistente: el array de entradas termina en el byte 448, ¡pero freemap[1] dice que hay espacio libre a partir del byte 388!\n\nAl final de la función, el freemap está en peor estado:\n\ni 0 base 456 size 0 rhs 456 count 47\ni 1 base 388 size 52 rhs 456 count 47\ni 2 base 2120 size 4 rhs 456 count 47\nfirstused = 440\n\nNota importante: 388 no está alineado con el tamaño de elemento del array de entradas de 8 bytes.\n\nBasado en el freemap incorrecto, el área de nombres comienza en el byte 440, ¡lo cual está por debajo del final del array de entradas! Por eso la aserción se activa y el sistema de archivos se apaga.\n\n¿Cómo llegamos a esto? Primero, recordemos del parche anterior que el array freemap en un bloque hoja xattr no está destinado a ser un mapa exhaustivo de todo el espacio libre en el bloque hoja. En otras palabras, es perfectamente legal tener un bloque hoja con:\n\n * 376 bytes en uso por el array de entradas\n * freemap[0] tiene [base = 376, size = 8]\n * freemap[1] tiene [base = 388, size = 1500]\n * el espacio entre 376 y 388 está libre, pero el freemap dejó de rastrearlo hace algún tiempo\n\nSi añadimos un xattr, el array de entradas crece a 384 bytes, y freemap[0] se convierte en [base = 384, size = 0]. Hasta ahora, todo bien. Pero si añadimos un segundo xattr, el array de entradas crece a 392 bytes, y freemap[0] se desplaza a [base = 392, size = 0]. Esto es malo, porque freemap[1] no ha sido actualizado, y ahora el array de entradas y el espacio libre reclaman el mismo espacio.\n\nLa solución aquí es ajustar todas las entradas del freemap para que ninguna de ellas colisione con el array de entradas. Tenga en cuenta que esta solución se basa en el commit 2a2b5932db6758 (’xfs: corrige el desbordamiento negativo de freemap.size del encabezado de la hoja de atributos’) y el parche anterior que restablece las entradas del freemap de longitud cero para que tengan base = 0.","source":"nvd"}],"published":"2026-05-06T11:27:37.848Z","modified":"2026-11-11T21:10:00.200Z","severity":{"scorer":"Linux","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H","score":8.8,"rating":"HIGH"},"severities":[{"scorer":"Linux","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H","score":8.8,"rating":"HIGH"}],"cwes":["CWE-664","CWE-787"],"affected":[{"ranges":[{"type":"git","introduced":"1da177e4c3f41524e886b7f1b8a0c1fc7321cac2","fixed":"d08976725355b9d54d8332fce223fa281cc304a5","status":"affected"},{"type":"git","introduced":"1da177e4c3f41524e886b7f1b8a0c1fc7321cac2","fixed":"6a8737afbccc340e718e0b22577312826390be8b","status":"affected"},{"type":"git","introduced":"1da177e4c3f41524e886b7f1b8a0c1fc7321cac2","fixed":"a396b3d73d51355e50acdb403ba9c4cae4c1174e","status":"affected"},{"type":"git","introduced":"1da177e4c3f41524e886b7f1b8a0c1fc7321cac2","fixed":"38613c01f69e1e77e6b8acab1e8ac665d01c2f15","status":"affected"},{"type":"git","introduced":"1da177e4c3f41524e886b7f1b8a0c1fc7321cac2","fixed":"ef42a8766ff3fdf51cf72fb36d0859c09d134478","status":"affected"},{"type":"git","introduced":"1da177e4c3f41524e886b7f1b8a0c1fc7321cac2","fixed":"43f3b18679615a93bd848afde3602ba160637a46","status":"affected"},{"type":"git","introduced":"1da177e4c3f41524e886b7f1b8a0c1fc7321cac2","fixed":"24ce71852f2cee6581e2cbebc15489ed52bf63b7","status":"affected"},{"type":"git","introduced":"1da177e4c3f41524e886b7f1b8a0c1fc7321cac2","fixed":"3eefc0c2b78444b64feeb3783c017d6adc3cd3ce","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.12","status":"affected"},{"type":"semver","introduced":"0","fixed":"2.6.12","status":"unaffected"},{"type":"semver","introduced":"5.10.252","lastAffected":"5.10.*","status":"unaffected"},{"type":"semver","introduced":"5.15.202","lastAffected":"5.15.*","status":"unaffected"},{"type":"semver","introduced":"6.1.165","lastAffected":"6.1.*","status":"unaffected"},{"type":"semver","introduced":"6.6.128","lastAffected":"6.6.*","status":"unaffected"},{"type":"semver","introduced":"6.12.75","lastAffected":"6.12.*","status":"unaffected"},{"type":"semver","introduced":"6.18.16","lastAffected":"6.18.*","status":"unaffected"},{"type":"semver","introduced":"6.19.6","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.12.1","fixed":"5.10.252"},{"status":"affected","introduced":"5.11","fixed":"5.15.202"},{"status":"affected","introduced":"5.16","fixed":"6.1.165"},{"status":"affected","introduced":"6.2","fixed":"6.6.128"},{"status":"affected","introduced":"6.7","fixed":"6.12.75"},{"status":"affected","introduced":"6.13","fixed":"6.18.16"},{"status":"affected","introduced":"6.19","fixed":"6.19.6"},{"status":"affected","version":"2.6.12"},{"status":"affected","version":"2.6.12"},{"status":"affected","version":"2.6.12"},{"status":"affected","version":"2.6.12"},{"status":"affected","version":"2.6.12"}],"vendor":"linux","product":"linux_kernel","cpe":"cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*","source":"nvd"}],"references":[{"url":"https://git.kernel.org/stable/c/d08976725355b9d54d8332fce223fa281cc304a5","tags":["patch"],"sources":["cvelist","nvd"]},{"url":"https://git.kernel.org/stable/c/6a8737afbccc340e718e0b22577312826390be8b","tags":["patch"],"sources":["cvelist","nvd"]},{"url":"https://git.kernel.org/stable/c/a396b3d73d51355e50acdb403ba9c4cae4c1174e","tags":["patch"],"sources":["cvelist","nvd"]},{"url":"https://git.kernel.org/stable/c/38613c01f69e1e77e6b8acab1e8ac665d01c2f15","tags":["patch"],"sources":["cvelist","nvd"]},{"url":"https://git.kernel.org/stable/c/ef42a8766ff3fdf51cf72fb36d0859c09d134478","tags":["patch"],"sources":["cvelist","nvd"]},{"url":"https://git.kernel.org/stable/c/43f3b18679615a93bd848afde3602ba160637a46","tags":["patch"],"sources":["cvelist","nvd"]},{"url":"https://git.kernel.org/stable/c/24ce71852f2cee6581e2cbebc15489ed52bf63b7","tags":["patch"],"sources":["cvelist","nvd"]},{"url":"https://git.kernel.org/stable/c/3eefc0c2b78444b64feeb3783c017d6adc3cd3ce","tags":["patch"],"sources":["cvelist","nvd"]}],"credits":[],"assigner":"Linux","ssvc":{"scorer":"CISA-ADP","exploitation":"none","automatable":"no","technicalImpact":"total","date":"2026-10-16T15:15:15.222Z"},"sources":[{"source":"cvelist","name":"CVE List","id":"CVE-2026-43158","url":"https://www.cve.org/CVERecord?id=CVE-2026-43158","licence":"CVE Terms of Use","modified":"2026-10-19T19:16:22.481Z"},{"source":"nvd","name":"NVD","id":"CVE-2026-43158","url":"https://nvd.nist.gov/vuln/detail/CVE-2026-43158","licence":"Public domain","modified":"2026-11-11T21:10:00.200Z"}],"updatedAt":"2026-11-25T22:59:20.703Z","epss":{"score":0.00469,"percentile":0.42203,"date":"2026-12-01T12:00:22.000Z"}}