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 6DA00A0A0C for ; Tue, 3 Aug 2021 14:23:10 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 67E7A40E3C; Tue, 3 Aug 2021 14:23:10 +0200 (CEST) Received: from mail-wm1-f50.google.com (mail-wm1-f50.google.com [209.85.128.50]) by mails.dpdk.org (Postfix) with ESMTP id 3755C411CE for ; Tue, 3 Aug 2021 14:23:09 +0200 (CEST) Received: by mail-wm1-f50.google.com with SMTP id l34-20020a05600c1d22b02902573c214807so1607039wms.2 for ; Tue, 03 Aug 2021 05:23:09 -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:in-reply-to:references :mime-version:content-transfer-encoding; bh=Dw/SOxMzFNp/x5XCarungGvmFMvJkROkSxf8HU4oyQs=; b=bMxmVJw5yITEbNEn6DqNvm37eews6irRa4gURIwj3P0vANmpadsRs0zgOMbuyDKmap B6tAFhs0U+5pjVieK0vBBnqE5L+NmQf7IUC/ON/n1CvDOP+s/MDMArsjLEEB8ysRrSiL +9/aPFnsUvQblTqtlHOF+HIkYSTLrH+5QZng3lJ6PQLvkNxbvHPiwbMGHU9Bhk+ad/zf PpEBQFUUKQbSMLfghApiyrOq4Ft//gn7SqDH6tA9rQBGbaWlXlscImF8UzhnZFjk2fqD HLnxPGVIgeKf9sRDxDqd2BSv/KEApsAv9bq5tpGvu3VG6ZNiIT3rHPrcCxwpxT88pweb U2uQ== 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=Dw/SOxMzFNp/x5XCarungGvmFMvJkROkSxf8HU4oyQs=; b=AU2oBPDbBZokM5zoBwcIq4DMRNAlMeePtOylGhQhztWzIn+JfWwvhlcSI9t+h2uAo/ zJIzpF35T1jLHtE85gi+4OqCGKe+Hv3Z0YfMvFdWu6s8zyCZwR0++eOIVx+xQvzR89fJ 7NST6p2iUyWG0g7qYmBLy1S43GiLnQDm8w85BBRdgqrHZUzo3cJMIYKuepCzIh0JM4iX vYVlqZtK4f6zJkYnNbSGGrAuESU/1xiIhTYlGHbobeOXwS/5hpk6KRvVA7iHsZsH3UCZ Ta7dM+3Mw37c4cGqO/u3I2EWzF+nF7kSfP9Yb9UMc4WGr4Ljo0C14D4s5wLyJYCrPMpy UGaw== X-Gm-Message-State: AOAM531wP5ZrbrcjqqeJwHOmyfoP5L2QwYZWBpfAtQWg/5oMpmQ5C61Y GzRjvVWG5TNnNzXyIgcxGKk= X-Google-Smtp-Source: ABdhPJwu5mmrvbcutKQ4HpUOipf6i19JQvPfDtPQ0H/sxdv8tEgZWem7crVDsQIQouLzCidgqs7p0A== X-Received: by 2002:a7b:c094:: with SMTP id r20mr21410462wmh.107.1627993388992; Tue, 03 Aug 2021 05:23:08 -0700 (PDT) Received: from localhost ([137.220.125.106]) by smtp.gmail.com with ESMTPSA id h12sm14178465wrm.62.2021.08.03.05.23.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Aug 2021 05:23:08 -0700 (PDT) From: luca.boccassi@gmail.com To: Ciara Power Cc: Zhihong Peng , Akhil Goyal , dpdk stable Date: Tue, 3 Aug 2021 13:22:09 +0100 Message-Id: <20210803122214.1094992-20-luca.boccassi@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210803122214.1094992-1-luca.boccassi@gmail.com> References: <20210726135322.149850-59-luca.boccassi@gmail.com> <20210803122214.1094992-1-luca.boccassi@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-stable] patch 'cryptodev: fix freeing after device release' has been queued to stable release 20.11.3 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 Sender: "stable" Hi, FYI, your patch has been queued to stable release 20.11.3 Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet. It will be pushed if I get no objections before 08/05/21. 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/bluca/dpdk-stable This queued commit can be viewed at: https://github.com/bluca/dpdk-stable/commit/151569886c10a82650a59813a1f595fcfd25abef Thanks. Luca Boccassi --- >From 151569886c10a82650a59813a1f595fcfd25abef Mon Sep 17 00:00:00 2001 From: Ciara Power Date: Wed, 21 Jul 2021 12:51:22 +0000 Subject: [PATCH] cryptodev: fix freeing after device release [ upstream commit eeaeca82b8cbd6599bafd4029aad5ce4dedff7a2 ] The PMD destroy function was calling the release function, which frees cryptodev->data, and then tries to free cryptodev->data->dev_private, which causes the heap use after free issue. A temporary pointer is set before the free of cryptodev->data, which can then be used afterwards to free dev_private. The free cannot be moved to before the release function is called, as dev_private is used in the PMD close function while being released. Fixes: 9e6edea41805 ("cryptodev: add APIs to assist PMD initialisation") Reported-by: Zhihong Peng Signed-off-by: Ciara Power Acked-by: Akhil Goyal --- lib/librte_cryptodev/rte_cryptodev_pmd.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/librte_cryptodev/rte_cryptodev_pmd.c b/lib/librte_cryptodev/rte_cryptodev_pmd.c index 0912004127..e342daabc4 100644 --- a/lib/librte_cryptodev/rte_cryptodev_pmd.c +++ b/lib/librte_cryptodev/rte_cryptodev_pmd.c @@ -140,6 +140,7 @@ int rte_cryptodev_pmd_destroy(struct rte_cryptodev *cryptodev) { int retval; + void *dev_priv = cryptodev->data->dev_private; CDEV_LOG_INFO("Closing crypto device %s", cryptodev->device->name); @@ -149,7 +150,7 @@ rte_cryptodev_pmd_destroy(struct rte_cryptodev *cryptodev) return retval; if (rte_eal_process_type() == RTE_PROC_PRIMARY) - rte_free(cryptodev->data->dev_private); + rte_free(dev_priv); cryptodev->device = NULL; -- 2.30.2 --- Diff of the applied patch vs upstream commit (please double-check if non-empty: --- --- - 2021-08-03 12:35:09.007029969 +0100 +++ 0020-cryptodev-fix-freeing-after-device-release.patch 2021-08-03 12:35:08.242819288 +0100 @@ -1 +1 @@ -From eeaeca82b8cbd6599bafd4029aad5ce4dedff7a2 Mon Sep 17 00:00:00 2001 +From 151569886c10a82650a59813a1f595fcfd25abef Mon Sep 17 00:00:00 2001 @@ -5,0 +6,2 @@ +[ upstream commit eeaeca82b8cbd6599bafd4029aad5ce4dedff7a2 ] + @@ -16 +17,0 @@ -Cc: stable@dpdk.org @@ -22 +23 @@ - lib/cryptodev/rte_cryptodev_pmd.c | 3 ++- + lib/librte_cryptodev/rte_cryptodev_pmd.c | 3 ++- @@ -25 +26 @@ -diff --git a/lib/cryptodev/rte_cryptodev_pmd.c b/lib/cryptodev/rte_cryptodev_pmd.c +diff --git a/lib/librte_cryptodev/rte_cryptodev_pmd.c b/lib/librte_cryptodev/rte_cryptodev_pmd.c @@ -27,2 +28,2 @@ ---- a/lib/cryptodev/rte_cryptodev_pmd.c -+++ b/lib/cryptodev/rte_cryptodev_pmd.c +--- a/lib/librte_cryptodev/rte_cryptodev_pmd.c ++++ b/lib/librte_cryptodev/rte_cryptodev_pmd.c