fs.rst 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334
  1. ===============================
  2. Documentation for /proc/sys/fs/
  3. ===============================
  4. Copyright (c) 1998, 1999, Rik van Riel <riel@nl.linux.org>
  5. Copyright (c) 2009, Shen Feng<shen@cn.fujitsu.com>
  6. For general info and legal blurb, please look in intro.rst.
  7. ------------------------------------------------------------------------------
  8. This file contains documentation for the sysctl files and directories
  9. in ``/proc/sys/fs/``.
  10. The files in this directory can be used to tune and monitor
  11. miscellaneous and general things in the operation of the Linux
  12. kernel. Since some of the files *can* be used to screw up your
  13. system, it is advisable to read both documentation and source
  14. before actually making adjustments.
  15. 1. /proc/sys/fs
  16. ===============
  17. Currently, these files might (depending on your configuration)
  18. show up in ``/proc/sys/fs``:
  19. .. contents:: :local:
  20. aio-nr & aio-max-nr
  21. -------------------
  22. ``aio-nr`` shows the current system-wide number of asynchronous io
  23. requests. ``aio-max-nr`` allows you to change the maximum value
  24. ``aio-nr`` can grow to. If ``aio-nr`` reaches ``aio-nr-max`` then
  25. ``io_setup`` will fail with ``EAGAIN``. Note that raising
  26. ``aio-max-nr`` does not result in the
  27. pre-allocation or re-sizing of any kernel data structures.
  28. dentry-state
  29. ------------
  30. This file shows the values in ``struct dentry_stat_t``, as defined in
  31. ``fs/dcache.c``::
  32. struct dentry_stat_t dentry_stat {
  33. long nr_dentry;
  34. long nr_unused;
  35. long age_limit; /* age in seconds */
  36. long want_pages; /* pages requested by system */
  37. long nr_negative; /* # of unused negative dentries */
  38. long dummy; /* Reserved for future use */
  39. };
  40. Dentries are dynamically allocated and deallocated.
  41. ``nr_dentry`` shows the total number of dentries allocated (active
  42. + unused). ``nr_unused shows`` the number of dentries that are not
  43. actively used, but are saved in the LRU list for future reuse.
  44. ``age_limit`` is the age in seconds after which dcache entries
  45. can be reclaimed when memory is short and ``want_pages`` is
  46. nonzero when ``shrink_dcache_pages()`` has been called and the
  47. dcache isn't pruned yet.
  48. ``nr_negative`` shows the number of unused dentries that are also
  49. negative dentries which do not map to any files. Instead,
  50. they help speeding up rejection of non-existing files provided
  51. by the users.
  52. file-max & file-nr
  53. ------------------
  54. The value in ``file-max`` denotes the maximum number of file-
  55. handles that the Linux kernel will allocate. When you get lots
  56. of error messages about running out of file handles, you might
  57. want to increase this limit.
  58. Historically,the kernel was able to allocate file handles
  59. dynamically, but not to free them again. The three values in
  60. ``file-nr`` denote the number of allocated file handles, the number
  61. of allocated but unused file handles, and the maximum number of
  62. file handles. Linux 2.6 and later always reports 0 as the number of free
  63. file handles -- this is not an error, it just means that the
  64. number of allocated file handles exactly matches the number of
  65. used file handles.
  66. Attempts to allocate more file descriptors than ``file-max`` are
  67. reported with ``printk``, look for::
  68. VFS: file-max limit <number> reached
  69. in the kernel logs.
  70. inode-nr & inode-state
  71. ----------------------
  72. As with file handles, the kernel allocates the inode structures
  73. dynamically, but can't free them yet.
  74. The file ``inode-nr`` contains the first two items from
  75. ``inode-state``, so we'll skip to that file...
  76. ``inode-state`` contains three actual numbers and four dummies.
  77. The actual numbers are, in order of appearance, ``nr_inodes``,
  78. ``nr_free_inodes`` and ``preshrink``.
  79. ``nr_inodes`` stands for the number of inodes the system has
  80. allocated.
  81. ``nr_free_inodes`` represents the number of free inodes (?) and
  82. preshrink is nonzero when the
  83. system needs to prune the inode list instead of allocating
  84. more.
  85. mount-max
  86. ---------
  87. This denotes the maximum number of mounts that may exist
  88. in a mount namespace.
  89. nr_open
  90. -------
  91. This denotes the maximum number of file-handles a process can
  92. allocate. Default value is 1024*1024 (1048576) which should be
  93. enough for most machines. Actual limit depends on ``RLIMIT_NOFILE``
  94. resource limit.
  95. overflowgid & overflowuid
  96. -------------------------
  97. Some filesystems only support 16-bit UIDs and GIDs, although in Linux
  98. UIDs and GIDs are 32 bits. When one of these filesystems is mounted
  99. with writes enabled, any UID or GID that would exceed 65535 is translated
  100. to a fixed value before being written to disk.
  101. These sysctls allow you to change the value of the fixed UID and GID.
  102. The default is 65534.
  103. pipe-user-pages-hard
  104. --------------------
  105. Maximum total number of pages a non-privileged user may allocate for pipes.
  106. Once this limit is reached, no new pipes may be allocated until usage goes
  107. below the limit again. When set to 0, no limit is applied, which is the default
  108. setting.
  109. pipe-user-pages-soft
  110. --------------------
  111. Maximum total number of pages a non-privileged user may allocate for pipes
  112. before the pipe size gets limited to a single page. Once this limit is reached,
  113. new pipes will be limited to a single page in size for this user in order to
  114. limit total memory usage, and trying to increase them using ``fcntl()`` will be
  115. denied until usage goes below the limit again. The default value allows to
  116. allocate up to 1024 pipes at their default size. When set to 0, no limit is
  117. applied.
  118. protected_fifos
  119. ---------------
  120. The intent of this protection is to avoid unintentional writes to
  121. an attacker-controlled FIFO, where a program expected to create a regular
  122. file.
  123. When set to "0", writing to FIFOs is unrestricted.
  124. When set to "1" don't allow ``O_CREAT`` open on FIFOs that we don't own
  125. in world writable sticky directories, unless they are owned by the
  126. owner of the directory.
  127. When set to "2" it also applies to group writable sticky directories.
  128. This protection is based on the restrictions in Openwall.
  129. protected_hardlinks
  130. --------------------
  131. A long-standing class of security issues is the hardlink-based
  132. time-of-check-time-of-use race, most commonly seen in world-writable
  133. directories like ``/tmp``. The common method of exploitation of this flaw
  134. is to cross privilege boundaries when following a given hardlink (i.e. a
  135. root process follows a hardlink created by another user). Additionally,
  136. on systems without separated partitions, this stops unauthorized users
  137. from "pinning" vulnerable setuid/setgid files against being upgraded by
  138. the administrator, or linking to special files.
  139. When set to "0", hardlink creation behavior is unrestricted.
  140. When set to "1" hardlinks cannot be created by users if they do not
  141. already own the source file, or do not have read/write access to it.
  142. This protection is based on the restrictions in Openwall and grsecurity.
  143. protected_regular
  144. -----------------
  145. This protection is similar to `protected_fifos`_, but it
  146. avoids writes to an attacker-controlled regular file, where a program
  147. expected to create one.
  148. When set to "0", writing to regular files is unrestricted.
  149. When set to "1" don't allow ``O_CREAT`` open on regular files that we
  150. don't own in world writable sticky directories, unless they are
  151. owned by the owner of the directory.
  152. When set to "2" it also applies to group writable sticky directories.
  153. protected_symlinks
  154. ------------------
  155. A long-standing class of security issues is the symlink-based
  156. time-of-check-time-of-use race, most commonly seen in world-writable
  157. directories like ``/tmp``. The common method of exploitation of this flaw
  158. is to cross privilege boundaries when following a given symlink (i.e. a
  159. root process follows a symlink belonging to another user). For a likely
  160. incomplete list of hundreds of examples across the years, please see:
  161. https://cve.mitre.org/cgi-bin/cvekey.cgi?keyword=/tmp
  162. When set to "0", symlink following behavior is unrestricted.
  163. When set to "1" symlinks are permitted to be followed only when outside
  164. a sticky world-writable directory, or when the uid of the symlink and
  165. follower match, or when the directory owner matches the symlink's owner.
  166. This protection is based on the restrictions in Openwall and grsecurity.
  167. suid_dumpable
  168. -------------
  169. This value can be used to query and set the core dump mode for setuid
  170. or otherwise protected/tainted binaries. The modes are
  171. = ========== ===============================================================
  172. 0 (default) Traditional behaviour. Any process which has changed
  173. privilege levels or is execute only will not be dumped.
  174. 1 (debug) All processes dump core when possible. The core dump is
  175. owned by the current user and no security is applied. This is
  176. intended for system debugging situations only.
  177. Ptrace is unchecked.
  178. This is insecure as it allows regular users to examine the
  179. memory contents of privileged processes.
  180. 2 (suidsafe) Any binary which normally would not be dumped is dumped
  181. anyway, but only if the ``core_pattern`` kernel sysctl (see
  182. :ref:`Documentation/admin-guide/sysctl/kernel.rst <core_pattern>`)
  183. is set to
  184. either a pipe handler or a fully qualified path. (For more
  185. details on this limitation, see CVE-2006-2451.) This mode is
  186. appropriate when administrators are attempting to debug
  187. problems in a normal environment, and either have a core dump
  188. pipe handler that knows to treat privileged core dumps with
  189. care, or specific directory defined for catching core dumps.
  190. If a core dump happens without a pipe handler or fully
  191. qualified path, a message will be emitted to syslog warning
  192. about the lack of a correct setting.
  193. = ========== ===============================================================
  194. 2. /proc/sys/fs/binfmt_misc
  195. ===========================
  196. Documentation for the files in ``/proc/sys/fs/binfmt_misc`` is
  197. in Documentation/admin-guide/binfmt-misc.rst.
  198. 3. /proc/sys/fs/mqueue - POSIX message queues filesystem
  199. ========================================================
  200. The "mqueue" filesystem provides the necessary kernel features to enable the
  201. creation of a user space library that implements the POSIX message queues
  202. API (as noted by the MSG tag in the POSIX 1003.1-2001 version of the System
  203. Interfaces specification.)
  204. The "mqueue" filesystem contains values for determining/setting the
  205. amount of resources used by the file system.
  206. ``/proc/sys/fs/mqueue/queues_max`` is a read/write file for
  207. setting/getting the maximum number of message queues allowed on the
  208. system.
  209. ``/proc/sys/fs/mqueue/msg_max`` is a read/write file for
  210. setting/getting the maximum number of messages in a queue value. In
  211. fact it is the limiting value for another (user) limit which is set in
  212. ``mq_open`` invocation. This attribute of a queue must be less than
  213. or equal to ``msg_max``.
  214. ``/proc/sys/fs/mqueue/msgsize_max`` is a read/write file for
  215. setting/getting the maximum message size value (it is an attribute of
  216. every message queue, set during its creation).
  217. ``/proc/sys/fs/mqueue/msg_default`` is a read/write file for
  218. setting/getting the default number of messages in a queue value if the
  219. ``attr`` parameter of ``mq_open(2)`` is ``NULL``. If it exceeds
  220. ``msg_max``, the default value is initialized to ``msg_max``.
  221. ``/proc/sys/fs/mqueue/msgsize_default`` is a read/write file for
  222. setting/getting the default message size value if the ``attr``
  223. parameter of ``mq_open(2)`` is ``NULL``. If it exceeds
  224. ``msgsize_max``, the default value is initialized to ``msgsize_max``.
  225. 4. /proc/sys/fs/epoll - Configuration options for the epoll interface
  226. =====================================================================
  227. This directory contains configuration options for the epoll(7) interface.
  228. max_user_watches
  229. ----------------
  230. Every epoll file descriptor can store a number of files to be monitored
  231. for event readiness. Each one of these monitored files constitutes a "watch".
  232. This configuration option sets the maximum number of "watches" that are
  233. allowed for each user.
  234. Each "watch" costs roughly 90 bytes on a 32-bit kernel, and roughly 160 bytes
  235. on a 64-bit one.
  236. The current default value for ``max_user_watches`` is 4% of the
  237. available low memory, divided by the "watch" cost in bytes.