[v2] eventdev/eth_tx: fix queue_del function

Message ID 20211110060015.258508-1-s.v.naga.harish.k@intel.com (mailing list archive)
State Accepted, archived
Delegated to: Jerin Jacob
Headers
Series [v2] eventdev/eth_tx: fix queue_del function |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/github-robot: build success github build: passed
ci/Intel-compilation success Compilation OK
ci/intel-Testing success Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-broadcom-Functional success Functional Testing PASS
ci/iol-broadcom-Performance success Performance Testing PASS
ci/iol-x86_64-compile-testing success Testing PASS
ci/iol-aarch64-unit-testing success Testing PASS
ci/iol-x86_64-unit-testing fail Testing issues
ci/iol-aarch64-compile-testing success Testing PASS
ci/iol-intel-Functional fail Functional Testing issues
ci/iol-intel-Performance success Performance Testing PASS

Commit Message

Naga Harish K, S V Nov. 10, 2021, 6 a.m. UTC
  This patch fixes heap-use-after-free reported by ASAN,
please reference https://bugs.dpdk.org/show_bug.cgi?id=869

The application can use the queue_id as `-1` to delete all
the queues of the eth_device that are added to tx_adapter
instance.
In above case, the queue_del api is trying to use number of
queues from adapter level instead of eth_device queues.
When there are queues added from multiple eth devices,
it will result in heap-use-after-free as reported by ASAN.

This patch fixes the queue_del api to use correct number of
queues.

Bugzilla ID: 869
Fixes: a3bbf2e09756 ("eventdev: add eth Tx adapter implementation")
Cc: stable@dpdk.org

Signed-off-by: Naga Harish K S V <s.v.naga.harish.k@intel.com>
Acked-by: Jay Jayatheerthan <jay.jayatheerthan@intel.com>
---
 lib/eventdev/rte_event_eth_tx_adapter.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
  

Comments

Jerin Jacob Nov. 10, 2021, 6:58 p.m. UTC | #1
On Wed, Nov 10, 2021 at 11:30 AM Naga Harish K S V
<s.v.naga.harish.k@intel.com> wrote:
>
> This patch fixes heap-use-after-free reported by ASAN,
> please reference https://bugs.dpdk.org/show_bug.cgi?id=869
>
> The application can use the queue_id as `-1` to delete all
> the queues of the eth_device that are added to tx_adapter
> instance.
> In above case, the queue_del api is trying to use number of
> queues from adapter level instead of eth_device queues.
> When there are queues added from multiple eth devices,
> it will result in heap-use-after-free as reported by ASAN.
>
> This patch fixes the queue_del api to use correct number of
> queues.
>
> Bugzilla ID: 869
> Fixes: a3bbf2e09756 ("eventdev: add eth Tx adapter implementation")
> Cc: stable@dpdk.org
>
> Signed-off-by: Naga Harish K S V <s.v.naga.harish.k@intel.com>
> Acked-by: Jay Jayatheerthan <jay.jayatheerthan@intel.com>

Updated the commit log as:

    eventdev/eth_tx: fix queue delete logic

    This patch fixes heap-use-after-free reported by ASan.

    The application can use the queue_id as `-1` to delete all
    the queues of the eth_device that are added to tx_adapter
    instance.
    In above case, the queue_del API is trying to use number of
    queues from adapter level instead of eth_device queues.
    When there are queues added from multiple eth devices,
    it will result in heap-use-after-free as reported by ASAN.

    This patch fixes the queue_del API to use correct number of
    queues.

    Bugzilla ID: 869
    Fixes: a3bbf2e09756 ("eventdev: add eth Tx adapter implementation")
    Cc: stable@dpdk.org

    Signed-off-by: Naga Harish K S V <s.v.naga.harish.k@intel.com>
    Acked-by: Jay Jayatheerthan <jay.jayatheerthan@intel.com>
    Tested-by: David Marchand <david.marchand@redhat.com>


Applied to dpdk-next-net-eventdev/for-main. Thanks



> ---
>  lib/eventdev/rte_event_eth_tx_adapter.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/lib/eventdev/rte_event_eth_tx_adapter.c b/lib/eventdev/rte_event_eth_tx_adapter.c
> index da55d2c2dc..c17f33f098 100644
> --- a/lib/eventdev/rte_event_eth_tx_adapter.c
> +++ b/lib/eventdev/rte_event_eth_tx_adapter.c
> @@ -864,7 +864,7 @@ txa_service_queue_del(uint8_t id,
>                 uint16_t i, q, nb_queues;
>                 int ret = 0;
>
> -               nb_queues = txa->nb_queues;
> +               nb_queues = txa->txa_ethdev[port_id].nb_queues;
>                 if (nb_queues == 0)
>                         return 0;
>
> --
> 2.25.1
>
  

Patch

diff --git a/lib/eventdev/rte_event_eth_tx_adapter.c b/lib/eventdev/rte_event_eth_tx_adapter.c
index da55d2c2dc..c17f33f098 100644
--- a/lib/eventdev/rte_event_eth_tx_adapter.c
+++ b/lib/eventdev/rte_event_eth_tx_adapter.c
@@ -864,7 +864,7 @@  txa_service_queue_del(uint8_t id,
 		uint16_t i, q, nb_queues;
 		int ret = 0;
 
-		nb_queues = txa->nb_queues;
+		nb_queues = txa->txa_ethdev[port_id].nb_queues;
 		if (nb_queues == 0)
 			return 0;