• Liam R. Howlett's avatar
    mm: change failure of MAP_FIXED to restoring the gap on failure · 4f87153e
    Liam R. Howlett authored
    Prior to call_mmap(), the vmas that will be replaced need to clear the way
    for what may happen in the call_mmap().  This clean up work includes
    clearing the ptes and calling the close() vm_ops.  Some users do more
    setup than can be restored by calling the vm_ops open() function.  It is
    safer to store the gap in the vma tree in these cases.
    
    That is to say that the failure scenario that existed before the MAP_FIXED
    gap exposure is restored as it is safer than trying to undo a partial
    mapping.
    
    Since abort_munmap_vmas() is only reattaching vmas with this change, the
    function is renamed to reattach_vmas().
    
    There is also a secondary failure that may occur if there is not enough
    memory to store the gap.  In this case, the vmas are reattached and
    resources freed.  If the system cannot complete the call_mmap() and fails
    to allocate with GFP_KERNEL, then the system will print a warning about
    the failure.
    
    [lorenzo.stoakes@oracle.com: fix off-by-one error in vms_abort_munmap_vmas()]
      Link: https://lkml.kernel.org/r/52ee7eb3-955c-4ade-b5f0-28fed8ba3d0b@lucifer.local
    Link: https://lkml.kernel.org/r/20240830040101.822209-16-Liam.Howlett@oracle.comSigned-off-by: default avatarLiam R. Howlett <Liam.Howlett@Oracle.com>
    Signed-off-by: default avatarLorenzo Stoakes <lorenzo.stoakes@oracle.com>
    Reviewed-by: default avatarLorenzo Stoakes <lorenzo.stoakes@oracle.com>
    Cc: Bert Karwatzki <spasswolf@web.de>
    Cc: Jeff Xu <jeffxu@chromium.org>
    Cc: Jiri Olsa <olsajiri@gmail.com>
    Cc: Kees Cook <kees@kernel.org>
    Cc: Lorenzo Stoakes <lstoakes@gmail.com>
    Cc: Mark Brown <broonie@kernel.org>
    Cc: Matthew Wilcox <willy@infradead.org>
    Cc: "Paul E. McKenney" <paulmck@kernel.org>
    Cc: Paul Moore <paul@paul-moore.com>
    Cc: Sidhartha Kumar <sidhartha.kumar@oracle.com>
    Cc: Suren Baghdasaryan <surenb@google.com>
    Cc: Vlastimil Babka <vbabka@suse.cz>
    Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
    4f87153e
vma.h 15.3 KB