[PATCH OLK-6.6] tracing: Fix crash passing ERR_PTR to kthread_stop()
From: Hui Su <sh_def@163.com> mainline inclusion from mainline-v7.3-rc1 commit 649bc7df3e5d7be6f7996a95084037dbf3cad1e5 category: bugfix bugzilla: https://atomgit.com/src-openeuler/kernel/issues/18775 CVE: CVE-2026-89749 Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?i... -------------------------------- event_test_stuff() calls kthread_run() and unconditionally passes the returned task_struct pointer to kthread_stop(). kthread_run() returns an error pointer such as ERR_PTR(-ENOMEM) when kthread creation fails, for example under memory pressure during the boot-time event self-test. kthread_stop() then dereferences the invalid pointer, crashing the kernel. Check the result of kthread_run() before passing it to kthread_stop(). Use WARN_ON() so that a failure to create the self-test thread does not go unnoticed, matching the ring-buffer self-test fix in commit 91542863abad ("ring-buffer: Fix crash passing ERR_PTR to kthread_stop()"). Cc: stable@vger.kernel.org Fixes: e6187007d6c3 ("tracing/events: add startup tests for events") Link: https://patch.msgid.link/20260817120642.668375-3-sh_def@163.com Signed-off-by: Hui Su <sh_def@163.com> Signed-off-by: Steven Rostedt <rostedt@goodmis.org> Signed-off-by: Tengda Wu <wutengda2@huawei.com> --- kernel/trace/trace_events.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c index 7326cfafcc23..48a29993b95d 100644 --- a/kernel/trace/trace_events.c +++ b/kernel/trace/trace_events.c @@ -4291,6 +4291,8 @@ static __init void event_test_stuff(void) struct task_struct *test_thread; test_thread = kthread_run(event_test_thread, NULL, "test-events"); + if (WARN_ON(IS_ERR(test_thread))) + return; msleep(1); kthread_stop(test_thread); } -- 2.34.1
反馈: 您发送到kernel@openeuler.org的补丁/补丁集,已成功转换为PR! PR链接地址: https://atomgit.com/openeuler/kernel/merge_requests/27489 邮件列表地址:https://mailweb.openeuler.org/archives/list/kernel@openeuler.org/message/CMS... FeedBack: The patch(es) which you have sent to kernel@openeuler.org mailing list has been converted to a pull request successfully! Pull request link: https://atomgit.com/openeuler/kernel/merge_requests/27489 Mailing list address: https://mailweb.openeuler.org/archives/list/kernel@openeuler.org/message/CMS...
participants (2)
-
patchwork bot -
Tengda Wu