From: KY Srinivasan <kys@microsoft.com>
To: Vitaly Kuznetsov <vkuznets@redhat.com>,
Haiyang Zhang <haiyangz@microsoft.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
"devel@linuxdriverproject.org" <devel@linuxdriverproject.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: RE: [PATCH] Drivers: hv: vmbus: Fix a race condition when unregistering a device
Date: Tue, 4 Nov 2014 16:50:42 +0000 [thread overview]
Message-ID: <c4546b3420864d0d8be7e4b8e36d1875@BY2PR0301MB0711.namprd03.prod.outlook.com> (raw)
In-Reply-To: <1415104811-28142-1-git-send-email-vkuznets@redhat.com>
> -----Original Message-----
> From: Vitaly Kuznetsov [mailto:vkuznets@redhat.com]
> Sent: Tuesday, November 4, 2014 4:40 AM
> To: KY Srinivasan; Haiyang Zhang
> Cc: Greg Kroah-Hartman; devel@linuxdriverproject.org; linux-
> kernel@vger.kernel.org
> Subject: [PATCH] Drivers: hv: vmbus: Fix a race condition when unregistering
> a device
>
> When build with Debug the following crash is sometimes observed:
> Call Trace:
> [<ffffffff812b9600>] string+0x40/0x100
> [<ffffffff812bb038>] vsnprintf+0x218/0x5e0 [<ffffffff810baf7d>] ?
> trace_hardirqs_off+0xd/0x10 [<ffffffff812bb4c1>] vscnprintf+0x11/0x30
> [<ffffffff8107a2f0>] vprintk+0xd0/0x5c0 [<ffffffffa0051ea0>] ?
> vmbus_process_rescind_offer+0x0/0x110 [hv_vmbus] [<ffffffff8155c71c>]
> printk+0x41/0x45 [<ffffffffa004ebac>] vmbus_device_unregister+0x2c/0x40
> [hv_vmbus] [<ffffffffa0051ecb>]
> vmbus_process_rescind_offer+0x2b/0x110 [hv_vmbus] ...
>
> This happens due to the following race: between 'if (channel->device_obj)'
> check in vmbus_process_rescind_offer() and pr_debug() in
> vmbus_device_unregister() the device can disappear. Fix the issue by taking
> an additional reference to the device before proceeding to
> vmbus_device_unregister().
>
Thank you.
> Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com>
Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Cc: <stable@vger.kernel.org>
> ---
> drivers/hv/channel_mgmt.c | 11 +++++++++--
> 1 file changed, 9 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/hv/channel_mgmt.c b/drivers/hv/channel_mgmt.c index
> a2d1a96..d36ce68 100644
> --- a/drivers/hv/channel_mgmt.c
> +++ b/drivers/hv/channel_mgmt.c
> @@ -216,9 +216,16 @@ static void vmbus_process_rescind_offer(struct
> work_struct *work)
> unsigned long flags;
> struct vmbus_channel *primary_channel;
> struct vmbus_channel_relid_released msg;
> + struct device *dev;
> +
> + if (channel->device_obj) {
> + dev = get_device(&channel->device_obj->device);
> + if (dev) {
> + vmbus_device_unregister(channel->device_obj);
> + put_device(dev);
> + }
> + }
>
> - if (channel->device_obj)
> - vmbus_device_unregister(channel->device_obj);
> memset(&msg, 0, sizeof(struct vmbus_channel_relid_released));
> msg.child_relid = channel->offermsg.child_relid;
> msg.header.msgtype = CHANNELMSG_RELID_RELEASED;
> --
> 1.9.3
prev parent reply other threads:[~2014-11-04 16:50 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-11-04 12:40 Vitaly Kuznetsov
2014-11-04 16:50 ` KY Srinivasan [this message]
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=c4546b3420864d0d8be7e4b8e36d1875@BY2PR0301MB0711.namprd03.prod.outlook.com \
--to=kys@microsoft.com \
--cc=devel@linuxdriverproject.org \
--cc=gregkh@linuxfoundation.org \
--cc=haiyangz@microsoft.com \
--cc=linux-kernel@vger.kernel.org \
--cc=vkuznets@redhat.com \
/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®