CVE-2025-21899
JSON

7.8high

tracing: Fix bad hist from corrupting named_triggers list

Severity
7.8high CVSS:3.1 by Linux
Exploit likelihood
0.23% (higher than 15% of CVEs; EPSS, by FIRST)
Published
Last changed
Assigned by
Linux

Description

In the Linux kernel, the following vulnerability has been resolved: tracing: Fix bad hist from corrupting named_triggers list The following commands causes a crash: ~# cd /sys/kernel/tracing/events/rcu/rcu_callback ~# echo 'hist:name=bad:keys=common_pid:onmax(bogus).save(common_pid)' > trigger bash: echo: write error: Invalid argument ~# echo 'hist:name=bad:keys=common_pid' > trigger Because the following occurs: event_trigger_write() { trigger_process_regex() { event_hist_trigger_parse() { data = event_trigger_alloc(..); event_trigger_register(.., data) { cmd_ops->reg(.., data, ..) [hist_register_trigger()] { data->ops->init() [event_hist_trigger_init()] { save_named_trigger(name, data) { list_add(&data->named_list, &named_triggers); } } } } ret = create_actions(); (return -EINVAL) if (ret) goto out_unreg; [..] ret = hist_trigger_enable(data, ...) { list_add_tail_rcu(&data->list, &file->triggers); <<<---- SKIPPED!!! (this is important!) [..] out_unreg: event_hist_unregister(.., data) { cmd_ops->unreg(.., data, ..) [hist_unregister_trigger()] { list_for_each_entry(iter, &file->triggers, list) { if (!hist_trigger_match(data, iter, named_data, false)) <- never matches continue; [..] test = iter; } if (test && test->ops->free) <<<-- test is NULL test->ops->free(test) [event_hist_trigger_free()] { [..] if (data->name) del_named_trigger(data) { list_del(&data->named_list); <<<<-- NEVER gets removed! } } } } [..] kfree(data); <<<-- frees item but it is still on list The next time a hist with name is registered, it causes an u-a-f bug and the kernel can crash. Move the code around such that if event_trigger_register() succeeds, the next thing called is hist_trigger_enable() which adds it to the list. A bunch of actions is called if get_named_trigger_data() returns false. But that doesn't need to be called after event_trigger_register(), so it can be moved up, allowing event_trigger_register() to be called just before hist_trigger_enable() keeping them together and allowing the file->triggers to be properly populated.

Affected

Product or packageVersionsReported by
Linux Linuxfrom 067fe038e70f6e64960d26a79c4df5f1413d0f13 before 5ae1b18f05ee2b849dc03b6c15d7da0c1c6efa77, from 067fe038e70f6e64960d26a79c4df5f1413d0f13 before 43b254d46c740bf9dbe65709afa021dd726dfa99, from 067fe038e70f6e64960d26a79c4df5f1413d0f13 before 435d2964af815aae456db554c62963b4515f19d0, from 067fe038e70f6e64960d26a79c4df5f1413d0f13 before f1ae50cfb818ce1ac7a674406dfadb7653e2552d, from 067fe038e70f6e64960d26a79c4df5f1413d0f13 before 6f86bdeab633a56d5c6dccf1a2c5989b6a5e323e, 4.17
Not affected: before 4.17, from 6.1.130 up to 6.1.*, from 6.6.81 up to 6.6.*, from 6.12.18 up to 6.12.*, from 6.13.6 up to 6.13.*, from 6.14 up to *
CVE List
linux linux_kernelfrom 4.17 before 6.1.130, from 6.2 before 6.6.81, from 6.7 before 6.12.18, from 6.13 before 6.13.6, 6.14NVD

All scores

Linux7.8high CVSS:3.1CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H
NVD5.5medium CVSS:3.1CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:N/I:N/A:H

Classification

CWE-476

SSVC (CISA-ADP): exploitation none, automatable no, technical impact total.

What each source says

CVE List

In the Linux kernel, the following vulnerability has been resolved: tracing: Fix bad hist from corrupting named_triggers list The following commands causes a crash: ~# cd /sys/kernel/tracing/events/rcu/rcu_callback ~# echo 'hist:name=bad:keys=common_pid:onmax(bogus).save(common_pid)' > trigger bash: echo: write error: Invalid argument ~# echo 'hist:name=bad:keys=common_pid' > trigger Because the following occurs: event_trigger_write() { trigger_process_regex() { event_hist_trigger_parse() { data = event_trigger_alloc(..); event_trigger_register(.., data) { cmd_ops->reg(.., data, ..) [hist_register_trigger()] { data->ops->init() [event_hist_trigger_init()] { save_named_trigger(name, data) { list_add(&data->named_list, &named_triggers); } } } } ret = create_actions(); (return -EINVAL) if (ret) goto out_unreg; [..] ret = hist_trigger_enable(data, ...) { list_add_tail_rcu(&data->list, &file->triggers); <<<---- SKIPPED!!! (this is important!) [..] out_unreg: event_hist_unregister(.., data) { cmd_ops->unreg(.., data, ..) [hist_unregister_trigger()] { list_for_each_entry(iter, &file->triggers, list) { if (!hist_trigger_match(data, iter, named_data, false)) <- never matches continue; [..] test = iter; } if (test && test->ops->free) <<<-- test is NULL test->ops->free(test) [event_hist_trigger_free()] { [..] if (data->name) del_named_trigger(data) { list_del(&data->named_list); <<<<-- NEVER gets removed! } } } } [..] kfree(data); <<<-- frees item but it is still on list The next time a hist with name is registered, it causes an u-a-f bug and the kernel can crash. Move the code around such that if event_trigger_register() succeeds, the next thing called is hist_trigger_enable() which adds it to the list. A bunch of actions is called if get_named_trigger_data() returns false. But that doesn't need to be called after event_trigger_register(), so it can be moved up, allowing event_trigger_register() to be called just before hist_trigger_enable() keeping them together and allowing the file->triggers to be properly populated.

NVD (es)

En el kernel de Linux, se ha resuelto la siguiente vulnerabilidad: tracing: Fix bad hist from corrupting named_triggers list Los siguientes comandos provocan un bloqueo: ~# cd /sys/kernel/tracing/events/rcu/rcu_callback ~# echo 'hist:name=bad:keys=common_pid:onmax(bogus).save(common_pid)' &gt; trigger bash: echo: error de escritura: argumento no válido ~# echo 'hist:name=bad:keys=common_pid' &gt; trigger Porque ocurre lo siguiente: event_trigger_write() { trigger_process_regex() { event_hist_trigger_parse() { data = event_trigger_alloc(..); event_trigger_register(.., data) { cmd_ops-&gt;reg(.., data, ..) [hist_register_trigger()] { data-&gt;ops-&gt;init() [event_hist_trigger_init()] { save_named_trigger(name, data) { list_add(&amp;data-&gt;named_list, &amp;named_triggers); } } } } ret = create_actions(); (return -EINVAL) if (ret) goto out_unreg; [..] ret = hist_trigger_enable(data, ...) { list_add_tail_rcu(&amp;data-&gt;list, &amp;file-&gt;triggers); &lt;&lt;&lt;---- ¡¡¡SALTAR!!! (¡esto es importante!) [..] out_unreg: event_hist_unregister(.., data) { cmd_ops-&gt;unreg(.., data, ..) [hist_unregister_trigger()] { list_for_each_entry(iter, &amp;file-&gt;triggers, list) { if (!hist_trigger_match(data, iter, named_data, false)) &lt;- never matches continue; [..] test = iter; } if (test &amp;&amp; test-&gt;ops-&gt;free) &lt;&lt;&lt;-- test is NULL test-&gt;ops-&gt;free(test) [event_hist_trigger_free()] { [..] if (data-&gt;name) del_named_trigger(data) { list_del(&amp;data-&gt;named_list); &lt;&lt;&lt;&lt;-- ¡NUNCA se elimina! } } } } [..] kfree(datos); &lt;&lt;&lt;-- libera el elemento, pero sigue en la lista. La próxima vez que se registre un hist con nombre, se producirá un error de uaf y el kernel podría bloquearse. Desplace el código de forma que, si event_trigger_register() tiene éxito, se llame a hist_trigger_enable(), lo que lo añade a la lista. Se invocan varias acciones si get_named_trigger_data() devuelve falso. Sin embargo, no es necesario llamarlo después de event_trigger_register(), por lo que se puede adelantar, lo que permite llamar a event_trigger_register() justo antes de hist_trigger_enable(), manteniéndolos juntos y permitiendo que los disparadores de archivo se rellenen correctamente.

References

Sources

SourceRecordLicence
CVE ListCVE-2025-21899 changed 2026-10-15CVE Terms of Use
NVDCVE-2025-21899 changed 2026-10-15Public domain