From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out-177.mta0.migadu.com (out-177.mta0.migadu.com [91.218.175.177]) (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 7853026FD9B for ; Wed, 20 May 2026 07:38:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.177 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779262710; cv=none; b=OqDOPE/2p2/LMf0Jx7IbssPYAE2+kk/SYN2d8VdW7a0bl666SdM/py71bIvpxkOmKfn1J4VvNITF0MpOe4i6C5DQv7OXNvLzy2brqbJ1PGaLxIr6MTE/+maQEqYXqGz/yb8ypxnI2vPX+oxMrAeryM/3fARj+2qTiKTqufoajZQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779262710; c=relaxed/simple; bh=W9Wf6+1EnvL4wZQtjY/HoofUXLpADwBl0zleq9Tdm84=; h=Content-Type:Mime-Version:Subject:From:In-Reply-To:Date:Cc: Message-Id:References:To; b=nv07NQHsPVHl8chQY21ja/3DtSowZ+3dwbPQBPo5DqVNFBpRLd9+jtlq4K7WFsjmq8YOKwCpoX3NnNLvv5ACRzXMsWkZBVr/9Iub34oJkXEPJgIVtfE70JW32PCR/xZIflhVaX84dOQlrF68Wv6VVOKjHeG1GoMWOKz5W2LpPAk= 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=guf+lFQy; arc=none smtp.client-ip=91.218.175.177 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="guf+lFQy" Content-Type: text/plain; charset=us-ascii DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1779262706; 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=W9Wf6+1EnvL4wZQtjY/HoofUXLpADwBl0zleq9Tdm84=; b=guf+lFQyC1RCTuzV3Otmw4kOpcCj/qPP9u1eo5RT962dqQXAvTE7BzDrn7qejVsyAwaWPI 4vM4H7zfd15REfct9cR5yZwiyQIf3V8R9/JS9Cz+BDABGc/MIrnH8PV+yvMzCcWIFLi8AU cMwZU9Ru850/P2jTlZlkrUIqjlR5ykE= 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: Date: Wed, 20 May 2026 15:37:43 +0800 Cc: Muchun Song , Andrew Morton , David Hildenbrand , 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> To: "Oscar Salvador (SUSE)" X-Migadu-Flow: FLOW_OUT > On May 20, 2026, at 15:27, Oscar Salvador (SUSE) = wrote: >=20 > On Wed, May 20, 2026 at 02:10:25PM +0800, 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 > For the change: >=20 > Acked-by: Oscar Salvador (SUSE) >=20 > About Fixes, does this mean that before c009da4258f9 ("mm, cma: = support > multiple contiguous ranges, if requested"), this was already = triggerable > after 2e32b947606d? c009da4258f9 introduced the invalid access to bitmap file. 2e32b947606d = introduced the invalid access to cma->lock. This change applies to both issues. So I added two Fixes tags. Thanks. >=20 >=20 > --=20 > Oscar Salvador > SUSE Labs