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: <Y3IbBCioK1Clt/3a@electric-eye.fr.zoreil.com>
Date:   Mon, 14 Nov 2022 11:40:04 +0100
From:   Francois Romieu <romieu@...zoreil.com>
To:     Zhang Changzhong <zhangchangzhong@...wei.com>
Cc:     "David S. Miller" <davem@...emloft.net>,
        Eric Dumazet <edumazet@...gle.com>,
        Jakub Kicinski <kuba@...nel.org>,
        Paolo Abeni <pabeni@...hat.com>,
        Moritz Fischer <mdf@...nel.org>, netdev@...r.kernel.org,
        linux-kernel@...r.kernel.org
Subject: Re: [PATCH net] net: nixge: fix potential memory leak in
 nixge_start_xmit()

Zhang Changzhong <zhangchangzhong@...wei.com> :
> The nixge_start_xmit() returns NETDEV_TX_OK but does not free skb on two
> error handling cases, which can lead to memory leak.
> 
> To fix this, return NETDEV_TX_BUSY in case of nixge_check_tx_bd_space()
> fails and add dev_kfree_skb_any() in case of dma_map_single() fails.

This patch merge two unrelated changes. Please split.

> Fixes: 492caffa8a1a ("net: ethernet: nixge: Add support for National Instruments XGE netdev")
> Signed-off-by: Zhang Changzhong <zhangchangzhong@...wei.com>
> ---
>  drivers/net/ethernet/ni/nixge.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/net/ethernet/ni/nixge.c b/drivers/net/ethernet/ni/nixge.c
> index 19d043b593cc..b9091f9bbc77 100644
> --- a/drivers/net/ethernet/ni/nixge.c
> +++ b/drivers/net/ethernet/ni/nixge.c
> @@ -521,13 +521,15 @@ static netdev_tx_t nixge_start_xmit(struct sk_buff *skb,
>  	if (nixge_check_tx_bd_space(priv, num_frag)) {
>  		if (!netif_queue_stopped(ndev))
>  			netif_stop_queue(ndev);
> -		return NETDEV_TX_OK;
> +		return NETDEV_TX_BUSY;
>  	}

The driver should probably check the available room before returning
from hard_start_xmit and turn the check above unlikely().

Btw there is no lock and the Tx completion is irq driven: the driver
is racy. :o(

-- 
Ueimor

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ