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 BDAC72253EB for ; Sun, 9 Aug 2026 14:25:42 +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=1786285545; cv=none; b=YrQASDj7C/SqofEkFlg5EGAp1lPMdNyYU6T/rMWRtUiaQn+Wb//4+7nDo7m3WE3d6etCjLk2tIuViYzmyiR6Ur5PYndQZJobF5DZG4884kdKTzcj5sDKBg+Y/Gfk4+JVO5qdBEGUuaxfDEJmrXzKySyC4Iy+fzkUUf8bE6kj6NY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786285545; c=relaxed/simple; bh=cYldKq2LszjwTTomAUJZVV4SO9q8ck8k/d6DnANtx9k=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=nteodK/Z6w7XIWy+2IMrx/Q61DuKzdv2IcCtw5ymzjJiA931Hnz2RoaNhGiWiAsRNeYr2qVysx494ShPlq7r1HdWcJVqZeXjmVoTC0C9P0TvC2PBDzs3+3IidvHaLTUy2B4uGevBsSB6TPWPFuWTDG4CrNMUKbaYun7QZFs4JUk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=VMy+Lg+b; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="VMy+Lg+b" Received: by smtp.kernel.org (Postfix) with ESMTPSA id D4AEA1F000E9; Sun, 9 Aug 2026 14:25:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1786285541; bh=+mUtOVgyzqDU/k3Pbcj2HKLEv+mxt8OFSMeHs/bRNlQ=; h=Date:From:To:Cc:Subject:References:In-Reply-To; b=VMy+Lg+bZfaZP8oorEjOei5gN0ErIP9YRQxC8p71GVD4YUPW8rQ8czAeQETBAcUee sBxZHH+PJh63GSlYQmHUww4cNgRqCvX3soypbcIzYZ54s/nef2TZmvR6638Vvl3Kpj liY8bwwM8rSQ97DWoGRwzL9CN3YeVH2y2+ddaXVPxTJsZpXb2uy3mhC/bq8d8q/IgK p3ceXktYG5V7bRYWW1JuHaC6HFUkOUXeb4FrCGQmAapAJawX7J7grmiXPPHamPZUyI PW0BFkZGq470qpfMYuiFI78hJAMlXLXV9qsU/VVoepqaolqLWZnX/C2lEPFZPYoXDs WuuXAVtB0P7pQ== Date: Sun, 9 Aug 2026 17:25:34 +0300 From: Mike Rapoport To: Jianhui Zhou Cc: akpm@linux-foundation.org, linux-mm@kvack.org, peterx@redhat.com, linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com, syzbot+18d274a59b87cf80e86d@syzkaller.appspotmail.com Subject: Re: [PATCH] mm/userfaultfd: clear uffd-wp PTE state when re-registering without WP Message-ID: References: <20260601082609.170076-1-jianhuizzzzz@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20260601082609.170076-1-jianhuizzzzz@gmail.com> On Mon, Jun 01, 2026 at 04:26:09PM +0800, Jianhui Zhou wrote: > UFFDIO_REGISTER can be issued on a range that is already registered in > the same userfaultfd context, replacing the VMA's userfaultfd tracking > mode. For example, a range can be registered with > UFFDIO_REGISTER_MODE_WP and later re-registered with > UFFDIO_REGISTER_MODE_MISSING. > > When the second registration removes VM_UFFD_WP, the VMA flags are > updated but existing uffd-wp state in page-table entries is left behind. > That stale state can survive in swap PTEs. On swapin, do_swap_page() > restores _PAGE_UFFD_WP from the swap PTE and can then install a writable > PTE, triggering page_table_check: > > pte_uffd_wp(pte) && pte_write(pte) > > Handle removal of WP mode through UFFDIO_REGISTER the same way as > UFFDIO_UNREGISTER: resolve the per-PTE uffd-wp state before dropping > VM_UFFD_WP from the VMA. > > Also make the same-context fast path require an exact UFFD mode match. > The old subset check treats MISSING|WP -> MISSING as a no-op, even though > WP mode is being removed. The recent RWP changes prevent re-registering to the same uffd with a mode that clears VM_UFFD_WP or VM_UFFD_RWP. See commit 6eab8f2cc646 ("userfaultfd: add UFFDIO_REGISTER_MODE_RWP and UFFDIO_RWPROTECT plumbing") in the mm tree. Andrew, can you please drop this patch from mm-unstable? > Fixes: f45ec5ff16a7 ("userfaultfd: wp: support swap and page migration") > Reported-by: syzbot+18d274a59b87cf80e86d@syzkaller.appspotmail.com > Closes: https://syzkaller.appspot.com/bug?extid=18d274a59b87cf80e86d > Signed-off-by: Jianhui Zhou > --- > mm/userfaultfd.c | 10 +++++++++- > 1 file changed, 9 insertions(+), 1 deletion(-) -- Sincerely yours, Mike.