From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 E621948AE1E for ; Thu, 2 Jul 2026 12:52:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782996736; cv=none; b=SOXYoqamSHSWxL7cHOB5kqujzPekbfNfEXbtzlN5d3cDYK192MC1hv65wsj78O46gMh4b9cjdlPIdCdDbUtdHwwhudgPobRVNh2vHoV3dri3TezagHJEvte3u7D9gkveiuHLHsud1KLKGNzIciQxKJr2puLCkT8IbG+UxpWS/EY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782996736; c=relaxed/simple; bh=TNIZSrUCGqtcv3JcTYGDyzwzw4ZZP6IuSAzhk4lPDhM=; h=Subject:To:Cc:From:Date:Message-ID:MIME-Version:Content-Type; b=C0NYTcqumO8X15u8ZXQMkD8VtLds6qW0oT405qCuFi0jJOXeJRriD0KQELLTQhlnwoukF4nGUrXrC/OxLVRZRZrN4g5q9iVCxta4k3aFOkU8MNRK6F0o2qbwaucDADuj1Pb4eGFLmAAoMhBJCmqA6vn8WYonNgPAvw4WRPyVzgE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=z2i3UJh8; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="z2i3UJh8" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2C4481F00A3A; Thu, 2 Jul 2026 12:52:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1782996734; bh=z6+pZmNi4d8+3ZGhHe0btBNTchxi8lquSFBnDllFdaE=; h=Subject:To:Cc:From:Date; b=z2i3UJh8PH5/MG3Z/+UlqfCFKoZZPKyYdwko++GXaE/Jc08KwIGAl+0XtkYOrE+KH hMTTUJNpQIvzvMcyKYXALQNyb2JBXQEfnqs13HzcKeoD8VmeLZ1Jx1QO6mcGb32sLh 4fZH7jGreu3t8uGuc3A3UyFzTYxmPpEsm9EUJjL0= Subject: FAILED: patch "[PATCH] userfaultfd: ensure mremap_userfaultfd_fail() releases" failed to apply to 6.6-stable tree To: rppt@kernel.org,akpm@linux-foundation.org,brauner@kernel.org,david@kernel.org,jack@suse.cz,peterx@redhat.com,stable@vger.kernel.org,viro@zeniv.linux.org.uk Cc: From: Date: Thu, 02 Jul 2026 14:52:12 +0200 Message-ID: <2026070212-rebate-record-0f74@gregkh> Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=ANSI_X3.4-1968 Content-Transfer-Encoding: 8bit The patch below does not apply to the 6.6-stable tree. If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to . To reproduce the conflict and resubmit, you may use the following commands: git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-6.6.y git checkout FETCH_HEAD git cherry-pick -x 0496a59745b0723ea74274db16fd5c8b1379b9a9 # git commit -s git send-email --to '' --in-reply-to '2026070212-rebate-record-0f74@gregkh' --subject-prefix 'PATCH 6.6.y' 'HEAD^..' Possible dependencies: thanks, greg k-h ------------------ original commit in Linus's tree ------------------ >From 0496a59745b0723ea74274db16fd5c8b1379b9a9 Mon Sep 17 00:00:00 2001 From: "Mike Rapoport (Microsoft)" Date: Wed, 13 May 2026 11:14:16 +0300 Subject: [PATCH] userfaultfd: ensure mremap_userfaultfd_fail() releases mmap_changing Sashiko says: mremap_userfaultfd_prep() increments ctx->mmap_changing to stall concurrent operations, but mremap_userfaultfd_fail() does not decrement it before dropping the context reference. If an mremap operation fails, ctx->mmap_changing remains elevated. This will causes subsequent userfaultfd operations like a UFFDIO_COPY to fail with -EAGAIN. Decrement ctx->mmap_changing in mremap_userfaultfd_fail(). Link: https://sashiko.dev/#/patchset/20260430113512.115938-1-rppt@kernel.org Link: https://lore.kernel.org/20260513081416.495963-1-rppt@kernel.org Fixes: df2cc96e7701 ("userfaultfd: prevent non-cooperative events vs mcopy_atomic races") Signed-off-by: Mike Rapoport (Microsoft) Reviewed-by: David Hildenbrand (Arm) Cc: Al Viro Cc: Christian Brauner Cc: Jan Kara Cc: Peter Xu Cc: Signed-off-by: Andrew Morton diff --git a/fs/userfaultfd.c b/fs/userfaultfd.c index 4b53dc4a3266..390e4b7d9cb9 100644 --- a/fs/userfaultfd.c +++ b/fs/userfaultfd.c @@ -786,6 +786,8 @@ void mremap_userfaultfd_fail(struct vm_userfaultfd_ctx *vm_ctx) if (!ctx) return; + atomic_dec(&ctx->mmap_changing); + VM_WARN_ON_ONCE(atomic_read(&ctx->mmap_changing) < 0); userfaultfd_ctx_put(ctx); }