From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 5FB7B381B1C for ; Thu, 9 Apr 2026 17:14:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775754893; cv=none; b=YGmq1rdvQ258UbKunon2z594a024pI0+Kro90qP9mT2NrvYtk/kW7bXYce2YL5nABDBRQ0ATJgdcSuPM/4F1o3uVWGfUJ4C++PZaBdwPHI7MFU3mdNe7+KqMLitZ42ixMlC8US/gvCu47pD3nM7NAwFYe9nJmHWIr9e5NZkSWVg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775754893; c=relaxed/simple; bh=3BChr3pIQsQ8PuJ7qEoL1q4y61ENqab/lZVBbI7+0ck=; h=Date:From:To:Cc:Subject:Message-Id:In-Reply-To:References: Mime-Version:Content-Type; b=G1T0U3xZ0xgStWXUPXW7wRauEjID0LTdE7hx6mx6ocRVtnxoqXs460LsyVJSjotsBOJr4n6C5BShp3ujEhPf7aV1NF1ulbfFBobPdWrVWC7DcaE/bLXn7H2bZmcGt5C4tOf4X/DVc8R87Thk9S5WZZEmKOacVvCl+kYmSyJ56Uc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.b=DgDpsfcx; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.b="DgDpsfcx" Received: by smtp.kernel.org (Postfix) with ESMTPSA id A61D9C4CEF7; Thu, 9 Apr 2026 17:14:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1775754892; bh=3BChr3pIQsQ8PuJ7qEoL1q4y61ENqab/lZVBbI7+0ck=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=DgDpsfcxzv5NSiLvN+IVMfiNmnB9+X62wNIrc5QZfF+yE4uKuz7UrX3dWxCV8BZ85 xB1WCcuNus+YVK4iAlGApK7T7XmbQLkfEE5He6IgNNO+8mjkRbg1tE+InusWEXbHzC PUDqWENRvR45tLlSdKZbp74J7G/sFOCy3gxUBDfo= Date: Thu, 9 Apr 2026 10:14:51 -0700 From: Andrew Morton To: "Vlastimil Babka (SUSE)" Cc: David Carlier , Mike Rapoport , Peter Xu , "Liam R . Howlett" , Lorenzo Stoakes , Jann Horn , linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v5] mm/userfaultfd: detect VMA type change after copy retry in mfill_copy_folio_retry() Message-Id: <20260409101451.66dcee85281b84f00c645ecb@linux-foundation.org> In-Reply-To: References: <20260409120653.290386-1-devnexen@gmail.com> X-Mailer: Sylpheed 3.8.0beta1 (GTK+ 2.24.33; x86_64-pc-linux-gnu) 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-Transfer-Encoding: 7bit On Thu, 9 Apr 2026 19:04:49 +0200 "Vlastimil Babka (SUSE)" wrote: > On 4/9/26 14:06, David Carlier wrote: > > mfill_copy_folio_retry() drops mmap_lock for the copy_from_user() call. > > During this window, the VMA can be replaced with a different type (e.g. > > hugetlb), making the caller's ops pointer stale. Subsequent use of the > > stale ops can lead to incorrect folio handling or a kernel crash. > > > > Pass the caller's ops into mfill_copy_folio_retry() and compare against > > the current vma_uffd_ops() after re-acquiring the lock. Return -EAGAIN > > if they differ so the operation can be retried. > > > > Fixes: 59da5c32ffa3 ("userfaultfd: mfill_atomic(): remove retry logic") > > I don't have such sha1, is it a stale mm-unstable commit? Seems to be > 4974a6aaa768 ("userfaultfd: mfill_atomic(): remove retry logic") now in > mm-unstable (and can further change) Yup. I queued this as a squashable fix "userfaultfd-mfill_atomic-remove-retry-logic-fix.patch". Against Mike's "userfaultfd: mfill_atomic(): remove retry logic", queued for 2nd week of he merge window. I'll remove that Fixes: tag - it changes every day and results in "invalid Fixes:" emails from Mark.