lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20191004181828.GB9935@lunn.ch>
Date:   Fri, 4 Oct 2019 20:18:28 +0200
From:   Andrew Lunn <andrew@...n.ch>
To:     Ioana Ciornei <ioana.ciornei@....com>
Cc:     davem@...emloft.net, netdev@...r.kernel.org,
        Ioana Radulescu <ruxandra.radulescu@....com>
Subject: Re: [PATCH 3/3] dpaa2-eth: Avoid unbounded while loops

On Fri, Oct 04, 2019 at 12:21:33PM +0300, Ioana Ciornei wrote:
> From: Ioana Radulescu <ruxandra.radulescu@....com>
> 
> Throughout the driver there are several places where we wait
> indefinitely for DPIO portal commands to be executed, while
> the portal returns a busy response code.
> 
> Even though in theory we are guaranteed the portals become
> available eventually, in practice the QBMan hardware module
> may become unresponsive in various corner cases.
> 
> Make sure we can never get stuck in an infinite while loop
> by adding a retry counter for all portal commands.
> 
> Signed-off-by: Ioana Radulescu <ruxandra.radulescu@....com>
> Signed-off-by: Ioana Ciornei <ioana.ciornei@....com>
> ---
>  drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c | 30 ++++++++++++++++++++----
>  drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.h |  8 +++++++
>  2 files changed, 33 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c b/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c
> index 2c5072fa9aa0..29702756734c 100644
> --- a/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c
> +++ b/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c
> @@ -221,6 +221,7 @@ static void xdp_release_buf(struct dpaa2_eth_priv *priv,
>  			    struct dpaa2_eth_channel *ch,
>  			    dma_addr_t addr)
>  {
> +	int retries = 0;
>  	int err;
>  
>  	ch->xdp.drop_bufs[ch->xdp.drop_cnt++] = addr;
> @@ -229,8 +230,11 @@ static void xdp_release_buf(struct dpaa2_eth_priv *priv,
>  
>  	while ((err = dpaa2_io_service_release(ch->dpio, priv->bpid,
>  					       ch->xdp.drop_bufs,
> -					       ch->xdp.drop_cnt)) == -EBUSY)
> +					       ch->xdp.drop_cnt)) == -EBUSY) {
> +		if (retries++ >= DPAA2_ETH_SWP_BUSY_RETRIES)
> +			break;
>  		cpu_relax();
> +	}
>  
>  	if (err) {
>  		free_bufs(priv, ch->xdp.drop_bufs, ch->xdp.drop_cnt);
> @@ -458,7 +462,7 @@ static int consume_frames(struct dpaa2_eth_channel *ch,
>  	struct dpaa2_eth_fq *fq = NULL;
>  	struct dpaa2_dq *dq;
>  	const struct dpaa2_fd *fd;
> -	int cleaned = 0;
> +	int cleaned = 0, retries = 0;
>  	int is_last;
>  
>  	do {
> @@ -469,6 +473,11 @@ static int consume_frames(struct dpaa2_eth_channel *ch,
>  			 * the store until we get some sort of valid response
>  			 * token (either a valid frame or an "empty dequeue")
>  			 */
> +			if (retries++ >= DPAA2_ETH_SWP_BUSY_RETRIES) {
> +				netdev_err_once(priv->net_dev,
> +						"Unable to read a valid dequeue response\n");
> +				return 0;
> +			}
>  			continue;

Hi Ioana

It seems a bit odd that here you could return -ETIMEDOUT, but you
print an error, and return 0. But in the two cases above in void
functions, you don't print anything.

Please at least return -ETIMEDOUT when you can.

       Andrew

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ