[lkml]   [2018]   [Jan]   [15]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
Patch in this message
Subject[PATCH] ipmi: Clear smi_info->thread to prevent use-after-free during module unload
Subject:[PATCH] ipmi: Clear smi_info->thread to prevent use-after-free during module unload
To: Corey Minyard <>

During code inspection, I found an use-after-free possibility during unloading
ipmi_si in the polling mode.

If start_new_msg() is called after kthread_stop(), the function will try to
wake up non-existing kthread using the dangling pointer.

Possible scenario is when a new internal message is generated after
ipmi_unregister_smi()[*1] and remains after stop_timer_and_thread()
in clenaup_one_si() [*2].
Use-after-free could occur as follows depending on BMC replies.

=> ipmi_unregister_smi
=> stop_timer_and_thread
=> kthread_stop(smi_info->thread)
=> poll
=> smi_event_handler
=> start_new_msg
=> if (smi_info->thread)
wake_up_process(smi_info->thread) <== use-after-free!!

Although currently it seems no such message is generated in the polling mode,
some changes might introduce that in thefuture. For example in the interrupt
mode, disable_si_irq() does that at [*2].

So let's prevent such a critical issue possibility now.

Signed-off-by: Yamazaki Masamitsu <>

diff -Nurp a/drivers/char/ipmi/ipmi_si_intf.c b/drivers/char/ipmi/ipmi_si_intf.c
--- a/drivers/char/ipmi/ipmi_si_intf.c 2018-01-09 13:40:14.624785104 +0900
+++ b/drivers/char/ipmi/ipmi_si_intf.c 2018-01-09 13:44:39.174780570 +0900
@@ -1938,8 +1938,10 @@ static void check_for_broken_irqs(struct

static inline void stop_timer_and_thread(struct smi_info *smi_info)
- if (smi_info->thread != NULL)
+ if (smi_info->thread != NULL) {
+ smi_info->thread = NULL;
+ }

smi_info->timer_can_start = false;
if (smi_info->timer_running)
 \ /
  Last update: 2018-01-15 09:18    [W:0.061 / U:0.852 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site