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, 21 Nov 2023 12:15:30 +0100
From: Alexander Lobakin <aleksander.lobakin@...el.com>
To: Kunwu Chan <chentao@...inos.cn>
CC: <horms@...nel.org>, <anthony.l.nguyen@...el.com>, <davem@...emloft.net>,
	<edumazet@...gle.com>, <intel-wired-lan@...ts.osuosl.org>,
	<jeffrey.t.kirsher@...el.com>, <jesse.brandeburg@...el.com>,
	<kuba@...nel.org>, <kunwu.chan@...mail.com>, <linux-kernel@...r.kernel.org>,
	<netdev@...r.kernel.org>, <pabeni@...hat.com>, <shannon.nelson@....com>
Subject: Re: [PATCH iwl-next] i40e: Use correct buffer size

From: Kunwu Chan <chentao@...inos.cn>
Date: Tue, 21 Nov 2023 10:12:17 +0800

> Thanks for your reply. I understand what you mean, i.e. the caller of
> 'kasprintf' is responsible for calling 'kfree' to free up memory.
> 
> My concern is that in many scenarios, the requested memory will be
> released after a period of use.
> 
> Has anyone else forgotten to free up the requested memory when using
> 'kasprintf'? e.g. 'dam_heap_init' calls 'dma_heap_devnode' to allocate
> memory:
> dam_heap_init
>     -> dma_heap_devnode
>           -> kasprintf
>             ->kvasprintf
>                  ->kmalloc_node_track_caller
>                   -> __kmalloc_node_track_caller
>                       -> __do_kmalloc_node
>                           -> kasan_kmalloc
> 
> 
> There is no function like 'dam_heap_exit' to free the memmory allocated
> by dma_heap_devnode.
> 
> Another case is 'cpuid_devnode'. Will this cause a memory leak, and is
> there a better way to avoid the memory leak in this case?
> 
> Or is there a uniform place in the memory management module to free up
> this memory?

If the lifetime of the allocated buffer equals to the lifetime of the
kernel, i.e. it's allocated once at kernel init and then used throughout
the whole uptime, there's no need to free this piece.
Temporary buffers or buffers allocated from a driver are a different
story, their lifetime is shorter, which means you always need to
manually free each of them on exit.

> 
> Thanks,
> Kunwu
Thanks,
Olek

Powered by blists - more mailing lists