mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Greg KH <greg@kroah.com>
To: minyard@acm.org
Cc: stable@vger.kernel.org, linux-kernel@vger.kernel.org,
	Masamitsu Yamazaki <m-yamazaki@ah.jp.nec.com>,
	Corey Minyard <cminyard@mvista.com>
Subject: Re: [PATCH] ipmi: Stop timers before cleaning up the module
Date: Thu, 14 Dec 2017 18:43:39 +0100	[thread overview]
Message-ID: <20171214174339.GB10610@kroah.com> (raw)
In-Reply-To: <1513264598-31845-1-git-send-email-minyard@acm.org>

On Thu, Dec 14, 2017 at 09:16:38AM -0600, minyard@acm.org wrote:
> From: Masamitsu Yamazaki <m-yamazaki@ah.jp.nec.com>
> 
> commit 4f7f5551a760eb0124267be65763008169db7087 upstream.
> 
> System may crash after unloading ipmi_si.ko module
> because a timer may remain and fire after the module cleaned up resources.
> 
> cleanup_one_si() contains the following processing.
> 
>         /*
>          * Make sure that interrupts, the timer and the thread are
>          * stopped and will not run again.
>          */
>         if (to_clean->irq_cleanup)
>                 to_clean->irq_cleanup(to_clean);
>         wait_for_timer_and_thread(to_clean);
> 
>         /*
>          * Timeouts are stopped, now make sure the interrupts are off
>          * in the BMC.  Note that timers and CPU interrupts are off,
>          * so no need for locks.
>          */
>         while (to_clean->curr_msg || (to_clean->si_state != SI_NORMAL)) {
>                 poll(to_clean);
>                 schedule_timeout_uninterruptible(1);
>         }
> 
> si_state changes as following in the while loop calling poll(to_clean).
> 
>   SI_GETTING_MESSAGES
>     => SI_CHECKING_ENABLES
>      => SI_SETTING_ENABLES
>       => SI_GETTING_EVENTS
>        => SI_NORMAL
> 
> As written in the code comments above,
> timers are expected to stop before the polling loop and not to run again.
> But the timer is set again in the following process
> when si_state becomes SI_SETTING_ENABLES.
> 
>   => poll
>      => smi_event_handler
>        => handle_transaction_done
>           // smi_info->si_state == SI_SETTING_ENABLES
>          => start_getting_events
>            => start_new_msg
>             => smi_mod_timer
>               => mod_timer
> 
> As a result, before the timer set in start_new_msg() expires,
> the polling loop may see si_state becoming SI_NORMAL
> and the module clean-up finishes.
> 
> For example, hard LOCKUP and panic occurred as following.
> smi_timeout was called after smi_event_handler,
> kcs_event and hangs at port_inb()
> trying to access I/O port after release.
> 
>     [exception RIP: port_inb+19]
>     RIP: ffffffffc0473053  RSP: ffff88069fdc3d80  RFLAGS: 00000006
>     RAX: ffff8806800f8e00  RBX: ffff880682bd9400  RCX: 0000000000000000
>     RDX: 0000000000000ca3  RSI: 0000000000000ca3  RDI: ffff8806800f8e40
>     RBP: ffff88069fdc3d80   R8: ffffffff81d86dfc   R9: ffffffff81e36426
>     R10: 00000000000509f0  R11: 0000000000100000  R12: 0000000000]:000000
>     R13: 0000000000000000  R14: 0000000000000246  R15: ffff8806800f8e00
>     ORIG_RAX: ffffffffffffffff  CS: 0010  SS: 0000
>  --- <NMI exception stack> ---
> 
> To fix the problem I defined a flag, timer_can_start,
> as member of struct smi_info.
> The flag is enabled immediately after initializing the timer
> and disabled immediately before waiting for timer deletion.
> 
> Fixes: 0cfec916e86d ("ipmi: Start the timer and thread on internal msgs")
> Signed-off-by: Yamazaki Masamitsu <m-yamazaki@ah.jp.nec.com>
> [Some fairly major changes went into the IPMI driver in 4.15, so this
>  required a backport as the code had changed and moved to a different
>  file.  The 4.14 version of this patch moved some code under an
>  if statement causing it to not apply to 4.7-4.13.]
> Signed-off-by: Corey Minyard <cminyard@mvista.com>
> ---
> This is for kernel versions 4.7-4.13 only.  Code and API changes required
> backporting.  There is another version for 4.14 and another for
> 4.4-4.6 coming, too.  Bug was introduced in 4.4.

All 3 patches now applied, thanks for the backports.

greg k-h

  reply	other threads:[~2017-12-14 17:46 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-12-14 15:16 minyard
2017-12-14 17:43 ` Greg KH [this message]
  -- strict thread matches above, loose matches on Subject: below --
2017-12-14 15:17 minyard
2017-12-14 15:16 minyard
2017-11-15  7:33 Masamitsu Yamazaki

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20171214174339.GB10610@kroah.com \
    --to=greg@kroah.com \
    --cc=cminyard@mvista.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=m-yamazaki@ah.jp.nec.com \
    --cc=minyard@acm.org \
    --cc=stable@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®