linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* Re: MREMAP_FIXED unmaps dest on error
       [not found] <18c36a78-4082-fab6-c7c9-69a249516803@yandex.ru>
@ 2023-04-03 11:58 ` David Hildenbrand
  0 siblings, 0 replies; only message in thread
From: David Hildenbrand @ 2023-04-03 11:58 UTC (permalink / raw)
  To: stsp, Linux Kernel Mailing List
  Cc: linux-mm, Jakub Matěna, Hugh Dickins, Vlastimil Babka,
	Peter Zijlstra (Intel)

On 30.03.23 17:48, stsp wrote:
> Hello.
> 
> The attached test-case demonstrates a
> bug in mremap(). If MREMAP_FIXED is used
> over an existing mapping and mremap() fails,
> destination area gets unmapped.
> AFAIK the failed syscall should have no
> observable effects.

I remember that holds for various mapping-related syscalls: if something 
goes wrong, the end result is not guaranteed to be what we had before 
the syscall.

For example, if you use mmap(MAP_FIXED) to replace part of an exiting 
mapping, we first munmap what's there and then try to mmap the new 
mapping. If something goes wrong while doing that, we cannot simple undo 
what we already did.

Long story short: the semantics of these syscalls has never been to 
leave the system in the state as it was before in case anything goes wrong.


As another example, if you do an mprotect() that covers multiple VMAS, 
and there is an issue with the last VMA, all but the last VMA will have 
their permissions changed.

-- 
Thanks,

David / dhildenb



^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-04-03 11:58 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <18c36a78-4082-fab6-c7c9-69a249516803@yandex.ru>
2023-04-03 11:58 ` MREMAP_FIXED unmaps dest on error David Hildenbrand

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox