public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/1] Fix race in ipmi timer cleanup
@ 2019-08-28 20:36 Jes Sorensen
  2019-08-28 20:36 ` [PATCH 1/1] ipmi_si_intf: Fix race in timer shutdown handling Jes Sorensen
  2019-08-28 22:32 ` [PATCH 0/1] Fix race in ipmi timer cleanup Corey Minyard
  0 siblings, 2 replies; 7+ messages in thread
From: Jes Sorensen @ 2019-08-28 20:36 UTC (permalink / raw)
  To: minyard; +Cc: linux-kernel, openipmi-developer, kernel-team

From: Jes Sorensen <jsorensen@fb.com>

I came across this in 4.16, but I believe the bug is still present
in current 5.x, even if it is less likely to trigger.

Basially stop_timer_and_thread() only calls del_timer_sync() if
timer_running == true. However smi_mod_timer enables the timer before
setting timer_running = true.

I was able to reproduce this in 4.16 running the following on a host

   while :; do rmmod ipmi_si ; modprobe ipmi_si; done

while rebooting the BMC on it in parallel.

5.2 moves the error handling around and does it more centralized, but
relying on timer_running still seems dubious to me.

static void smi_mod_timer(struct smi_info *smi_info, unsigned long new_val)
{
        if (!smi_info->timer_can_start)
                return;
        smi_info->last_timeout_jiffies = jiffies;
        mod_timer(&smi_info->si_timer, new_val);
        smi_info->timer_running = true;
}

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

        smi_info->timer_can_start = false;
        if (smi_info->timer_running)
                del_timer_sync(&smi_info->si_timer);
}

Cheers,
Jes

Jes Sorensen (1):
  ipmi_si_intf: Fix race in timer shutdown handling

 drivers/char/ipmi/ipmi_si_intf.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

-- 
2.21.0


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2019-09-16 14:01 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-08-28 20:36 [PATCH 0/1] Fix race in ipmi timer cleanup Jes Sorensen
2019-08-28 20:36 ` [PATCH 1/1] ipmi_si_intf: Fix race in timer shutdown handling Jes Sorensen
2019-08-28 22:32 ` [PATCH 0/1] Fix race in ipmi timer cleanup Corey Minyard
2019-08-29  0:53   ` Jes Sorensen
2019-08-29 18:15     ` Corey Minyard
2019-09-15  1:08       ` [Openipmi-developer] " Corey Minyard
2019-09-16 14:01         ` Jes Sorensen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox