sysctl_binary.c 50 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476
  1. // SPDX-License-Identifier: GPL-2.0
  2. #include <linux/stat.h>
  3. #include <linux/sysctl.h>
  4. #include "../fs/xfs/xfs_sysctl.h"
  5. #include <linux/sunrpc/debug.h>
  6. #include <linux/string.h>
  7. #include <linux/syscalls.h>
  8. #include <linux/namei.h>
  9. #include <linux/mount.h>
  10. #include <linux/fs.h>
  11. #include <linux/nsproxy.h>
  12. #include <linux/pid_namespace.h>
  13. #include <linux/file.h>
  14. #include <linux/ctype.h>
  15. #include <linux/netdevice.h>
  16. #include <linux/kernel.h>
  17. #include <linux/uuid.h>
  18. #include <linux/slab.h>
  19. #include <linux/compat.h>
  20. #ifdef CONFIG_SYSCTL_SYSCALL
  21. struct bin_table;
  22. typedef ssize_t bin_convert_t(struct file *file,
  23. void __user *oldval, size_t oldlen, void __user *newval, size_t newlen);
  24. static bin_convert_t bin_dir;
  25. static bin_convert_t bin_string;
  26. static bin_convert_t bin_intvec;
  27. static bin_convert_t bin_ulongvec;
  28. static bin_convert_t bin_uuid;
  29. static bin_convert_t bin_dn_node_address;
  30. #define CTL_DIR bin_dir
  31. #define CTL_STR bin_string
  32. #define CTL_INT bin_intvec
  33. #define CTL_ULONG bin_ulongvec
  34. #define CTL_UUID bin_uuid
  35. #define CTL_DNADR bin_dn_node_address
  36. #define BUFSZ 256
  37. struct bin_table {
  38. bin_convert_t *convert;
  39. int ctl_name;
  40. const char *procname;
  41. const struct bin_table *child;
  42. };
  43. static const struct bin_table bin_random_table[] = {
  44. { CTL_INT, RANDOM_POOLSIZE, "poolsize" },
  45. { CTL_INT, RANDOM_ENTROPY_COUNT, "entropy_avail" },
  46. { CTL_INT, RANDOM_READ_THRESH, "read_wakeup_threshold" },
  47. { CTL_INT, RANDOM_WRITE_THRESH, "write_wakeup_threshold" },
  48. { CTL_UUID, RANDOM_BOOT_ID, "boot_id" },
  49. { CTL_UUID, RANDOM_UUID, "uuid" },
  50. {}
  51. };
  52. static const struct bin_table bin_pty_table[] = {
  53. { CTL_INT, PTY_MAX, "max" },
  54. { CTL_INT, PTY_NR, "nr" },
  55. {}
  56. };
  57. static const struct bin_table bin_kern_table[] = {
  58. { CTL_STR, KERN_OSTYPE, "ostype" },
  59. { CTL_STR, KERN_OSRELEASE, "osrelease" },
  60. /* KERN_OSREV not used */
  61. { CTL_STR, KERN_VERSION, "version" },
  62. /* KERN_SECUREMASK not used */
  63. /* KERN_PROF not used */
  64. { CTL_STR, KERN_NODENAME, "hostname" },
  65. { CTL_STR, KERN_DOMAINNAME, "domainname" },
  66. { CTL_INT, KERN_PANIC, "panic" },
  67. { CTL_INT, KERN_REALROOTDEV, "real-root-dev" },
  68. { CTL_STR, KERN_SPARC_REBOOT, "reboot-cmd" },
  69. { CTL_INT, KERN_CTLALTDEL, "ctrl-alt-del" },
  70. { CTL_INT, KERN_PRINTK, "printk" },
  71. /* KERN_NAMETRANS not used */
  72. /* KERN_PPC_HTABRECLAIM not used */
  73. /* KERN_PPC_ZEROPAGED not used */
  74. { CTL_INT, KERN_PPC_POWERSAVE_NAP, "powersave-nap" },
  75. { CTL_STR, KERN_MODPROBE, "modprobe" },
  76. { CTL_INT, KERN_SG_BIG_BUFF, "sg-big-buff" },
  77. { CTL_INT, KERN_ACCT, "acct" },
  78. /* KERN_PPC_L2CR "l2cr" no longer used */
  79. /* KERN_RTSIGNR not used */
  80. /* KERN_RTSIGMAX not used */
  81. { CTL_ULONG, KERN_SHMMAX, "shmmax" },
  82. { CTL_INT, KERN_MSGMAX, "msgmax" },
  83. { CTL_INT, KERN_MSGMNB, "msgmnb" },
  84. /* KERN_MSGPOOL not used*/
  85. { CTL_INT, KERN_SYSRQ, "sysrq" },
  86. { CTL_INT, KERN_MAX_THREADS, "threads-max" },
  87. { CTL_DIR, KERN_RANDOM, "random", bin_random_table },
  88. { CTL_ULONG, KERN_SHMALL, "shmall" },
  89. { CTL_INT, KERN_MSGMNI, "msgmni" },
  90. { CTL_INT, KERN_SEM, "sem" },
  91. { CTL_INT, KERN_SPARC_STOP_A, "stop-a" },
  92. { CTL_INT, KERN_SHMMNI, "shmmni" },
  93. { CTL_INT, KERN_OVERFLOWUID, "overflowuid" },
  94. { CTL_INT, KERN_OVERFLOWGID, "overflowgid" },
  95. { CTL_STR, KERN_HOTPLUG, "hotplug", },
  96. { CTL_INT, KERN_IEEE_EMULATION_WARNINGS, "ieee_emulation_warnings" },
  97. { CTL_INT, KERN_S390_USER_DEBUG_LOGGING, "userprocess_debug" },
  98. { CTL_INT, KERN_CORE_USES_PID, "core_uses_pid" },
  99. /* KERN_TAINTED "tainted" no longer used */
  100. { CTL_INT, KERN_CADPID, "cad_pid" },
  101. { CTL_INT, KERN_PIDMAX, "pid_max" },
  102. { CTL_STR, KERN_CORE_PATTERN, "core_pattern" },
  103. { CTL_INT, KERN_PANIC_ON_OOPS, "panic_on_oops" },
  104. { CTL_INT, KERN_HPPA_PWRSW, "soft-power" },
  105. { CTL_INT, KERN_HPPA_UNALIGNED, "unaligned-trap" },
  106. { CTL_INT, KERN_PRINTK_RATELIMIT, "printk_ratelimit" },
  107. { CTL_INT, KERN_PRINTK_RATELIMIT_BURST, "printk_ratelimit_burst" },
  108. { CTL_DIR, KERN_PTY, "pty", bin_pty_table },
  109. { CTL_INT, KERN_NGROUPS_MAX, "ngroups_max" },
  110. { CTL_INT, KERN_SPARC_SCONS_PWROFF, "scons-poweroff" },
  111. /* KERN_HZ_TIMER "hz_timer" no longer used */
  112. { CTL_INT, KERN_UNKNOWN_NMI_PANIC, "unknown_nmi_panic" },
  113. { CTL_INT, KERN_BOOTLOADER_TYPE, "bootloader_type" },
  114. { CTL_INT, KERN_RANDOMIZE, "randomize_va_space" },
  115. { CTL_INT, KERN_SPIN_RETRY, "spin_retry" },
  116. /* KERN_ACPI_VIDEO_FLAGS "acpi_video_flags" no longer used */
  117. { CTL_INT, KERN_IA64_UNALIGNED, "ignore-unaligned-usertrap" },
  118. { CTL_INT, KERN_COMPAT_LOG, "compat-log" },
  119. { CTL_INT, KERN_MAX_LOCK_DEPTH, "max_lock_depth" },
  120. { CTL_INT, KERN_PANIC_ON_NMI, "panic_on_unrecovered_nmi" },
  121. { CTL_INT, KERN_PANIC_ON_WARN, "panic_on_warn" },
  122. {}
  123. };
  124. static const struct bin_table bin_vm_table[] = {
  125. { CTL_INT, VM_OVERCOMMIT_MEMORY, "overcommit_memory" },
  126. { CTL_INT, VM_PAGE_CLUSTER, "page-cluster" },
  127. { CTL_INT, VM_DIRTY_BACKGROUND, "dirty_background_ratio" },
  128. { CTL_INT, VM_DIRTY_RATIO, "dirty_ratio" },
  129. /* VM_DIRTY_WB_CS "dirty_writeback_centisecs" no longer used */
  130. /* VM_DIRTY_EXPIRE_CS "dirty_expire_centisecs" no longer used */
  131. /* VM_NR_PDFLUSH_THREADS "nr_pdflush_threads" no longer used */
  132. { CTL_INT, VM_OVERCOMMIT_RATIO, "overcommit_ratio" },
  133. /* VM_PAGEBUF unused */
  134. /* VM_HUGETLB_PAGES "nr_hugepages" no longer used */
  135. { CTL_INT, VM_SWAPPINESS, "swappiness" },
  136. { CTL_INT, VM_LOWMEM_RESERVE_RATIO, "lowmem_reserve_ratio" },
  137. { CTL_INT, VM_MIN_FREE_KBYTES, "min_free_kbytes" },
  138. { CTL_INT, VM_MAX_MAP_COUNT, "max_map_count" },
  139. { CTL_INT, VM_LAPTOP_MODE, "laptop_mode" },
  140. { CTL_INT, VM_BLOCK_DUMP, "block_dump" },
  141. { CTL_INT, VM_HUGETLB_GROUP, "hugetlb_shm_group" },
  142. { CTL_INT, VM_VFS_CACHE_PRESSURE, "vfs_cache_pressure" },
  143. { CTL_INT, VM_LEGACY_VA_LAYOUT, "legacy_va_layout" },
  144. /* VM_SWAP_TOKEN_TIMEOUT unused */
  145. { CTL_INT, VM_DROP_PAGECACHE, "drop_caches" },
  146. { CTL_INT, VM_PERCPU_PAGELIST_FRACTION, "percpu_pagelist_fraction" },
  147. { CTL_INT, VM_ZONE_RECLAIM_MODE, "zone_reclaim_mode" },
  148. { CTL_INT, VM_MIN_UNMAPPED, "min_unmapped_ratio" },
  149. { CTL_INT, VM_PANIC_ON_OOM, "panic_on_oom" },
  150. { CTL_INT, VM_VDSO_ENABLED, "vdso_enabled" },
  151. { CTL_INT, VM_MIN_SLAB, "min_slab_ratio" },
  152. {}
  153. };
  154. static const struct bin_table bin_net_core_table[] = {
  155. { CTL_INT, NET_CORE_WMEM_MAX, "wmem_max" },
  156. { CTL_INT, NET_CORE_RMEM_MAX, "rmem_max" },
  157. { CTL_INT, NET_CORE_WMEM_DEFAULT, "wmem_default" },
  158. { CTL_INT, NET_CORE_RMEM_DEFAULT, "rmem_default" },
  159. /* NET_CORE_DESTROY_DELAY unused */
  160. { CTL_INT, NET_CORE_MAX_BACKLOG, "netdev_max_backlog" },
  161. /* NET_CORE_FASTROUTE unused */
  162. { CTL_INT, NET_CORE_MSG_COST, "message_cost" },
  163. { CTL_INT, NET_CORE_MSG_BURST, "message_burst" },
  164. { CTL_INT, NET_CORE_OPTMEM_MAX, "optmem_max" },
  165. /* NET_CORE_HOT_LIST_LENGTH unused */
  166. /* NET_CORE_DIVERT_VERSION unused */
  167. /* NET_CORE_NO_CONG_THRESH unused */
  168. /* NET_CORE_NO_CONG unused */
  169. /* NET_CORE_LO_CONG unused */
  170. /* NET_CORE_MOD_CONG unused */
  171. { CTL_INT, NET_CORE_DEV_WEIGHT, "dev_weight" },
  172. { CTL_INT, NET_CORE_SOMAXCONN, "somaxconn" },
  173. { CTL_INT, NET_CORE_BUDGET, "netdev_budget" },
  174. { CTL_INT, NET_CORE_AEVENT_ETIME, "xfrm_aevent_etime" },
  175. { CTL_INT, NET_CORE_AEVENT_RSEQTH, "xfrm_aevent_rseqth" },
  176. { CTL_INT, NET_CORE_WARNINGS, "warnings" },
  177. {},
  178. };
  179. static const struct bin_table bin_net_unix_table[] = {
  180. /* NET_UNIX_DESTROY_DELAY unused */
  181. /* NET_UNIX_DELETE_DELAY unused */
  182. { CTL_INT, NET_UNIX_MAX_DGRAM_QLEN, "max_dgram_qlen" },
  183. {}
  184. };
  185. static const struct bin_table bin_net_ipv4_route_table[] = {
  186. { CTL_INT, NET_IPV4_ROUTE_FLUSH, "flush" },
  187. /* NET_IPV4_ROUTE_MIN_DELAY "min_delay" no longer used */
  188. /* NET_IPV4_ROUTE_MAX_DELAY "max_delay" no longer used */
  189. { CTL_INT, NET_IPV4_ROUTE_GC_THRESH, "gc_thresh" },
  190. { CTL_INT, NET_IPV4_ROUTE_MAX_SIZE, "max_size" },
  191. { CTL_INT, NET_IPV4_ROUTE_GC_MIN_INTERVAL, "gc_min_interval" },
  192. { CTL_INT, NET_IPV4_ROUTE_GC_MIN_INTERVAL_MS, "gc_min_interval_ms" },
  193. { CTL_INT, NET_IPV4_ROUTE_GC_TIMEOUT, "gc_timeout" },
  194. /* NET_IPV4_ROUTE_GC_INTERVAL "gc_interval" no longer used */
  195. { CTL_INT, NET_IPV4_ROUTE_REDIRECT_LOAD, "redirect_load" },
  196. { CTL_INT, NET_IPV4_ROUTE_REDIRECT_NUMBER, "redirect_number" },
  197. { CTL_INT, NET_IPV4_ROUTE_REDIRECT_SILENCE, "redirect_silence" },
  198. { CTL_INT, NET_IPV4_ROUTE_ERROR_COST, "error_cost" },
  199. { CTL_INT, NET_IPV4_ROUTE_ERROR_BURST, "error_burst" },
  200. { CTL_INT, NET_IPV4_ROUTE_GC_ELASTICITY, "gc_elasticity" },
  201. { CTL_INT, NET_IPV4_ROUTE_MTU_EXPIRES, "mtu_expires" },
  202. { CTL_INT, NET_IPV4_ROUTE_MIN_PMTU, "min_pmtu" },
  203. { CTL_INT, NET_IPV4_ROUTE_MIN_ADVMSS, "min_adv_mss" },
  204. {}
  205. };
  206. static const struct bin_table bin_net_ipv4_conf_vars_table[] = {
  207. { CTL_INT, NET_IPV4_CONF_FORWARDING, "forwarding" },
  208. { CTL_INT, NET_IPV4_CONF_MC_FORWARDING, "mc_forwarding" },
  209. { CTL_INT, NET_IPV4_CONF_ACCEPT_REDIRECTS, "accept_redirects" },
  210. { CTL_INT, NET_IPV4_CONF_SECURE_REDIRECTS, "secure_redirects" },
  211. { CTL_INT, NET_IPV4_CONF_SEND_REDIRECTS, "send_redirects" },
  212. { CTL_INT, NET_IPV4_CONF_SHARED_MEDIA, "shared_media" },
  213. { CTL_INT, NET_IPV4_CONF_RP_FILTER, "rp_filter" },
  214. { CTL_INT, NET_IPV4_CONF_ACCEPT_SOURCE_ROUTE, "accept_source_route" },
  215. { CTL_INT, NET_IPV4_CONF_PROXY_ARP, "proxy_arp" },
  216. { CTL_INT, NET_IPV4_CONF_MEDIUM_ID, "medium_id" },
  217. { CTL_INT, NET_IPV4_CONF_BOOTP_RELAY, "bootp_relay" },
  218. { CTL_INT, NET_IPV4_CONF_LOG_MARTIANS, "log_martians" },
  219. { CTL_INT, NET_IPV4_CONF_TAG, "tag" },
  220. { CTL_INT, NET_IPV4_CONF_ARPFILTER, "arp_filter" },
  221. { CTL_INT, NET_IPV4_CONF_ARP_ANNOUNCE, "arp_announce" },
  222. { CTL_INT, NET_IPV4_CONF_ARP_IGNORE, "arp_ignore" },
  223. { CTL_INT, NET_IPV4_CONF_ARP_ACCEPT, "arp_accept" },
  224. { CTL_INT, NET_IPV4_CONF_ARP_NOTIFY, "arp_notify" },
  225. { CTL_INT, NET_IPV4_CONF_NOXFRM, "disable_xfrm" },
  226. { CTL_INT, NET_IPV4_CONF_NOPOLICY, "disable_policy" },
  227. { CTL_INT, NET_IPV4_CONF_FORCE_IGMP_VERSION, "force_igmp_version" },
  228. { CTL_INT, NET_IPV4_CONF_PROMOTE_SECONDARIES, "promote_secondaries" },
  229. {}
  230. };
  231. static const struct bin_table bin_net_ipv4_conf_table[] = {
  232. { CTL_DIR, NET_PROTO_CONF_ALL, "all", bin_net_ipv4_conf_vars_table },
  233. { CTL_DIR, NET_PROTO_CONF_DEFAULT, "default", bin_net_ipv4_conf_vars_table },
  234. { CTL_DIR, 0, NULL, bin_net_ipv4_conf_vars_table },
  235. {}
  236. };
  237. static const struct bin_table bin_net_neigh_vars_table[] = {
  238. { CTL_INT, NET_NEIGH_MCAST_SOLICIT, "mcast_solicit" },
  239. { CTL_INT, NET_NEIGH_UCAST_SOLICIT, "ucast_solicit" },
  240. { CTL_INT, NET_NEIGH_APP_SOLICIT, "app_solicit" },
  241. /* NET_NEIGH_RETRANS_TIME "retrans_time" no longer used */
  242. { CTL_INT, NET_NEIGH_REACHABLE_TIME, "base_reachable_time" },
  243. { CTL_INT, NET_NEIGH_DELAY_PROBE_TIME, "delay_first_probe_time" },
  244. { CTL_INT, NET_NEIGH_GC_STALE_TIME, "gc_stale_time" },
  245. { CTL_INT, NET_NEIGH_UNRES_QLEN, "unres_qlen" },
  246. { CTL_INT, NET_NEIGH_PROXY_QLEN, "proxy_qlen" },
  247. /* NET_NEIGH_ANYCAST_DELAY "anycast_delay" no longer used */
  248. /* NET_NEIGH_PROXY_DELAY "proxy_delay" no longer used */
  249. /* NET_NEIGH_LOCKTIME "locktime" no longer used */
  250. { CTL_INT, NET_NEIGH_GC_INTERVAL, "gc_interval" },
  251. { CTL_INT, NET_NEIGH_GC_THRESH1, "gc_thresh1" },
  252. { CTL_INT, NET_NEIGH_GC_THRESH2, "gc_thresh2" },
  253. { CTL_INT, NET_NEIGH_GC_THRESH3, "gc_thresh3" },
  254. { CTL_INT, NET_NEIGH_RETRANS_TIME_MS, "retrans_time_ms" },
  255. { CTL_INT, NET_NEIGH_REACHABLE_TIME_MS, "base_reachable_time_ms" },
  256. {}
  257. };
  258. static const struct bin_table bin_net_neigh_table[] = {
  259. { CTL_DIR, NET_PROTO_CONF_DEFAULT, "default", bin_net_neigh_vars_table },
  260. { CTL_DIR, 0, NULL, bin_net_neigh_vars_table },
  261. {}
  262. };
  263. static const struct bin_table bin_net_ipv4_netfilter_table[] = {
  264. { CTL_INT, NET_IPV4_NF_CONNTRACK_MAX, "ip_conntrack_max" },
  265. /* NET_IPV4_NF_CONNTRACK_TCP_TIMEOUT_SYN_SENT "ip_conntrack_tcp_timeout_syn_sent" no longer used */
  266. /* NET_IPV4_NF_CONNTRACK_TCP_TIMEOUT_SYN_RECV "ip_conntrack_tcp_timeout_syn_recv" no longer used */
  267. /* NET_IPV4_NF_CONNTRACK_TCP_TIMEOUT_ESTABLISHED "ip_conntrack_tcp_timeout_established" no longer used */
  268. /* NET_IPV4_NF_CONNTRACK_TCP_TIMEOUT_FIN_WAIT "ip_conntrack_tcp_timeout_fin_wait" no longer used */
  269. /* NET_IPV4_NF_CONNTRACK_TCP_TIMEOUT_CLOSE_WAIT "ip_conntrack_tcp_timeout_close_wait" no longer used */
  270. /* NET_IPV4_NF_CONNTRACK_TCP_TIMEOUT_LAST_ACK "ip_conntrack_tcp_timeout_last_ack" no longer used */
  271. /* NET_IPV4_NF_CONNTRACK_TCP_TIMEOUT_TIME_WAIT "ip_conntrack_tcp_timeout_time_wait" no longer used */
  272. /* NET_IPV4_NF_CONNTRACK_TCP_TIMEOUT_CLOSE "ip_conntrack_tcp_timeout_close" no longer used */
  273. /* NET_IPV4_NF_CONNTRACK_UDP_TIMEOUT "ip_conntrack_udp_timeout" no longer used */
  274. /* NET_IPV4_NF_CONNTRACK_UDP_TIMEOUT_STREAM "ip_conntrack_udp_timeout_stream" no longer used */
  275. /* NET_IPV4_NF_CONNTRACK_ICMP_TIMEOUT "ip_conntrack_icmp_timeout" no longer used */
  276. /* NET_IPV4_NF_CONNTRACK_GENERIC_TIMEOUT "ip_conntrack_generic_timeout" no longer used */
  277. { CTL_INT, NET_IPV4_NF_CONNTRACK_BUCKETS, "ip_conntrack_buckets" },
  278. { CTL_INT, NET_IPV4_NF_CONNTRACK_LOG_INVALID, "ip_conntrack_log_invalid" },
  279. /* NET_IPV4_NF_CONNTRACK_TCP_TIMEOUT_MAX_RETRANS "ip_conntrack_tcp_timeout_max_retrans" no longer used */
  280. { CTL_INT, NET_IPV4_NF_CONNTRACK_TCP_LOOSE, "ip_conntrack_tcp_loose" },
  281. { CTL_INT, NET_IPV4_NF_CONNTRACK_TCP_BE_LIBERAL, "ip_conntrack_tcp_be_liberal" },
  282. { CTL_INT, NET_IPV4_NF_CONNTRACK_TCP_MAX_RETRANS, "ip_conntrack_tcp_max_retrans" },
  283. /* NET_IPV4_NF_CONNTRACK_SCTP_TIMEOUT_CLOSED "ip_conntrack_sctp_timeout_closed" no longer used */
  284. /* NET_IPV4_NF_CONNTRACK_SCTP_TIMEOUT_COOKIE_WAIT "ip_conntrack_sctp_timeout_cookie_wait" no longer used */
  285. /* NET_IPV4_NF_CONNTRACK_SCTP_TIMEOUT_COOKIE_ECHOED "ip_conntrack_sctp_timeout_cookie_echoed" no longer used */
  286. /* NET_IPV4_NF_CONNTRACK_SCTP_TIMEOUT_ESTABLISHED "ip_conntrack_sctp_timeout_established" no longer used */
  287. /* NET_IPV4_NF_CONNTRACK_SCTP_TIMEOUT_SHUTDOWN_SENT "ip_conntrack_sctp_timeout_shutdown_sent" no longer used */
  288. /* NET_IPV4_NF_CONNTRACK_SCTP_TIMEOUT_SHUTDOWN_RECD "ip_conntrack_sctp_timeout_shutdown_recd" no longer used */
  289. /* NET_IPV4_NF_CONNTRACK_SCTP_TIMEOUT_SHUTDOWN_ACK_SENT "ip_conntrack_sctp_timeout_shutdown_ack_sent" no longer used */
  290. { CTL_INT, NET_IPV4_NF_CONNTRACK_COUNT, "ip_conntrack_count" },
  291. { CTL_INT, NET_IPV4_NF_CONNTRACK_CHECKSUM, "ip_conntrack_checksum" },
  292. {}
  293. };
  294. static const struct bin_table bin_net_ipv4_table[] = {
  295. {CTL_INT, NET_IPV4_FORWARD, "ip_forward" },
  296. { CTL_DIR, NET_IPV4_CONF, "conf", bin_net_ipv4_conf_table },
  297. { CTL_DIR, NET_IPV4_NEIGH, "neigh", bin_net_neigh_table },
  298. { CTL_DIR, NET_IPV4_ROUTE, "route", bin_net_ipv4_route_table },
  299. /* NET_IPV4_FIB_HASH unused */
  300. { CTL_DIR, NET_IPV4_NETFILTER, "netfilter", bin_net_ipv4_netfilter_table },
  301. { CTL_INT, NET_IPV4_TCP_TIMESTAMPS, "tcp_timestamps" },
  302. { CTL_INT, NET_IPV4_TCP_WINDOW_SCALING, "tcp_window_scaling" },
  303. { CTL_INT, NET_IPV4_TCP_SACK, "tcp_sack" },
  304. { CTL_INT, NET_IPV4_TCP_RETRANS_COLLAPSE, "tcp_retrans_collapse" },
  305. { CTL_INT, NET_IPV4_DEFAULT_TTL, "ip_default_ttl" },
  306. /* NET_IPV4_AUTOCONFIG unused */
  307. { CTL_INT, NET_IPV4_NO_PMTU_DISC, "ip_no_pmtu_disc" },
  308. { CTL_INT, NET_IPV4_NONLOCAL_BIND, "ip_nonlocal_bind" },
  309. { CTL_INT, NET_IPV4_TCP_SYN_RETRIES, "tcp_syn_retries" },
  310. { CTL_INT, NET_TCP_SYNACK_RETRIES, "tcp_synack_retries" },
  311. { CTL_INT, NET_TCP_MAX_ORPHANS, "tcp_max_orphans" },
  312. { CTL_INT, NET_TCP_MAX_TW_BUCKETS, "tcp_max_tw_buckets" },
  313. { CTL_INT, NET_IPV4_DYNADDR, "ip_dynaddr" },
  314. { CTL_INT, NET_IPV4_TCP_KEEPALIVE_TIME, "tcp_keepalive_time" },
  315. { CTL_INT, NET_IPV4_TCP_KEEPALIVE_PROBES, "tcp_keepalive_probes" },
  316. { CTL_INT, NET_IPV4_TCP_KEEPALIVE_INTVL, "tcp_keepalive_intvl" },
  317. { CTL_INT, NET_IPV4_TCP_RETRIES1, "tcp_retries1" },
  318. { CTL_INT, NET_IPV4_TCP_RETRIES2, "tcp_retries2" },
  319. { CTL_INT, NET_IPV4_TCP_FIN_TIMEOUT, "tcp_fin_timeout" },
  320. { CTL_INT, NET_TCP_SYNCOOKIES, "tcp_syncookies" },
  321. { CTL_INT, NET_TCP_TW_RECYCLE, "tcp_tw_recycle" },
  322. { CTL_INT, NET_TCP_ABORT_ON_OVERFLOW, "tcp_abort_on_overflow" },
  323. { CTL_INT, NET_TCP_STDURG, "tcp_stdurg" },
  324. { CTL_INT, NET_TCP_RFC1337, "tcp_rfc1337" },
  325. { CTL_INT, NET_TCP_MAX_SYN_BACKLOG, "tcp_max_syn_backlog" },
  326. { CTL_INT, NET_IPV4_LOCAL_PORT_RANGE, "ip_local_port_range" },
  327. { CTL_INT, NET_IPV4_IGMP_MAX_MEMBERSHIPS, "igmp_max_memberships" },
  328. { CTL_INT, NET_IPV4_IGMP_MAX_MSF, "igmp_max_msf" },
  329. { CTL_INT, NET_IPV4_INET_PEER_THRESHOLD, "inet_peer_threshold" },
  330. { CTL_INT, NET_IPV4_INET_PEER_MINTTL, "inet_peer_minttl" },
  331. { CTL_INT, NET_IPV4_INET_PEER_MAXTTL, "inet_peer_maxttl" },
  332. { CTL_INT, NET_IPV4_INET_PEER_GC_MINTIME, "inet_peer_gc_mintime" },
  333. { CTL_INT, NET_IPV4_INET_PEER_GC_MAXTIME, "inet_peer_gc_maxtime" },
  334. { CTL_INT, NET_TCP_ORPHAN_RETRIES, "tcp_orphan_retries" },
  335. { CTL_INT, NET_TCP_FACK, "tcp_fack" },
  336. { CTL_INT, NET_TCP_REORDERING, "tcp_reordering" },
  337. { CTL_INT, NET_TCP_ECN, "tcp_ecn" },
  338. { CTL_INT, NET_TCP_DSACK, "tcp_dsack" },
  339. { CTL_INT, NET_TCP_MEM, "tcp_mem" },
  340. { CTL_INT, NET_TCP_WMEM, "tcp_wmem" },
  341. { CTL_INT, NET_TCP_RMEM, "tcp_rmem" },
  342. { CTL_INT, NET_TCP_APP_WIN, "tcp_app_win" },
  343. { CTL_INT, NET_TCP_ADV_WIN_SCALE, "tcp_adv_win_scale" },
  344. { CTL_INT, NET_TCP_TW_REUSE, "tcp_tw_reuse" },
  345. { CTL_INT, NET_TCP_FRTO, "tcp_frto" },
  346. { CTL_INT, NET_TCP_FRTO_RESPONSE, "tcp_frto_response" },
  347. { CTL_INT, NET_TCP_LOW_LATENCY, "tcp_low_latency" },
  348. { CTL_INT, NET_TCP_NO_METRICS_SAVE, "tcp_no_metrics_save" },
  349. { CTL_INT, NET_TCP_MODERATE_RCVBUF, "tcp_moderate_rcvbuf" },
  350. { CTL_INT, NET_TCP_TSO_WIN_DIVISOR, "tcp_tso_win_divisor" },
  351. { CTL_STR, NET_TCP_CONG_CONTROL, "tcp_congestion_control" },
  352. { CTL_INT, NET_TCP_MTU_PROBING, "tcp_mtu_probing" },
  353. { CTL_INT, NET_TCP_BASE_MSS, "tcp_base_mss" },
  354. { CTL_INT, NET_IPV4_TCP_WORKAROUND_SIGNED_WINDOWS, "tcp_workaround_signed_windows" },
  355. { CTL_INT, NET_TCP_SLOW_START_AFTER_IDLE, "tcp_slow_start_after_idle" },
  356. { CTL_INT, NET_CIPSOV4_CACHE_ENABLE, "cipso_cache_enable" },
  357. { CTL_INT, NET_CIPSOV4_CACHE_BUCKET_SIZE, "cipso_cache_bucket_size" },
  358. { CTL_INT, NET_CIPSOV4_RBM_OPTFMT, "cipso_rbm_optfmt" },
  359. { CTL_INT, NET_CIPSOV4_RBM_STRICTVALID, "cipso_rbm_strictvalid" },
  360. /* NET_TCP_AVAIL_CONG_CONTROL "tcp_available_congestion_control" no longer used */
  361. { CTL_STR, NET_TCP_ALLOWED_CONG_CONTROL, "tcp_allowed_congestion_control" },
  362. { CTL_INT, NET_TCP_MAX_SSTHRESH, "tcp_max_ssthresh" },
  363. { CTL_INT, NET_IPV4_ICMP_ECHO_IGNORE_ALL, "icmp_echo_ignore_all" },
  364. { CTL_INT, NET_IPV4_ICMP_ECHO_IGNORE_BROADCASTS, "icmp_echo_ignore_broadcasts" },
  365. { CTL_INT, NET_IPV4_ICMP_IGNORE_BOGUS_ERROR_RESPONSES, "icmp_ignore_bogus_error_responses" },
  366. { CTL_INT, NET_IPV4_ICMP_ERRORS_USE_INBOUND_IFADDR, "icmp_errors_use_inbound_ifaddr" },
  367. { CTL_INT, NET_IPV4_ICMP_RATELIMIT, "icmp_ratelimit" },
  368. { CTL_INT, NET_IPV4_ICMP_RATEMASK, "icmp_ratemask" },
  369. { CTL_INT, NET_IPV4_IPFRAG_HIGH_THRESH, "ipfrag_high_thresh" },
  370. { CTL_INT, NET_IPV4_IPFRAG_LOW_THRESH, "ipfrag_low_thresh" },
  371. { CTL_INT, NET_IPV4_IPFRAG_TIME, "ipfrag_time" },
  372. { CTL_INT, NET_IPV4_IPFRAG_SECRET_INTERVAL, "ipfrag_secret_interval" },
  373. /* NET_IPV4_IPFRAG_MAX_DIST "ipfrag_max_dist" no longer used */
  374. { CTL_INT, 2088 /* NET_IPQ_QMAX */, "ip_queue_maxlen" },
  375. /* NET_TCP_DEFAULT_WIN_SCALE unused */
  376. /* NET_TCP_BIC_BETA unused */
  377. /* NET_IPV4_TCP_MAX_KA_PROBES unused */
  378. /* NET_IPV4_IP_MASQ_DEBUG unused */
  379. /* NET_TCP_SYN_TAILDROP unused */
  380. /* NET_IPV4_ICMP_SOURCEQUENCH_RATE unused */
  381. /* NET_IPV4_ICMP_DESTUNREACH_RATE unused */
  382. /* NET_IPV4_ICMP_TIMEEXCEED_RATE unused */
  383. /* NET_IPV4_ICMP_PARAMPROB_RATE unused */
  384. /* NET_IPV4_ICMP_ECHOREPLY_RATE unused */
  385. /* NET_IPV4_ALWAYS_DEFRAG unused */
  386. {}
  387. };
  388. static const struct bin_table bin_net_ipx_table[] = {
  389. { CTL_INT, NET_IPX_PPROP_BROADCASTING, "ipx_pprop_broadcasting" },
  390. /* NET_IPX_FORWARDING unused */
  391. {}
  392. };
  393. static const struct bin_table bin_net_atalk_table[] = {
  394. { CTL_INT, NET_ATALK_AARP_EXPIRY_TIME, "aarp-expiry-time" },
  395. { CTL_INT, NET_ATALK_AARP_TICK_TIME, "aarp-tick-time" },
  396. { CTL_INT, NET_ATALK_AARP_RETRANSMIT_LIMIT, "aarp-retransmit-limit" },
  397. { CTL_INT, NET_ATALK_AARP_RESOLVE_TIME, "aarp-resolve-time" },
  398. {},
  399. };
  400. static const struct bin_table bin_net_netrom_table[] = {
  401. { CTL_INT, NET_NETROM_DEFAULT_PATH_QUALITY, "default_path_quality" },
  402. { CTL_INT, NET_NETROM_OBSOLESCENCE_COUNT_INITIALISER, "obsolescence_count_initialiser" },
  403. { CTL_INT, NET_NETROM_NETWORK_TTL_INITIALISER, "network_ttl_initialiser" },
  404. { CTL_INT, NET_NETROM_TRANSPORT_TIMEOUT, "transport_timeout" },
  405. { CTL_INT, NET_NETROM_TRANSPORT_MAXIMUM_TRIES, "transport_maximum_tries" },
  406. { CTL_INT, NET_NETROM_TRANSPORT_ACKNOWLEDGE_DELAY, "transport_acknowledge_delay" },
  407. { CTL_INT, NET_NETROM_TRANSPORT_BUSY_DELAY, "transport_busy_delay" },
  408. { CTL_INT, NET_NETROM_TRANSPORT_REQUESTED_WINDOW_SIZE, "transport_requested_window_size" },
  409. { CTL_INT, NET_NETROM_TRANSPORT_NO_ACTIVITY_TIMEOUT, "transport_no_activity_timeout" },
  410. { CTL_INT, NET_NETROM_ROUTING_CONTROL, "routing_control" },
  411. { CTL_INT, NET_NETROM_LINK_FAILS_COUNT, "link_fails_count" },
  412. { CTL_INT, NET_NETROM_RESET, "reset" },
  413. {}
  414. };
  415. static const struct bin_table bin_net_ax25_param_table[] = {
  416. { CTL_INT, NET_AX25_IP_DEFAULT_MODE, "ip_default_mode" },
  417. { CTL_INT, NET_AX25_DEFAULT_MODE, "ax25_default_mode" },
  418. { CTL_INT, NET_AX25_BACKOFF_TYPE, "backoff_type" },
  419. { CTL_INT, NET_AX25_CONNECT_MODE, "connect_mode" },
  420. { CTL_INT, NET_AX25_STANDARD_WINDOW, "standard_window_size" },
  421. { CTL_INT, NET_AX25_EXTENDED_WINDOW, "extended_window_size" },
  422. { CTL_INT, NET_AX25_T1_TIMEOUT, "t1_timeout" },
  423. { CTL_INT, NET_AX25_T2_TIMEOUT, "t2_timeout" },
  424. { CTL_INT, NET_AX25_T3_TIMEOUT, "t3_timeout" },
  425. { CTL_INT, NET_AX25_IDLE_TIMEOUT, "idle_timeout" },
  426. { CTL_INT, NET_AX25_N2, "maximum_retry_count" },
  427. { CTL_INT, NET_AX25_PACLEN, "maximum_packet_length" },
  428. { CTL_INT, NET_AX25_PROTOCOL, "protocol" },
  429. { CTL_INT, NET_AX25_DAMA_SLAVE_TIMEOUT, "dama_slave_timeout" },
  430. {}
  431. };
  432. static const struct bin_table bin_net_ax25_table[] = {
  433. { CTL_DIR, 0, NULL, bin_net_ax25_param_table },
  434. {}
  435. };
  436. static const struct bin_table bin_net_rose_table[] = {
  437. { CTL_INT, NET_ROSE_RESTART_REQUEST_TIMEOUT, "restart_request_timeout" },
  438. { CTL_INT, NET_ROSE_CALL_REQUEST_TIMEOUT, "call_request_timeout" },
  439. { CTL_INT, NET_ROSE_RESET_REQUEST_TIMEOUT, "reset_request_timeout" },
  440. { CTL_INT, NET_ROSE_CLEAR_REQUEST_TIMEOUT, "clear_request_timeout" },
  441. { CTL_INT, NET_ROSE_ACK_HOLD_BACK_TIMEOUT, "acknowledge_hold_back_timeout" },
  442. { CTL_INT, NET_ROSE_ROUTING_CONTROL, "routing_control" },
  443. { CTL_INT, NET_ROSE_LINK_FAIL_TIMEOUT, "link_fail_timeout" },
  444. { CTL_INT, NET_ROSE_MAX_VCS, "maximum_virtual_circuits" },
  445. { CTL_INT, NET_ROSE_WINDOW_SIZE, "window_size" },
  446. { CTL_INT, NET_ROSE_NO_ACTIVITY_TIMEOUT, "no_activity_timeout" },
  447. {}
  448. };
  449. static const struct bin_table bin_net_ipv6_conf_var_table[] = {
  450. { CTL_INT, NET_IPV6_FORWARDING, "forwarding" },
  451. { CTL_INT, NET_IPV6_HOP_LIMIT, "hop_limit" },
  452. { CTL_INT, NET_IPV6_MTU, "mtu" },
  453. { CTL_INT, NET_IPV6_ACCEPT_RA, "accept_ra" },
  454. { CTL_INT, NET_IPV6_ACCEPT_REDIRECTS, "accept_redirects" },
  455. { CTL_INT, NET_IPV6_AUTOCONF, "autoconf" },
  456. { CTL_INT, NET_IPV6_DAD_TRANSMITS, "dad_transmits" },
  457. { CTL_INT, NET_IPV6_RTR_SOLICITS, "router_solicitations" },
  458. { CTL_INT, NET_IPV6_RTR_SOLICIT_INTERVAL, "router_solicitation_interval" },
  459. { CTL_INT, NET_IPV6_RTR_SOLICIT_DELAY, "router_solicitation_delay" },
  460. { CTL_INT, NET_IPV6_USE_TEMPADDR, "use_tempaddr" },
  461. { CTL_INT, NET_IPV6_TEMP_VALID_LFT, "temp_valid_lft" },
  462. { CTL_INT, NET_IPV6_TEMP_PREFERED_LFT, "temp_prefered_lft" },
  463. { CTL_INT, NET_IPV6_REGEN_MAX_RETRY, "regen_max_retry" },
  464. { CTL_INT, NET_IPV6_MAX_DESYNC_FACTOR, "max_desync_factor" },
  465. { CTL_INT, NET_IPV6_MAX_ADDRESSES, "max_addresses" },
  466. { CTL_INT, NET_IPV6_FORCE_MLD_VERSION, "force_mld_version" },
  467. { CTL_INT, NET_IPV6_ACCEPT_RA_DEFRTR, "accept_ra_defrtr" },
  468. { CTL_INT, NET_IPV6_ACCEPT_RA_PINFO, "accept_ra_pinfo" },
  469. { CTL_INT, NET_IPV6_ACCEPT_RA_RTR_PREF, "accept_ra_rtr_pref" },
  470. { CTL_INT, NET_IPV6_RTR_PROBE_INTERVAL, "router_probe_interval" },
  471. { CTL_INT, NET_IPV6_ACCEPT_RA_RT_INFO_MAX_PLEN, "accept_ra_rt_info_max_plen" },
  472. { CTL_INT, NET_IPV6_PROXY_NDP, "proxy_ndp" },
  473. { CTL_INT, NET_IPV6_ACCEPT_SOURCE_ROUTE, "accept_source_route" },
  474. { CTL_INT, NET_IPV6_ACCEPT_RA_FROM_LOCAL, "accept_ra_from_local" },
  475. {}
  476. };
  477. static const struct bin_table bin_net_ipv6_conf_table[] = {
  478. { CTL_DIR, NET_PROTO_CONF_ALL, "all", bin_net_ipv6_conf_var_table },
  479. { CTL_DIR, NET_PROTO_CONF_DEFAULT, "default", bin_net_ipv6_conf_var_table },
  480. { CTL_DIR, 0, NULL, bin_net_ipv6_conf_var_table },
  481. {}
  482. };
  483. static const struct bin_table bin_net_ipv6_route_table[] = {
  484. /* NET_IPV6_ROUTE_FLUSH "flush" no longer used */
  485. { CTL_INT, NET_IPV6_ROUTE_GC_THRESH, "gc_thresh" },
  486. { CTL_INT, NET_IPV6_ROUTE_MAX_SIZE, "max_size" },
  487. { CTL_INT, NET_IPV6_ROUTE_GC_MIN_INTERVAL, "gc_min_interval" },
  488. { CTL_INT, NET_IPV6_ROUTE_GC_TIMEOUT, "gc_timeout" },
  489. { CTL_INT, NET_IPV6_ROUTE_GC_INTERVAL, "gc_interval" },
  490. { CTL_INT, NET_IPV6_ROUTE_GC_ELASTICITY, "gc_elasticity" },
  491. { CTL_INT, NET_IPV6_ROUTE_MTU_EXPIRES, "mtu_expires" },
  492. { CTL_INT, NET_IPV6_ROUTE_MIN_ADVMSS, "min_adv_mss" },
  493. { CTL_INT, NET_IPV6_ROUTE_GC_MIN_INTERVAL_MS, "gc_min_interval_ms" },
  494. {}
  495. };
  496. static const struct bin_table bin_net_ipv6_icmp_table[] = {
  497. { CTL_INT, NET_IPV6_ICMP_RATELIMIT, "ratelimit" },
  498. {}
  499. };
  500. static const struct bin_table bin_net_ipv6_table[] = {
  501. { CTL_DIR, NET_IPV6_CONF, "conf", bin_net_ipv6_conf_table },
  502. { CTL_DIR, NET_IPV6_NEIGH, "neigh", bin_net_neigh_table },
  503. { CTL_DIR, NET_IPV6_ROUTE, "route", bin_net_ipv6_route_table },
  504. { CTL_DIR, NET_IPV6_ICMP, "icmp", bin_net_ipv6_icmp_table },
  505. { CTL_INT, NET_IPV6_BINDV6ONLY, "bindv6only" },
  506. { CTL_INT, NET_IPV6_IP6FRAG_HIGH_THRESH, "ip6frag_high_thresh" },
  507. { CTL_INT, NET_IPV6_IP6FRAG_LOW_THRESH, "ip6frag_low_thresh" },
  508. { CTL_INT, NET_IPV6_IP6FRAG_TIME, "ip6frag_time" },
  509. { CTL_INT, NET_IPV6_IP6FRAG_SECRET_INTERVAL, "ip6frag_secret_interval" },
  510. { CTL_INT, NET_IPV6_MLD_MAX_MSF, "mld_max_msf" },
  511. { CTL_INT, 2088 /* IPQ_QMAX */, "ip6_queue_maxlen" },
  512. {}
  513. };
  514. static const struct bin_table bin_net_x25_table[] = {
  515. { CTL_INT, NET_X25_RESTART_REQUEST_TIMEOUT, "restart_request_timeout" },
  516. { CTL_INT, NET_X25_CALL_REQUEST_TIMEOUT, "call_request_timeout" },
  517. { CTL_INT, NET_X25_RESET_REQUEST_TIMEOUT, "reset_request_timeout" },
  518. { CTL_INT, NET_X25_CLEAR_REQUEST_TIMEOUT, "clear_request_timeout" },
  519. { CTL_INT, NET_X25_ACK_HOLD_BACK_TIMEOUT, "acknowledgement_hold_back_timeout" },
  520. { CTL_INT, NET_X25_FORWARD, "x25_forward" },
  521. {}
  522. };
  523. static const struct bin_table bin_net_tr_table[] = {
  524. { CTL_INT, NET_TR_RIF_TIMEOUT, "rif_timeout" },
  525. {}
  526. };
  527. static const struct bin_table bin_net_decnet_conf_vars[] = {
  528. { CTL_INT, NET_DECNET_CONF_DEV_FORWARDING, "forwarding" },
  529. { CTL_INT, NET_DECNET_CONF_DEV_PRIORITY, "priority" },
  530. { CTL_INT, NET_DECNET_CONF_DEV_T2, "t2" },
  531. { CTL_INT, NET_DECNET_CONF_DEV_T3, "t3" },
  532. {}
  533. };
  534. static const struct bin_table bin_net_decnet_conf[] = {
  535. { CTL_DIR, NET_DECNET_CONF_ETHER, "ethernet", bin_net_decnet_conf_vars },
  536. { CTL_DIR, NET_DECNET_CONF_GRE, "ipgre", bin_net_decnet_conf_vars },
  537. { CTL_DIR, NET_DECNET_CONF_X25, "x25", bin_net_decnet_conf_vars },
  538. { CTL_DIR, NET_DECNET_CONF_PPP, "ppp", bin_net_decnet_conf_vars },
  539. { CTL_DIR, NET_DECNET_CONF_DDCMP, "ddcmp", bin_net_decnet_conf_vars },
  540. { CTL_DIR, NET_DECNET_CONF_LOOPBACK, "loopback", bin_net_decnet_conf_vars },
  541. { CTL_DIR, 0, NULL, bin_net_decnet_conf_vars },
  542. {}
  543. };
  544. static const struct bin_table bin_net_decnet_table[] = {
  545. { CTL_DIR, NET_DECNET_CONF, "conf", bin_net_decnet_conf },
  546. { CTL_DNADR, NET_DECNET_NODE_ADDRESS, "node_address" },
  547. { CTL_STR, NET_DECNET_NODE_NAME, "node_name" },
  548. { CTL_STR, NET_DECNET_DEFAULT_DEVICE, "default_device" },
  549. { CTL_INT, NET_DECNET_TIME_WAIT, "time_wait" },
  550. { CTL_INT, NET_DECNET_DN_COUNT, "dn_count" },
  551. { CTL_INT, NET_DECNET_DI_COUNT, "di_count" },
  552. { CTL_INT, NET_DECNET_DR_COUNT, "dr_count" },
  553. { CTL_INT, NET_DECNET_DST_GC_INTERVAL, "dst_gc_interval" },
  554. { CTL_INT, NET_DECNET_NO_FC_MAX_CWND, "no_fc_max_cwnd" },
  555. { CTL_INT, NET_DECNET_MEM, "decnet_mem" },
  556. { CTL_INT, NET_DECNET_RMEM, "decnet_rmem" },
  557. { CTL_INT, NET_DECNET_WMEM, "decnet_wmem" },
  558. { CTL_INT, NET_DECNET_DEBUG_LEVEL, "debug" },
  559. {}
  560. };
  561. static const struct bin_table bin_net_sctp_table[] = {
  562. { CTL_INT, NET_SCTP_RTO_INITIAL, "rto_initial" },
  563. { CTL_INT, NET_SCTP_RTO_MIN, "rto_min" },
  564. { CTL_INT, NET_SCTP_RTO_MAX, "rto_max" },
  565. { CTL_INT, NET_SCTP_RTO_ALPHA, "rto_alpha_exp_divisor" },
  566. { CTL_INT, NET_SCTP_RTO_BETA, "rto_beta_exp_divisor" },
  567. { CTL_INT, NET_SCTP_VALID_COOKIE_LIFE, "valid_cookie_life" },
  568. { CTL_INT, NET_SCTP_ASSOCIATION_MAX_RETRANS, "association_max_retrans" },
  569. { CTL_INT, NET_SCTP_PATH_MAX_RETRANS, "path_max_retrans" },
  570. { CTL_INT, NET_SCTP_MAX_INIT_RETRANSMITS, "max_init_retransmits" },
  571. { CTL_INT, NET_SCTP_HB_INTERVAL, "hb_interval" },
  572. { CTL_INT, NET_SCTP_PRESERVE_ENABLE, "cookie_preserve_enable" },
  573. { CTL_INT, NET_SCTP_MAX_BURST, "max_burst" },
  574. { CTL_INT, NET_SCTP_ADDIP_ENABLE, "addip_enable" },
  575. { CTL_INT, NET_SCTP_PRSCTP_ENABLE, "prsctp_enable" },
  576. { CTL_INT, NET_SCTP_SNDBUF_POLICY, "sndbuf_policy" },
  577. { CTL_INT, NET_SCTP_SACK_TIMEOUT, "sack_timeout" },
  578. { CTL_INT, NET_SCTP_RCVBUF_POLICY, "rcvbuf_policy" },
  579. {}
  580. };
  581. static const struct bin_table bin_net_llc_llc2_timeout_table[] = {
  582. { CTL_INT, NET_LLC2_ACK_TIMEOUT, "ack" },
  583. { CTL_INT, NET_LLC2_P_TIMEOUT, "p" },
  584. { CTL_INT, NET_LLC2_REJ_TIMEOUT, "rej" },
  585. { CTL_INT, NET_LLC2_BUSY_TIMEOUT, "busy" },
  586. {}
  587. };
  588. static const struct bin_table bin_net_llc_station_table[] = {
  589. { CTL_INT, NET_LLC_STATION_ACK_TIMEOUT, "ack_timeout" },
  590. {}
  591. };
  592. static const struct bin_table bin_net_llc_llc2_table[] = {
  593. { CTL_DIR, NET_LLC2, "timeout", bin_net_llc_llc2_timeout_table },
  594. {}
  595. };
  596. static const struct bin_table bin_net_llc_table[] = {
  597. { CTL_DIR, NET_LLC2, "llc2", bin_net_llc_llc2_table },
  598. { CTL_DIR, NET_LLC_STATION, "station", bin_net_llc_station_table },
  599. {}
  600. };
  601. static const struct bin_table bin_net_netfilter_table[] = {
  602. { CTL_INT, NET_NF_CONNTRACK_MAX, "nf_conntrack_max" },
  603. /* NET_NF_CONNTRACK_TCP_TIMEOUT_SYN_SENT "nf_conntrack_tcp_timeout_syn_sent" no longer used */
  604. /* NET_NF_CONNTRACK_TCP_TIMEOUT_SYN_RECV "nf_conntrack_tcp_timeout_syn_recv" no longer used */
  605. /* NET_NF_CONNTRACK_TCP_TIMEOUT_ESTABLISHED "nf_conntrack_tcp_timeout_established" no longer used */
  606. /* NET_NF_CONNTRACK_TCP_TIMEOUT_FIN_WAIT "nf_conntrack_tcp_timeout_fin_wait" no longer used */
  607. /* NET_NF_CONNTRACK_TCP_TIMEOUT_CLOSE_WAIT "nf_conntrack_tcp_timeout_close_wait" no longer used */
  608. /* NET_NF_CONNTRACK_TCP_TIMEOUT_LAST_ACK "nf_conntrack_tcp_timeout_last_ack" no longer used */
  609. /* NET_NF_CONNTRACK_TCP_TIMEOUT_TIME_WAIT "nf_conntrack_tcp_timeout_time_wait" no longer used */
  610. /* NET_NF_CONNTRACK_TCP_TIMEOUT_CLOSE "nf_conntrack_tcp_timeout_close" no longer used */
  611. /* NET_NF_CONNTRACK_UDP_TIMEOUT "nf_conntrack_udp_timeout" no longer used */
  612. /* NET_NF_CONNTRACK_UDP_TIMEOUT_STREAM "nf_conntrack_udp_timeout_stream" no longer used */
  613. /* NET_NF_CONNTRACK_ICMP_TIMEOUT "nf_conntrack_icmp_timeout" no longer used */
  614. /* NET_NF_CONNTRACK_GENERIC_TIMEOUT "nf_conntrack_generic_timeout" no longer used */
  615. { CTL_INT, NET_NF_CONNTRACK_BUCKETS, "nf_conntrack_buckets" },
  616. { CTL_INT, NET_NF_CONNTRACK_LOG_INVALID, "nf_conntrack_log_invalid" },
  617. /* NET_NF_CONNTRACK_TCP_TIMEOUT_MAX_RETRANS "nf_conntrack_tcp_timeout_max_retrans" no longer used */
  618. { CTL_INT, NET_NF_CONNTRACK_TCP_LOOSE, "nf_conntrack_tcp_loose" },
  619. { CTL_INT, NET_NF_CONNTRACK_TCP_BE_LIBERAL, "nf_conntrack_tcp_be_liberal" },
  620. { CTL_INT, NET_NF_CONNTRACK_TCP_MAX_RETRANS, "nf_conntrack_tcp_max_retrans" },
  621. /* NET_NF_CONNTRACK_SCTP_TIMEOUT_CLOSED "nf_conntrack_sctp_timeout_closed" no longer used */
  622. /* NET_NF_CONNTRACK_SCTP_TIMEOUT_COOKIE_WAIT "nf_conntrack_sctp_timeout_cookie_wait" no longer used */
  623. /* NET_NF_CONNTRACK_SCTP_TIMEOUT_COOKIE_ECHOED "nf_conntrack_sctp_timeout_cookie_echoed" no longer used */
  624. /* NET_NF_CONNTRACK_SCTP_TIMEOUT_ESTABLISHED "nf_conntrack_sctp_timeout_established" no longer used */
  625. /* NET_NF_CONNTRACK_SCTP_TIMEOUT_SHUTDOWN_SENT "nf_conntrack_sctp_timeout_shutdown_sent" no longer used */
  626. /* NET_NF_CONNTRACK_SCTP_TIMEOUT_SHUTDOWN_RECD "nf_conntrack_sctp_timeout_shutdown_recd" no longer used */
  627. /* NET_NF_CONNTRACK_SCTP_TIMEOUT_SHUTDOWN_ACK_SENT "nf_conntrack_sctp_timeout_shutdown_ack_sent" no longer used */
  628. { CTL_INT, NET_NF_CONNTRACK_COUNT, "nf_conntrack_count" },
  629. /* NET_NF_CONNTRACK_ICMPV6_TIMEOUT "nf_conntrack_icmpv6_timeout" no longer used */
  630. /* NET_NF_CONNTRACK_FRAG6_TIMEOUT "nf_conntrack_frag6_timeout" no longer used */
  631. { CTL_INT, NET_NF_CONNTRACK_FRAG6_LOW_THRESH, "nf_conntrack_frag6_low_thresh" },
  632. { CTL_INT, NET_NF_CONNTRACK_FRAG6_HIGH_THRESH, "nf_conntrack_frag6_high_thresh" },
  633. { CTL_INT, NET_NF_CONNTRACK_CHECKSUM, "nf_conntrack_checksum" },
  634. {}
  635. };
  636. static const struct bin_table bin_net_table[] = {
  637. { CTL_DIR, NET_CORE, "core", bin_net_core_table },
  638. /* NET_ETHER not used */
  639. /* NET_802 not used */
  640. { CTL_DIR, NET_UNIX, "unix", bin_net_unix_table },
  641. { CTL_DIR, NET_IPV4, "ipv4", bin_net_ipv4_table },
  642. { CTL_DIR, NET_IPX, "ipx", bin_net_ipx_table },
  643. { CTL_DIR, NET_ATALK, "appletalk", bin_net_atalk_table },
  644. { CTL_DIR, NET_NETROM, "netrom", bin_net_netrom_table },
  645. { CTL_DIR, NET_AX25, "ax25", bin_net_ax25_table },
  646. /* NET_BRIDGE "bridge" no longer used */
  647. { CTL_DIR, NET_ROSE, "rose", bin_net_rose_table },
  648. { CTL_DIR, NET_IPV6, "ipv6", bin_net_ipv6_table },
  649. { CTL_DIR, NET_X25, "x25", bin_net_x25_table },
  650. { CTL_DIR, NET_TR, "token-ring", bin_net_tr_table },
  651. { CTL_DIR, NET_DECNET, "decnet", bin_net_decnet_table },
  652. /* NET_ECONET not used */
  653. { CTL_DIR, NET_SCTP, "sctp", bin_net_sctp_table },
  654. { CTL_DIR, NET_LLC, "llc", bin_net_llc_table },
  655. { CTL_DIR, NET_NETFILTER, "netfilter", bin_net_netfilter_table },
  656. /* NET_DCCP "dccp" no longer used */
  657. /* NET_IRDA "irda" no longer used */
  658. { CTL_INT, 2089, "nf_conntrack_max" },
  659. {}
  660. };
  661. static const struct bin_table bin_fs_quota_table[] = {
  662. { CTL_INT, FS_DQ_LOOKUPS, "lookups" },
  663. { CTL_INT, FS_DQ_DROPS, "drops" },
  664. { CTL_INT, FS_DQ_READS, "reads" },
  665. { CTL_INT, FS_DQ_WRITES, "writes" },
  666. { CTL_INT, FS_DQ_CACHE_HITS, "cache_hits" },
  667. { CTL_INT, FS_DQ_ALLOCATED, "allocated_dquots" },
  668. { CTL_INT, FS_DQ_FREE, "free_dquots" },
  669. { CTL_INT, FS_DQ_SYNCS, "syncs" },
  670. { CTL_INT, FS_DQ_WARNINGS, "warnings" },
  671. {}
  672. };
  673. static const struct bin_table bin_fs_xfs_table[] = {
  674. { CTL_INT, XFS_SGID_INHERIT, "irix_sgid_inherit" },
  675. { CTL_INT, XFS_SYMLINK_MODE, "irix_symlink_mode" },
  676. { CTL_INT, XFS_PANIC_MASK, "panic_mask" },
  677. { CTL_INT, XFS_ERRLEVEL, "error_level" },
  678. { CTL_INT, XFS_SYNCD_TIMER, "xfssyncd_centisecs" },
  679. { CTL_INT, XFS_INHERIT_SYNC, "inherit_sync" },
  680. { CTL_INT, XFS_INHERIT_NODUMP, "inherit_nodump" },
  681. { CTL_INT, XFS_INHERIT_NOATIME, "inherit_noatime" },
  682. { CTL_INT, XFS_BUF_TIMER, "xfsbufd_centisecs" },
  683. { CTL_INT, XFS_BUF_AGE, "age_buffer_centisecs" },
  684. { CTL_INT, XFS_INHERIT_NOSYM, "inherit_nosymlinks" },
  685. { CTL_INT, XFS_ROTORSTEP, "rotorstep" },
  686. { CTL_INT, XFS_INHERIT_NODFRG, "inherit_nodefrag" },
  687. { CTL_INT, XFS_FILESTREAM_TIMER, "filestream_centisecs" },
  688. { CTL_INT, XFS_STATS_CLEAR, "stats_clear" },
  689. {}
  690. };
  691. static const struct bin_table bin_fs_ocfs2_nm_table[] = {
  692. { CTL_STR, 1, "hb_ctl_path" },
  693. {}
  694. };
  695. static const struct bin_table bin_fs_ocfs2_table[] = {
  696. { CTL_DIR, 1, "nm", bin_fs_ocfs2_nm_table },
  697. {}
  698. };
  699. static const struct bin_table bin_inotify_table[] = {
  700. { CTL_INT, INOTIFY_MAX_USER_INSTANCES, "max_user_instances" },
  701. { CTL_INT, INOTIFY_MAX_USER_WATCHES, "max_user_watches" },
  702. { CTL_INT, INOTIFY_MAX_QUEUED_EVENTS, "max_queued_events" },
  703. {}
  704. };
  705. static const struct bin_table bin_fs_table[] = {
  706. { CTL_INT, FS_NRINODE, "inode-nr" },
  707. { CTL_INT, FS_STATINODE, "inode-state" },
  708. /* FS_MAXINODE unused */
  709. /* FS_NRDQUOT unused */
  710. /* FS_MAXDQUOT unused */
  711. /* FS_NRFILE "file-nr" no longer used */
  712. { CTL_INT, FS_MAXFILE, "file-max" },
  713. { CTL_INT, FS_DENTRY, "dentry-state" },
  714. /* FS_NRSUPER unused */
  715. /* FS_MAXUPSER unused */
  716. { CTL_INT, FS_OVERFLOWUID, "overflowuid" },
  717. { CTL_INT, FS_OVERFLOWGID, "overflowgid" },
  718. { CTL_INT, FS_LEASES, "leases-enable" },
  719. { CTL_INT, FS_DIR_NOTIFY, "dir-notify-enable" },
  720. { CTL_INT, FS_LEASE_TIME, "lease-break-time" },
  721. { CTL_DIR, FS_DQSTATS, "quota", bin_fs_quota_table },
  722. { CTL_DIR, FS_XFS, "xfs", bin_fs_xfs_table },
  723. { CTL_ULONG, FS_AIO_NR, "aio-nr" },
  724. { CTL_ULONG, FS_AIO_MAX_NR, "aio-max-nr" },
  725. { CTL_DIR, FS_INOTIFY, "inotify", bin_inotify_table },
  726. { CTL_DIR, FS_OCFS2, "ocfs2", bin_fs_ocfs2_table },
  727. { CTL_INT, KERN_SETUID_DUMPABLE, "suid_dumpable" },
  728. {}
  729. };
  730. static const struct bin_table bin_ipmi_table[] = {
  731. { CTL_INT, DEV_IPMI_POWEROFF_POWERCYCLE, "poweroff_powercycle" },
  732. {}
  733. };
  734. static const struct bin_table bin_mac_hid_files[] = {
  735. /* DEV_MAC_HID_KEYBOARD_SENDS_LINUX_KEYCODES unused */
  736. /* DEV_MAC_HID_KEYBOARD_LOCK_KEYCODES unused */
  737. { CTL_INT, DEV_MAC_HID_MOUSE_BUTTON_EMULATION, "mouse_button_emulation" },
  738. { CTL_INT, DEV_MAC_HID_MOUSE_BUTTON2_KEYCODE, "mouse_button2_keycode" },
  739. { CTL_INT, DEV_MAC_HID_MOUSE_BUTTON3_KEYCODE, "mouse_button3_keycode" },
  740. /* DEV_MAC_HID_ADB_MOUSE_SENDS_KEYCODES unused */
  741. {}
  742. };
  743. static const struct bin_table bin_raid_table[] = {
  744. { CTL_INT, DEV_RAID_SPEED_LIMIT_MIN, "speed_limit_min" },
  745. { CTL_INT, DEV_RAID_SPEED_LIMIT_MAX, "speed_limit_max" },
  746. {}
  747. };
  748. static const struct bin_table bin_scsi_table[] = {
  749. { CTL_INT, DEV_SCSI_LOGGING_LEVEL, "logging_level" },
  750. {}
  751. };
  752. static const struct bin_table bin_dev_table[] = {
  753. /* DEV_CDROM "cdrom" no longer used */
  754. /* DEV_HWMON unused */
  755. /* DEV_PARPORT "parport" no longer used */
  756. { CTL_DIR, DEV_RAID, "raid", bin_raid_table },
  757. { CTL_DIR, DEV_MAC_HID, "mac_hid", bin_mac_hid_files },
  758. { CTL_DIR, DEV_SCSI, "scsi", bin_scsi_table },
  759. { CTL_DIR, DEV_IPMI, "ipmi", bin_ipmi_table },
  760. {}
  761. };
  762. static const struct bin_table bin_bus_isa_table[] = {
  763. { CTL_INT, BUS_ISA_MEM_BASE, "membase" },
  764. { CTL_INT, BUS_ISA_PORT_BASE, "portbase" },
  765. { CTL_INT, BUS_ISA_PORT_SHIFT, "portshift" },
  766. {}
  767. };
  768. static const struct bin_table bin_bus_table[] = {
  769. { CTL_DIR, CTL_BUS_ISA, "isa", bin_bus_isa_table },
  770. {}
  771. };
  772. static const struct bin_table bin_s390dbf_table[] = {
  773. { CTL_INT, 5678 /* CTL_S390DBF_STOPPABLE */, "debug_stoppable" },
  774. { CTL_INT, 5679 /* CTL_S390DBF_ACTIVE */, "debug_active" },
  775. {}
  776. };
  777. static const struct bin_table bin_sunrpc_table[] = {
  778. /* CTL_RPCDEBUG "rpc_debug" no longer used */
  779. /* CTL_NFSDEBUG "nfs_debug" no longer used */
  780. /* CTL_NFSDDEBUG "nfsd_debug" no longer used */
  781. /* CTL_NLMDEBUG "nlm_debug" no longer used */
  782. { CTL_INT, CTL_SLOTTABLE_UDP, "udp_slot_table_entries" },
  783. { CTL_INT, CTL_SLOTTABLE_TCP, "tcp_slot_table_entries" },
  784. { CTL_INT, CTL_MIN_RESVPORT, "min_resvport" },
  785. { CTL_INT, CTL_MAX_RESVPORT, "max_resvport" },
  786. {}
  787. };
  788. static const struct bin_table bin_pm_table[] = {
  789. /* frv specific */
  790. /* 1 == CTL_PM_SUSPEND "suspend" no longer used" */
  791. { CTL_INT, 2 /* CTL_PM_CMODE */, "cmode" },
  792. { CTL_INT, 3 /* CTL_PM_P0 */, "p0" },
  793. { CTL_INT, 4 /* CTL_PM_CM */, "cm" },
  794. {}
  795. };
  796. static const struct bin_table bin_root_table[] = {
  797. { CTL_DIR, CTL_KERN, "kernel", bin_kern_table },
  798. { CTL_DIR, CTL_VM, "vm", bin_vm_table },
  799. { CTL_DIR, CTL_NET, "net", bin_net_table },
  800. /* CTL_PROC not used */
  801. { CTL_DIR, CTL_FS, "fs", bin_fs_table },
  802. /* CTL_DEBUG "debug" no longer used */
  803. { CTL_DIR, CTL_DEV, "dev", bin_dev_table },
  804. { CTL_DIR, CTL_BUS, "bus", bin_bus_table },
  805. { CTL_DIR, CTL_ABI, "abi" },
  806. /* CTL_CPU not used */
  807. /* CTL_ARLAN "arlan" no longer used */
  808. { CTL_DIR, CTL_S390DBF, "s390dbf", bin_s390dbf_table },
  809. { CTL_DIR, CTL_SUNRPC, "sunrpc", bin_sunrpc_table },
  810. { CTL_DIR, CTL_PM, "pm", bin_pm_table },
  811. {}
  812. };
  813. static ssize_t bin_dir(struct file *file,
  814. void __user *oldval, size_t oldlen, void __user *newval, size_t newlen)
  815. {
  816. return -ENOTDIR;
  817. }
  818. static ssize_t bin_string(struct file *file,
  819. void __user *oldval, size_t oldlen, void __user *newval, size_t newlen)
  820. {
  821. ssize_t result, copied = 0;
  822. if (oldval && oldlen) {
  823. char __user *lastp;
  824. loff_t pos = 0;
  825. int ch;
  826. result = vfs_read(file, oldval, oldlen, &pos);
  827. if (result < 0)
  828. goto out;
  829. copied = result;
  830. lastp = oldval + copied - 1;
  831. result = -EFAULT;
  832. if (get_user(ch, lastp))
  833. goto out;
  834. /* Trim off the trailing newline */
  835. if (ch == '\n') {
  836. result = -EFAULT;
  837. if (put_user('\0', lastp))
  838. goto out;
  839. copied -= 1;
  840. }
  841. }
  842. if (newval && newlen) {
  843. loff_t pos = 0;
  844. result = vfs_write(file, newval, newlen, &pos);
  845. if (result < 0)
  846. goto out;
  847. }
  848. result = copied;
  849. out:
  850. return result;
  851. }
  852. static ssize_t bin_intvec(struct file *file,
  853. void __user *oldval, size_t oldlen, void __user *newval, size_t newlen)
  854. {
  855. ssize_t copied = 0;
  856. char *buffer;
  857. ssize_t result;
  858. result = -ENOMEM;
  859. buffer = kmalloc(BUFSZ, GFP_KERNEL);
  860. if (!buffer)
  861. goto out;
  862. if (oldval && oldlen) {
  863. unsigned __user *vec = oldval;
  864. size_t length = oldlen / sizeof(*vec);
  865. char *str, *end;
  866. int i;
  867. loff_t pos = 0;
  868. result = kernel_read(file, buffer, BUFSZ - 1, &pos);
  869. if (result < 0)
  870. goto out_kfree;
  871. str = buffer;
  872. end = str + result;
  873. *end++ = '\0';
  874. for (i = 0; i < length; i++) {
  875. unsigned long value;
  876. value = simple_strtoul(str, &str, 10);
  877. while (isspace(*str))
  878. str++;
  879. result = -EFAULT;
  880. if (put_user(value, vec + i))
  881. goto out_kfree;
  882. copied += sizeof(*vec);
  883. if (!isdigit(*str))
  884. break;
  885. }
  886. }
  887. if (newval && newlen) {
  888. unsigned __user *vec = newval;
  889. size_t length = newlen / sizeof(*vec);
  890. char *str, *end;
  891. int i;
  892. loff_t pos = 0;
  893. str = buffer;
  894. end = str + BUFSZ;
  895. for (i = 0; i < length; i++) {
  896. unsigned long value;
  897. result = -EFAULT;
  898. if (get_user(value, vec + i))
  899. goto out_kfree;
  900. str += scnprintf(str, end - str, "%lu\t", value);
  901. }
  902. result = kernel_write(file, buffer, str - buffer, &pos);
  903. if (result < 0)
  904. goto out_kfree;
  905. }
  906. result = copied;
  907. out_kfree:
  908. kfree(buffer);
  909. out:
  910. return result;
  911. }
  912. static ssize_t bin_ulongvec(struct file *file,
  913. void __user *oldval, size_t oldlen, void __user *newval, size_t newlen)
  914. {
  915. ssize_t copied = 0;
  916. char *buffer;
  917. ssize_t result;
  918. result = -ENOMEM;
  919. buffer = kmalloc(BUFSZ, GFP_KERNEL);
  920. if (!buffer)
  921. goto out;
  922. if (oldval && oldlen) {
  923. unsigned long __user *vec = oldval;
  924. size_t length = oldlen / sizeof(*vec);
  925. char *str, *end;
  926. int i;
  927. loff_t pos = 0;
  928. result = kernel_read(file, buffer, BUFSZ - 1, &pos);
  929. if (result < 0)
  930. goto out_kfree;
  931. str = buffer;
  932. end = str + result;
  933. *end++ = '\0';
  934. for (i = 0; i < length; i++) {
  935. unsigned long value;
  936. value = simple_strtoul(str, &str, 10);
  937. while (isspace(*str))
  938. str++;
  939. result = -EFAULT;
  940. if (put_user(value, vec + i))
  941. goto out_kfree;
  942. copied += sizeof(*vec);
  943. if (!isdigit(*str))
  944. break;
  945. }
  946. }
  947. if (newval && newlen) {
  948. unsigned long __user *vec = newval;
  949. size_t length = newlen / sizeof(*vec);
  950. char *str, *end;
  951. int i;
  952. loff_t pos = 0;
  953. str = buffer;
  954. end = str + BUFSZ;
  955. for (i = 0; i < length; i++) {
  956. unsigned long value;
  957. result = -EFAULT;
  958. if (get_user(value, vec + i))
  959. goto out_kfree;
  960. str += scnprintf(str, end - str, "%lu\t", value);
  961. }
  962. result = kernel_write(file, buffer, str - buffer, &pos);
  963. if (result < 0)
  964. goto out_kfree;
  965. }
  966. result = copied;
  967. out_kfree:
  968. kfree(buffer);
  969. out:
  970. return result;
  971. }
  972. static ssize_t bin_uuid(struct file *file,
  973. void __user *oldval, size_t oldlen, void __user *newval, size_t newlen)
  974. {
  975. ssize_t result, copied = 0;
  976. /* Only supports reads */
  977. if (oldval && oldlen) {
  978. char buf[UUID_STRING_LEN + 1];
  979. uuid_t uuid;
  980. loff_t pos = 0;
  981. result = kernel_read(file, buf, sizeof(buf) - 1, &pos);
  982. if (result < 0)
  983. goto out;
  984. buf[result] = '\0';
  985. result = -EIO;
  986. if (uuid_parse(buf, &uuid))
  987. goto out;
  988. if (oldlen > 16)
  989. oldlen = 16;
  990. result = -EFAULT;
  991. if (copy_to_user(oldval, &uuid, oldlen))
  992. goto out;
  993. copied = oldlen;
  994. }
  995. result = copied;
  996. out:
  997. return result;
  998. }
  999. static ssize_t bin_dn_node_address(struct file *file,
  1000. void __user *oldval, size_t oldlen, void __user *newval, size_t newlen)
  1001. {
  1002. ssize_t result, copied = 0;
  1003. if (oldval && oldlen) {
  1004. char buf[15], *nodep;
  1005. unsigned long area, node;
  1006. __le16 dnaddr;
  1007. loff_t pos = 0;
  1008. result = kernel_read(file, buf, sizeof(buf) - 1, &pos);
  1009. if (result < 0)
  1010. goto out;
  1011. buf[result] = '\0';
  1012. /* Convert the decnet address to binary */
  1013. result = -EIO;
  1014. nodep = strchr(buf, '.');
  1015. if (!nodep)
  1016. goto out;
  1017. ++nodep;
  1018. area = simple_strtoul(buf, NULL, 10);
  1019. node = simple_strtoul(nodep, NULL, 10);
  1020. result = -EIO;
  1021. if ((area > 63)||(node > 1023))
  1022. goto out;
  1023. dnaddr = cpu_to_le16((area << 10) | node);
  1024. result = -EFAULT;
  1025. if (put_user(dnaddr, (__le16 __user *)oldval))
  1026. goto out;
  1027. copied = sizeof(dnaddr);
  1028. }
  1029. if (newval && newlen) {
  1030. __le16 dnaddr;
  1031. char buf[15];
  1032. int len;
  1033. loff_t pos = 0;
  1034. result = -EINVAL;
  1035. if (newlen != sizeof(dnaddr))
  1036. goto out;
  1037. result = -EFAULT;
  1038. if (get_user(dnaddr, (__le16 __user *)newval))
  1039. goto out;
  1040. len = scnprintf(buf, sizeof(buf), "%hu.%hu",
  1041. le16_to_cpu(dnaddr) >> 10,
  1042. le16_to_cpu(dnaddr) & 0x3ff);
  1043. result = kernel_write(file, buf, len, &pos);
  1044. if (result < 0)
  1045. goto out;
  1046. }
  1047. result = copied;
  1048. out:
  1049. return result;
  1050. }
  1051. static const struct bin_table *get_sysctl(const int *name, int nlen, char *path)
  1052. {
  1053. const struct bin_table *table = &bin_root_table[0];
  1054. int ctl_name;
  1055. /* The binary sysctl tables have a small maximum depth so
  1056. * there is no danger of overflowing our path as it PATH_MAX
  1057. * bytes long.
  1058. */
  1059. memcpy(path, "sys/", 4);
  1060. path += 4;
  1061. repeat:
  1062. if (!nlen)
  1063. return ERR_PTR(-ENOTDIR);
  1064. ctl_name = *name;
  1065. name++;
  1066. nlen--;
  1067. for ( ; table->convert; table++) {
  1068. int len = 0;
  1069. /*
  1070. * For a wild card entry map from ifindex to network
  1071. * device name.
  1072. */
  1073. if (!table->ctl_name) {
  1074. #ifdef CONFIG_NET
  1075. struct net *net = current->nsproxy->net_ns;
  1076. struct net_device *dev;
  1077. dev = dev_get_by_index(net, ctl_name);
  1078. if (dev) {
  1079. len = strlen(dev->name);
  1080. memcpy(path, dev->name, len);
  1081. dev_put(dev);
  1082. }
  1083. #endif
  1084. /* Use the well known sysctl number to proc name mapping */
  1085. } else if (ctl_name == table->ctl_name) {
  1086. len = strlen(table->procname);
  1087. memcpy(path, table->procname, len);
  1088. }
  1089. if (len) {
  1090. path += len;
  1091. if (table->child) {
  1092. *path++ = '/';
  1093. table = table->child;
  1094. goto repeat;
  1095. }
  1096. *path = '\0';
  1097. return table;
  1098. }
  1099. }
  1100. return ERR_PTR(-ENOTDIR);
  1101. }
  1102. static char *sysctl_getname(const int *name, int nlen, const struct bin_table **tablep)
  1103. {
  1104. char *tmp, *result;
  1105. result = ERR_PTR(-ENOMEM);
  1106. tmp = __getname();
  1107. if (tmp) {
  1108. const struct bin_table *table = get_sysctl(name, nlen, tmp);
  1109. result = tmp;
  1110. *tablep = table;
  1111. if (IS_ERR(table)) {
  1112. __putname(tmp);
  1113. result = ERR_CAST(table);
  1114. }
  1115. }
  1116. return result;
  1117. }
  1118. static ssize_t binary_sysctl(const int *name, int nlen,
  1119. void __user *oldval, size_t oldlen, void __user *newval, size_t newlen)
  1120. {
  1121. const struct bin_table *table = NULL;
  1122. struct vfsmount *mnt;
  1123. struct file *file;
  1124. ssize_t result;
  1125. char *pathname;
  1126. int flags;
  1127. pathname = sysctl_getname(name, nlen, &table);
  1128. result = PTR_ERR(pathname);
  1129. if (IS_ERR(pathname))
  1130. goto out;
  1131. /* How should the sysctl be accessed? */
  1132. if (oldval && oldlen && newval && newlen) {
  1133. flags = O_RDWR;
  1134. } else if (newval && newlen) {
  1135. flags = O_WRONLY;
  1136. } else if (oldval && oldlen) {
  1137. flags = O_RDONLY;
  1138. } else {
  1139. result = 0;
  1140. goto out_putname;
  1141. }
  1142. mnt = task_active_pid_ns(current)->proc_mnt;
  1143. file = file_open_root(mnt->mnt_root, mnt, pathname, flags, 0);
  1144. result = PTR_ERR(file);
  1145. if (IS_ERR(file))
  1146. goto out_putname;
  1147. result = table->convert(file, oldval, oldlen, newval, newlen);
  1148. fput(file);
  1149. out_putname:
  1150. __putname(pathname);
  1151. out:
  1152. return result;
  1153. }
  1154. #else /* CONFIG_SYSCTL_SYSCALL */
  1155. static ssize_t binary_sysctl(const int *name, int nlen,
  1156. void __user *oldval, size_t oldlen, void __user *newval, size_t newlen)
  1157. {
  1158. return -ENOSYS;
  1159. }
  1160. #endif /* CONFIG_SYSCTL_SYSCALL */
  1161. static void deprecated_sysctl_warning(const int *name, int nlen)
  1162. {
  1163. int i;
  1164. /*
  1165. * CTL_KERN/KERN_VERSION is used by older glibc and cannot
  1166. * ever go away.
  1167. */
  1168. if (nlen >= 2 && name[0] == CTL_KERN && name[1] == KERN_VERSION)
  1169. return;
  1170. if (printk_ratelimit()) {
  1171. printk(KERN_INFO
  1172. "warning: process `%s' used the deprecated sysctl "
  1173. "system call with ", current->comm);
  1174. for (i = 0; i < nlen; i++)
  1175. printk(KERN_CONT "%d.", name[i]);
  1176. printk(KERN_CONT "\n");
  1177. }
  1178. return;
  1179. }
  1180. #define WARN_ONCE_HASH_BITS 8
  1181. #define WARN_ONCE_HASH_SIZE (1<<WARN_ONCE_HASH_BITS)
  1182. static DECLARE_BITMAP(warn_once_bitmap, WARN_ONCE_HASH_SIZE);
  1183. #define FNV32_OFFSET 2166136261U
  1184. #define FNV32_PRIME 0x01000193
  1185. /*
  1186. * Print each legacy sysctl (approximately) only once.
  1187. * To avoid making the tables non-const use a external
  1188. * hash-table instead.
  1189. * Worst case hash collision: 6, but very rarely.
  1190. * NOTE! We don't use the SMP-safe bit tests. We simply
  1191. * don't care enough.
  1192. */
  1193. static void warn_on_bintable(const int *name, int nlen)
  1194. {
  1195. int i;
  1196. u32 hash = FNV32_OFFSET;
  1197. for (i = 0; i < nlen; i++)
  1198. hash = (hash ^ name[i]) * FNV32_PRIME;
  1199. hash %= WARN_ONCE_HASH_SIZE;
  1200. if (__test_and_set_bit(hash, warn_once_bitmap))
  1201. return;
  1202. deprecated_sysctl_warning(name, nlen);
  1203. }
  1204. static ssize_t do_sysctl(int __user *args_name, int nlen,
  1205. void __user *oldval, size_t oldlen, void __user *newval, size_t newlen)
  1206. {
  1207. int name[CTL_MAXNAME];
  1208. int i;
  1209. /* Check args->nlen. */
  1210. if (nlen < 0 || nlen > CTL_MAXNAME)
  1211. return -ENOTDIR;
  1212. /* Read in the sysctl name for simplicity */
  1213. for (i = 0; i < nlen; i++)
  1214. if (get_user(name[i], args_name + i))
  1215. return -EFAULT;
  1216. warn_on_bintable(name, nlen);
  1217. return binary_sysctl(name, nlen, oldval, oldlen, newval, newlen);
  1218. }
  1219. SYSCALL_DEFINE1(sysctl, struct __sysctl_args __user *, args)
  1220. {
  1221. struct __sysctl_args tmp;
  1222. size_t oldlen = 0;
  1223. ssize_t result;
  1224. if (copy_from_user(&tmp, args, sizeof(tmp)))
  1225. return -EFAULT;
  1226. if (tmp.oldval && !tmp.oldlenp)
  1227. return -EFAULT;
  1228. if (tmp.oldlenp && get_user(oldlen, tmp.oldlenp))
  1229. return -EFAULT;
  1230. result = do_sysctl(tmp.name, tmp.nlen, tmp.oldval, oldlen,
  1231. tmp.newval, tmp.newlen);
  1232. if (result >= 0) {
  1233. oldlen = result;
  1234. result = 0;
  1235. }
  1236. if (tmp.oldlenp && put_user(oldlen, tmp.oldlenp))
  1237. return -EFAULT;
  1238. return result;
  1239. }
  1240. #ifdef CONFIG_COMPAT
  1241. struct compat_sysctl_args {
  1242. compat_uptr_t name;
  1243. int nlen;
  1244. compat_uptr_t oldval;
  1245. compat_uptr_t oldlenp;
  1246. compat_uptr_t newval;
  1247. compat_size_t newlen;
  1248. compat_ulong_t __unused[4];
  1249. };
  1250. COMPAT_SYSCALL_DEFINE1(sysctl, struct compat_sysctl_args __user *, args)
  1251. {
  1252. struct compat_sysctl_args tmp;
  1253. compat_size_t __user *compat_oldlenp;
  1254. size_t oldlen = 0;
  1255. ssize_t result;
  1256. if (copy_from_user(&tmp, args, sizeof(tmp)))
  1257. return -EFAULT;
  1258. if (tmp.oldval && !tmp.oldlenp)
  1259. return -EFAULT;
  1260. compat_oldlenp = compat_ptr(tmp.oldlenp);
  1261. if (compat_oldlenp && get_user(oldlen, compat_oldlenp))
  1262. return -EFAULT;
  1263. result = do_sysctl(compat_ptr(tmp.name), tmp.nlen,
  1264. compat_ptr(tmp.oldval), oldlen,
  1265. compat_ptr(tmp.newval), tmp.newlen);
  1266. if (result >= 0) {
  1267. oldlen = result;
  1268. result = 0;
  1269. }
  1270. if (compat_oldlenp && put_user(oldlen, compat_oldlenp))
  1271. return -EFAULT;
  1272. return result;
  1273. }
  1274. #endif /* CONFIG_COMPAT */