From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) (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 9EAA741C62 for ; Tue, 19 May 2026 21:34:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.168.131 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779226482; cv=none; b=C1ooSvDYMRUg0VJTdoZeeKq/WQcsQw7GPKomlHar65ihNKPfFlll4AOrEHxbnLQf1D6h3URaWLrUzuo8fG6yTUJY0Yco8LWmedPsVtGZK1tzj2BJ35WaOktb9QbktqmRKRh8mf+F+d1xepgpDkxFgeMkJPjz3U6Z62XnKH+IAEQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779226482; c=relaxed/simple; bh=E1sHCyblrk7BJl7Dj8sMzoANqsn0uVEMsM3jmhvZQdU=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=s2RLe9S2DKzqudPqGm8CQu+9mguBUPvNL9M/aRQCqri3CC3+Q4EO/raDM1dCDP9kJIeX6yquIkDVQ1TGHlCKboysbwTT7l8aTujzHtEHYypBCwnLhy2HQKJQpze/3R4SGnwIqck0x8WL/jOwqQLooD4o6e+Zese+GPfT5Wzrit0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oss.qualcomm.com; spf=pass smtp.mailfrom=oss.qualcomm.com; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b=FPDGbx0T; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b=BHjdr4il; arc=none smtp.client-ip=205.220.168.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b="FPDGbx0T"; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="BHjdr4il" Received: from pps.filterd (m0279862.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 64JEx5qX2868052 for ; Tue, 19 May 2026 21:34:35 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=qcppdkim1; bh= VDn4qGggayMUbM2m3q+lfb9GiCRfeMM4D3/Bti+Y/68=; b=FPDGbx0TuXRy5ByC aCnLH69AqWtqKU0ZeYV2Mz1Ff+ymL1ypchmygcp/NXSBhhcbVOHDdrujTXkaTnQu QTG27uEWjq/j0GPled3OiBWUk3Mff18opD4MMsyt3p7wE4mdv/fEDGSjXYmMKM11 KZKZVgGDN6N2+N5Qw0Rlv/RlU3YNXN2FAXZWC2CV6oAGgUM8jljG9qUM3QPouv+9 a3OslV8v0u6xIs12ZxpO4AlGGc9iCySIeDXMLWU6N7h4R8Ja1E8+koWYHIwqqTH7 7x9wOHwSA/VAxMC0UbejwlQ3wEeNs7v2Y7dEmIFzVEpzsPwr6woMSVr6k44gd3e/ zHyBLg== Received: from mail-dy1-f200.google.com (mail-dy1-f200.google.com [74.125.82.200]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4e8t3w9kdf-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Tue, 19 May 2026 21:34:35 +0000 (GMT) Received: by mail-dy1-f200.google.com with SMTP id 5a478bee46e88-30230e64087so4765983eec.0 for ; Tue, 19 May 2026 14:34:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1779226474; x=1779831274; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=VDn4qGggayMUbM2m3q+lfb9GiCRfeMM4D3/Bti+Y/68=; b=BHjdr4ilI6uJff+7X3tqF4sc7+gkQQICg5MQHZSjRX9amp3BqCQayhiPKoeJ57hwOy Y+GSyhNuZYZQt8RKxjC1b72IjHjbchTB+jBVondpIyl0JnQ58tu+q+XgziZq8Uov/Tza xW+wOQueyBaVS4FI596wZ0VEVM/BVZbN66xm0oh5ZzlYGK7WZESNNsFlEz5ezDi3JcnZ s83Mvm29O39x/y1ZiXoQwK2nrQEYRtD1ZCIDPLbBuuF9noj7kId+FiQwNyzUDnhF64IR DpJx0rL33Z4eJjSj6yC2+7UORlguNLBUZiIYGAGtdXrlENXMHxwgIESIlaUH/9ROkqvO hQKg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1779226474; x=1779831274; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=VDn4qGggayMUbM2m3q+lfb9GiCRfeMM4D3/Bti+Y/68=; b=NQe1Nkxj8JqL2LyzhKDQCH1+ocZzbQdEiiLlKH6kg0E1ZCLLRhwftijf7teQMHavzc bHbyMNs1d7Pw6VU8KCD0BfYPcDcbSPJYgCwAxC2yh8cPubHsPYaDnf8qS/3Ih6EsAm4z pFgYSP6HVeL25/vevo8iMC4Y9EnRSvEMH4mt1KkCSfcHKrtlAO3MM0ZrAk7SBgThG6M4 5HU10Tc0TSfP48TWBqhD6rT4t+sos2m0JIBedpfHFjUyrfsTQ96GjsBmac9drzJ+fZWh EmGG3Blu+skuCiYAhYe0fMJOvCLxOJK3YvoDD53e4hk05xKc/UFf8I34K9uM70tLZm4x iM6g== X-Forwarded-Encrypted: i=1; AFNElJ9bC12Ly/UTw90Pg2UDYGSGqQUP1lKeEoikTG71MD0CkXiK781tKKdk3aX3kJjzRhK3U4ZKcCN5IggAR0I=@vger.kernel.org X-Gm-Message-State: AOJu0Yw6EmB1zxNShRbbmvp1YbCmENXTkngbmup1Ap/exv/G2H3mMYMO heFr9Zw+LgY0TEzXxEtyhO+BjLyAxp7FKMtJGPVuCiXpGxT4dUy1gJHWzYKCICthDrKsm3lOoW3 BW4Z2QkPiLN5Pti51CaTpascHwTO4ABuMCM8HrTJgJSKiggJkc7K0p6G2rXsG7asMmqE= X-Gm-Gg: Acq92OFEGAValtaxEHRvmlGBxqqaOZeEiAikn8zNy4OkhRhgipv7h04eowdGab4743Q qkXql3pbkKgHfqrJy/J9B52wS1F5mi6sjnBOl0KGP+KfZoQwBK2L0qNPSkqGw8v6PePOUeUUdaH XWi2VFZrhH1uoqAbAQppqKU9RD5jjWrV4Y4RCXaqNY1+6ZphISOLd5aof4F7EgT/E5lVqYDGx+f kjdgGP4EjyE7soDFBqmrnmJZJ1bzEjmJJM4R4eFuFPVOaiFOBSlNfYU+/ewAziIi9vAKxS2tfS+ o0lgRydJC4DLq+1Q9Tloz/olFStlJedk27PXLHEvnKvmPHDbzQCWn7dRL/TlRMJNDl6B0iq5w8G D2vzWAlIUro5ZbjHE1sUAxkMdxO0cSit+0eCx0YLrmRNHWeTKUHg+ X-Received: by 2002:a05:7301:19ae:b0:304:13f3:e461 with SMTP id 5a478bee46e88-30413f4159bmr584072eec.3.1779226474502; Tue, 19 May 2026 14:34:34 -0700 (PDT) X-Received: by 2002:a05:7301:19ae:b0:304:13f3:e461 with SMTP id 5a478bee46e88-30413f4159bmr584047eec.3.1779226473901; Tue, 19 May 2026 14:34:33 -0700 (PDT) Received: from [192.168.0.31] ([212.5.153.243]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-302973bc9d4sm16873423eec.23.2026.05.19.14.34.28 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 19 May 2026 14:34:33 -0700 (PDT) Message-ID: <35028dcc-3bb1-4e76-b471-183f319a7f46@oss.qualcomm.com> Date: Wed, 20 May 2026 00:34:25 +0300 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v8 2/6] mm/memory_hotplug: Fix incorrect altmap passing in error path To: Muchun Song , Andrew Morton , David Hildenbrand , Muchun Song , Oscar Salvador , Michael Ellerman , Madhavan Srinivasan Cc: Lorenzo Stoakes , "Liam R . Howlett" , Vlastimil Babka , Mike Rapoport , Suren Baghdasaryan , Michal Hocko , Nicholas Piggin , Christophe Leroy , aneesh.kumar@linux.ibm.com, joao.m.martins@oracle.com, linux-mm@kvack.org, linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org References: <20260428081855.1249045-1-songmuchun@bytedance.com> <20260428081855.1249045-3-songmuchun@bytedance.com> Content-Language: en-US From: Georgi Djakov In-Reply-To: <20260428081855.1249045-3-songmuchun@bytedance.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNTE5MDIxNCBTYWx0ZWRfX1nbGlPhS8+0A HR33KL2Ud8jRWWt9oc5jSAVSf0FF7WS7zPQDcjxMUrjTk6kdXY03TBsT2xORCq/+lvTy37cmsDM BhTuzqBGwFcqyfoKp3Y+XeG+0xzyenRBhE8RIaGn3TpYPTOA/Gpu1g2ScVuWyw+n9RJGpbmEdJl rk67jaWK0xrm2q3PPJ0dlbAAzL66+MTMBN8RFeSgqIt02ZmVYyRsMBO9hgQdkbuVM7k41BrAxg2 s7pAJ+zZcL2XRVj1veQY6l0SB5PDBib1ghrODWquOUR3GtxWuYsGJEeOhFYWh2KiouDEYEpn8WN rHXSzxzvsxGKLwmAsABPsId6Dx3Irpj2/cxOOvCnJoq7g8Oc747ApVXJic0dzDnw9UN4uPTsImw 1XOzG4rUzpWXDhycgpkBStsK9FFUNlfoar0VJKei5eKk3UNyFuEi0R30QwWPEGl7a1VguQubIDs LNMqLCVPu3O5xwG2+mQ== X-Authority-Analysis: v=2.4 cv=Q/viJY2a c=1 sm=1 tr=0 ts=6a0cd76b cx=c_pps a=PfFC4Oe2JQzmKTvty2cRDw==:117 a=douLNevBrtimd63D7eljNA==:17 a=IkcTkHD0fZMA:10 a=NGcC8JguVDcA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=_K5XuSEh1TEqbUxoQ0s3:22 a=VwQbUJbxAAAA:8 a=968KyxNXAAAA:8 a=EUspDBNiAAAA:8 a=cJIYO2twRcDUUobFbVwA:9 a=QEXdDO2ut3YA:10 a=6Ab_bkdmUrQuMsNx7PHu:22 X-Proofpoint-GUID: t7wjn529F_20ZUASHtD9714G7qCMvojd X-Proofpoint-ORIG-GUID: t7wjn529F_20ZUASHtD9714G7qCMvojd X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.51,FMLib:17.12.100.49 definitions=2026-05-19_05,2026-05-18_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 adultscore=0 impostorscore=0 priorityscore=1501 suspectscore=0 spamscore=0 clxscore=1011 phishscore=0 bulkscore=0 lowpriorityscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2605130000 definitions=main-2605190214 On 4/28/2026 11:18 AM, Muchun Song wrote: > In create_altmaps_and_memory_blocks(), when arch_add_memory() succeeds > with memmap_on_memory enabled, the vmemmap pages are allocated from > params.altmap. If create_memory_block_devices() subsequently fails, the > error path calls arch_remove_memory() with a NULL altmap instead of > params.altmap. > > This is a bug that could lead to memory corruption. Since altmap is > NULL, vmemmap_free() falls back to freeing the vmemmap pages into the > system buddy allocator via free_pages() instead of the altmap. > arch_remove_memory() then immediately destroys the physical linear > mapping for this memory. This injects unowned pages into the buddy > allocator, causing machine checks or memory corruption if the system > later attempts to allocate and use those freed pages. > > Fix this by passing params.altmap to arch_remove_memory() in the error > path. > > Fixes: 6b8f0798b85a ("mm/memory_hotplug: split memmap_on_memory requests across memblocks") > Cc: stable@vger.kernel.org > Signed-off-by: Muchun Song > Acked-by: David Hildenbrand (Arm) Reviewed-by: Georgi Djakov > --- > mm/memory_hotplug.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c > index 4426abb05655..e3352284f635 100644 > --- a/mm/memory_hotplug.c > +++ b/mm/memory_hotplug.c > @@ -1469,7 +1469,7 @@ static int create_altmaps_and_memory_blocks(int nid, struct memory_group *group, > ret = create_memory_block_devices(cur_start, memblock_size, nid, > params.altmap, group); > if (ret) { > - arch_remove_memory(cur_start, memblock_size, NULL); > + arch_remove_memory(cur_start, memblock_size, params.altmap); > kfree(params.altmap); > goto out; > }