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 C896D3C5DBE for ; Thu, 9 Apr 2026 18:12:34 +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=1775758354; cv=none; b=Umcdpzby0vIm85Wr2xhVGbjvxXUzZqitvss5nuk8CJlV0lcE1yMn1XCOuhrNA5pX9IamoGbRnd7AvmkB43C2QiPlU0iBCpTYNo6PGWruTb5onwpgtpCQ4/gzEwuOnig1WfULgG6Ki6T7XMhePyaObTkpGVC4/HWTcco/xtZkw7o= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775758354; c=relaxed/simple; bh=gcApZAdBePxG8cWm/tm+Oc6ad9GPWAlW6Va4NZC3jW0=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=amS8LW/6v6sCru2SkIEdBwIkoCLeE9iXtsz8MCiRgtSyh8bJuSF7TLxMWg7HSXO4iuT066+gxV2ikwZI0di2PjaD2rbqFSqkYr2jX5tqnRsb5H235pBTi2FR4FiJfRVBMnegfUOEyOWbd0GvATfOEtVM9Nlk1jVRaBxy1iGtmaM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=XZB+gt1h; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="XZB+gt1h" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 60A26C19424; Thu, 9 Apr 2026 18:12:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1775758354; bh=gcApZAdBePxG8cWm/tm+Oc6ad9GPWAlW6Va4NZC3jW0=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=XZB+gt1huoeyJXJMf+p7UwRj6HsC/FbEy7qDkwD5ZUGfQ127x36eeMNORElkDhlWW EsiTvceg0xAtxiVpe12HgsCQHniaF0JL2nWrf+0/h5qykNkkKsu9HlaTx6MfoWWv9V Ul1ARvPVql//ctwHzw2xatqCy3LFLujevTXXG7Z5cv6EuRM/e8BW2R3M+XvQ1C7F1c RSsSoF5jgAw/KbMM8GQzF6R41ANa1hp/L4SQv7K+XkrDLve192cWb/yDkk9vtxR9tb AtwuC0p6/HReEzEgQcoJahUaQ6svxKToJ4yrtlNOVXAAFutcI2X6YTHzqcCzOVagOm GJHhcCFXLywoQ== Date: Thu, 9 Apr 2026 21:12:27 +0300 From: Mike Rapoport To: Peter Xu Cc: David Carlier , Andrew Morton , "Liam R . Howlett" , Lorenzo Stoakes , Vlastimil Babka , 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: References: <20260409120653.290386-1-devnexen@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: On Thu, Apr 09, 2026 at 01:09:41PM -0400, Peter Xu wrote: > On Thu, Apr 09, 2026 at 01:06:53PM +0100, David Carlier wrote: > > @@ -465,6 +467,14 @@ static int mfill_copy_folio_retry(struct mfill_state *state, struct folio *folio > > if (err) > > return err; > > > > + /* > > + * The VMA type may have changed while the lock was dropped > > + * (e.g. replaced with a hugetlb mapping), making the caller's > > + * ops pointer stale. > > + */ > > + if (vma_uffd_ops(state->vma) != ops) > > + return -EAGAIN; > > I agree with -EAGAIN here, but we discussed over all the things on possible > inode change and I don't know why we don't consider that. > > I still think those should be considered. > > If the vma snapshot idea is not welcomed, fine. We need to think of > something to cover those too. Current patch won't cover "ops unchaged" but > "inode changed", or offset changed, for example. This patch is enough to fix the regression introduced by my refactoring. The inode/file/vma_snapshot checks are needed to solve the issue that existed roughly for a decade. This should be a separate patch and it's really not urgent. > Thanks, > -- > Peter Xu > -- Sincerely yours, Mike.