Sujet : Re: Memory protection between compilation units?
De : mateusz (at) *nospam* x.invalid (Mateusz Viste)
Groupes : comp.lang.cDate : 13. Jun 2025, 07:42:05
Autres entêtes
Organisation : ...
Message-ID : <20250613084205.09e4fc9f@mateusz>
References : 1 2 3
User-Agent : Claws Mail 4.2.0 (GTK 3.24.43; x86_64-suse-linux-gnu)
On Thu, 12 Jun 2025 18:59 Kaz Kylheku wrote:
Below is a proof-of-concept program that works in GNU/Linux. For
rapidity of prototyping, I have assumed a page size of 4096; this is
not right for all systems.
This is very cool! A variation of the classic "sentinel-guarded
memory" concept, where sentinels are write-protected rather than
requiring runtime checks against some magic signature.
Another potential strategy would be to safeguard the static array
itself, or any other data storage for that matter, immediately after the
legitimate code has finished using it. Then unprotect it only when
needed again. While this might not be a good performer for
high-frequency operations, it could be an interesting practice
for memory regions that are rarely modified.
man mprotect() suggests that it should be used only on mmap-ed memory,
but apparently under Linux it works with everything.
Mateusz