Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1419015
| Path | csiph.com!goblin3!goblin.stu.neva.ru!sewer!news.mixmin.net!aioe.org!news.servidellagleba.it!bofh.it!news.nic.it!robomod |
|---|---|
| From | Corey Minyard <minyard@acm.org> |
| Newsgroups | linux.kernel |
| Subject | Re: [PATCH] ipmi: Remove smi_msg from waiting_rcv_msgs list before handle_one_recv_msg() |
| Date | Fri, 10 Jun 2016 06:40:02 +0200 |
| Message-ID | <rImoG-8ma-5@gated-at.bofh.it> (permalink) |
| References | <rImoG-8ma-3@gated-at.bofh.it> |
| X-Original-To | Junichi Nomura <j-nomura@ce.jp.nec.com>, "openipmi-developer@lists.sourceforge.net" <openipmi-developer@lists.sourceforge.net> |
| Dkim-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:reply-to:subject:references:to:cc:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding; bh=A/CxfZPaQanLDzfEj9D7Tdg7wNNyWPFxk6P7HPVw+yE=; b=Hv+rjz2dW0IvV7Gub3vd+FTOMd86bqGJGGNxOg/xZBwdCIRMq6VySRELhm+W3sBdXZ MWOsUjRuJaSEO4PDUg22IURPrVzjXLxp+Ji1cA4dkaGzfh7v8dSFGPLxPdp+0KtWyQ4J cYm0kVA5an6ZXw9DA2Q1D8WPF/QRwGc1XXBnF+6RrraexJJ8H3+u76P0DO+gie0a0TD1 SiC9fMvkov9YXUFi+lHNVlsFTpsMPP5VmDcTV6mGgdSB/xPD5JMr7LdBNR8UPSC4MG9o 3YSKXy3i3DvYKCfF6hBJsPMfbFdo99bZrEEdYSR20CVIM+eOsOzg5e66efsgVG8R2SvQ Bxsw== |
| X-Google-Dkim-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:reply-to:subject:references:to:cc:from :message-id:date:user-agent:mime-version:in-reply-to :content-transfer-encoding; bh=A/CxfZPaQanLDzfEj9D7Tdg7wNNyWPFxk6P7HPVw+yE=; b=jx1Yo2ckK/jgO7WBhfmPOVK2kju0RRLXbJx2Q8HmiYH9aRKAI23PB/A0slTPQ2Yf9j lF2zBef4iIqvy1YN+U4HtWmtTKYVG2xtfMZbf69TQeof4+JSm1Au09i60XZ1euEKT51C L2AGxuRmLMBe1vJEHZTRiesKZ4TXq9Yv/ihRGZJ5/1q2Ar666gwf0tfnXuzQFGmz1Ryv xqsfHWWyLYrwnqAjF5ni1FCybTBpl3bB3OElPyJS87OrGxcT3ATOUbMBl4YVV1AH77+H ONxyXq67sFIPflh4voVxSSOHqYP119cng4p28j4Eci/jXynhF84/g16KyLG00oLTPbmC YgFw== |
| X-Gm-Message-State | ALyK8tKfepXYq+uYrHBTwfGntBK6PCD/Dxcx/rs04lVIVcRxqZbdEOdGAcvo63wK16Z7RQ== |
| X-Received | by 10.157.51.21 with SMTP id f21mr14614otc.8.1465533423769; Thu, 09 Jun 2016 21:37:03 -0700 (PDT) |
| Reply-To | minyard@acm.org |
| User-Agent | Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.8.0 |
| MIME-Version | 1.0 |
| Content-Type | text/plain; charset=UTF-8; format=flowed |
| Content-Transfer-Encoding | 7bit |
| Sender | robomod@news.nic.it |
| List-ID | <linux-kernel.vger.kernel.org> |
| X-Mailing-List | linux-kernel@vger.kernel.org |
| Approved | robomod@news.nic.it |
| Lines | 73 |
| Organization | linux.* mail to news gateway |
| X-Original-Cc | "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>, "cminyard@mvista.com" <cminyard@mvista.com> |
| X-Original-Date | Thu, 9 Jun 2016 23:36:55 -0500 |
| X-Original-Message-ID | <575A43E7.2090701@acm.org> |
| X-Original-References | <7727de24-6867-1a37-3fed-1bdb1fd6084f@ce.jp.nec.com> |
| X-Original-Sender | linux-kernel-owner@vger.kernel.org |
| Xref | csiph.com linux.kernel:1419015 |
Show key headers only | View raw
I actually just wrote this exact patch, moments ago. But you deserve
credit, I'll use yours :).
-corey
On 06/09/2016 11:31 PM, Junichi Nomura wrote:
> Commit 7ea0ed2b5be8 ("ipmi: Make the message handler easier to use for
> SMI interfaces") changed handle_new_recv_msgs() to call handle_one_recv_msg()
> for a smi_msg while the smi_msg is still connected to waiting_rcv_msgs list.
> That could lead to following list corruption problems:
>
> 1) low-level function treats smi_msg as not connected to list
>
> handle_one_recv_msg() could end up calling smi_send(), which
> assumes the msg is not connected to list.
>
> For example, the following sequence could corrupt list by
> doing list_add_tail() for the entry still connected to other list.
>
> handle_new_recv_msgs()
> msg = list_entry(waiting_rcv_msgs)
> handle_one_recv_msg(msg)
> handle_ipmb_get_msg_cmd(msg)
> smi_send(msg)
> spin_lock(xmit_msgs_lock)
> list_add_tail(msg)
> spin_unlock(xmit_msgs_lock)
>
> 2) race between multiple handle_new_recv_msgs() instances
>
> handle_new_recv_msgs() once releases waiting_rcv_msgs_lock before calling
> handle_one_recv_msg() then retakes the lock and list_del() it.
>
> If others call handle_new_recv_msgs() during the window shown below
> list_del() will be done twice for the same smi_msg.
>
> handle_new_recv_msgs()
> spin_lock(waiting_rcv_msgs_lock)
> msg = list_entry(waiting_rcv_msgs)
> spin_unlock(waiting_rcv_msgs_lock)
> |
> | handle_one_recv_msg(msg)
> |
> spin_lock(waiting_rcv_msgs_lock)
> list_del(msg)
> spin_unlock(waiting_rcv_msgs_lock)
>
> Fixes: 7ea0ed2b5be8 ("ipmi: Make the message handler easier to use for SMI interfaces")
> Signed-off-by: Jun'ichi Nomura <j-nomura@ce.jp.nec.com>
>
> diff --git a/drivers/char/ipmi/ipmi_msghandler.c b/drivers/char/ipmi/ipmi_msghandler.c
> index 94fb407..94e4a88 100644
> --- a/drivers/char/ipmi/ipmi_msghandler.c
> +++ b/drivers/char/ipmi/ipmi_msghandler.c
> @@ -3820,6 +3820,7 @@ static void handle_new_recv_msgs(ipmi_smi_t intf)
> while (!list_empty(&intf->waiting_rcv_msgs)) {
> smi_msg = list_entry(intf->waiting_rcv_msgs.next,
> struct ipmi_smi_msg, link);
> + list_del(&smi_msg->link);
> if (!run_to_completion)
> spin_unlock_irqrestore(&intf->waiting_rcv_msgs_lock,
> flags);
> @@ -3831,9 +3832,9 @@ static void handle_new_recv_msgs(ipmi_smi_t intf)
> * To preserve message order, quit if we
> * can't handle a message.
> */
> + list_add(&smi_msg->link, &intf->waiting_rcv_msgs);
> break;
> } else {
> - list_del(&smi_msg->link);
> if (rv == 0)
> /* Message handled */
> ipmi_free_smi_msg(smi_msg);
Back to linux.kernel | Previous | Next — Previous in thread | Find similar | Unroll thread
[PATCH] ipmi: Remove smi_msg from waiting_rcv_msgs list before handle_one_recv_msg() Junichi Nomura <j-nomura@ce.jp.nec.com> - 2016-06-10 06:40 +0200 Re: [PATCH] ipmi: Remove smi_msg from waiting_rcv_msgs list before handle_one_recv_msg() Corey Minyard <minyard@acm.org> - 2016-06-10 06:40 +0200
csiph-web