r/ProgrammingLanguages • u/ThomasMertes • Oct 14 '26
Improved article about memory safety
Thank you to everyone who gave feedback on my article about memory safety.
I used the input to vastly improve the article (see "Achieving memory safety").
Please take a look and share your thoughts again and consider starring the Seed7 project on GitHub.
13
Upvotes
View all comments
Show parent comment
3
u/ThomasMertes Oct 15 '26
So for functions which allow IO there is no distinction between normal reading from a file and reading its own memory via
/proc.For memory safety I would need exactly this distinction. Having a class of functions which are not allowed to do IO does not help in this regard.
Protecting a program against reading its own memory via /proc needs a different strategy.
The Seed7 run-time could check the path every time a file is opened. This would include absolute and relative paths to
/proc/self/mem,/proc/self/maps,/proc/thread-self/mem,/proc/thread-self/maps,/proc/<PID>/mem, and/proc/<PID>/maps.As an alternative functions which open files could be protected like this:
Sub-processes could still access the memory of the parent process. To prevent this
prctl(PR_SET_DUMPABLE, 0)would be necessary for sub-processes as well. But withprctl(PR_SET_DUMPABLE, 0)a process cannot be debugged.Thank you.