eventdev/eth_tx: fix service function

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

Checks

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

Commit Message

Naga Harish K, S V Jan. 7, 2023, 4:40 p.m. UTC
  adapter service function is using RTE_ETH_FOREACH_DEV() macro for
looping through all available eth devices and flushing any pending
buffered packets.

When Traffic Management nodes (vports) are added and deleted dynamically,
there is a possibility of accessing the device info memory beyond the
allocated limit which can result in segfaults. Fixed the logic to
prevent illegal memory access.

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>
---
 lib/eventdev/rte_event_eth_tx_adapter.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
  

Comments

Jerin Jacob Jan. 17, 2023, 4 p.m. UTC | #1
On Sat, Jan 7, 2023 at 10:11 PM Naga Harish K S V
<s.v.naga.harish.k@intel.com> wrote:
>
> adapter service function is using RTE_ETH_FOREACH_DEV() macro for
> looping through all available eth devices and flushing any pending
> buffered packets.
>
> When Traffic Management nodes (vports) are added and deleted dynamically,
> there is a possibility of accessing the device info memory beyond the
> allocated limit which can result in segfaults. Fixed the logic to
> prevent illegal memory access.
>
> 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>


Updated the git commit as follows and applied to
dpdk-next-net-eventdev/for-main. Thanks

    eventdev/eth_tx: fix invalid memory access

    Adapter service function is using RTE_ETH_FOREACH_DEV() macro for
    looping through all available eth devices and flushing any pending
    buffered packets.

    When Traffic Management nodes (vports) are added and deleted dynamically,
    there is a possibility of accessing the device info memory beyond the
    allocated limit which can result in segfaults. Fixed the logic to
    prevent illegal memory access.

    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>

> ---
>  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 88309d2aaa..ba7a1c7f1b 100644
> --- a/lib/eventdev/rte_event_eth_tx_adapter.c
> +++ b/lib/eventdev/rte_event_eth_tx_adapter.c
> @@ -676,7 +676,7 @@ txa_service_func(void *args)
>                 RTE_ETH_FOREACH_DEV(i) {
>                         uint16_t q;
>
> -                       if (i == txa->dev_count)
> +                       if (i >= txa->dev_count)
>                                 break;
>
>                         dev = tdi[i].dev;
> --
> 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 88309d2aaa..ba7a1c7f1b 100644
--- a/lib/eventdev/rte_event_eth_tx_adapter.c
+++ b/lib/eventdev/rte_event_eth_tx_adapter.c
@@ -676,7 +676,7 @@  txa_service_func(void *args)
 		RTE_ETH_FOREACH_DEV(i) {
 			uint16_t q;
 
-			if (i == txa->dev_count)
+			if (i >= txa->dev_count)
 				break;
 
 			dev = tdi[i].dev;