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: <c81af94d-3b56-4169-b2eb-5d82623ab0af@kernel.org>
Date: Mon, 22 Jul 2024 09:28:46 +0800
From: Chao Yu <chao@...nel.org>
To: Yongpeng Yang <yangyongpeng1@...o.com>, Jaegeuk Kim <jaegeuk@...nel.org>
Cc: linux-f2fs-devel@...ts.sourceforge.net, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] f2fs: free victim_secmap when pinned_secmap allocation
 fails

On 2024/7/20 18:33, Yongpeng Yang wrote:
> In the init_victim_secmap function, if the allocation of
> dirty_i->pinned_secmap fails, dirty_i->victim_secmap is not
> freed, which can cause a memory leak.
> 
> Signed-off-by: Yongpeng Yang <yangyongpeng1@...o.com>
> ---
>   fs/f2fs/segment.c | 4 +++-
>   1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
> index 78c3198a6308..1e784ea3dbb4 100644
> --- a/fs/f2fs/segment.c
> +++ b/fs/f2fs/segment.c
> @@ -4971,8 +4971,10 @@ static int init_victim_secmap(struct f2fs_sb_info *sbi)
>   		return -ENOMEM;
>   
>   	dirty_i->pinned_secmap = f2fs_kvzalloc(sbi, bitmap_size, GFP_KERNEL);
> -	if (!dirty_i->pinned_secmap)
> +	if (!dirty_i->pinned_secmap) {
> +		kvfree(dirty_i->victim_secmap);

Yongpeng,

In below path, it will release pinned_secmap/victim_secmap?

- f2fs_destroy_segment_manager
  - destroy_victim_secmap
   : kvfree(dirty_i->pinned_secmap);
   : kvfree(dirty_i->victim_secmap);

Thanks,

>   		return -ENOMEM;
> +	}
>   
>   	dirty_i->pinned_secmap_cnt = 0;
>   	dirty_i->enable_pin_section = true;

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ