From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E2ABC606A32C for ; Tue, 1 Dec 2026 14:56:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=jvDkykDo Received: by kanga.kvack.org (Postfix) id 0AAF96B05D5; Tue, 1 Dec 2026 09:56:59 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 082856B05D6; Tue, 1 Dec 2026 09:56:59 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id EDA9D6B05E0; Tue, 1 Dec 2026 09:56:58 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 88AF16B05D5 for ; Tue, 1 Dec 2026 09:56:58 -0500 (EST) Received: from smtpin10.hostedemail.com (lb01a-stub [10.200.18.249]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 2739C1A0DEA for ; Tue, 1 Dec 2026 14:56:58 +0000 (UTC) X-FDA: 85495716516.10.B1D4F08 Received: from sea.source.kernel.org (sea.source.kernel.org [172.234.252.31]) by imf17.hostedemail.com (Postfix) with ESMTP id 742CB4000A for ; Tue, 1 Dec 2026 14:56:56 +0000 (UTC) Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20260515 header.b=jvDkykDo; dmarc=pass (policy=quarantine) header.from=kernel.org; spf=pass (imf17.hostedemail.com: domain of ljs@kernel.org designates 172.234.252.31 as permitted sender) smtp.mailfrom=ljs@kernel.org ARC-Seal: i=1; a=rsa-sha256; d=hostedemail.com; s=arc-20220608; cv=none; t=1796137016; b=CTzsR7gSL1U5Q8hhxpgJaFd3yRmzvL61OEaxhOUXAGJuDW10LnPA7JpXhf06hw3U6xeFNB EUB8+H6oBL9bYKLuxVlw1CMswwUa+Wd9z2BCPQ+3b2Q0YI3RXhZFFseXNveVITGpUhRX7E yw78/d0YAFKZtHkYiHVr9dh+VumMVos= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1796137016; h=from:from:sender: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: in-reply-to:in-reply-to:references:references:dkim-signature; bh=sfnVH6Sbig37aqKOecsHiH6gHyI4uti3OowWjbnqEXk=; b=0di7xhI7oQ7DKm90pj0a9hbb7LAy9Q5s2WRoEW8vtrLLxEttAFPOphJXUGrGEvQlVRG3Zs RqU8aHt81j4sL6j5KjSPysgWdEts6HBcMWTzJ7F6dGuRoxFm/f3MPZjdpkPKZwdsemNX1G zqgf0hAjWRG/LRWaecVqxO2vhaN/hmQ= ARC-Authentication-Results: i=1; imf17.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20260515 header.b=jvDkykDo; dmarc=pass (policy=quarantine) header.from=kernel.org; spf=pass (imf17.hostedemail.com: domain of ljs@kernel.org designates 172.234.252.31 as permitted sender) smtp.mailfrom=ljs@kernel.org Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by sea.source.kernel.org (Postfix) with ESMTP id 9751A414F4; Tue, 1 Dec 2026 14:56:55 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 185E91F008A0; Tue, 1 Dec 2026 14:56:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796137015; bh=sfnVH6Sbig37aqKOecsHiH6gHyI4uti3OowWjbnqEXk=; h=Date:From:To:Cc:Subject:References:In-Reply-To; b=jvDkykDodCfCssytRSHvcxrEkXMPE3fL1Blke5HRSh1/C2yW7aThlOE5GzGwkOtBI q2lCYFE7ZS2SuOoIKnlFcBmtTal3H7cISN31UOOqr3QGwt1ayYAJo5ss1LOYToOLSM y1uPECfmMD1qALibcoTOJbbi6Zvtf2z1i7jV8H8fGvIwt3LklRe8Eymb3/4yxKrvyD +hwCoTgPt27kUc17UIdQmYfvovkHxQM8/KSkKG9sClte89kMXoq2LTOZBknfgxEpz3 uqtolKglcrV/OY+d1aWy3pGnUFPLKEdlNr+wlW3TbHjWGIygPoB+0GJDgGSP+6bJyR 5pn/kaTfDSkXQ== Date: Tue, 1 Dec 2026 14:56:49 +0000 From: "Lorenzo Stoakes (ARM)" To: "Mike Rapoport (Microsoft)" Cc: Andrew Morton , "Liam R. Howlett" , David Hildenbrand , Jann Horn , Noah Weinberger , Pedro Falcato , Peter Xu , Vlastimil Babka , linux-kernel@vger.kernel.org, linux-mm@kvack.org, stable@vger.kernel.org Subject: Re: [PATCH] mm/vma: undo userfaultfd unmap preparation when unmapping fails Message-ID: References: <20261101-uffd-unmap-abort-v1-1-1588d7a7c61a@kernel.org> X-Archived-By: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20261101-uffd-unmap-abort-v1-1-1588d7a7c61a@kernel.org> X-Stat-Signature: fqcapq4c7h5c4yehnndd15wotte3e1z9 X-Rspamd-Queue-Id: 742CB4000A X-Rspam-User: X-Rspamd-Server: rspam05 X-Spam-Status: No, score=-10.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,MAILING_LIST_MULTI,SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=4.0.1 X-HE-Tag: 1796137016-904459 X-HE-Meta: U2FsdGVkX1+w3XRor9FdQRZFK7pHW+OUEbE09McUGLwnQfPqL3//5Nw7+qFmoEoXPU2jP1x5CLlgsWTTyo+JUwSgIkGRohEB+a72b0paVl73RxLiyg2EkGqPWPyPj97B8AePJXYtYkbmVKBk8Y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4cLZbZYmfzgzI7CT0PcZpH2aPizbqztlftF6vSHcEC9Z68i2YNu3Jpw78pZuIH+ATQ6K+A9wezHjXNmjzw6I3+Bqfwf1uAQTNo49sHMHChLCot2aF1kJJgxJP3XnXtwgDXcnwX/bxxfhCXRQf1JlenU035zS9I/uNcS6oYMNnV5AgeenYXgeDixHR80+gbTyHZx5CgwhDXNJlPT92dme2R9dKkVfocgpjd0dVF6/V9cjjFixoPlsiE+jvhhq30JXvHpvHFgCVnvqi3c4VynOWl Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 On Sun, Nov 01, 2026 at 10:24:02AM +0200, Mike Rapoport (Microsoft) wrote: > vms_gather_munmap_vmas() collects VMAs to unmap and calls > userfaultfd_unmap_prep() for each of these VMAs. This takes a reference > to the userfaultfd context, raises ctx->mmap_changing and queues an > UFFD_EVENT_UNMAP on the caller's list. > > If gathering fails half way, e.g. because one of the VMAs is sealed, or > the operation fails after the VMAs were gathered, the original mappings > stay intact but the queued events remain on the list. > > Depending on the caller they are either delivered although nothing was > unmapped (munmap(), mremap(), mmap(MAP_FIXED)), or silently dropped > (brk()). In the latter case the userfaultfd context and the mm_struct it > pins are leaked and mmap_changing is never lowered, so UFFDIO_COPY, > UFFDIO_ZEROPAGE and all other ioctls that check mmap_changing fail with > -EAGAIN forever. > > With mseal() this is trivially triggered by an unprivileged process. Great... :) > > Collect the events in do_vmi_align_munmap() on a local list and splice > it to the caller's list only when the unmap completes, because mremap() > may already have events for earlier unmaps on that list. > > Drop the pending events with a new userfaultfd_unmap_abort() helper when > do_vmi_align_munmap() or __mmap_setup() fail. > > Fixes: 65ac132027a88 ("userfaultfd: fix regression in userfaultfd_unmap_prep()") > Reported-by: Noah Weinberger > Cc: stable@vger.kernel.org > Signed-off-by: Mike Rapoport (Microsoft) Ahem. I see this got merged already without any input from VMA people :) The AI slop wave is making the workload nearly unmanageable, so it's easy to miss stuff, you are welcome to nag though. This gets fixed next cycle when the VMA tree becomes independent, but let's try to avoid this for the remainder of the cycle please! I wonder if we could have avoided propagating this terrible linked list stuff here. But ah well, too late. Maybe not possible for a backport but would have been good to explore at least! -- Cheers, Lorenzo