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]
Message-ID: <a2ac5b97-ea63-3187-164c-9568d7810a0a@huawei.com>
Date: Mon, 1 Sep 2025 20:10:11 +0800
From: Hanjun Guo <guohanjun@...wei.com>
To: Miaoqian Lin <linmq006@...il.com>, Lorenzo Pieralisi
	<lpieralisi@...nel.org>, Sudeep Holla <sudeep.holla@....com>, "Rafael J.
 Wysocki" <rafael@...nel.org>, Len Brown <lenb@...nel.org>, Joerg Roedel
	<jroedel@...e.de>, Shameer Kolothum <shameerali.kolothum.thodi@...wei.com>,
	Robin Murphy <robin.murphy@....com>, <linux-acpi@...r.kernel.org>,
	<linux-arm-kernel@...ts.infradead.org>, <linux-kernel@...r.kernel.org>,
	<bpf@...r.kernel.org>
CC: <stable@...r.kernel.org>, Catalin Marinas <catalin.marinas@....com>, Will
 Deacon <will@...nel.org>
Subject: Re: [PATCH] ACPI/IORT: Fix memory leak in iort_rmr_alloc_sids()

+Cc Catalin, Will

On 2025/8/28 19:22, Miaoqian Lin wrote:
> If krealloc_array() fails in iort_rmr_alloc_sids(), the function returns
> NULL but does not free the original 'sids' allocation. This results in a
> memory leak since the caller overwrites the original pointer with the
> NULL return value.
> 
> Fixes: 491cf4a6735a ("ACPI/IORT: Add support to retrieve IORT RMR reserved regions")
> Cc: <stable@...r.kernel.org>
> Signed-off-by: Miaoqian Lin <linmq006@...il.com>
> ---
> This follows the same pattern as the fix in commit 06615967d488
> ("bpf, verifier: Fix memory leak in array reallocation for stack state").
> ---
>   drivers/acpi/arm64/iort.c | 4 +++-
>   1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/acpi/arm64/iort.c b/drivers/acpi/arm64/iort.c
> index 98759d6199d3..65f0f56ad753 100644
> --- a/drivers/acpi/arm64/iort.c
> +++ b/drivers/acpi/arm64/iort.c
> @@ -937,8 +937,10 @@ static u32 *iort_rmr_alloc_sids(u32 *sids, u32 count, u32 id_start,
>   
>   	new_sids = krealloc_array(sids, count + new_count,
>   				  sizeof(*new_sids), GFP_KERNEL);
> -	if (!new_sids)
> +	if (!new_sids) {
> +		kfree(sids);
>   		return NULL;
> +	}
>   
>   	for (i = count; i < total_count; i++)
>   		new_sids[i] = id_start++;

Good catch!

Reviewed-by: Hanjun Guo <guohanjun@...wei.com>

Thanks
Hanjun

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ