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: <99A7645C-B8FB-4F28-B4B8-D5372F4C001E@linux.dev>
Date: Wed, 5 Mar 2025 11:17:48 +0800
From: Muchun Song <muchun.song@...ux.dev>
To: Liu Ye <liuye@...inos.cn>
Cc: akpm@...ux-foundation.org,
 david@...morbit.com,
 zhengqi.arch@...edance.com,
 roman.gushchin@...ux.dev,
 linux-mm@...ck.org,
 linux-kernel@...r.kernel.org
Subject: Re: [PATCH] mm/shrinker_debug: Fix possible memory leak in
 shrinker_debugfs_rename function.



> On Mar 5, 2025, at 10:01, Liu Ye <liuye@...inos.cn> wrote:
> 
> After calling debugfs_change_name function, the return value should be
> checked and the old name restored. If debugfs_change_name fails, the new
> name memory should be freed.

Seems it is not a big problem, no memory leak at least. The effect is that
the shrinker->name is not consistent with the name displayed in debugfs.
Right? But the improvement LGTM. So:

Reviewed-by: Muchun Song <muchun.song@...ux.dev>

Thanks.

> 
> Signed-off-by: Liu Ye <liuye@...inos.cn>
> ---
> mm/shrinker_debug.c | 8 ++++++--
> 1 file changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/mm/shrinker_debug.c b/mm/shrinker_debug.c
> index 794bd433cce0..20eaee3e97f7 100644
> --- a/mm/shrinker_debug.c
> +++ b/mm/shrinker_debug.c
> @@ -214,10 +214,14 @@ int shrinker_debugfs_rename(struct shrinker *shrinker, const char *fmt, ...)
> ret = debugfs_change_name(shrinker->debugfs_entry, "%s-%d",
> shrinker->name, shrinker->debugfs_id);
> 
> + 	if (ret) {
> + 		shrinker->name = old;
> + 		kfree_const(new);
> + 	} else {
> + 		kfree_const(old);
> + 	}
> 	mutex_unlock(&shrinker_mutex);
> 
> - 	kfree_const(old);
> -
> 	return ret;
> }
> EXPORT_SYMBOL(shrinker_debugfs_rename);
> -- 
> 2.25.1
> 


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ