From patchwork Fri Sep 7 00:53:07 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qiang Zhou X-Patchwork-Id: 44372 X-Patchwork-Delegate: maxime.coquelin@redhat.com Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 493244C80; Fri, 7 Sep 2018 02:53:32 +0200 (CEST) Received: from mail-pl1-f193.google.com (mail-pl1-f193.google.com [209.85.214.193]) by dpdk.org (Postfix) with ESMTP id CD44E3772; Fri, 7 Sep 2018 02:53:30 +0200 (CEST) Received: by mail-pl1-f193.google.com with SMTP id w14-v6so5759631plp.6; Thu, 06 Sep 2018 17:53:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=LODiD/i/CfV5o7lt5erb3P+vUBZTmDlaKTMZuIZEVNE=; b=nCXCIget8LflNSOXiMiYhQ37wEUg5fB9UlY7mHBtlDmf0t7s3qovDzCnaLZ9ucTxh2 3T22i7Rn0M2SCHzggzHSoGykv+3+vL1uOZCbXifldL9KxGjQeEs08XWoWKjBYXuaOWXR xjEh9lr6+ogW6UsFx38iMerHu+64xlWYDPQO2Phhvns26Qy3KsATsJuSYDGy6VOvfdfb gqowfPmkQB3We4NVVGVtVJ0xnBufxukOKgfzgtjGVdOV7BHq3NDqYn4pn5oW490GTQC8 k5/WTAr30cIx+VarY0PJuo68mziQexSUmVYsYhYxdHszMSr7bx1patW0/n2+z9czZsEy 6jJA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=LODiD/i/CfV5o7lt5erb3P+vUBZTmDlaKTMZuIZEVNE=; b=TpR2eLfp8JwWfgj6j468fupuxrU2z/C3vMEH3PzdEAvniX2eA8zgw8zqUewLlTvA+Z 2UpUxWnl0GpMp66McHW/7d4+QVlRyxM7MirDDjuYjSbTeBRA8H4XfJgothzuWZvv411D YqvToH1KpaDf6PUpSw/bFRcDRfwLUN91B21n1fOwIH81zYuOZ8n11ChnjlJpobQIVL5k xl/ZM86UunM+9uCkxO2Ag31PIOEaOJ7JD8TJNNzxng2PmXQuoKrpH96BTv3iWqnb1eJ8 tVTrfZBchaNFMF0Jo98a29DJPyJr2MoZHxVmGezAdEtcDs+JYxj/BVwCZXdG0rI6QqBA LbrA== X-Gm-Message-State: APzg51D/Y9yd8c7+RcYebHSGBGuibCN0A7qwEuOhgAE/VROBjA9NCVS9 Bbim1/ECB/4uAHavxdjycy5oILxr X-Google-Smtp-Source: ANB0VdYOVPAnqxTh8MyfTXEWuUCGzlUkN/WySwMgyjvGIPDLBFpTCyY8JKLtkQzosMZnBOLnb0oRYw== X-Received: by 2002:a17:902:3a3:: with SMTP id d32-v6mr5413907pld.294.1536281609989; Thu, 06 Sep 2018 17:53:29 -0700 (PDT) Received: from localhost.localdomain ([203.100.54.194]) by smtp.gmail.com with ESMTPSA id c1-v6sm7938460pfi.142.2018.09.06.17.53.28 (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 06 Sep 2018 17:53:29 -0700 (PDT) From: Qiang Zhou To: dev@dpdk.org Cc: Qiang Zhou , stable@dpdk.org Date: Fri, 7 Sep 2018 08:53:07 +0800 Message-Id: <20180907005307.98363-1-zhouqiang2633@gmail.com> X-Mailer: git-send-email 2.14.3 (Apple Git-98) Subject: [dpdk-dev] [PATCH] vhost: fix crash on unregistering in client mode 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: , Errors-To: dev-bounces@dpdk.org Sender: "dev" when rte_vhost_driver_unregister delete the connection fd, the fd lock will prevent the vsocket to be freed. But when vhost_user_msg_handler return error, it will delete vsocket conn_list. And then the fd lock will become invalid. So the vsocket will be freed in rte_vhost_drivere_unregister and the vhost_user_read_cb will reconnect. To fix this: move delete vsocket conn after reconnect Cc: stable@dpdk.org Signed-off-by: Qiang Zhou --- lib/librte_vhost/socket.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/librte_vhost/socket.c b/lib/librte_vhost/socket.c index d63031747..43da1c51b 100644 --- a/lib/librte_vhost/socket.c +++ b/lib/librte_vhost/socket.c @@ -293,16 +293,16 @@ vhost_user_read_cb(int connfd, void *dat, int *remove) if (vsocket->notify_ops->destroy_connection) vsocket->notify_ops->destroy_connection(conn->vid); + if (vsocket->reconnect) { + create_unix_socket(vsocket); + vhost_user_start_client(vsocket); + } + pthread_mutex_lock(&vsocket->conn_mutex); TAILQ_REMOVE(&vsocket->conn_list, conn, next); pthread_mutex_unlock(&vsocket->conn_mutex); free(conn); - - if (vsocket->reconnect) { - create_unix_socket(vsocket); - vhost_user_start_client(vsocket); - } } }