mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Stephen Hemminger <stephen@networkplumber.org>
To: Michael Kelley <mikelley@microsoft.com>
Cc: Olaf Hering <olaf@aepfle.de>, KY Srinivasan <kys@microsoft.com>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"devel@linuxdriverproject.org" <devel@linuxdriverproject.org>
Subject: Re: [PATCH V2 3/4] vmbus: add per-channel sysfs info
Date: Thu, 18 Oct 2018 09:41:45 -0700	[thread overview]
Message-ID: <20181018094127.6a48fa55@shemminger-XPS-13-9360> (raw)
In-Reply-To: <CY4PR21MB0773D6885EC71F92D1A1369FD7F80@CY4PR21MB0773.namprd21.prod.outlook.com>

On Thu, 18 Oct 2018 15:32:35 +0000
Michael Kelley <mikelley@microsoft.com> wrote:

> From Olaf Hering  Sent: Thursday, October 18, 2018 8:20 AM
> >  
> > > This extends existing vmbus related sysfs structure to provide per-channel
> > > state information. This is useful when diagnosing issues with multiple
> > > queues in networking and storage.  
> >   
> > > +++ b/drivers/hv/vmbus_drv.c
> > > +static ssize_t write_avail_show(const struct vmbus_channel *channel, char *buf)
> > > +{
> > > +	const struct hv_ring_buffer_info *rbi = &channel->outbound;
> > > +
> > > +	return sprintf(buf, "%u\n", hv_get_bytes_to_write(rbi));
> > > +}
> > > +VMBUS_CHAN_ATTR_RO(write_avail);  
> > 
> > This is upstream since a year.
> > 
> > But I wonder how this can work if vmbus_device_register is called,
> > and then something reads the populated sysfs files before vmbus_open returns.
> > Nothing protects rbi->ring_buffer in this case, which remains NULL
> > until vmbus_open populates it.
> > 
> > A simple reproduce, with a modular kernel, is to boot with init=/bin/bash
> > head /sys/bus/vmbus/devices/*/channels/*/*
> >   
> 
> There are multiple race conditions with this and other VMbus sysfs information.
> There's a race on the close path as well.  I've got an action on my list to get it
> cleaned up.
> 
> Michael
> 

There is also a bunch of issues with code like:

static ssize_t id_show(struct device *dev, struct device_attribute *dev_attr,
		       char *buf)
{
	struct hv_device *hv_dev = device_to_hv_device(dev);

	if (!hv_dev->channel)
		return -ENODEV;
	return sprintf(buf, "%d\n", hv_dev->channel->offermsg.child_relid);
}

Which should be using ACCESS_ONCE on hv_dev->channel or doing proper RCU.

  reply	other threads:[~2018-10-18 16:41 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-09-18  3:49 [PATCH V2 0/4] Drivers: hv: Miscellaneous fixes kys
2017-09-18  3:54 ` [PATCH V2 1/4] vmbus: don't acquire the mutex in vmbus_hvsock_device_unregister() kys
2017-09-18  3:54   ` [PATCH V2 2/4] Drivers: hv: fcopy: restore correct transfer length kys
2017-09-18 13:59     ` Greg KH
2017-09-18  3:54   ` [PATCH V2 3/4] vmbus: add per-channel sysfs info kys
2017-09-18 13:59     ` Greg KH
2018-10-18 15:19     ` Olaf Hering
2018-10-18 15:32       ` Michael Kelley
2018-10-18 16:41         ` Stephen Hemminger [this message]
2018-10-18 16:39       ` Stephen Hemminger
2017-09-18  3:54   ` [PATCH V2 4/4] Drivers: hv: vmbus: Expose per-channel event counters events counters kys
2017-09-18 13:59     ` Greg KH
2017-09-18 13:57   ` [PATCH V2 1/4] vmbus: don't acquire the mutex in vmbus_hvsock_device_unregister() Greg KH
2017-09-18 14:00   ` Greg KH
2017-09-18 14:43     ` KY Srinivasan

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=20181018094127.6a48fa55@shemminger-XPS-13-9360 \
    --to=stephen@networkplumber.org \
    --cc=devel@linuxdriverproject.org \
    --cc=kys@microsoft.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mikelley@microsoft.com \
    --cc=olaf@aepfle.de \
    /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®