From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-qk0-f172.google.com (mail-qk0-f172.google.com [209.85.220.172]) by dpdk.org (Postfix) with ESMTP id EFD652A5D for ; Thu, 12 Oct 2017 08:29:46 +0200 (CEST) Received: by mail-qk0-f172.google.com with SMTP id k123so266034qke.3 for ; Wed, 11 Oct 2017 23:29:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to; bh=IEqcxv/wM6RdZLxLDwyePjWf0a0Mo1J7yruFucKM+dA=; b=RVlHoh0qJENlarOMFloZRtVynb4iXgd/slGUCNcWIk7V8UxHN3CnzRkqXAfdZ6HST4 vaDh22h2Rr27GDBn3mrWl2uN7SJjtNuBi1JvRo47mBR0Opcu3mUxySCelkpPk+eT4/Qf s2hdUbV0sdN30ofYqdOs9gjIlqCFzZTM//Vo+CCs050fJy6iqZIsN8cYEYmztu70e2dz Ct5Znq3uzErA9zlU38dgVXOyC5TBk+8mTdDhpovc47cceWhB5ycexN9qh6eUCY36jRTK TDrLTLmYA5OVSvtkiSuAxV2cyDjVAux41l3lgRyWOVwA+aR5gSyQUcX4oOQznpJ4OwXi 4Hmw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=IEqcxv/wM6RdZLxLDwyePjWf0a0Mo1J7yruFucKM+dA=; b=dGavYQ66yc/JKwNZTkLtxllw0mPN3XZsA89CsISnIkg4jFArinsSIuPnaeS6bhXqB0 MfIGGZdsywHYs1ynhvVC/MAqmDDFgFHuC8235E5JThAgOI1nZdsy98j/oDBIsM5tD3Qk mMTP0r63WCXgfobcjDPPVNWitBisR1yIMEqsff+Kc1qXyI/Gv/WBQNZitr0GbBn+2eXd tD/+JNitPmEVH+jNOonOLYc+OdiJYESZd7Ln2pJ0uX062wPJQVxrsoeyFozyyp9lFO+K /xSWmh9sVc6Us9k4voY7aU3j4EF2YPh8ZDm3IoJMLF4mssaIvp/htLdkfqHGHygTynkK 41NQ== X-Gm-Message-State: AMCzsaWLlH6HCGIkZTP23FNqfswzlrpRak2FWtLC2aDITMlcSuibj95a vgBUpNgecncTheoaB1Px26h5cu/Yj4eay2SEANHV9A== X-Google-Smtp-Source: AOwi7QAQVPxJw/Sdf8TLbkC1teKGFMBaGmUUeWgRAaucXS0KbGQFk26dsZ9nVdAe62AXIixd9UPUt4Mwsx2vbcwFJuc= X-Received: by 10.55.18.223 with SMTP id 92mr1818552qks.303.1507789786045; Wed, 11 Oct 2017 23:29:46 -0700 (PDT) MIME-Version: 1.0 Received: by 10.140.98.181 with HTTP; Wed, 11 Oct 2017 23:29:45 -0700 (PDT) From: Sam Date: Thu, 12 Oct 2017 14:29:45 +0800 Message-ID: To: dev@dpdk.org Content-Type: text/plain; charset="UTF-8" X-Content-Filtered-By: Mailman/MimeDel 2.1.15 Subject: [dpdk-dev] [BUG-REPORT] Need to add mutex on vhost_devices[] in virtio-net.c in DPDK-2.2? X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 12 Oct 2017 06:29:47 -0000 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?