From nobody Mon May 25 01:13:04 2026 Received: from mail-wm1-f43.google.com (mail-wm1-f43.google.com [209.85.128.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 755EE32B120 for ; Tue, 19 May 2026 23:05:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.43 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779231910; cv=none; b=AIAWWfFuyqxam3YPPDfufMEhRMG6L3rew2BZL9zivcc9HElxbceYT679AxGkRY1Hf7yoIl8omuXZmaC5Foodfow8P+QwSlvXW8Cs1g27uERgE/k1CXB34LWuu1GqTRIcztGlvCQVCsXyd/DjkHW0nSVQnUIb3zPF4dA4MN2AHuQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779231910; c=relaxed/simple; bh=kmljMs8Rf1PVvpETVY9rWE5evYqbcKNafcvaVomh9aU=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=cbhzPZ4nz8otyduyBcqe7Ay/iUzHwZGqCNZCFs6Munah/gKD/7VN6536S3RjmhvuJcwVxrTzpOS9pruN1cd5zn5REUiMvlaaO7w3AtB4K8Ii9+s1UWW0vSS9Wz+aW/ieoho660iiXNR9Qy4JSbTnjWr6PkDVkcOhnYoT0RqhrEE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=IeHnFgUy; arc=none smtp.client-ip=209.85.128.43 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="IeHnFgUy" Received: by mail-wm1-f43.google.com with SMTP id 5b1f17b1804b1-488af96f6b2so45365715e9.0 for ; Tue, 19 May 2026 16:05:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1779231907; x=1779836707; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=BL0u1dhtcx4RdNvWcLeas7d26YUbe0kObwGLJD5YkoQ=; b=IeHnFgUymFEHamfPbsJqgwAaKtIlKsImHI4VhxEDvEQiBYHFi9/ar0PRW98jkEwQlv 6PLM0KHbat6pYSOX9QzZLAheJZtXgew394XqbzEBEsVswFCQfFRUaUcnhi6q3Wnm/piD ESQNx5KwLbspeZKk07xZYM7W5q26iWEjlDhdHwHOAu1ckStcEyo6SJaWpz19tyrkJO02 D/THVJMet+pZbCQj6mgK/+COXG5fOflSMoCYpTjZ4h8A2vM1YPaCuW7yCqpGTMUaMK3S //Ah+lXX16rMEQjxDsxLZfNr4SOmN1jrLAiHzkajDUoftL6DAEHjG01mfTdJwJe9d+Nl mjFA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1779231907; x=1779836707; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=BL0u1dhtcx4RdNvWcLeas7d26YUbe0kObwGLJD5YkoQ=; b=mRJvACIMPyyQmM7WFDLEROoNFkv+ic00K6HbAIExJf/yvAkwbPOR38pb1PHFMH0m7v oB5IT1h58ocy26UCHb65hUHCiSsubD20h3vsdjtcxjF0WMH/GTLgGfeuKRSs+lq+MhJp vpJgOfnrazZtvDSYvMXMipgbqkJ3W2flm8h4l1G0aTJ7mgoKKDqHSjPOSs5b9767s1QK gBh9bWhycdV3ao4bsNU2zmzG3GfNAPQbUYLaMmEsIRqhOV5QpacwvYNkaXhf9/02MpP3 RDCj+89lHbaG8Ts+G08zRqBDwhlULxR7RBi+aF9M4+GT//9ddNlIoJGQugCwaZ5i/5bH mZdg== X-Forwarded-Encrypted: i=1; AFNElJ+toxtoWotIUw6aVTrj91uPM0r0ztGkX11d2In3kn+kn7CwwZ25594WPtA4whioMZpsUtw0XJ/DBIQtEzU=@vger.kernel.org X-Gm-Message-State: AOJu0Ywi06bV4pMvoRprWidv20Ywy2dTNnBK3xTiU/ff9IGDCLlH/cev mMOm3u8HtQC+WYjW3PjTmh6ysj5CO0k+sBzQ0+D23JDvtXdO3u0s9ZA1 X-Gm-Gg: Acq92OGlyn+NckbFobECBrmdM/Wn5mZuqG+RcmyX6liBAnEISTSIc68B6QHZysxOJyJ Q89pqsLG2sVXab8Pa4tr/8HCXS1rmBvQ90CbfUGsmoI0eBql01jb4c6C/UalHi5CQYEmmyWk3ar vcRcrWxNhj17hAa8WiblaJr4UJ0tQuXp4DJJBZ+u4903YngYXf98RAm+u61ah0gWNO+Qe6cT9Us HqDaTqtMdlIyziRq8Ywirkco6nZYknHFYtrtAPQhK1UrD/XjEAS/KKRFSBXx0RJSpnEqp5JTa3b +/T9JqAjJyE2ZnOJ7QcFrGbDaHKPG3r8IgySIO6aSdrRireHFZoLjrW9XqOzA1Zdot1NVEBniKa y3pEYyPcMml1vhxITXPmOfbSkkbDBoGqNOHKRYpEVACXppu0i8bvcoR6ezmIFx6GZexW2l+l/l8 /clugi6jRY0UNBvBeGWL38KhbXuSsfLoXiHPRXsDSjvR7js5sb1UbN6oIaF1nAydI+CnM7ACHO4 NGb8942x8c= X-Received: by 2002:a05:600c:3506:b0:485:40db:d40c with SMTP id 5b1f17b1804b1-48fe60e13d1mr327492765e9.3.1779231906632; Tue, 19 May 2026 16:05:06 -0700 (PDT) Received: from dohko.chello.ie (188-141-5-72.dynamic.upc.ie. [188.141.5.72]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-45da0fe0fecsm45197684f8f.26.2026.05.19.16.05.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 May 2026 16:05:05 -0700 (PDT) From: David Carlier To: akpm@linux-foundation.org Cc: muchun.song@linux.dev, 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, David Carlier Subject: [PATCH v2] mm/hugetlb: restore reservation on error in hugetlb_mfill_atomic_pte() resubmission path Date: Wed, 20 May 2026 00:05:03 +0100 Message-ID: <20260519230503.121293-1-devnexen@gmail.com> X-Mailer: git-send-email 2.53.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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. 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. Add the missing restore_reserve_on_error() call before folio_put(), matching the first-attempt error path which already handles this correctly. 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. Andrew, please drop the v1 currently queued as 270157aef0d1 in mm-unstable. v1: https://lore.kernel.org/all/20260322052120.14021-1-devnexen@gmail.com/ mm/hugetlb.c | 1 + 1 file changed, 1 insertion(+) 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); folio_put(folio); goto out; } --=20 2.53.0