logo

oasis-root

Compiled tree of Oasis Linux based on own branch at <https://hacktivis.me/git/oasis/> git clone https://anongit.hacktivis.me/git/oasis-root.git

mprotect.3p (4696B)


  1. '\" et
  2. .TH MPROTECT "3P" 2017 "IEEE/The Open Group" "POSIX Programmer's Manual"
  3. .\"
  4. .SH PROLOG
  5. This manual page is part of the POSIX Programmer's Manual.
  6. The Linux implementation of this interface may differ (consult
  7. the corresponding Linux manual page for details of Linux behavior),
  8. or the interface may not be implemented on Linux.
  9. .\"
  10. .SH NAME
  11. mprotect
  12. \(em set protection of memory mapping
  13. .SH SYNOPSIS
  14. .LP
  15. .nf
  16. #include <sys/mman.h>
  17. .P
  18. int mprotect(void *\fIaddr\fP, size_t \fIlen\fP, int \fIprot\fP);
  19. .fi
  20. .SH DESCRIPTION
  21. The
  22. \fImprotect\fR()
  23. function shall change the access protections to be that specified by
  24. .IR prot
  25. for those whole pages containing any part of the address space of the
  26. process starting at address
  27. .IR addr
  28. and continuing for
  29. .IR len
  30. bytes. The parameter
  31. .IR prot
  32. determines whether read, write, execute, or some combination of
  33. accesses are permitted to the data being mapped. The
  34. .IR prot
  35. argument should be either PROT_NONE or the bitwise-inclusive OR of one
  36. or more of PROT_READ, PROT_WRITE, and PROT_EXEC.
  37. .P
  38. If an implementation cannot support the combination of access types
  39. specified by
  40. .IR prot ,
  41. the call to
  42. \fImprotect\fR()
  43. shall fail.
  44. .P
  45. An implementation may permit accesses other than those specified by
  46. .IR prot ;
  47. however, no implementation shall permit a write to succeed where
  48. PROT_WRITE has not been set or shall permit any access where PROT_NONE
  49. alone has been set. Implementations shall support at least the
  50. following values of
  51. .IR prot :
  52. PROT_NONE, PROT_READ, PROT_WRITE, and the bitwise-inclusive OR of
  53. PROT_READ and PROT_WRITE. If PROT_WRITE is specified, the application
  54. shall ensure that it has opened the mapped objects in the specified
  55. address range with write permission, unless MAP_PRIVATE
  56. was specified in the original mapping, regardless of whether the file
  57. descriptors used to map the objects have since been closed.
  58. .P
  59. The implementation may require that
  60. .IR addr
  61. be a multiple of the page size as returned by
  62. \fIsysconf\fR().
  63. .P
  64. The behavior of this function is unspecified if the mapping was not
  65. established by a call to
  66. \fImmap\fR().
  67. .P
  68. When
  69. \fImprotect\fR()
  70. fails for reasons other than
  71. .BR [EINVAL] ,
  72. the protections on some of the pages in the range
  73. [\fIaddr\fP,\fIaddr\fP+\fIlen\fR) may have been changed.
  74. .SH "RETURN VALUE"
  75. Upon successful completion,
  76. \fImprotect\fR()
  77. shall return 0; otherwise, it shall return \-1 and set
  78. .IR errno
  79. to indicate the error.
  80. .SH ERRORS
  81. The
  82. \fImprotect\fR()
  83. function shall fail if:
  84. .TP
  85. .BR EACCES
  86. The
  87. .IR prot
  88. argument specifies a protection that violates the access permission the
  89. process has to the underlying memory object.
  90. .TP
  91. .BR EAGAIN
  92. The
  93. .IR prot
  94. argument specifies PROT_WRITE over a MAP_PRIVATE mapping and there are
  95. insufficient memory resources to reserve for locking the private page.
  96. .TP
  97. .BR ENOMEM
  98. Addresses in the range [\fIaddr\fP,\fIaddr\fP+\fIlen\fR) are invalid
  99. for the address space of a process, or specify one or more pages which
  100. are not mapped.
  101. .TP
  102. .BR ENOMEM
  103. The
  104. .IR prot
  105. argument specifies PROT_WRITE on a MAP_PRIVATE mapping, and it would
  106. require more space than the system is able to supply for locking the
  107. private pages, if required.
  108. .TP
  109. .BR ENOTSUP
  110. The implementation does not support the combination of accesses
  111. requested in the
  112. .IR prot
  113. argument.
  114. .P
  115. The
  116. \fImprotect\fR()
  117. function may fail if:
  118. .TP
  119. .BR EINVAL
  120. The
  121. .IR addr
  122. argument is not a multiple of the page size as returned by
  123. \fIsysconf\fR().
  124. .LP
  125. .IR "The following sections are informative."
  126. .SH EXAMPLES
  127. None.
  128. .SH "APPLICATION USAGE"
  129. Most implementations require that
  130. .IR addr
  131. is a multiple of the page size as returned by
  132. \fIsysconf\fR().
  133. .SH RATIONALE
  134. None.
  135. .SH "FUTURE DIRECTIONS"
  136. None.
  137. .SH "SEE ALSO"
  138. .IR "\fImmap\fR\^(\|)",
  139. .IR "\fIsysconf\fR\^(\|)"
  140. .P
  141. The Base Definitions volume of POSIX.1\(hy2017,
  142. .IR "\fB<sys_mman.h>\fP"
  143. .\"
  144. .SH COPYRIGHT
  145. Portions of this text are reprinted and reproduced in electronic form
  146. from IEEE Std 1003.1-2017, Standard for Information Technology
  147. -- Portable Operating System Interface (POSIX), The Open Group Base
  148. Specifications Issue 7, 2018 Edition,
  149. Copyright (C) 2018 by the Institute of
  150. Electrical and Electronics Engineers, Inc and The Open Group.
  151. In the event of any discrepancy between this version and the original IEEE and
  152. The Open Group Standard, the original IEEE and The Open Group Standard
  153. is the referee document. The original Standard can be obtained online at
  154. http://www.opengroup.org/unix/online.html .
  155. .PP
  156. Any typographical or formatting errors that appear
  157. in this page are most likely
  158. to have been introduced during the conversion of the source files to
  159. man page format. To report such errors, see
  160. https://www.kernel.org/doc/man-pages/reporting_bugs.html .