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: <3b19f145-8318-4f92-aa92-3ab160667c79@amd.com>
Date: Tue, 17 Jun 2025 09:56:55 -0700
From: Brett Creeley <bcreeley@....com>
To: Thomas Fourier <fourier.thomas@...il.com>
Cc: Shannon Nelson <shannon.nelson@....com>,
 Brett Creeley <brett.creeley@....com>, Andrew Lunn <andrew+netdev@...n.ch>,
 "David S. Miller" <davem@...emloft.net>, Eric Dumazet <edumazet@...gle.com>,
 Jakub Kicinski <kuba@...nel.org>, Paolo Abeni <pabeni@...hat.com>,
 Alexei Starovoitov <ast@...nel.org>, Daniel Borkmann <daniel@...earbox.net>,
 Jesper Dangaard Brouer <hawk@...nel.org>,
 John Fastabend <john.fastabend@...il.com>,
 Stanislav Fomichev <sdf@...ichev.me>,
 Vladimir Oltean <vladimir.oltean@....com>,
 Caleb Sander Mateos <csander@...estorage.com>,
 Taehee Yoo <ap420073@...il.com>, netdev@...r.kernel.org,
 linux-kernel@...r.kernel.org, bpf@...r.kernel.org
Subject: Re: [PATCH net] ethernet: ionic: Fix DMA mapping test in
 `ionic_xdp_post_frame()`

On 6/17/2025 2:18 AM, Thomas Fourier wrote:
> Caution: This message originated from an External Source. Use proper caution when opening attachments, clicking links, or responding.
> 
> 
> The `ionic_tx_map_frag()` wrapper function is used which returns 0 or a
> valid DMA address.  Testing that pointer with `dma_mapping_error()`could
> be eroneous since the error value exptected by `dma_mapping_error()` is
> not 0 but `DMA_MAPPING_ERROR` which is often ~0.
> 
> Fixes: ac8813c0ab7d ("ionic: convert Rx queue buffers to use page_pool")
> Signed-off-by: Thomas Fourier <fourier.thomas@...il.com>
> ---
>   drivers/net/ethernet/pensando/ionic/ionic_txrx.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/net/ethernet/pensando/ionic/ionic_txrx.c b/drivers/net/ethernet/pensando/ionic/ionic_txrx.c
> index 2ac59564ded1..beefdc43013e 100644
> --- a/drivers/net/ethernet/pensando/ionic/ionic_txrx.c
> +++ b/drivers/net/ethernet/pensando/ionic/ionic_txrx.c
> @@ -357,7 +357,7 @@ static int ionic_xdp_post_frame(struct ionic_queue *q, struct xdp_frame *frame,
>                          } else {
>                                  dma_addr = ionic_tx_map_frag(q, frag, 0,
>                                                               skb_frag_size(frag));
> -                               if (dma_mapping_error(q->dev, dma_addr)) {
> +                               if (!dma_addr) {

Thanks for the fix.

After looking at this and Olek's comment, I think it makes the most 
sense to return DMA_MAPPING_ERROR from ionic_tx_map_frag() and 
ionic_tx_map_single() instead of 0 on failures.

Then any callers would do the following check:

	if (unlikely(dma_addr == DMA_MAPPING_ERROR))
		/* failure path */

Another option is always returning dma_addr regardless of 
success/failure from the ionic_tx_map* functions, but then I'd be 
inclined to use dma_mapping_error() again in the caller. This approach 
seems wrong to me, especially when CONFIG_DMA_API_DEBUG is enabled.

Thanks,

Brett



>                                          ionic_tx_desc_unmap_bufs(q, desc_info);
>                                          return -EIO;
>                                  }
> --
> 2.43.0
> 


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ