Commit 0b4ffbe
tracing: Correct the refcount if the hist/hist_debug file fails to open
The function event_{hist,hist_debug}_open() maintains the refcount of
'file->tr' and 'file' through tracing_open_file_tr(). However, it does
not roll back these counts on subsequent failure paths, resulting in a
refcount leak.
A very obvious case is that if the hist/hist_debug file belongs to a
specific instance, the refcount leak will prevent the deletion of that
instance, as it relies on the condition 'tr->ref == 1' within
__remove_instance().
Fix this by calling tracing_release_file_tr() on all failure paths in
event_{hist,hist_debug}_open() to correct the refcount.
Cc: stable@vger.kernel.org
Cc: Masami Hiramatsu <mhiramat@kernel.org>
Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Cc: Zheng Yejian <zhengyejian1@huawei.com>
Link: https://lore.kernel.org/20250314065335.1202817-1-wutengda@huaweicloud.com
Fixes: 1cc111b ("tracing: Fix uaf issue when open the hist or hist_debug file")
Signed-off-by: Tengda Wu <wutengda@huaweicloud.com>
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>1 parent 7eb1721 commit 0b4ffbe
1 file changed
Lines changed: 18 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5689 | 5689 | | |
5690 | 5690 | | |
5691 | 5691 | | |
5692 | | - | |
5693 | | - | |
| 5692 | + | |
| 5693 | + | |
| 5694 | + | |
| 5695 | + | |
5694 | 5696 | | |
5695 | 5697 | | |
5696 | | - | |
5697 | | - | |
| 5698 | + | |
| 5699 | + | |
| 5700 | + | |
| 5701 | + | |
5698 | 5702 | | |
5699 | 5703 | | |
5700 | 5704 | | |
5701 | 5705 | | |
5702 | 5706 | | |
5703 | 5707 | | |
5704 | 5708 | | |
5705 | | - | |
| 5709 | + | |
5706 | 5710 | | |
| 5711 | + | |
| 5712 | + | |
5707 | 5713 | | |
| 5714 | + | |
| 5715 | + | |
| 5716 | + | |
5708 | 5717 | | |
5709 | 5718 | | |
5710 | 5719 | | |
| |||
5979 | 5988 | | |
5980 | 5989 | | |
5981 | 5990 | | |
5982 | | - | |
| 5991 | + | |
| 5992 | + | |
| 5993 | + | |
| 5994 | + | |
5983 | 5995 | | |
5984 | 5996 | | |
5985 | 5997 | | |
| |||
0 commit comments