fs.rst 14 KB

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