[<prev] [next>] [day] [month] [year] [list]
Message-ID: <2025040132-CVE-2025-21899-bf75@gregkh>
Date: Tue, 1 Apr 2025 16:25:35 +0100
From: Greg Kroah-Hartman <gregkh@...uxfoundation.org>
To: linux-cve-announce@...r.kernel.org
Cc: Greg Kroah-Hartman <gregkh@...uxfoundation.org>
Subject: CVE-2025-21899: tracing: Fix bad hist from corrupting named_triggers list
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.
The Linux kernel CVE team has assigned CVE-2025-21899 to this issue.
Affected and fixed versions
===========================
Issue introduced in 4.17 with commit 067fe038e70f6e64960d26a79c4df5f1413d0f13 and fixed in 6.1.130 with commit 5ae1b18f05ee2b849dc03b6c15d7da0c1c6efa77
Issue introduced in 4.17 with commit 067fe038e70f6e64960d26a79c4df5f1413d0f13 and fixed in 6.6.81 with commit 43b254d46c740bf9dbe65709afa021dd726dfa99
Issue introduced in 4.17 with commit 067fe038e70f6e64960d26a79c4df5f1413d0f13 and fixed in 6.12.18 with commit 435d2964af815aae456db554c62963b4515f19d0
Issue introduced in 4.17 with commit 067fe038e70f6e64960d26a79c4df5f1413d0f13 and fixed in 6.13.6 with commit f1ae50cfb818ce1ac7a674406dfadb7653e2552d
Issue introduced in 4.17 with commit 067fe038e70f6e64960d26a79c4df5f1413d0f13 and fixed in 6.14 with commit 6f86bdeab633a56d5c6dccf1a2c5989b6a5e323e
Please see https://www.kernel.org for a full list of currently supported
kernel versions by the kernel community.
Unaffected versions might change over time as fixes are backported to
older supported kernel versions. The official CVE entry at
https://cve.org/CVERecord/?id=CVE-2025-21899
will be updated if fixes are backported, please check that for the most
up to date information about this issue.
Affected files
==============
The file(s) affected by this issue are:
kernel/trace/trace_events_hist.c
Mitigation
==========
The Linux kernel CVE team recommends that you update to the latest
stable kernel version for this, and many other bugfixes. Individual
changes are never tested alone, but rather are part of a larger kernel
release. Cherry-picking individual commits is not recommended or
supported by the Linux kernel community at all. If however, updating to
the latest release is impossible, the individual changes to resolve this
issue can be found at these commits:
https://git.kernel.org/stable/c/5ae1b18f05ee2b849dc03b6c15d7da0c1c6efa77
https://git.kernel.org/stable/c/43b254d46c740bf9dbe65709afa021dd726dfa99
https://git.kernel.org/stable/c/435d2964af815aae456db554c62963b4515f19d0
https://git.kernel.org/stable/c/f1ae50cfb818ce1ac7a674406dfadb7653e2552d
https://git.kernel.org/stable/c/6f86bdeab633a56d5c6dccf1a2c5989b6a5e323e
Powered by blists - more mailing lists