linux/drivers/char/ipmi
Masamitsu Yamazaki bd1c06a4f5 ipmi: Clear smi_info->thread to prevent use-after-free during module unload
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.

  cleanup_one_si
    => ipmi_unregister_smi
       [*1]
    => stop_timer_and_thread
       => kthread_stop(smi_info->thread)
       [*2]
    => 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 <m-yamazaki@ah.jp.nec.com>
Signed-off-by: Corey Minyard <cminyard@mvista.com>
2018-01-15 18:34:34 -06:00
..
bt-bmc.c treewide: setup_timer() -> timer_setup() 2017-11-21 15:57:07 -08:00
ipmi_bt_sm.c
ipmi_devintf.c ipmi: get rid of field-by-field __get_user() 2017-06-26 17:02:54 -04:00
ipmi_dmi.c IPMI updates for 4.15 2017-11-15 15:12:28 -08:00
ipmi_dmi.h IPMI updates for 4.15 2017-11-15 15:12:28 -08:00
ipmi_kcs_sm.c
ipmi_msghandler.c ipmi: use correct string length 2018-01-08 20:02:47 -06:00
ipmi_powernv.c ipmi: Remove the device id from ipmi_register_smi() 2017-09-27 16:03:45 -05:00
ipmi_poweroff.c Merge branch 'modules-next' of git://git.kernel.org/pub/scm/linux/kernel/git/jeyu/linux into for-next 2017-11-02 11:19:15 -05:00
ipmi_si_hardcode.c ipmi_si: Move hardcode handling to a separate file. 2017-09-27 16:03:45 -05:00
ipmi_si_hotmod.c Merge branch 'modules-next' of git://git.kernel.org/pub/scm/linux/kernel/git/jeyu/linux into for-next 2017-11-02 11:19:15 -05:00
ipmi_si_intf.c ipmi: Clear smi_info->thread to prevent use-after-free during module unload 2018-01-15 18:34:34 -06:00
ipmi_si_mem_io.c ipmi_si: Move port and mem I/O handling to their own files 2017-09-28 12:26:00 -05:00
ipmi_si_parisc.c ipmi_si: fix crash on parisc 2017-12-11 07:43:26 -06:00
ipmi_si_pci.c ipmi_si: Fix oops with PCI devices 2017-12-11 07:42:50 -06:00
ipmi_si_platform.c ipmi_si_platform: Fix typo in parameter description 2017-12-12 07:00:01 -06:00
ipmi_si_port_io.c ipmi_si: Move port and mem I/O handling to their own files 2017-09-28 12:26:00 -05:00
ipmi_si_sm.h ipmi: Make the DMI probe into a generic platform probe 2017-09-28 12:26:03 -05:00
ipmi_si.h ipmi_si: Move port and mem I/O handling to their own files 2017-09-28 12:26:00 -05:00
ipmi_smic_sm.c
ipmi_ssif.c treewide: setup_timer() -> timer_setup() 2017-11-21 15:57:07 -08:00
ipmi_watchdog.c ipmi: use correct string length 2018-01-08 20:02:47 -06:00
Kconfig ipmi: Make the IPMI proc interface configurable 2017-09-28 12:26:03 -05:00
Makefile IPMI updates for 4.15 2017-11-15 15:12:28 -08:00