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: <100d8307-4ae6-d370-e836-6c76aff4d920@huawei.com>
Date:   Wed, 7 Dec 2022 18:07:16 +0800
From:   Zhang Changzhong <zhangchangzhong@...wei.com>
To:     Leon Romanovsky <leon@...nel.org>
CC:     Giuseppe Cavallaro <peppe.cavallaro@...com>,
        Alexandre Torgue <alexandre.torgue@...s.st.com>,
        Jose Abreu <joabreu@...opsys.com>,
        "David S. Miller" <davem@...emloft.net>,
        Eric Dumazet <edumazet@...gle.com>,
        Jakub Kicinski <kuba@...nel.org>,
        Paolo Abeni <pabeni@...hat.com>,
        Maxime Coquelin <mcoquelin.stm32@...il.com>,
        <netdev@...r.kernel.org>, <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH net] net: stmmac: selftests: fix potential memleak in
 stmmac_test_arpoffload()

On 2022/12/7 17:12, Leon Romanovsky wrote:
> On Wed, Dec 07, 2022 at 04:31:59PM +0800, Zhang Changzhong wrote:
>> The skb allocated by stmmac_test_get_arp_skb() hasn't been released in
>> some error handling case, which will lead to a memory leak. Fix this up
>> by adding kfree_skb() to release skb.
>>
>> Compile tested only.
>>
>> Fixes: 5e3fb0a6e2b3 ("net: stmmac: selftests: Implement the ARP Offload test")
>> Signed-off-by: Zhang Changzhong <zhangchangzhong@...wei.com>
>> ---
>>  drivers/net/ethernet/stmicro/stmmac/stmmac_selftests.c | 8 ++++++--
>>  1 file changed, 6 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_selftests.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_selftests.c
>> index 49af7e7..687f43c 100644
>> --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_selftests.c
>> +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_selftests.c
>> @@ -1654,12 +1654,16 @@ static int stmmac_test_arpoffload(struct stmmac_priv *priv)
>>  	}
>>  
>>  	ret = stmmac_set_arp_offload(priv, priv->hw, true, ip_addr);
>> -	if (ret)
>> +	if (ret) {
>> +		kfree_skb(skb);
>>  		goto cleanup;
>> +	}
>>  
>>  	ret = dev_set_promiscuity(priv->dev, 1);
>> -	if (ret)
>> +	if (ret) {
>> +		kfree_skb(skb);
>>  		goto cleanup;
>> +	}
>>  
>>  	ret = dev_direct_xmit(skb, 0);
>>  	if (ret)
> 
> You should release skb here too. So the better patch will be to write
> something like that:
> 

Hi Leon,

Thanks for your review, but I don't think we need release skb here,
because dev_direct_xmit() is responsible for freeing it.

Regards,
Changzhong

> cleanup:
>   stmmac_set_arp_offload(priv, priv->hw, false, 0x0);
>   if (ret)
>   	kfree_skb(skb);
>> Thanks
> 
>> -- 
>> 2.9.5
>>
> .
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ