From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 9673DA00C2 for ; Thu, 3 Nov 2022 10:30:15 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 91E9641143; Thu, 3 Nov 2022 10:30:15 +0100 (CET) Received: from mail-wr1-f49.google.com (mail-wr1-f49.google.com [209.85.221.49]) by mails.dpdk.org (Postfix) with ESMTP id 8E65D42685 for ; Thu, 3 Nov 2022 10:30:14 +0100 (CET) Received: by mail-wr1-f49.google.com with SMTP id w14so1705730wru.8 for ; Thu, 03 Nov 2022 02:30:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=WmFIL4llpbulQ19fgsf23YuFYBJ/Y0v8fGirw6FDFd8=; b=PrDLkl304J+k11HzEJrrh3b6+tpSvXvlEfKTz7yvOWY2RRPVaBnT44imKUqY7GEbc0 REQKXYByfACmQRYo5BCzLTLqsH8piA+jNdT+XbI9khPYso+ADrLB2a0bqw/LQYacPMBD yPP7e0QQiX5IkdjpnmcYRXTyYqs6bfSIUnaYPAT9scsIRswJpq1un5WVjeZFQQ84YM55 PRmVRjGjLFB7aw940CqFBLNrV4CuEcOc5Qm3S6RHHSigKRdQPKY/DParfGSxWozWw1GF 4TBTxUJrAYVAhS4mKCRUFmhtW4BwyE6/rhTuaizHjwGUfD2J7e+KhppWtn0W46ipVY6v SwYQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=WmFIL4llpbulQ19fgsf23YuFYBJ/Y0v8fGirw6FDFd8=; b=vfWrBRMB7XUO0xL5uMVUDQV71AvyuAEGydN2ja9dxnjLTQtlOFv48U+s3x2F8BWG+/ Q0f4tqkNXnVN6vOb4ZSJ1bMKQNNNC0gUEOpPjfYMHGeCnhF1PwUJ+TkDUusRGv+sphd2 vT9x6hPyjZnG1T5FavJaWBfr0GRdZQErX+tHp9PLZJKbaTlhFERS9mGVpfwhRhlNtJ+N XWFZAsyXGFCyLdb4JjArXvt7KNtDcWT46LfLba7oPb3oH+vKVGBLiaEipccK9i1MNYFb 48YG8gGDqhNgK0v1Q5mFS3Mp9a+lQphQAAjYODRg+M/mzglVKSxmS1rLuAHni7XMCeX1 PzPQ== X-Gm-Message-State: ACrzQf3oupnNSIKJncretoh6+1gr7cMleluhOIFML4VoPOiU4YpUxUEH SKb2kJzU2oUHebIc5GnkKuSEm5z+DMDx+QbL X-Google-Smtp-Source: AMsMyM7O2cUsQ1Kyv1raTnnVI3PT1j3eXQB9eFXbUesgRxmNtp/zlhOATsp54p+LsEjA34JOBFjE6A== X-Received: by 2002:adf:aa8c:0:b0:236:6e59:99ff with SMTP id h12-20020adfaa8c000000b002366e5999ffmr17342663wrc.688.1667467814265; Thu, 03 Nov 2022 02:30:14 -0700 (PDT) Received: from localhost ([2a01:4b00:d307:1000:f1d3:eb5e:11f4:a7d9]) by smtp.gmail.com with ESMTPSA id n18-20020a05600c4f9200b003c3a1d8c8e6sm729129wmq.19.2022.11.03.02.30.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Nov 2022 02:30:13 -0700 (PDT) From: luca.boccassi@gmail.com To: Alexander Chernavin Cc: Chenbo Xia , dpdk stable Subject: patch 'net/virtio: fix crash when configured twice' has been queued to stable release 20.11.7 Date: Thu, 3 Nov 2022 09:26:57 +0000 Message-Id: <20221103092758.1099402-39-luca.boccassi@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221103092758.1099402-1-luca.boccassi@gmail.com> References: <20221103092758.1099402-1-luca.boccassi@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 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 Hi, FYI, your patch has been queued to stable release 20.11.7 Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet. It will be pushed if I get no objections before 11/05/22. 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. Queued patches are on a temporary branch at: https://github.com/kevintraynor/dpdk-stable This queued commit can be viewed at: https://github.com/kevintraynor/dpdk-stable/commit/da94f7c81e620ef271a0458f6f8133102ce75760 Thanks. Luca Boccassi --- >From da94f7c81e620ef271a0458f6f8133102ce75760 Mon Sep 17 00:00:00 2001 From: Alexander Chernavin Date: Tue, 27 Sep 2022 10:15:04 +0000 Subject: [PATCH] net/virtio: fix crash when configured twice [ upstream commit 52bd03e969e9b38a7357287aece2488c7f92158f ] When first attempt to configure a device with RX interrupt enabled fails for some reason (e.g. because "Multiple intr vector not supported"), second attempt to configure the device with RX interrupt disabled and feature set unchanged will succeed but will leave virtio queues not allocated. Accessing the queues will cause a segfault. First attempt: - virtio_dev_configure() - virtio_init_device() is called to reinit the device because "dev->data->dev_conf.intr_conf.rxq" is "1" - virtio_configure_intr() fails and returns an error - virtio_free_queues() frees previously allocated virtio queues - virtio_init_device() fails and returns an error - virtio_dev_configure() fails and returns an error Second attempt: - virtio_dev_configure() - This time virtio_init_device() is not called, virtio queues are not allocated With this fix, reinit the device during configuration if virtio queues are not allocated. Fixes: 2b38151f745a ("net/virtio: fix queue memory leak on error") Signed-off-by: Alexander Chernavin Reviewed-by: Chenbo Xia --- drivers/net/virtio/virtio_ethdev.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/net/virtio/virtio_ethdev.c b/drivers/net/virtio/virtio_ethdev.c index 511735a6bf..ce612f7400 100644 --- a/drivers/net/virtio/virtio_ethdev.c +++ b/drivers/net/virtio/virtio_ethdev.c @@ -2356,6 +2356,13 @@ virtio_dev_configure(struct rte_eth_dev *dev) return ret; } + /* if queues are not allocated, reinit the device */ + if (hw->vqs == NULL) { + ret = virtio_init_device(dev, hw->req_guest_features); + if (ret < 0) + return ret; + } + if ((rx_offloads & (DEV_RX_OFFLOAD_UDP_CKSUM | DEV_RX_OFFLOAD_TCP_CKSUM)) && !vtpci_with_feature(hw, VIRTIO_NET_F_GUEST_CSUM)) { -- 2.34.1 --- Diff of the applied patch vs upstream commit (please double-check if non-empty: --- --- - 2022-11-03 09:27:27.804086418 +0000 +++ 0039-net-virtio-fix-crash-when-configured-twice.patch 2022-11-03 09:27:25.413423215 +0000 @@ -1 +1 @@ -From 52bd03e969e9b38a7357287aece2488c7f92158f Mon Sep 17 00:00:00 2001 +From da94f7c81e620ef271a0458f6f8133102ce75760 Mon Sep 17 00:00:00 2001 @@ -5,0 +6,2 @@ +[ upstream commit 52bd03e969e9b38a7357287aece2488c7f92158f ] + @@ -30 +31,0 @@ -Cc: stable@dpdk.org @@ -39 +40 @@ -index 7e07270a8b..574f671158 100644 +index 511735a6bf..ce612f7400 100644 @@ -42 +43 @@ -@@ -2617,6 +2617,13 @@ virtio_dev_configure(struct rte_eth_dev *dev) +@@ -2356,6 +2356,13 @@ virtio_dev_configure(struct rte_eth_dev *dev) @@ -53,3 +54,3 @@ - if ((rxmode->mq_mode & RTE_ETH_MQ_RX_RSS_FLAG) && - !virtio_with_feature(hw, VIRTIO_NET_F_RSS)) { - PMD_DRV_LOG(ERR, "RSS support requested but not supported by the device"); + if ((rx_offloads & (DEV_RX_OFFLOAD_UDP_CKSUM | + DEV_RX_OFFLOAD_TCP_CKSUM)) && + !vtpci_with_feature(hw, VIRTIO_NET_F_GUEST_CSUM)) {