{"id":"CVE-2025-40002","aliases":["CVE-2025-40002"],"related":[],"kind":"vulnerability","state":"published","title":"thunderbolt: Fix use-after-free in tb_dp_dprx_work","summary":"In the Linux kernel, the following vulnerability has been resolved:\n\nthunderbolt: Fix use-after-free in tb_dp_dprx_work\n\nThe original code relies on cancel_delayed_work() in tb_dp_dprx_stop(),\nwhich does not ensure that the delayed work item tunnel->dprx_work has\nfully completed if it was already running. This leads to use-after-free\nscenarios where tb_tunnel is deallocated by tb_tunnel_put(), while\ntunnel->dprx_work remains active and attempts to dereference tb_tunnel\nin tb_dp_dprx_work().\n\nA typical race condition is illustrated below:\n\nCPU 0                            | CPU 1\ntb_dp_tunnel_active()            |\n  tb_deactivate_and_free_tunnel()| tb_dp_dprx_start()\n    tb_tunnel_deactivate()       |   queue_delayed_work()\n      tb_dp_activate()           |\n        tb_dp_dprx_stop()        | tb_dp_dprx_work() //delayed worker\n          cancel_delayed_work()  |\n    tb_tunnel_put(tunnel);       |\n                                 |   tunnel = container_of(...); //UAF\n                                 |   tunnel-> //UAF\n\nReplacing cancel_delayed_work() with cancel_delayed_work_sync() is\nnot feasible as it would introduce a deadlock: both tb_dp_dprx_work()\nand the cleanup path acquire tb->lock, and cancel_delayed_work_sync()\nwould wait indefinitely for the work item that cannot proceed.\n\nInstead, implement proper reference counting:\n- If cancel_delayed_work() returns true (work is pending), we release\n  the reference in the stop function.\n- If it returns false (work is executing or already completed), the\n  reference is released in delayed work function itself.\n\nThis ensures the tb_tunnel remains valid during work item execution\nwhile preventing memory leaks.\n\nThis bug was found by static analysis.","summarySource":"cvelist","descriptions":[{"lang":"en","text":"In the Linux kernel, the following vulnerability has been resolved:\n\nthunderbolt: Fix use-after-free in tb_dp_dprx_work\n\nThe original code relies on cancel_delayed_work() in tb_dp_dprx_stop(),\nwhich does not ensure that the delayed work item tunnel->dprx_work has\nfully completed if it was already running. This leads to use-after-free\nscenarios where tb_tunnel is deallocated by tb_tunnel_put(), while\ntunnel->dprx_work remains active and attempts to dereference tb_tunnel\nin tb_dp_dprx_work().\n\nA typical race condition is illustrated below:\n\nCPU 0                            | CPU 1\ntb_dp_tunnel_active()            |\n  tb_deactivate_and_free_tunnel()| tb_dp_dprx_start()\n    tb_tunnel_deactivate()       |   queue_delayed_work()\n      tb_dp_activate()           |\n        tb_dp_dprx_stop()        | tb_dp_dprx_work() //delayed worker\n          cancel_delayed_work()  |\n    tb_tunnel_put(tunnel);       |\n                                 |   tunnel = container_of(...); //UAF\n                                 |   tunnel-> //UAF\n\nReplacing cancel_delayed_work() with cancel_delayed_work_sync() is\nnot feasible as it would introduce a deadlock: both tb_dp_dprx_work()\nand the cleanup path acquire tb->lock, and cancel_delayed_work_sync()\nwould wait indefinitely for the work item that cannot proceed.\n\nInstead, implement proper reference counting:\n- If cancel_delayed_work() returns true (work is pending), we release\n  the reference in the stop function.\n- If it returns false (work is executing or already completed), the\n  reference is released in delayed work function itself.\n\nThis ensures the tb_tunnel remains valid during work item execution\nwhile preventing memory leaks.\n\nThis bug was found by static analysis.","source":"cvelist"},{"lang":"es","text":"En el kernel de Linux, la siguiente vulnerabilidad ha sido resuelta:\n\nthunderbolt: Soluciona uso después de liberación en tb_dp_dprx_work\n\nEl código original se basa en cancel_delayed_work() en tb_dp_dprx_stop(), lo que no asegura que el elemento de trabajo retrasado tunnel->dprx_work haya completado completamente si ya estaba en ejecución. Esto lleva a escenarios de uso después de liberación donde tb_tunnel es desasignado por tb_tunnel_put(), mientras que tunnel->dprx_work permanece activo e intenta desreferenciar tb_tunnel en tb_dp_dprx_work().\n\nUna condición de carrera típica se ilustra a continuación:\n\nCPU 0                            | CPU 1\ntb_dp_tunnel_active()            |\n  tb_deactivate_and_free_tunnel()| tb_dp_dprx_start()\n    tb_tunnel_deactivate()       |   queue_delayed_work()\n      tb_dp_activate()           |\n        tb_dp_dprx_stop()        | tb_dp_dprx_work() //trabajador retrasado\n          cancel_delayed_work()  |\n    tb_tunnel_put(tunnel);       |\n                                 |   tunnel = container_of(...); //UAF\n                                 |   tunnel-> //UAF\n\nReemplazar cancel_delayed_work() con cancel_delayed_work_sync() no es factible ya que introduciría un interbloqueo: tanto tb_dp_dprx_work() como la ruta de limpieza adquieren tb->lock, y cancel_delayed_work_sync() esperaría indefinidamente por el elemento de trabajo que no puede continuar.\n\nEn su lugar, implementa un conteo de referencias adecuado:\n- Si cancel_delayed_work() devuelve verdadero (el trabajo está pendiente), liberamos la referencia en la función de parada.\n- Si devuelve falso (el trabajo se está ejecutando o ya ha completado), la referencia se libera en la propia función de trabajo retrasado.\n\nEsto asegura que el tb_tunnel permanezca válido durante la ejecución del elemento de trabajo mientras previene fugas de memoria.\n\nEste error fue encontrado mediante análisis estático.","source":"nvd"}],"published":"2025-10-18T08:03:22.718Z","modified":"2026-10-19T21:10:00.160Z","severities":[],"cwes":[],"affected":[{"ranges":[{"type":"git","introduced":"d6d458d42e1e1544a18f37f1d5c840e00d5261b9","fixed":"c07923f6a8729fc27ee652221a51702ff6654097","status":"affected"},{"type":"git","introduced":"d6d458d42e1e1544a18f37f1d5c840e00d5261b9","fixed":"67600ccfc4f38ebd331b9332ac94717bfbc87ea7","status":"affected"}],"vendor":"Linux","product":"Linux","repo":"https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git","source":"cvelist"},{"ranges":[{"version":"6.14","status":"affected"},{"type":"semver","introduced":"0","fixed":"6.14","status":"unaffected"},{"type":"semver","introduced":"6.17.3","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/c07923f6a8729fc27ee652221a51702ff6654097","tags":[],"sources":["cvelist","nvd"]},{"url":"https://git.kernel.org/stable/c/67600ccfc4f38ebd331b9332ac94717bfbc87ea7","tags":[],"sources":["cvelist","nvd"]}],"credits":[],"assigner":"Linux","sources":[{"source":"cvelist","name":"CVE List","id":"CVE-2025-40002","url":"https://www.cve.org/CVERecord?id=CVE-2025-40002","licence":"CVE Terms of Use","modified":"2026-05-11T21:40:34.575Z"},{"source":"nvd","name":"NVD","id":"CVE-2025-40002","url":"https://nvd.nist.gov/vuln/detail/CVE-2025-40002","licence":"Public domain","modified":"2026-10-19T21:10:00.160Z"}],"updatedAt":"2026-11-25T22:59:06.560Z","epss":{"score":0.00253,"percentile":0.17886,"date":"2026-12-01T12:00:22.000Z"}}