lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <478a6003-7dc8-444c-b8a6-a29c521abe72@suse.cz>
Date: Thu, 10 Jul 2025 16:24:43 +0200
From: Vlastimil Babka <vbabka@...e.cz>
To: Lorenzo Stoakes <lorenzo.stoakes@...cle.com>,
 Andrew Morton <akpm@...ux-foundation.org>
Cc: Peter Xu <peterx@...hat.com>, Alexander Viro <viro@...iv.linux.org.uk>,
 Christian Brauner <brauner@...nel.org>, Jan Kara <jack@...e.cz>,
 "Liam R . Howlett" <Liam.Howlett@...cle.com>, Jann Horn <jannh@...gle.com>,
 Pedro Falcato <pfalcato@...e.de>, Rik van Riel <riel@...riel.com>,
 linux-mm@...ck.org, linux-fsdevel@...r.kernel.org,
 linux-kernel@...r.kernel.org, linux-kselftest@...r.kernel.org
Subject: Re: [PATCH 05/10] mm/mremap: use an explicit uffd failure path for
 mremap

On 7/7/25 07:27, Lorenzo Stoakes wrote:
> Right now it appears that the code is relying upon the returned destination
> address having bits outside PAGE_MASK to indicate whether an error value is
> specified, and decrementing the increased refcount on the uffd ctx if so.
> 
> This is not a safe means of determining an error value, so instead, be
> specific. It makes far more sense to do so in a dedicated error path, so
> add mremap_userfaultfd_fail() for this purpose and use this when an error
> arises.
> 
> A vm_userfaultfd_ctx is not established until we are at the point where
> mremap_userfaultfd_prep() is invoked in copy_vma_and_data(), so this is a
> no-op until this happens.
> 
> That is - uffd remap notification only occurs if the VMA is actually moved
> - at which point a UFFD_EVENT_REMAP event is raised.
> 
> No errors can occur after this point currently, though it's certainly not
> guaranteed this will always remain the case, and we mustn't rely on this.
> 
> However, the reason for needing to handle this case is that, when an error
> arises on a VMA move at the point of adjusting page tables, we revert this
> operation, and propagate the error.
> 
> At this point, it is not correct to raise a uffd remap event, and we must
> handle it.
> 
> This refactoring makes it abundantly clear what we are doing.
> 
> We assume vrm->new_addr is always valid, which a prior change made the case
> even for mremap() invocations which don't move the VMA, however given no
> uffd context would be set up in this case it's immaterial to this change
> anyway.
> 
> No functional change intended.
> 
> Signed-off-by: Lorenzo Stoakes <lorenzo.stoakes@...cle.com>

Reviewed-by: Vlastimil Babka <vbabka@...e.cz>

Guess that renders my previous nit unimportant.


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ