Update mmap mapping to be readonly without overwriting existing data
2
votes
2
answers
101
views
I'm making a custom ELF loader to learn how the dynamic loader works behind the scenes, and one of the program headers often found in them is
PT_GNU_RELRO
, which tells the loader to make that segment read-only after performing relocations.
However, it doesn't look like there's a good way to update existing memory mappings' protections without replacing the entire thing.
MAP_UNINITIALIZED
seems to be what I'm looking for, but mmap(2) states that it doesn't work on most systems for security reasons.
>**MAP_UNINITIALIZED (since Linux 2.6.33)**
>
>Don't clear anonymous pages. This flag is intended to
improve performance on embedded devices. This flag is
honored only if the kernel was configured with the
CONFIG_MMAP_ALLOW_UNINITIALIZED
option. Because of the
security implications, that option is normally enabled only
on embedded devices (i.e., devices where one has complete
control of the contents of user memory).
Which is reasonable for loosening permissions, but I'm looking to restrict them.
Is there a way, as a user process, to update a mmap mapping to be read-only without replacing existing data at that address?
Asked by Electro_593
(23 rep)
Jun 21, 2025, 02:49 AM
Last activity: Jun 21, 2025, 08:43 AM
Last activity: Jun 21, 2025, 08:43 AM