From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out-179.mta1.migadu.com (out-179.mta1.migadu.com [95.215.58.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 B6EFA358369 for ; Wed, 20 May 2026 08:29:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.215.58.179 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779265779; cv=none; b=GVNXCjbnBrFWRNlwRf1nx+gWXTUnxHXnaXTPdhdfX8rlV+i0O/qWqNU1uwfwNOSOGaBGp22MublblFaaNRYp93ZfGzAABV93AgsVwRONN3ajRtlhssDe9fdXhi8cpfWR9opBt8lMRN9Y+oYL+PUSThsHIZdWEmsr9L/x51ZHwbo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779265779; c=relaxed/simple; bh=Toc6Hf57MsxqjcmT4Wwv1Dez0FV6nEjIiy/BCwrLaT4=; h=Content-Type:Mime-Version:Subject:From:In-Reply-To:Date:Cc: Message-Id:References:To; b=WbZK1rhioEQzsqh7VwrMdTR7iEkJM+UnSWXHMP+aZWcDuyfM9ohYSJYbqyRR0QdBgBk/WHQwVlpKcd1w05DAhgmLMiMqR5h2IlO/6IMOR0NY0UhRzk3sBBVyvRyotZqgfCtJ1MJZZSqoVW96emXoh/GoPlzp9tkv23sQeKxgcck= 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=Mf4Y5h71; arc=none smtp.client-ip=95.215.58.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="Mf4Y5h71" Content-Type: text/plain; charset=us-ascii DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1779265765; 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=Toc6Hf57MsxqjcmT4Wwv1Dez0FV6nEjIiy/BCwrLaT4=; b=Mf4Y5h71GBTlwpU539Q7BpbVNRdZ4P70r5Ia7Es3et5LVM7XirXAvHh+DSzRgnXo4Isqhf fzM5loPs05h0o8nqF5QaXHMdq3VFxROeF3cusFoOziqnTOf3todhElqflVEhbui9kRCBXr mcY0tPrqWBVx11r1sUlF6cEeNOFwu78= Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3864.500.181\)) Subject: Re: [PATCH] mm/cma_debug: fix invalid accesses for inactive CMA areas X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Muchun Song In-Reply-To: <55481a8b-dcfc-4bef-ba59-aa0b43dca88b@kernel.org> Date: Wed, 20 May 2026 16:28:32 +0800 Cc: Muchun Song , Andrew Morton , linux-mm@kvack.org, Lorenzo Stoakes , "Liam R. Howlett" , Vlastimil Babka , Mike Rapoport , Suren Baghdasaryan , Michal Hocko , Frank van der Linden , Stefan Strogin , Dmitry Safonov <0x7f454c46@gmail.com>, Michal Nazarewicz , linux-kernel@vger.kernel.org, stable@vger.kernel.org Content-Transfer-Encoding: quoted-printable Message-Id: References: <20260520061025.3971821-1-songmuchun@bytedance.com> <55481a8b-dcfc-4bef-ba59-aa0b43dca88b@kernel.org> To: "David Hildenbrand (Arm)" X-Migadu-Flow: FLOW_OUT > On May 20, 2026, at 16:19, David Hildenbrand (Arm) = wrote: >=20 > On 5/20/26 08:10, Muchun Song wrote: >> cma_activate_area() can fail after allocating range bitmaps. Its = cleanup >> path frees those bitmaps, but only clears cma->count and >> cma->available_count. It leaves cma->nranges and each range's count = in >> place, so cma_debugfs_init() can still register debugfs files for an = area >> that never activated successfully. >>=20 >> That exposes two problems. Reading the bitmap file can make debugfs = walk a >> freed range bitmap and trigger an invalid memory access. Reading = maxchunk >> can also take cma->lock even though that lock is initialized only on = the >> successful activation path. >>=20 >> Fix this by creating debugfs entries only for CMA areas that reached >> CMA_ACTIVATED. >>=20 >> Fixes: c009da4258f9 ("mm, cma: support multiple contiguous ranges, if = requested") >> Fixes: 2e32b947606d ("mm: cma: add functions to get region pages = counters") >> Cc: stable@vger.kernel.org >> Signed-off-by: Muchun Song >> --- >=20 > Acked-by: David Hildenbrand (Arm) Thanks. >=20 > cma_sysfs_init() also traverses all cma_area_count. Does it make sense = to expose > them there? It is better to hide them from users. A separate cleanup patch is better = since there is no critical issue when accessing those sysfs files. Thanks, Muhcun >=20 > --=20 > Cheers, >=20 > David