Operating System - OpenVMS
1752339 Members
5659 Online
108787 Solutions
New Discussion

Usage of mprotect() on address space mapped via sys$mgblsc

 
Shreesha Hebbar
Occasional Contributor

Usage of mprotect() on address space mapped via sys$mgblsc

Is there is any restrictions on using mprotect on memory residing in a global sections?
The mprotect works fine when used on memory obtained via malloc(), but fails with ENOMEM when used on addresses residing in a global section.
1 REPLY 1
John Gillings
Honored Contributor

Re: Usage of mprotect() on address space mapped via sys$mgblsc

Shreesha,

This doesn't surprise me much. Are individual process mappings allowed to have different protections on the same global section? The lack of a "prot" argument for $mgblsc suggests not. Fairly obviously, you don't want to allow a process to change the protection for other processes.

According to the documentation ENOMEM has two meanings:

[ENOMEM]
Addresses in the range [addr, addr + len) are invalid for the address space of a process, or specify one or more pages which are not mapped.
[ENOMEM]
The prot argument specifies PROT_WRITE on a MAP_PRIVATE mapping, and it would require more space than the system is able to supply for locking the private pages, if required.

I suspect the former applies to global sections, but it's worth checking that your sizes are correct.

Any reason the protection specified at the time the section was created isn't correct?
A crucible of informative mistakes