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 4EF5130F92E for ; Thu, 28 May 2026 07:33:19 +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=1779953600; cv=none; b=XLifueHn/MQS0+QhgdEubzuAVpArj0gyoYXquU6Cict6iOX/3L0tL5ZUUA2BjjaL7FMcLEMv9OY4NOqnENWCoKT4JHawPRLUJEoPzMTBXlUxWMJ/DU/bgnDPR5b1myEPxZ45neVcVwqy4yd2QiA7BWQdcP33MQAAndGNimo5Rj8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779953600; c=relaxed/simple; bh=yvY+e4/rS7+9H/soDSAl2fHxR3+QPIO2QxdXeBVGtN8=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=GIldRwXVQaCh83eHfYovGmBRxDQ7Rb3dFh6F7wnyM953nHCcVMfqQFe7z6ea/xXxdzzEvAE2RJxjVVHzd/kttJBuwq2w/l/soVHe9bEkvmHPEZMiU3RCuMSpoLQqrbUpBEfg9NrbejRklYTrVWIJ7fPioOVRKisuxCme+IpwZng= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=EAjbWHGO; 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="EAjbWHGO" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 92BB61F00A3A; Thu, 28 May 2026 07:33:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1779953598; bh=YDa9wMSfYYNphGeMQHvqmiXt3L8QPz7i/ws9GTBQqJk=; h=Date:From:To:Cc:Subject:References:In-Reply-To; b=EAjbWHGO1NgmGqsUhE0AvTIokCQTquUZ9eFHAjOZlVY0tv6GU+4QHLFfviiSa80dB zOmmonUwUB+W0k9sjSJOGT9JJ0emB4jEuPNPsufcatNlK6IZxE0kF0DfulzjvHkyOu Agy1rkd+6er2HXtxNSc5s6y+2U4AfFKZQQ3s9+UGNm7q3CtsDKJRFM7nIcZOStAfUU C1XzUp5SoyEX9vZ7/FK9OP/EcHXwadC2JpufQAXo6dsuYwbaTYOdoZMa1wouJofqA3 JQ0z/FAlENAx602rKk/4uP42RhkTBw9eMwwQZh3r9nR2mbAXCpoJ7Vc9vejrbAE8WC hDEYgTWmWk7Wg== Date: Thu, 28 May 2026 10:33:12 +0300 From: Mike Rapoport To: David CARLIER Cc: Andrew Morton , David Hildenbrand , Heechan Kang , "Liam R. Howlett" , Lorenzo Stoakes , Michael Bommarito , Peter Xu , linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2 2/3] userfaultfd: refuse to __mfill_atomic_pte() for unsupported VMAs Message-ID: References: <20260527184751.4147364-1-rppt@kernel.org> <20260527184751.4147364-3-rppt@kernel.org> 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 Wed, May 27, 2026 at 08:09:01PM +0100, David CARLIER wrote: > Hi, > > just chiming it > > On Wed, 27 May 2026 at 19:48, Mike Rapoport wrote: > > > > From: "Mike Rapoport (Microsoft)" > > > > __mfill_atomic_pte() unconditionally dereferences ops because there is an > > assumption that VMAs that can undergo mfill_* operations are vetted on > > registration and must have valid vm_uffd_ops. > > > > Add a guard against potential bugs and make sure __mfill_atomic_pte() bails > > out if ops is NULL. > > > > Suggested-by: Lorenzo Stoakes > > Fixes: ad9ac3081332 ("userfaultfd: introduce vm_uffd_ops->alloc_folio()") > > Signed-off-by: Mike Rapoport (Microsoft) > > --- > > mm/userfaultfd.c | 5 +++++ > > 1 file changed, 5 insertions(+) > > > > diff --git a/mm/userfaultfd.c b/mm/userfaultfd.c > > index e5d2fb3ce2c1..2872c71bbf36 100644 > > --- a/mm/userfaultfd.c > > +++ b/mm/userfaultfd.c > > @@ -552,6 +552,11 @@ static int __mfill_atomic_pte(struct mfill_state *state, > > struct folio *folio; > > int ret; > > > > + if (!ops) { > > + VM_WARN_ONCE(1, "UFFDIO_COPY for unsupported VMA"); > > nit: Is the warning message a bit too specific ? i.e. Also handle > MFILL_ATOMIC_ZEROPAGE case. It handles ZEROPAGE case by actually copying a zeroed page there so in a sense it's still a copy. Differentiating COPY and ZEROPAGE here will add complexity that is not justified for a message that should be never printed. > > + return -EOPNOTSUPP; > > + } > > + > > folio = ops->alloc_folio(state->vma, state->dst_addr); > > if (!folio) > > return -ENOMEM; > > -- > > 2.53.0 > > > > Cheers. > -- Sincerely yours, Mike.