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 58D28396B7B for ; Mon, 30 Mar 2026 20:40:22 +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=1774903222; cv=none; b=SSIq6mzSTsfu5vUJmEtKqnireMqhXcdUb9e4oZHX/pDWlsent6GwgNEtyr/BHHXaG32IHVwrEE8l4R3NRb70xTCjKrjlXdcVO+U1/oWB/bWz/OImd1DUkwz9a1PPC5g5XyDaErEUuWiZWn4hpXwfxcXxHZGJsthqwgfy3W+TxSM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774903222; c=relaxed/simple; bh=K6QoBOHE7iajrxILRT8WbjPboIxXi6OCtQUz9pCgm4k=; h=Date:From:To:Cc:Subject:Message-Id:In-Reply-To:References: Mime-Version:Content-Type; b=HYLVe0P79m25Vr0xg/ZWvKNM7wTT8fFOsObZjFNF+eJlrhdiNRLx29aa2NGsulBiBBVDm/Y4pRQrfgEKymovuhjNMqP06Irrw6E3qmTIiVvFym9IDKdvV/1m5/a3VAyH+nwNMNBkO8b0zWRqmdU4S1+jRvIXdissmQ80dseegAE= 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=yzsqtF6j; 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="yzsqtF6j" Received: by smtp.kernel.org (Postfix) with ESMTPSA id B4997C2BCB0; Mon, 30 Mar 2026 20:40:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1774903221; bh=K6QoBOHE7iajrxILRT8WbjPboIxXi6OCtQUz9pCgm4k=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=yzsqtF6jiYGBZlz4SdvbqNPJcJ/LvRiQ3K68q2rH7j7zCoAMQNZxZ4k79hD7wIro3 qd9HFDL4FYBAT8IrxeShgzpg8M6E1cmVZy88IY9KhUuvHYeX37sCPVrZwSD1zYbJ3I dNQ1gqUG95rncu/NCCOLwrGEYMztox5TSdNqdSA4= Date: Mon, 30 Mar 2026 13:40:21 -0700 From: Andrew Morton To: David Carlier Cc: Peter Xu , Mike Rapoport , linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2] mm/userfaultfd: detect VMA replacement after copy retry in mfill_copy_folio_retry() Message-Id: <20260330134021.171441c4c236b03efebc9a77@linux-foundation.org> In-Reply-To: <20260330202909.136776-1-devnexen@gmail.com> References: <20260330202909.136776-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 Mon, 30 Mar 2026 21:29:09 +0100 David Carlier wrote: > In mfill_copy_folio_retry(), all locks are dropped to retry > copy_from_user() with page faults enabled. During this window, the VMA > can be replaced entirely (e.g. munmap + mmap + UFFDIO_REGISTER by > another thread), but the caller proceeds with a folio allocated from the > original VMA's backing store. > > Checking ops alone is insufficient: the replacement VMA could be the > same type (e.g. shmem -> shmem) with identical flags but a different > backing inode. Take a snapshot of the VMA's inode and flags before > dropping locks, and compare after re-acquiring them. If anything > changed, bail out with -EAGAIN. Thanks. What are the userspace-visible runtime effects of the bug? If they're serious we might be looking at a cc:stable and a Fixes: tag?