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]
Date:   Tue, 19 Oct 2021 19:47:17 +0000
From:   Claudiu Manoil <claudiu.manoil@....com>
To:     Tim Gardner <tim.gardner@...onical.com>,
        "netdev@...r.kernel.org" <netdev@...r.kernel.org>
CC:     "David S. Miller" <davem@...emloft.net>,
        Jakub Kicinski <kuba@...nel.org>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
        Po Liu <po.liu@....com>,
        Claudiu Manoil <claudiu.manoil@....com>
Subject: RE: [PATCH][linux-next] net: enetc: unmap DMA in enetc_send_cmd()

> -----Original Message-----
> From: Tim Gardner <tim.gardner@...onical.com>
> Sent: Tuesday, October 19, 2021 9:20 PM
[...]
> Subject: [PATCH][linux-next] net: enetc: unmap DMA in enetc_send_cmd()
> 
> Coverity complains of a possible dereference of a null return value.
> 
>    	5. returned_null: kzalloc returns NULL. [show details]
>    	6. var_assigned: Assigning: si_data = NULL return value from kzalloc.
> 488        si_data = kzalloc(data_size, __GFP_DMA | GFP_KERNEL);
> 489        cbd.length = cpu_to_le16(data_size);
> 490
> 491        dma = dma_map_single(&priv->si->pdev->dev, si_data,
> 492                             data_size, DMA_FROM_DEVICE);
> 
> While this kzalloc() is unlikely to fail, I did notice that the function
> returned without unmapping si_data.
> 
> Fix this by refactoring the error paths and checking for kzalloc()
> failure.
> 
> Fixes: 888ae5a3952ba ("net: enetc: add tc flower psfp offload driver")
> Cc: Claudiu Manoil <claudiu.manoil@....com>
> Cc: "David S. Miller" <davem@...emloft.net>
> Cc: Jakub Kicinski <kuba@...nel.org>
> Cc: netdev@...r.kernel.org
> Cc: linux-kernel@...r.kernel.org (open list)
> Signed-off-by: Tim Gardner <tim.gardner@...onical.com>
> ---
> 
> I am curious why you do not need to call dma_sync_single_for_device()
> before enetc_send_cmd()
> in order to flush the contents of CPU cache to RAM. Is it because
> __GFP_DMA marks
> that page as uncached ? Or is it because of the SOC this runs on ?
> 

Not sure how it works like this, but I think dma_alloc_coherent() should have
been used here instead of the kmalloc + dma_map scheme. I don't have the
means to test this particular code path however.

Acked-by: Claudiu Manoil <claudiu.manoil@....com>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ