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 A352E43CAD for ; Thu, 14 Mar 2024 01:12:04 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 9693742E6F; Thu, 14 Mar 2024 01:12:04 +0100 (CET) Received: from mail-wr1-f45.google.com (mail-wr1-f45.google.com [209.85.221.45]) by mails.dpdk.org (Postfix) with ESMTP id C8B2740297 for ; Thu, 14 Mar 2024 01:12:02 +0100 (CET) Received: by mail-wr1-f45.google.com with SMTP id ffacd0b85a97d-33ec7e1d542so290f8f.1 for ; Wed, 13 Mar 2024 17:12:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1710375122; x=1710979922; darn=dpdk.org; 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=ZKcIHvTknq4aBpgq+QDE6SKFRQiZch3XiHy0tnJhoMI=; b=CN8Kpdqb5IWQKqpKbNbk9Nls7e+xxWha0oPgnI5PwWEbCvC2PkxzK+/A1rMbjnMKVh EEP1DK/cSmawGVfvmLeVJPGHrofrrVgoFWQlILJQuAh9bVFkZ04SZVQA6EVJ3P3Ml+Va kYryg8JOZZq6G5W9ld8M/5mj5Msk3Cfm9ZHF7VF+VbHPrDvMrikzi+c+hCv03PfqxaXn 4LtZoMT3eMUYED6AgJpkusThEYnw7ZnWjv8ARLAq4cbZjDV3HNZPEN66ryZXZq5vfnzt mm1ktx1eXhL3ahiTg/yAxgR7PCRHz1MPI+td0/pz9uIwkY5N/PIaIJh/J2wo8SqmLa4T C+ow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710375122; x=1710979922; 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=ZKcIHvTknq4aBpgq+QDE6SKFRQiZch3XiHy0tnJhoMI=; b=D9/rgJdouyJtYcVFFNu9/dOKokEHxIZAT4sfWMGR2OWnks+KRqof91N1qRSe6ktaa/ Nbtn8rUk8e2N8AjI2hPg4vQFlRBIxtx5FjC44RC99aGsYe3zmZRAN+oVp/Hv4Q/ttqjB KXqB0r30xKhdBn3ygJgxx3A4Pa9XoIPAdEwf8+JD703HS490Y9qZT4YlZl3ivwM2LhDY lPyvLCthUQtcwTRit7Jt9X/sFJJTe2j+WprWzMKlqPuyQQ8YbcO6oeGG1GYVGD2pYSeB yZAljFg3mcI3M6SjvGB3eT+/KEeMfVJz/n4xaNYfV/izHQ4GyqtVxjeHv9jRktkkz2uq +YkA== X-Forwarded-Encrypted: i=1; AJvYcCWv6dig5AJsTdGbhjgjfbM+gq2T2NvxMNbQAG8j3GkUjXNqCJ9AaxOl2B5EbBAIVaTay4LOxz+qjevHGGLckTY= X-Gm-Message-State: AOJu0Yyd2YjQ/O4HLLuE7qmfAKw2lXaN5HvjAmfRV3lhzFco+cuUEcDW ps/ao/yl8+UcNuDMzv0lW87H49QdsH+IgAqCJ0BgxB6IDSvsjaId X-Google-Smtp-Source: AGHT+IEpZSxqhUNkgPmioEVOqmjYyhq1p042okMc7r1z7AHOC+TEe/LT9G8KoqgAf4vG/gQtkOE+VA== X-Received: by 2002:adf:a31d:0:b0:33e:9731:2d8b with SMTP id c29-20020adfa31d000000b0033e97312d8bmr73973wrb.68.1710375122411; Wed, 13 Mar 2024 17:12:02 -0700 (PDT) Received: from localhost ([2a01:4b00:d036:ae00:7aef:1aaa:3dff:d546]) by smtp.gmail.com with ESMTPSA id bk1-20020a0560001d8100b0033e95794186sm279014wrb.83.2024.03.13.17.12.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Mar 2024 17:12:01 -0700 (PDT) From: luca.boccassi@gmail.com To: Pengfei Sun Cc: Yunjian Wang , Dariusz Sosnowski , dpdk stable Subject: patch 'net/mlx5: fix use after free when releasing Tx queues' has been queued to stable release 22.11.5 Date: Thu, 14 Mar 2024 00:09:36 +0000 Message-Id: <20240314000957.2810803-40-luca.boccassi@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240314000957.2810803-1-luca.boccassi@gmail.com> References: <20240307013159.1735343-102-luca.boccassi@gmail.com> <20240314000957.2810803-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 22.11.5 Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet. It will be pushed if I get no objections before 03/16/24. 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/5126f7dd1094e8a1366cc52ac946831f3129b53b Thanks. Luca Boccassi --- >From 5126f7dd1094e8a1366cc52ac946831f3129b53b Mon Sep 17 00:00:00 2001 From: Pengfei Sun Date: Tue, 20 Feb 2024 17:31:39 +0800 Subject: [PATCH] net/mlx5: fix use after free when releasing Tx queues [ upstream commit b805b7c451f1ee5bafa5628ee67f3a495f6a8682 ] In function mlx5_dev_configure, dev->data->tx_queues is assigned to priv->txqs. When a member is removed from a bond, the function eth_dev_tx_queue_config is called to release dev->data->tx_queues. However, function mlx5_dev_close will access priv->txqs again and cause the use after free problem. In function mlx5_dev_close, before free priv->txqs, we add a check that dev->data->tx_queues is not NULL. build/app/dpdk-testpmd -c7 -a 0000:08:00.2 -- -i --nb-cores=2 --total-num-mbufs=2048 testpmd> port stop 0 testpmd> create bonding device 4 0 testpmd> add bonding member 0 1 testpmd> remove bonding member 0 1 testpmd> quit ASan reports: ==2571911==ERROR: AddressSanitizer: heap-use-after-free on address 0x000174529880 at pc 0x0000113c8440 bp 0xffffefae0ea0 sp 0xffffefae0eb0 READ of size 8 at 0x000174529880 thread T0 #0 0x113c843c in mlx5_txq_release ../drivers/net/mlx5/mlx5_txq.c: 1203 #1 0xffdb53c in mlx5_dev_close ../drivers/net/mlx5/mlx5.c:2286 #2 0xe12dc0 in rte_eth_dev_close ../lib/ethdev/rte_ethdev.c:1877 #3 0x6bac1c in close_port ../app/test-pmd/testpmd.c:3540 #4 0x6bc320 in pmd_test_exit ../app/test-pmd/testpmd.c:3808 #5 0x6c1a94 in main ../app/test-pmd/testpmd.c:4759 #6 0xffff9328f038 (/usr/lib64/libc.so.6+0x2b038) #7 0xffff9328f110 in __libc_start_main (/usr/lib64/libc.so.6+ 0x2b110) Fixes: 6e78005a9b30 ("net/mlx5: add reference counter on DPDK Tx queues") Reported-by: Yunjian Wang Signed-off-by: Pengfei Sun Acked-by: Dariusz Sosnowski --- drivers/net/mlx5/mlx5.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/mlx5/mlx5.c b/drivers/net/mlx5/mlx5.c index 1a5f95b22b..d41b0d1363 100644 --- a/drivers/net/mlx5/mlx5.c +++ b/drivers/net/mlx5/mlx5.c @@ -2074,7 +2074,7 @@ mlx5_dev_close(struct rte_eth_dev *dev) mlx5_free(priv->rxq_privs); priv->rxq_privs = NULL; } - if (priv->txqs != NULL) { + if (priv->txqs != NULL && dev->data->tx_queues != NULL) { /* XXX race condition if mlx5_tx_burst() is still running. */ rte_delay_us_sleep(1000); for (i = 0; (i != priv->txqs_n); ++i) -- 2.39.2 --- Diff of the applied patch vs upstream commit (please double-check if non-empty: --- --- - 2024-03-14 00:09:22.527955679 +0000 +++ 0040-net-mlx5-fix-use-after-free-when-releasing-Tx-queues.patch 2024-03-14 00:09:20.629615539 +0000 @@ -1 +1 @@ -From b805b7c451f1ee5bafa5628ee67f3a495f6a8682 Mon Sep 17 00:00:00 2001 +From 5126f7dd1094e8a1366cc52ac946831f3129b53b Mon Sep 17 00:00:00 2001 @@ -5,0 +6,2 @@ +[ upstream commit b805b7c451f1ee5bafa5628ee67f3a495f6a8682 ] + @@ -40 +41,0 @@ -Cc: stable@dpdk.org @@ -50 +51 @@ -index 881c42a97a..f2ca0ae4c2 100644 +index 1a5f95b22b..d41b0d1363 100644 @@ -53 +54 @@ -@@ -2362,7 +2362,7 @@ mlx5_dev_close(struct rte_eth_dev *dev) +@@ -2074,7 +2074,7 @@ mlx5_dev_close(struct rte_eth_dev *dev)