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] [day] [month] [year] [list]
Date: Sat, 23 Mar 2024 10:29:22 +0100
From: Takashi Iwai <tiwai@...e.de>
To: LuMingYin <lumingyindetect@....com>
Cc: linux-sound@...r.kernel.org,
	linux-kernel@...r.kernel.org,
	tiwai@...e.com,
	perex@...ex.cz,
	minhuadotchen@...il.com
Subject: Re: [PATCH] sound:Fix a memory leak related to variable data

On Sat, 23 Mar 2024 09:04:13 +0100,
LuMingYin wrote:
> 
> In the file /linux/sound/core/control_compat.c, a pointer named 'data' is defined at line 82. This pointer allocates a block of dynamic memory using the 'kzalloc' function at line 85. When the if statement at line 86 returns false, it indicates successful allocation of the dynamic memory area pointed to by 'data'. However, when the if statement at line 90 returns true, the program returns at line 91. During this process, the dynamic memory area pointed to by 'data' is neither used as in the switch statement at line 108 nor deallocated, leading to a memory leak bug. The if statement at line 95 also has the same issue. This commit fixes this problem.
> 
> Signed-off-by: LuMingYin <lumingyindetect@....com>

It's using the new automatic free mechanism.  See the commit
1052d9882269 ("ALSA: control: Use automatic cleanup of kfree()")


thanks,

Takashi


> ---
>  sound/core/control_compat.c | 10 ++++++++--
>  1 file changed, 8 insertions(+), 2 deletions(-)
> 
> diff --git a/sound/core/control_compat.c b/sound/core/control_compat.c
> index 934bb945e702..32113eb06f68 100644
> --- a/sound/core/control_compat.c
> +++ b/sound/core/control_compat.c
> @@ -87,13 +87,19 @@ static int snd_ctl_elem_info_compat(struct snd_ctl_file *ctl,
>  		return -ENOMEM;
>  
>  	/* copy id */
> -	if (copy_from_user(&data->id, &data32->id, sizeof(data->id)))
> +	if (copy_from_user(&data->id, &data32->id, sizeof(data->id))){
> +		kfree(data);
> +		data = NULL;
>  		return -EFAULT;
> +	}
>  	/* we need to copy the item index.
>  	 * hope this doesn't break anything..
>  	 */
> -	if (get_user(data->value.enumerated.item, &data32->value.enumerated.item))
> +	if (get_user(data->value.enumerated.item, &data32->value.enumerated.item)){
> +		kfree(data);
> +		data = NULL;
>  		return -EFAULT;
> +	}
>  
>  	err = snd_ctl_elem_info(ctl, data);
>  	if (err < 0)
> -- 
> 2.25.1
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ