From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out-171.mta0.migadu.com (out-171.mta0.migadu.com [91.218.175.171]) (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 DC5C846B5 for ; Wed, 20 May 2026 02:48:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.171 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779245339; cv=none; b=R4CvyeBlJsDggQnp1YkVqvSvq/n23rm7vCG+JLoApbYHnMaftlUrOsXe/6G2Re50qhu1GdCNz0kS+IKJ/KN9cfYkeWuyDtE6hWapIBd7b00ySL5elv62fbB67/rFYS3hi6Y4gq4Xg6bUOvKzlydzXiMRR32/TTG/X0ulhdyrG0Q= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779245339; c=relaxed/simple; bh=gsVfysqJMKHRA2McsoIlM4I/NhfXB6JBQhgaMzkkhAA=; h=Content-Type:Mime-Version:Subject:From:In-Reply-To:Date:Cc: Message-Id:References:To; b=s37N5na04weOvqQZDSkWia6ygCQmyzPwwt5wcYvGmKrgT5JwMFWroV5/U5jV7M2ElEgpZXt3ubsBwB2uaSoQys6WWDsefWcNvWH/qW/W4quzB/h+7dWzha723W+3TVhGCsqXTcpe/TStopPC6egWISKg01VFDUUFQXM2s1mRcy8= 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=iVWj2ar3; arc=none smtp.client-ip=91.218.175.171 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="iVWj2ar3" Content-Type: text/plain; charset=us-ascii DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1779245334; 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=yR5a/g6E0YQo8Yn47vVbWDxzDy8B4ttLwABPXqZO/PY=; b=iVWj2ar3W6DM9iZJ3unqUquzdYaVIuZfx+BLVyEnZvs2xAz49Un9DteKbYuYPovBK1eagB F1nWlqfJfQiojq7LeeHnSyGAT7ao4ZEvWlU7b5u4xd9e49Pe+8hGf1KCH6IrmWV2vr4jHy b52jkzG7DXAbiNevV1mhiZmnolBAjbA= 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 v2] mm/hugetlb: restore reservation on error in hugetlb_mfill_atomic_pte() resubmission path X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Muchun Song In-Reply-To: <20260519230503.121293-1-devnexen@gmail.com> Date: Wed, 20 May 2026 10:48:17 +0800 Cc: akpm@linux-foundation.org, david@kernel.org, almasrymina@google.com, osalvador@suse.de, yuehaibing@huawei.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org Content-Transfer-Encoding: quoted-printable Message-Id: <24F945C3-3A62-4250-909C-65D0CEB9F182@linux.dev> References: <20260519230503.121293-1-devnexen@gmail.com> To: David Carlier X-Migadu-Flow: FLOW_OUT > On May 20, 2026, at 07:05, David Carlier wrote: >=20 > When the resubmission path in hugetlb_mfill_atomic_pte() allocates a = new > hugetlb folio via alloc_hugetlb_folio(), a VMA reservation is = consumed. > If copy_user_large_folio() subsequently fails (e.g. -EHWPOISON when = the > source page is hwpoisoned), folio_put() restores the global hugetlb = pool > count through free_huge_folio(), but the per-VMA reservation map entry > is left marked consumed. >=20 > User-visible effect: on a UFFDIO_COPY into a private hugetlb VMA where > the resubmission path's copy fails, the reservation for that address = is > leaked from the VMA's reserve map. A subsequent fault at the same > address takes the no-reservation path, and under hugetlb pool pressure > the task is SIGBUSed at an address it had previously reserved. One map > entry is leaked per occurrence. >=20 > Add the missing restore_reserve_on_error() call before folio_put(), > matching the first-attempt error path which already handles this > correctly. >=20 > Fixes: 1cb9dc4b475c ("mm: hwpoison: support recovery from HugePage = copy-on-write faults") > Cc: > Signed-off-by: David Carlier > --- > v2: > - Add user-visible effects paragraph in changelog (per akpm, > required for Cc: stable). > - Correct Fixes: tag to 1cb9dc4b475c (per Muchun) -- the failing > arm only exists since copy_user_large_folio() became int-returning. >=20 > Andrew, please drop the v1 currently queued as 270157aef0d1 in > mm-unstable. >=20 > v1: = https://lore.kernel.org/all/20260322052120.14021-1-devnexen@gmail.com/ >=20 > mm/hugetlb.c | 1 + > 1 file changed, 1 insertion(+) >=20 > diff --git a/mm/hugetlb.c b/mm/hugetlb.c > index 4b80b167cc9c..c6dee98840db 100644 > --- a/mm/hugetlb.c > +++ b/mm/hugetlb.c > @@ -6270,6 +6270,7 @@ int hugetlb_mfill_atomic_pte(pte_t *dst_pte, > folio_put(*foliop); > * foliop =3D NULL; > if (ret) { > + restore_reserve_on_error(h, dst_vma, dst_addr, folio); I think you should fix the same problem in copy_hugetlb_page_range() within this patch as well since both are introduced by the same commit. Muchun, Thanks. > folio_put(folio); > goto out; > } > --=20 > 2.53.0 >=20