From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 64B22A051C for ; Tue, 11 Feb 2020 12:42:24 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 575DD1C012; Tue, 11 Feb 2020 12:42:24 +0100 (CET) Received: from mail-wr1-f66.google.com (mail-wr1-f66.google.com [209.85.221.66]) by dpdk.org (Postfix) with ESMTP id 8AA291C06C for ; Tue, 11 Feb 2020 12:42:22 +0100 (CET) Received: by mail-wr1-f66.google.com with SMTP id y11so11961772wrt.6 for ; Tue, 11 Feb 2020 03:42:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=rlIocms0eE0Ij68D+GOQwrA78bwz6jux85uMfMZ8hq0=; b=V63ftnG1P3Qg9yMbWoU48QoZKO7rfY5Xu0qraVzDtt5dn0igikhXB/nGHzGkcZHiCW hEfVZjNAHgGrJaxdC5HvRWxhGe/BsgG86a7w9uVZM4vd7XdHHguiUID3uQsVEqEbjBWd 3slWOvI4bMHlxjSshHJtdJat2URquFD+qMVMNId9PFKQxNEoJ7Aw08fsWY+6wk8NfO+k Qk6RBbPNipnFgpb4Otec1ghK1OLW7AkZqwWNjqwb7iPNmfVknfYvluufuNFnQemOX6N0 tWzSd+WwSgi+0xAk6wbMHhy4T/DT3sq0K1HfBrISNvauHrw7JIwLK6eVLtOHnqBZeiqH kHWw== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=rlIocms0eE0Ij68D+GOQwrA78bwz6jux85uMfMZ8hq0=; b=FRAze70Bvz/g1YLTfuI9T6HlhL+69t9pFewoURKhDFsNBh80Jj31GWKb7SuXjahohu B0jjDoyuGLtoMi32Mr2YUtBsCopIFcsxgi90JVZJKxVVNMUaqikh9vfHIko8PMxvZ4NV 8jzmSNy4vnyAz3i1+Xkl4/ke6poll2Vld8Qy5kQqRdT5OWL30ZO3or5JodwTaT6tUYEp JaY41T892tPFYGM82Gldpwtizuwbbc0lS09TPUYxUjCnbWkKzmLw2n3/FlFDrKsLuZlc Ceiw2Zgc8AdpCod5ZqqOT+MY3pEQ/beQjq8PzVcG0YRbog6W1BcosgHkk96BpAeZjDKG r0sw== X-Gm-Message-State: APjAAAUuWI8CIOfIOBj5uqGpfhIYZUj5bsa9z+0Db8ZX/GOMFHnZ+I8l EpEFxZAEMtR30iAbpIjhkDY= X-Google-Smtp-Source: APXvYqwIcVPTj/k/068+Q9A/1G8v/FV71+YK7uDUbDb+5vf1vr0FV2jliUsL5XNz6aedeY9b/D70jg== X-Received: by 2002:a5d:474d:: with SMTP id o13mr7973062wrs.309.1581421342296; Tue, 11 Feb 2020 03:42:22 -0800 (PST) Received: from localhost ([88.98.246.218]) by smtp.gmail.com with ESMTPSA id l15sm4909809wrv.39.2020.02.11.03.42.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Feb 2020 03:42:21 -0800 (PST) From: luca.boccassi@gmail.com To: Zhike Wang Cc: Maxime Coquelin , dpdk stable Date: Tue, 11 Feb 2020 11:22:02 +0000 Message-Id: <20200211112216.3929-176-luca.boccassi@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200211112216.3929-1-luca.boccassi@gmail.com> References: <20200211112216.3929-1-luca.boccassi@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-stable] patch 'vhost: fix crash on port deletion' has been queued to stable release 19.11.1 X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org Sender: "stable" Hi, FYI, your patch has been queued to stable release 19.11.1 Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet. It will be pushed if I get no objections before 02/13/20. So please shout if anyone has objections. Also note that after the patch there's a diff of the upstream commit vs the patch applied to the branch. This will indicate if there was any rebasing needed to apply to the stable branch. If there were code changes for rebasing (ie: not only metadata diffs), please double check that the rebase was correctly done. Thanks. Luca Boccassi --- >From a8e274db1b0a8cf241d8a95f4e87174e56eb7ea5 Mon Sep 17 00:00:00 2001 From: Zhike Wang Date: Thu, 16 Jan 2020 10:07:37 +0800 Subject: [PATCH] vhost: fix crash on port deletion [ upstream commit 499fd8e5b89c2ce65d57875d0a7d67f3a7f2fb6b ] The vhost_user_read_cb() and rte_vhost_driver_unregister() can be called at the same time by 2 threads. Eg thread1 calls vhost_user_read_cb() and removes the vsocket from conn_list, then thread2 calls rte_vhost_driver_unregister() and frees the vsocket since it is NOT in the conn_list. So thread1 will access invalid memory when trying to reconnect. The fix is to move the "removing of vsocket from conn_list" to end of the vhost_user_read_cb(), then avoid the race condition. The core trace is: Program terminated with signal 11, Segmentation fault. Fixes: af1475918124 ("vhost: introduce API to start a specific driver") Signed-off-by: Zhike Wang Reviewed-by: Maxime Coquelin --- 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 785cea46e5..26b9bb5534 100644 --- a/lib/librte_vhost/socket.c +++ b/lib/librte_vhost/socket.c @@ -318,16 +318,16 @@ vhost_user_read_cb(int connfd, void *dat, int *remove) vhost_destroy_device(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); - } } } -- 2.20.1 --- Diff of the applied patch vs upstream commit (please double-check if non-empty: --- --- - 2020-02-11 11:17:44.687407231 +0000 +++ 0176-vhost-fix-crash-on-port-deletion.patch 2020-02-11 11:17:38.820009200 +0000 @@ -1,8 +1,10 @@ -From 499fd8e5b89c2ce65d57875d0a7d67f3a7f2fb6b Mon Sep 17 00:00:00 2001 +From a8e274db1b0a8cf241d8a95f4e87174e56eb7ea5 Mon Sep 17 00:00:00 2001 From: Zhike Wang Date: Thu, 16 Jan 2020 10:07:37 +0800 Subject: [PATCH] vhost: fix crash on port deletion +[ upstream commit 499fd8e5b89c2ce65d57875d0a7d67f3a7f2fb6b ] + The vhost_user_read_cb() and rte_vhost_driver_unregister() can be called at the same time by 2 threads. Eg thread1 calls vhost_user_read_cb() and removes the vsocket from @@ -19,7 +21,6 @@ Program terminated with signal 11, Segmentation fault. Fixes: af1475918124 ("vhost: introduce API to start a specific driver") -Cc: stable@dpdk.org Signed-off-by: Zhike Wang Reviewed-by: Maxime Coquelin @@ -28,7 +29,7 @@ 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/librte_vhost/socket.c b/lib/librte_vhost/socket.c -index 9740fb3403..85c64485c2 100644 +index 785cea46e5..26b9bb5534 100644 --- a/lib/librte_vhost/socket.c +++ b/lib/librte_vhost/socket.c @@ -318,16 +318,16 @@ vhost_user_read_cb(int connfd, void *dat, int *remove)