DPDK patches and discussions
 help / color / mirror / Atom feed
From: Sam <batmanustc@gmail.com>
To: dev@dpdk.org
Subject: [dpdk-dev] [BUG-REPORT] Need to add mutex on vhost_devices[] in virtio-net.c in DPDK-2.2?
Date: Thu, 12 Oct 2017 14:29:45 +0800	[thread overview]
Message-ID: <CAOE=1Z0USNAzUneFtOVAdopXiM9CksEx0+vNxagO2f4yfJBraQ@mail.gmail.com> (raw)

Hi all,

I'm running vhostuser part code of dpdk, and I found a crash, which is
caused by call NULL pointer. Then I debug code and I found I use NULL
pointer which is got from vhost_devices[].

I read code of virtio-net.c, and I found there is no lock on
vhost_devices[] !!! vhost_devices[] is used
by vhost_destroy_device, get_device, vhost_new_device. If one thread use
get_device to get the dev pointer, and another thread use
vhost_destroy_device to destroy it, then crash will happen.

Also I know that, if one thread to call get_device or other functions, it
must supply vid, which means thread must hold vid itself, this mechanism
could solve the problem above. But now there is a requirement to dump all
info of dev in vhost_devices[] which is not NULL, so if there is no lock on
this array, crash will happens.

So how to fix this? And if this bug has already fixed in new version?

                 reply	other threads:[~2017-10-12  6:29 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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='CAOE=1Z0USNAzUneFtOVAdopXiM9CksEx0+vNxagO2f4yfJBraQ@mail.gmail.com' \
    --to=batmanustc@gmail.com \
    --cc=dev@dpdk.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;
as well as URLs for NNTP newsgroup(s).