From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out-179.mta0.migadu.com (out-179.mta0.migadu.com [91.218.175.179]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 146C52309AA for ; Tue, 26 May 2026 12:59:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.179 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779800387; cv=none; b=FpV3Y0lpvk8d86K0v7JZR+Hl/0gYJOZFhvVx8n44ecOKwkZ4baZpMnv6JGF+0wqmAgF15sUhqVNYBvTqOZEld1hN0zGjOc/dnuFFm47gj256ZYtTR0KIsetDVbuBRg+t7YRFLCGJDz1Qm1zGO9fjXKfQhGT5iaJQT5T7C2df7f4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779800387; c=relaxed/simple; bh=JRwfVSK7Bo+hVVeIuCi/spRY9GEU8tG4fcsk+VY8nBo=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=bz7N4EAsiY3d3sE68cZqcTU5g4/LXCw31zxNGyrEuCw6++QPDVDorlA2B88EIlho6glvox/OJ2zl6XM/fXH1+gAQJCmvNjw6NQ+D8MkYHhVfx8TxB41l2Ka3kzNOBzY/uJdZpt6JBQRvRGY7AZ2yvJq4R1zzT17LjPjtJ4RE4E8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=U7FFtse2; arc=none smtp.client-ip=91.218.175.179 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="U7FFtse2" Message-ID: <206dc5f5-0278-4100-a595-4923da30b900@linux.dev> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1779800384; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=zHTwPvQeI3NSDvgqwGcFB5R2OzdXWrLDStlSCxXrhzw=; b=U7FFtse2S1tSBDZwOBMwS45HA/T/U66Sxth5rABgqKjubFtl2vU6dpsX0Qmlc/bJREFOAz gC1FAbtntfPKPXwn64hsVo/1QECyy5ExehlKkQCbkKC1jrGg9ycUOLOxrbNuvQ1zMGs0uZ uCjD7KoU1MaCgiSAp57zhZZFcHAOB9E= Date: Tue, 26 May 2026 13:59:40 +0100 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Subject: Re: [PATCH] mm/cma: fix reserved page leak on activation failure To: Muchun Song , Oscar Salvador Cc: Muchun Song , Andrew Morton , David Hildenbrand , Lorenzo Stoakes , "Liam R. Howlett" , Vlastimil Babka , Mike Rapoport , Suren Baghdasaryan , Michal Hocko , Frank van der Linden , linux-mm@kvack.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org References: <9A340644-CD8D-44B0-BBC5-43D29E9D046E@linux.dev> Content-Language: en-US X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Usama Arif In-Reply-To: <9A340644-CD8D-44B0-BBC5-43D29E9D046E@linux.dev> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Migadu-Flow: FLOW_OUT On 26/05/2026 13:44, Muchun Song wrote: > > >> On May 26, 2026, at 19:51, Oscar Salvador (SUSE) wrote: >> >> On Tue, May 26, 2026 at 04:30:03AM -0700, Usama Arif wrote: >>> On Fri, 22 May 2026 14:26:58 +0800 Muchun Song wrote: >> ... >>>> diff --git a/mm/cma.c b/mm/cma.c >>>> index c7ca567f4c5c..a30075507d41 100644 >>>> --- a/mm/cma.c >>>> +++ b/mm/cma.c >>>> @@ -188,10 +188,13 @@ static void __init cma_activate_area(struct cma *cma) >>>> >>>> /* Expose all pages to the buddy, they are useless for CMA. */ >>>> if (!test_bit(CMA_RESERVE_PAGES_ON_ERROR, &cma->flags)) { >>>> - for (r = 0; r < allocrange; r++) { >>>> + for (r = 0; r < cma->nranges; r++) { >>>> + unsigned long start_pfn; >>>> + >>>> cmr = &cma->ranges[r]; >>>> + start_pfn = r < allocrange ? early_pfn[r] : cmr->early_pfn; >>> >>> Should this be r <= allocrange? > > Yes. So I sent a v2 to fix it last Saturday. > > https://lore.kernel.org/linux-mm/20260523060123.2207992-1-songmuchun@bytedance.com/ > > Thanks. Ah still catching up on the mailing list. Thanks! > >> >> Yes, I think you are right. I missed that. >> >> early_pfn[alloc_range] holds the last assignment, so we should start >> from the next one reading cmr->early_pfn. >> >> >> >> -- >> Oscar Salvador >> SUSE Labs