From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dispatch1-us1.ppe-hosted.com (dispatch1-us1.ppe-hosted.com [67.231.154.164]) by dpdk.org (Postfix) with ESMTP id 7927B1AEF5; Fri, 31 Aug 2018 18:16:42 +0200 (CEST) X-Virus-Scanned: Proofpoint Essentials engine Received: from webmail.solarflare.com (webmail.solarflare.com [12.187.104.26]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mx1-us4.ppe-hosted.com (Proofpoint Essentials ESMTP Server) with ESMTPS id 47423B40073; Fri, 31 Aug 2018 16:16:41 +0000 (UTC) Received: from ocex03.SolarFlarecom.com (10.20.40.36) by ocex03.SolarFlarecom.com (10.20.40.36) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Fri, 31 Aug 2018 09:16:38 -0700 Received: from opal.uk.solarflarecom.com (10.17.10.1) by ocex03.SolarFlarecom.com (10.20.40.36) with Microsoft SMTP Server (TLS) id 15.0.1395.4 via Frontend Transport; Fri, 31 Aug 2018 09:16:38 -0700 Received: from ukv-loginhost.uk.solarflarecom.com (ukv-loginhost.uk.solarflarecom.com [10.17.10.39]) by opal.uk.solarflarecom.com (8.13.8/8.13.8) with ESMTP id w7VGGafa030806; Fri, 31 Aug 2018 17:16:36 +0100 Received: from ukv-loginhost.uk.solarflarecom.com (localhost [127.0.0.1]) by ukv-loginhost.uk.solarflarecom.com (Postfix) with ESMTP id D63B81626D1; Fri, 31 Aug 2018 17:16:36 +0100 (BST) From: Andrew Rybchenko To: Gaetan Rivet CC: , Igor Romanov , Date: Fri, 31 Aug 2018 17:16:32 +0100 Message-ID: <1535732192-3058-1-git-send-email-arybchenko@solarflare.com> X-Mailer: git-send-email 1.8.3.1 MIME-Version: 1.0 Content-Type: text/plain X-TM-AS-Product-Ver: SMEX-12.5.0.1300-8.5.1010-24064.005 X-TM-AS-Result: No-3.209100-4.000000-10 X-TMASE-MatchedRID: CpBUfk8vmJuuhCBFl/b63hcqpH7D1rtQL34I8IpvQcL1gF7PCEF9btKe uoOP1lboQOGSNyQBW1ImAjVreEJWp/VTeZLup9NPA9lly13c/gET1RzDMx9VmJJrnaK7r+OG0c8 aNDRHFani8zVgXoAltsIJ+4gwXrEtWBd6ltyXuvsJcmWdc8ykR3yUzigi2PsdHf5wExeqygGC+y 3NFF+q+R1sYxJSKlkGkNo40+yr/GVFlHoDF3eXBZvLQnuM9oUoGYiAXim4R+e9Tbikt9AWZ0CBS GS7bIBtA1B/p1SzcogrKiD/U8b7SYci0ewgZmW0ftwZ3X11IV0= X-TM-AS-User-Approved-Sender: No X-TM-AS-User-Blocked-Sender: No X-TMASE-Result: 10--3.209100-4.000000 X-TMASE-Version: SMEX-12.5.0.1300-8.5.1010-24064.005 X-MDID: 1535732202-kwK49l-3Mgmp Subject: [dpdk-dev] [PATCH] net/failsafe: fix crash on slave queue release 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: Fri, 31 Aug 2018 16:16:42 -0000 From: Igor Romanov Releasing a queue that is already released by slave may cause a segmentation fault. For example, after a successfull device configuration a queue is set up. Afterwards the device is reconfigured with an invalid argument, forcing slaves to release the queues (e.g. rte_eth_dev.data.tx_queues). Finally the failsafe's queues are released. The queue release functions also try to release slaves' queues using ETH(sdev)->data->tx_queues which is NULL at the time. Add checks for NULL slaves' Tx and Rx queues before releasing them. Fixes: a46f8d584eb8 ("net/failsafe: add fail-safe PMD") Cc: stable@dpdk.org Signed-off-by: Igor Romanov Signed-off-by: Andrew Rybchenko --- drivers/net/failsafe/failsafe_ops.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/drivers/net/failsafe/failsafe_ops.c b/drivers/net/failsafe/failsafe_ops.c index 24e91c931..94b9769e7 100644 --- a/drivers/net/failsafe/failsafe_ops.c +++ b/drivers/net/failsafe/failsafe_ops.c @@ -309,9 +309,13 @@ fs_rx_queue_release(void *queue) fs_lock(dev, 0); if (rxq->event_fd > 0) close(rxq->event_fd); - FOREACH_SUBDEV_STATE(sdev, i, dev, DEV_ACTIVE) - SUBOPS(sdev, rx_queue_release) - (ETH(sdev)->data->rx_queues[rxq->qid]); + FOREACH_SUBDEV_STATE(sdev, i, dev, DEV_ACTIVE) { + if (ETH(sdev)->data->rx_queues != NULL && + ETH(sdev)->data->rx_queues[rxq->qid] != NULL) { + SUBOPS(sdev, rx_queue_release) + (ETH(sdev)->data->rx_queues[rxq->qid]); + } + } dev->data->rx_queues[rxq->qid] = NULL; rte_free(rxq); fs_unlock(dev, 0); @@ -477,9 +481,13 @@ fs_tx_queue_release(void *queue) txq = queue; dev = txq->priv->dev; fs_lock(dev, 0); - FOREACH_SUBDEV_STATE(sdev, i, dev, DEV_ACTIVE) - SUBOPS(sdev, tx_queue_release) - (ETH(sdev)->data->tx_queues[txq->qid]); + FOREACH_SUBDEV_STATE(sdev, i, dev, DEV_ACTIVE) { + if (ETH(sdev)->data->tx_queues != NULL && + ETH(sdev)->data->tx_queues[txq->qid] != NULL) { + SUBOPS(sdev, tx_queue_release) + (ETH(sdev)->data->tx_queues[txq->qid]); + } + } dev->data->tx_queues[txq->qid] = NULL; rte_free(txq); fs_unlock(dev, 0); -- 2.17.1