Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796087481; b=y/qbSFafush9kwx8MQo0RsecN7d5MzGqFmSeI6MByyPNGVgm54yXpbd0CGKaVgNnomzS +KXihb1vJhGEdeGa1GzQdiNnQJ4kxq644sOmWde7EzK/+n/8e4IaRFB4lh0O1bQMAu0Ls Ols1qg377/5PQjaJxm6077rYToFPg6GVOhk+9vaemmRzq3IBL4rj7uenDBqnNaLStcyyN UxEPGMjvr6v42Kk8gXk0zg75iZEFasYbP/Z8MGUfJeZcxt5mPolImRxZLd9TwfBCeYygp jci12YuRgq3nfKWPgPmL3GYpKG9IM10OGys6TRWdU0UFIPF6UQliGfJNMiiIDYGqbKQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796087481; h=Received:DKIM-Signature:Date:To:From:In-Reply-To:References:Subject: Message-Id; bh=ka9Vb3fTgSIUX1XRx4RoqiKslSXJ3DffF6sdBM9ksv4=; b=Nr5B97s4IxPIzhIUDWb8ybThM5JBvruZ2Dp/jadq36STiQ05dMeEygszkmwPJlhbZo4s kte1Xg/TGhDqZXClQc1m/IjKIp7UUazAy1olNyEX7BGGxsQ2zbEZFSdUlMBahrj/PAqEJ tc/j1lK/9dsvC2ZJ3IXUqy68H05ZKfOpm2VMOOXiffFcYMscqo8lWQWE30ujOVDkSnr70 RGgq/5ZtZdPiOalt08O5J4G1EZe4Db/MpACUYL/gAJAaijhXSQ2/eNQP4PP4oyVm8r+90 O+R7dd+Al/ZuxM0dlix7+StDX5HFl/OR15ZbiTpoyeCI/NF7/eWPlhbY5B2OBhaoH1w== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linux-foundation.org header.i=@linux-foundation.org header.a=rsa-sha256 header.s=korg header.b=pikQS82q; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A84BF606A31A for ; Tue, 1 Dec 2026 01:11:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.a=rsa-sha256 header.s=korg header.b=pikQS82q Received: by smtp.kernel.org (Postfix) with ESMTPSA id 438F01F00893; Tue, 1 Dec 2026 01:11:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=korg; t=1796087481; bh=ka9Vb3fTgSIUX1XRx4RoqiKslSXJ3DffF6sdBM9ksv4=; h=Date:To:From:In-Reply-To:References:Subject; b=pikQS82qqpGA/TMuXlWttKad8VPLttck3SAm8t00w3/XmrqvUg43v9Ah8i62tiU1g js6ObzpA4dPzMirmWcEQHwcFejlw+lpZeCAcYryuNQLEpWxPUhDgiRdbtfVJ3TmZ4b 8GticlfbNNvjLOEXowVmgHRZJpvxROT5z6ui4siE= Date: Mon, 30 Nov 2026 17:11:20 -0800 To: mm-commits@vger.kernel.org,rppt@kernel.org,peterx@redhat.com, david@kernel.org,azpijr@gmail.com,mason@kernel.org,akpm@linux-foundation.org From: Andrew Morton In-Reply-To: <20261129-fixes-uffd-fork-acct-v1-1-f39cc449d92c@kernel.org> References: <20261129-fixes-uffd-fork-acct-v1-1-f39cc449d92c@kernel.org> Subject: + mm-userfaultfd-account-memory-allocated-for-unmap-events.patch added to mm-new branch Message-Id: <20261201011121.438F01F00893@smtp.kernel.org> X-Mailing-List: mm-commits@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list The patch titled Subject: mm/userfaultfd: account memory allocated for unmap events has been added to the -mm mm-new branch. Its filename is mm-userfaultfd-account-memory-allocated-for-unmap-events.patch This patch will shortly appear at https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/mm-userfaultfd-account-memory-allocated-for-unmap-events.patch This patch will later appear in the mm-new branch at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm Note, mm-new is a provisional staging ground for work-in-progress patches, and acceptance into mm-new is a notification for others take notice and to finish up reviews. Please do not hesitate to respond to review feedback and post updated versions to replace or incrementally fixup patches in mm-new. The mm-new branch of mm.git is not included in linux-next If a few days of testing in mm-new is successful, the patch will me moved into mm.git's mm-unstable branch, which is included in linux-next Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/process/submit-checklist.rst when testing your code *** The -mm tree is included into linux-next via various branches at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm and is updated there most days ------------------------------------------------------ From: Chris Mason Subject: mm/userfaultfd: account memory allocated for unmap events Date: Sun, 29 Nov 2026 18:25:07 +0200 Patch series "mm/userfaultfd: fixes for unmap and fork events". These are two small fixes for userfaultfd events. The first patch charges the memory allocated for unmap events to a memory cgroup, so that these events can't be abused to bypass memcg memory limits. The second patch fixes a purely theoretical deadlock in the handling of fork events. So many unlikely things have to happen at the same time that it's hard to imagine anybody hitting it in real life, but it's easy to fix. This patch (of 2): When memory registered with UFFD_FEATURE_EVENT_UNMAP is unmapped, userfaultfd_unmap_prep() allocates a small structure for each userfaultfd context that should be notified. These structures are usually freed only after the monitor reads the events, so userspace controls how many of them are allocated and how long they stay around. They are allocated with GFP_KERNEL, so this memory is not charged to any memory cgroup and memory cgroup limits don't apply to it. Use GFP_KERNEL_ACCOUNT to charge this memory to the memory cgroup of the task that does the unmap. When the memory cgroup reaches its limit, the allocation can now trigger reclaim or the OOM killer there. If the charge fails, it is handled in the same way as any other failure of this allocation. [rppt@kernel.org: rewrote the changelog] Link: https://lore.kernel.org/20261129-fixes-uffd-fork-acct-v1-0-f39cc449d92c@kernel.org Link: https://patch.msgid.link/20261129-fixes-uffd-fork-acct-v1-1-f39cc449d92c@kernel.org Fixes: 897ab3e0c49e ("userfaultfd: non-cooperative: add event for memory unmaps") Signed-off-by: Chris Mason Signed-off-by: Mike Rapoport (Microsoft) Signed-off-by: David Hildenbrand (Arm) Signed-off-by: Andrew Morton Reviewed-by: David Hildenbrand (Arm) Reviewed-by: Jose A. Perez de Azpillaga Cc: Peter Xu mm/userfaultfd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/mm/userfaultfd.c~mm-userfaultfd-account-memory-allocated-for-unmap-events +++ a/mm/userfaultfd.c @@ -3267,7 +3267,7 @@ int userfaultfd_unmap_prep(struct vm_are has_unmap_ctx(ctx, unmaps, start, end)) return 0; - unmap_ctx = kzalloc_obj(*unmap_ctx); + unmap_ctx = kzalloc_obj(*unmap_ctx, GFP_KERNEL_ACCOUNT); if (!unmap_ctx) return -ENOMEM; _ Patches currently in -mm which might be from mason@kernel.org are mm-swap-fix-large-swap-in-across-swap-file-extents.patch hugetlbfs-do-not-grow-a-sealed-file-in-mmap.patch mm-hugetlb-keep-surplus-folios-that-are-reserved.patch mm-hugetlb-fix-reservation-leak-on-min_size=-mounts.patch mm-cachestat-count-each-page-only-once.patch mm-cachestat-restart-the-walk-after-each-entry.patch percpu-queue-the-balance-work-on-an-unbound-workqueue.patch mm-vma-fix-uncharge-after-failed-stack-relocation.patch mm-mremap-apply-the-mmap-offset-limits-on-expansion.patch mm-mremap-respect-guard-gaps-on-in-place-expansion.patch mm-vma-make-brk-mappings-non-executable-under-mdwe.patch mm-hmm-refuse-secretmem-vmas-in-hmm_range_fault.patch mm-mglru-count-all-generations-as-evictable.patch mm-mglru-test-pg_lru-before-taking-a-folio-reference.patch mm-mglru-report-root-reclaim-to-memorypressure_level.patch kfence-use-a-nofault-store-to-zero-the-guard-page.patch mm-hugetlb-fix-truncated-copy-result-in-uffdio_copy.patch hugetlbfs-fix-deadlock-between-hole-punching-and-memory-failure.patch hugetlbfs-recheck-the-vma-range-after-the-lock-wait.patch mm-hugetlb-dont-zap-non-present-entries-when-unmapping-a-folio.patch mm-hugetlb-unshare-pmds-of-a-split-vma-if-allocating-its-lock-fails.patch mm-hugetlb_cgroup-track-in-use-folios-per-cgroup.patch hugetlbfs-seal-shm_hugetlb-files-against-growth.patch mm-hugetlb-resolve-protnone-faults-without-a-uffd-bit.patch mm-filemap-update-the-folio-order-range-atomically.patch mm-userfaultfd-account-memory-allocated-for-unmap-events.patch mm-userfaultfd-drop-fork-context-reference-outside-event_wqhlock.patch