DPDK patches and discussions
 help / color / mirror / Atom feed
From: "Naga Harish K, S V" <s.v.naga.harish.k@intel.com>
To: "Kundapura, Ganapati" <ganapati.kundapura@intel.com>,
	"jerinj@marvell.com" <jerinj@marvell.com>,
	"dev@dpdk.org" <dev@dpdk.org>
Cc: "Jayatheerthan, Jay" <jay.jayatheerthan@intel.com>,
	"Gujjar, Abhinandan S" <abhinandan.gujjar@intel.com>
Subject: RE: [PATCH v1] eventdev/eth_rx: fix null pointer dereference
Date: Fri, 25 Aug 2023 13:46:55 +0000	[thread overview]
Message-ID: <DM6PR11MB38682081C2AB451BB5919BA9A1E3A@DM6PR11MB3868.namprd11.prod.outlook.com> (raw)
In-Reply-To: <20230824082331.713236-1-ganapati.kundapura@intel.com>



> -----Original Message-----
> From: Kundapura, Ganapati <ganapati.kundapura@intel.com>
> Sent: Thursday, August 24, 2023 1:54 PM
> To: jerinj@marvell.com; Naga Harish K, S V <s.v.naga.harish.k@intel.com>;
> dev@dpdk.org
> Cc: Jayatheerthan, Jay <jay.jayatheerthan@intel.com>; Gujjar, Abhinandan S
> <abhinandan.gujjar@intel.com>
> Subject: [PATCH v1] eventdev/eth_rx: fix null pointer dereference
> 
> On passing NULL as a last parameter to xxx_create_ext_with_params(),
> rxa_config_params_validate() uses default values and dereferences NULL
> pointer leading to segmentation fault.
> 
> Fixed by returning after using default values without dereferencing NULL
> pointer.
> 
> Fixes: 8be6c94d6d90 ("eventdev/eth_rx: add new adapter create API")
> 
> Signed-off-by: Ganapati Kundapura <ganapati.kundapura@intel.com>
> 

Acked-by: Naga Harish K S V <s.v.naga.harish.k@intel.com>

> diff --git a/app/test/test_event_eth_rx_adapter.c
> b/app/test/test_event_eth_rx_adapter.c
> index 2d5e197666..0233c87779 100644
> --- a/app/test/test_event_eth_rx_adapter.c
> +++ b/app/test/test_event_eth_rx_adapter.c
> @@ -407,6 +407,12 @@ adapter_create(void)
>  	return err;
>  }
> 
> +static void
> +adapter_free(void)
> +{
> +	rte_event_eth_rx_adapter_free(TEST_INST_ID);
> +}
> +
>  static int
>  adapter_create_with_params(void)
>  {
> @@ -427,6 +433,13 @@ adapter_create_with_params(void)
>  	rxa_params.use_queue_event_buf = false;
>  	rxa_params.event_buf_size = 0;
> 
> +	/* Pass rxa_params = NULL */
> +	err = rte_event_eth_rx_adapter_create_with_params(TEST_INST_ID,
> +				TEST_DEV_ID, &rx_p_conf, NULL);
> +	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
> +	if (err == 0)
> +		adapter_free();
> +
>  	err = rte_event_eth_rx_adapter_create_with_params(TEST_INST_ID,
>  				TEST_DEV_ID, &rx_p_conf, &rxa_params);
>  	TEST_ASSERT(err == -EINVAL, "Expected -EINVAL got %d", err); @@ -
> 512,6 +525,13 @@ adapter_create_ext_with_params(void)
>  	rxa_params.use_queue_event_buf = false;
>  	rxa_params.event_buf_size = 0;
> 
> +	/* Pass rxa_params = NULL */
> +	err =
> rte_event_eth_rx_adapter_create_ext_with_params(TEST_INST_ID,
> +			TEST_DEV_ID, test_port_conf_cb, NULL, NULL);
> +	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
> +	if (err == 0)
> +		adapter_free();
> +
>  	err =
> rte_event_eth_rx_adapter_create_ext_with_params(TEST_INST_ID,
>  			TEST_DEV_ID, test_port_conf_cb, NULL,
> &rxa_params);
>  	TEST_ASSERT(err == -EINVAL, "Expected -EINVAL got %d", err); @@ -
> 634,12 +654,6 @@ adapter_queue_stats_test(void)
>  	return TEST_SUCCESS;
>  }
> 
> -static void
> -adapter_free(void)
> -{
> -	rte_event_eth_rx_adapter_free(TEST_INST_ID);
> -}
> -
>  static int
>  adapter_create_free(void)
>  {
> diff --git a/lib/eventdev/rte_event_eth_rx_adapter.c
> b/lib/eventdev/rte_event_eth_rx_adapter.c
> index 93bed18e93..fe84471523 100644
> --- a/lib/eventdev/rte_event_eth_rx_adapter.c
> +++ b/lib/eventdev/rte_event_eth_rx_adapter.c
> @@ -2493,6 +2493,7 @@ rxa_config_params_validate(struct
> rte_event_eth_rx_adapter_params *rxa_params,
>  		/* use default values if rxa_params is NULL */
>  		temp_params->event_buf_size = ETH_EVENT_BUFFER_SIZE;
>  		temp_params->use_queue_event_buf = false;
> +		return 0;
>  	} else if (!rxa_params->use_queue_event_buf &&
>  		    rxa_params->event_buf_size == 0) {
>  		RTE_EDEV_LOG_ERR("event buffer size can't be zero\n");
> --
> 2.23.0


  parent reply	other threads:[~2023-08-25 13:47 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-24  8:23 Ganapati Kundapura
2023-08-25  7:04 ` Jerin Jacob
2023-08-25 13:46 ` Naga Harish K, S V [this message]
2023-08-28 15:49   ` Jerin Jacob

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=DM6PR11MB38682081C2AB451BB5919BA9A1E3A@DM6PR11MB3868.namprd11.prod.outlook.com \
    --to=s.v.naga.harish.k@intel.com \
    --cc=abhinandan.gujjar@intel.com \
    --cc=dev@dpdk.org \
    --cc=ganapati.kundapura@intel.com \
    --cc=jay.jayatheerthan@intel.com \
    --cc=jerinj@marvell.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).