{"id":"CVE-2026-31703","aliases":["CVE-2026-31703"],"related":[],"kind":"vulnerability","state":"published","title":"writeback: Fix use after free in inode_switch_wbs_work_fn()","summary":"In the Linux kernel, the following vulnerability has been resolved:\n\nwriteback: Fix use after free in inode_switch_wbs_work_fn()\n\ninode_switch_wbs_work_fn() has a loop like:\n\n  wb_get(new_wb);\n  while (1) {\n    list = llist_del_all(&new_wb->switch_wbs_ctxs);\n    /* Nothing to do? */\n    if (!list)\n      break;\n    ... process the items ...\n  }\n\nNow adding of items to the list looks like:\n\nwb_queue_isw()\n  if (llist_add(&isw->list, &wb->switch_wbs_ctxs))\n    queue_work(isw_wq, &wb->switch_work);\n\nBecause inode_switch_wbs_work_fn() loops when processing isw items, it\ncan happen that wb->switch_work is pending while wb->switch_wbs_ctxs is\nempty. This is a problem because in that case wb can get freed (no isw\nitems -> no wb reference) while the work is still pending causing\nuse-after-free issues.\n\nWe cannot just fix this by cancelling work when freeing wb because that\ncould still trigger problematic 0 -> 1 transitions on wb refcount due to\nwb_get() in inode_switch_wbs_work_fn(). It could be all handled with\nmore careful code but that seems unnecessarily complex so let's avoid\nthat until it is proven that the looping actually brings practical\nbenefit. Just remove the loop from inode_switch_wbs_work_fn() instead.\nThat way when wb_queue_isw() queues work, we are guaranteed we have\nadded the first item to wb->switch_wbs_ctxs and nobody is going to\nremove it (and drop the wb reference it holds) until the queued work\nruns.","summarySource":"cvelist","descriptions":[{"lang":"en","text":"In the Linux kernel, the following vulnerability has been resolved:\n\nwriteback: Fix use after free in inode_switch_wbs_work_fn()\n\ninode_switch_wbs_work_fn() has a loop like:\n\n  wb_get(new_wb);\n  while (1) {\n    list = llist_del_all(&new_wb->switch_wbs_ctxs);\n    /* Nothing to do? */\n    if (!list)\n      break;\n    ... process the items ...\n  }\n\nNow adding of items to the list looks like:\n\nwb_queue_isw()\n  if (llist_add(&isw->list, &wb->switch_wbs_ctxs))\n    queue_work(isw_wq, &wb->switch_work);\n\nBecause inode_switch_wbs_work_fn() loops when processing isw items, it\ncan happen that wb->switch_work is pending while wb->switch_wbs_ctxs is\nempty. This is a problem because in that case wb can get freed (no isw\nitems -> no wb reference) while the work is still pending causing\nuse-after-free issues.\n\nWe cannot just fix this by cancelling work when freeing wb because that\ncould still trigger problematic 0 -> 1 transitions on wb refcount due to\nwb_get() in inode_switch_wbs_work_fn(). It could be all handled with\nmore careful code but that seems unnecessarily complex so let's avoid\nthat until it is proven that the looping actually brings practical\nbenefit. Just remove the loop from inode_switch_wbs_work_fn() instead.\nThat way when wb_queue_isw() queues work, we are guaranteed we have\nadded the first item to wb->switch_wbs_ctxs and nobody is going to\nremove it (and drop the wb reference it holds) until the queued work\nruns.","source":"cvelist"},{"lang":"es","text":"En el kernel de Linux, la siguiente vulnerabilidad ha sido resuelta: writeback: Corrección de uso después de liberación en inode_switch_wbs_work_fn() inode_switch_wbs_work_fn() tiene un bucle como: wb_get(new_wb); while (1) { list = llist_del_all( y new_wb  ->  switch_wbs_ctxs); /* ¿Nada que hacer? */ if (!list) break; ... procesar los elementos ... } Ahora la adición de elementos a la lista se ve así: wb_queue_isw() if (llist_add( y isw  ->  list, y wb  ->  switch_wbs_ctxs)) queue_work(isw_wq, y wb  ->  switch_work); Debido a que inode_switch_wbs_work_fn() itera al procesar elementos isw, puede ocurrir que wb  ->  switch_work esté pendiente mientras wb  ->  switch_wbs_ctxs esté vacío. Esto es un problema porque en ese caso wb puede ser liberado (sin elementos isw   ->   sin referencia a wb) mientras el trabajo aún está pendiente, causando problemas de uso después de liberación. No podemos simplemente solucionar esto cancelando el trabajo al liberar wb porque eso aún podría desencadenar transiciones problemáticas de 0 -mayor que 1 en el contador de referencias de wb debido a wb_get() en inode_switch_wbs_work_fn(). Todo podría manejarse con un código más cuidadoso, pero eso parece innecesariamente complejo, así que evitemos eso hasta que se demuestre que la iteración realmente aporta un beneficio práctico. Simplemente eliminemos el bucle de inode_switch_wbs_work_fn() en su lugar. De esa manera, cuando wb_queue_isw() encola trabajo, se nos garantiza que hemos añadido el primer elemento a wb  ->  switch_wbs_ctxs y nadie lo va a eliminar (y soltar la referencia a wb que contiene) hasta que se ejecute el trabajo encolado.","source":"nvd"}],"published":"2026-05-01T13:56:02.415Z","modified":"2026-11-11T21:10:00.200Z","severity":{"scorer":"Linux","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H","score":7.8,"rating":"HIGH"},"severities":[{"scorer":"Linux","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H","score":7.8,"rating":"HIGH"},{"scorer":"redhat-SADP","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:L/AC:H/PR:L/UI:N/S:U/C:H/I:H/A:H","score":7,"rating":"HIGH"}],"cwes":["CWE-416","CWE-825"],"affected":[{"ranges":[{"type":"git","introduced":"d072b38a64ddbc2d58c2e525a24af24ecbfebcb7","fixed":"382cf81cae89e58d22b4bdc38891cd4d0b9ba921","status":"affected"},{"type":"git","introduced":"ac7b2c21f2269d815ad0cdf0f8258d55185b805c","fixed":"19ec404b079be057b387643ba0c69bbcc5867c35","status":"affected"},{"type":"git","introduced":"fabfc1fcddc5d8185722d4fde5f0968c4760b71e","fixed":"156cc63691c1f20905510b1007896e090355e6c2","status":"affected"},{"type":"git","introduced":"e1b849cfa6b61f1c866a908c9e8dd9b5aaab820b","fixed":"028103656b84273c73e9e271cf95c9f3421f4b8a","status":"affected"},{"type":"git","introduced":"e1b849cfa6b61f1c866a908c9e8dd9b5aaab820b","fixed":"9223e5f30403a9b506d6d0bff4f2e29a2d7d46af","status":"affected"},{"type":"git","introduced":"e1b849cfa6b61f1c866a908c9e8dd9b5aaab820b","fixed":"6689f01d6740cf358932b3e97ee968c6099800d9","status":"affected"}],"vendor":"Linux","product":"Linux","repo":"https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git","source":"cvelist"},{"ranges":[{"version":"6.18","status":"affected"},{"type":"semver","introduced":"0","fixed":"6.18","status":"unaffected"},{"type":"semver","introduced":"6.18.25","lastAffected":"6.18.*","status":"unaffected"},{"type":"semver","introduced":"7.0.2","lastAffected":"7.0.*","status":"unaffected"},{"type":"original_commit_for_fix","introduced":"7.1","lastAffected":"*","status":"unaffected"}],"vendor":"Linux","product":"Linux","repo":"https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git","source":"cvelist"},{"ranges":[],"vendor":"Red Hat","product":"Red Hat Enterprise Linux 10","package":"kernel","cpe":"cpe:/o:redhat:enterprise_linux:10","source":"cvelist"},{"ranges":[],"vendor":"Red Hat","product":"Red Hat Enterprise Linux 6","package":"kernel","cpe":"cpe:/o:redhat:enterprise_linux:6","source":"cvelist"},{"ranges":[],"vendor":"Red Hat","product":"Red Hat Enterprise Linux 7","package":"kernel","cpe":"cpe:/o:redhat:enterprise_linux:7","source":"cvelist"},{"ranges":[],"vendor":"Red Hat","product":"Red Hat Enterprise Linux 7","package":"kernel-rt","cpe":"cpe:/o:redhat:enterprise_linux:7","source":"cvelist"},{"ranges":[],"vendor":"Red Hat","product":"Red Hat Enterprise Linux 8","package":"kernel","cpe":"cpe:/o:redhat:enterprise_linux:8","source":"cvelist"},{"ranges":[],"vendor":"Red Hat","product":"Red Hat Enterprise Linux 8","package":"kernel-rt","cpe":"cpe:/o:redhat:enterprise_linux:8","source":"cvelist"},{"ranges":[],"vendor":"Red Hat","product":"Red Hat Enterprise Linux 9","package":"kernel","cpe":"cpe:/o:redhat:enterprise_linux:9","source":"cvelist"},{"ranges":[],"vendor":"Red Hat","product":"Red Hat Enterprise Linux 9","package":"kernel-rt","cpe":"cpe:/o:redhat:enterprise_linux:9","source":"cvelist"},{"ranges":[{"status":"affected","introduced":"6.18","fixed":"6.18.25"},{"status":"affected","introduced":"6.19","fixed":"7.0.2"},{"status":"affected","version":"7.1"},{"status":"affected","version":"7.1"}],"vendor":"linux","product":"linux_kernel","cpe":"cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*","source":"nvd"}],"references":[{"url":"https://git.kernel.org/stable/c/382cf81cae89e58d22b4bdc38891cd4d0b9ba921","tags":[],"sources":["cvelist","nvd"]},{"url":"https://git.kernel.org/stable/c/19ec404b079be057b387643ba0c69bbcc5867c35","tags":[],"sources":["cvelist","nvd"]},{"url":"https://git.kernel.org/stable/c/156cc63691c1f20905510b1007896e090355e6c2","tags":[],"sources":["cvelist","nvd"]},{"url":"https://git.kernel.org/stable/c/028103656b84273c73e9e271cf95c9f3421f4b8a","tags":["patch"],"sources":["cvelist","nvd"]},{"url":"https://git.kernel.org/stable/c/9223e5f30403a9b506d6d0bff4f2e29a2d7d46af","tags":["patch"],"sources":["cvelist","nvd"]},{"url":"https://git.kernel.org/stable/c/6689f01d6740cf358932b3e97ee968c6099800d9","tags":["patch"],"sources":["cvelist","nvd"]},{"url":"https://access.redhat.com/security/cve/CVE-2026-31703","tags":["vdb-entry","x-refsource-redhat"],"sources":["cvelist","nvd"]},{"url":"https://bugzilla.redhat.com/show_bug.cgi?id=2464385","tags":["issue-tracking","x-refsource-redhat"],"sources":["cvelist","nvd"]},{"url":"https://security.access.redhat.com/data/csaf/v2/vex/2026/cve-2026-31703.json","tags":["x-sadp-csaf-vex"],"sources":["cvelist","nvd"]}],"credits":[],"assigner":"Linux","sources":[{"source":"cvelist","name":"CVE List","id":"CVE-2026-31703","url":"https://www.cve.org/CVERecord?id=CVE-2026-31703","licence":"CVE Terms of Use","modified":"2026-08-20T12:32:00.881Z"},{"source":"nvd","name":"NVD","id":"CVE-2026-31703","url":"https://nvd.nist.gov/vuln/detail/CVE-2026-31703","licence":"Public domain","modified":"2026-11-11T21:10:00.200Z"}],"updatedAt":"2026-11-25T22:59:20.338Z","epss":{"score":0.00121,"percentile":0.02095,"date":"2026-12-01T12:00:22.000Z"}}