sysctl_binary.c 52 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523
  1. #include <linux/stat.h>
  2. #include <linux/sysctl.h>
  3. #include "../fs/xfs/xfs_sysctl.h"
  4. #include <linux/sunrpc/debug.h>
  5. #include <linux/string.h>
  6. #include <net/ip_vs.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/slab.h>
  18. #ifdef CONFIG_SYSCTL_SYSCALL
  19. struct bin_table;
  20. typedef ssize_t bin_convert_t(struct file *file,
  21. void __user *oldval, size_t oldlen, void __user *newval, size_t newlen);
  22. static bin_convert_t bin_dir;
  23. static bin_convert_t bin_string;
  24. static bin_convert_t bin_intvec;
  25. static bin_convert_t bin_ulongvec;
  26. static bin_convert_t bin_uuid;
  27. static bin_convert_t bin_dn_node_address;
  28. #define CTL_DIR bin_dir
  29. #define CTL_STR bin_string
  30. #define CTL_INT bin_intvec
  31. #define CTL_ULONG bin_ulongvec
  32. #define CTL_UUID bin_uuid
  33. #define CTL_DNADR bin_dn_node_address
  34. #define BUFSZ 256
  35. struct bin_table {
  36. bin_convert_t *convert;
  37. int ctl_name;
  38. const char *procname;
  39. const struct bin_table *child;
  40. };
  41. static const struct bin_table bin_random_table[] = {
  42. { CTL_INT, RANDOM_POOLSIZE, "poolsize" },
  43. { CTL_INT, RANDOM_ENTROPY_COUNT, "entropy_avail" },
  44. { CTL_INT, RANDOM_READ_THRESH, "read_wakeup_threshold" },
  45. { CTL_INT, RANDOM_WRITE_THRESH, "write_wakeup_threshold" },
  46. { CTL_UUID, RANDOM_BOOT_ID, "boot_id" },
  47. { CTL_UUID, RANDOM_UUID, "uuid" },
  48. {}
  49. };
  50. static const struct bin_table bin_pty_table[] = {
  51. { CTL_INT, PTY_MAX, "max" },
  52. { CTL_INT, PTY_NR, "nr" },
  53. {}
  54. };
  55. static const struct bin_table bin_kern_table[] = {
  56. { CTL_STR, KERN_OSTYPE, "ostype" },
  57. { CTL_STR, KERN_OSRELEASE, "osrelease" },
  58. /* KERN_OSREV not used */
  59. { CTL_STR, KERN_VERSION, "version" },
  60. /* KERN_SECUREMASK not used */
  61. /* KERN_PROF not used */
  62. { CTL_STR, KERN_NODENAME, "hostname" },
  63. { CTL_STR, KERN_DOMAINNAME, "domainname" },
  64. { CTL_INT, KERN_PANIC, "panic" },
  65. { CTL_INT, KERN_REALROOTDEV, "real-root-dev" },
  66. { CTL_STR, KERN_SPARC_REBOOT, "reboot-cmd" },
  67. { CTL_INT, KERN_CTLALTDEL, "ctrl-alt-del" },
  68. { CTL_INT, KERN_PRINTK, "printk" },
  69. /* KERN_NAMETRANS not used */
  70. /* KERN_PPC_HTABRECLAIM not used */
  71. /* KERN_PPC_ZEROPAGED not used */
  72. { CTL_INT, KERN_PPC_POWERSAVE_NAP, "powersave-nap" },
  73. { CTL_STR, KERN_MODPROBE, "modprobe" },
  74. { CTL_INT, KERN_SG_BIG_BUFF, "sg-big-buff" },
  75. { CTL_INT, KERN_ACCT, "acct" },
  76. /* KERN_PPC_L2CR "l2cr" no longer used */
  77. /* KERN_RTSIGNR not used */
  78. /* KERN_RTSIGMAX not used */
  79. { CTL_ULONG, KERN_SHMMAX, "shmmax" },
  80. { CTL_INT, KERN_MSGMAX, "msgmax" },
  81. { CTL_INT, KERN_MSGMNB, "msgmnb" },
  82. /* KERN_MSGPOOL not used*/
  83. { CTL_INT, KERN_SYSRQ, "sysrq" },
  84. { CTL_INT, KERN_MAX_THREADS, "threads-max" },
  85. { CTL_DIR, KERN_RANDOM, "random", bin_random_table },
  86. { CTL_ULONG, KERN_SHMALL, "shmall" },
  87. { CTL_INT, KERN_MSGMNI, "msgmni" },
  88. { CTL_INT, KERN_SEM, "sem" },
  89. { CTL_INT, KERN_SPARC_STOP_A, "stop-a" },
  90. { CTL_INT, KERN_SHMMNI, "shmmni" },
  91. { CTL_INT, KERN_OVERFLOWUID, "overflowuid" },
  92. { CTL_INT, KERN_OVERFLOWGID, "overflowgid" },
  93. { CTL_STR, KERN_HOTPLUG, "hotplug", },
  94. { CTL_INT, KERN_IEEE_EMULATION_WARNINGS, "ieee_emulation_warnings" },
  95. { CTL_INT, KERN_S390_USER_DEBUG_LOGGING, "userprocess_debug" },
  96. { CTL_INT, KERN_CORE_USES_PID, "core_uses_pid" },
  97. /* KERN_TAINTED "tainted" no longer used */
  98. { CTL_INT, KERN_CADPID, "cad_pid" },
  99. { CTL_INT, KERN_PIDMAX, "pid_max" },
  100. { CTL_STR, KERN_CORE_PATTERN, "core_pattern" },
  101. { CTL_INT, KERN_PANIC_ON_OOPS, "panic_on_oops" },
  102. { CTL_INT, KERN_HPPA_PWRSW, "soft-power" },
  103. { CTL_INT, KERN_HPPA_UNALIGNED, "unaligned-trap" },
  104. { CTL_INT, KERN_PRINTK_RATELIMIT, "printk_ratelimit" },
  105. { CTL_INT, KERN_PRINTK_RATELIMIT_BURST, "printk_ratelimit_burst" },
  106. { CTL_DIR, KERN_PTY, "pty", bin_pty_table },
  107. { CTL_INT, KERN_NGROUPS_MAX, "ngroups_max" },
  108. { CTL_INT, KERN_SPARC_SCONS_PWROFF, "scons-poweroff" },
  109. /* KERN_HZ_TIMER "hz_timer" no longer used */
  110. { CTL_INT, KERN_UNKNOWN_NMI_PANIC, "unknown_nmi_panic" },
  111. { CTL_INT, KERN_BOOTLOADER_TYPE, "bootloader_type" },
  112. { CTL_INT, KERN_RANDOMIZE, "randomize_va_space" },
  113. { CTL_INT, KERN_SPIN_RETRY, "spin_retry" },
  114. /* KERN_ACPI_VIDEO_FLAGS "acpi_video_flags" no longer used */
  115. { CTL_INT, KERN_IA64_UNALIGNED, "ignore-unaligned-usertrap" },
  116. { CTL_INT, KERN_COMPAT_LOG, "compat-log" },
  117. { CTL_INT, KERN_MAX_LOCK_DEPTH, "max_lock_depth" },
  118. { CTL_INT, KERN_PANIC_ON_NMI, "panic_on_unrecovered_nmi" },
  119. { CTL_INT, KERN_BOOT_REASON, "boot_reason" },
  120. { CTL_INT, KERN_COLD_BOOT, "cold_boot" },
  121. {}
  122. };
  123. static const struct bin_table bin_vm_table[] = {
  124. { CTL_INT, VM_OVERCOMMIT_MEMORY, "overcommit_memory" },
  125. { CTL_INT, VM_PAGE_CLUSTER, "page-cluster" },
  126. { CTL_INT, VM_DIRTY_BACKGROUND, "dirty_background_ratio" },
  127. { CTL_INT, VM_DIRTY_RATIO, "dirty_ratio" },
  128. /* VM_DIRTY_WB_CS "dirty_writeback_centisecs" no longer used */
  129. /* VM_DIRTY_EXPIRE_CS "dirty_expire_centisecs" no longer used */
  130. { CTL_INT, VM_NR_PDFLUSH_THREADS, "nr_pdflush_threads" },
  131. { CTL_INT, VM_OVERCOMMIT_RATIO, "overcommit_ratio" },
  132. /* VM_PAGEBUF unused */
  133. /* VM_HUGETLB_PAGES "nr_hugepages" no longer used */
  134. { CTL_INT, VM_SWAPPINESS, "swappiness" },
  135. { CTL_INT, VM_LOWMEM_RESERVE_RATIO, "lowmem_reserve_ratio" },
  136. { CTL_INT, VM_MIN_FREE_KBYTES, "min_free_kbytes" },
  137. { CTL_INT, VM_MAX_MAP_COUNT, "max_map_count" },
  138. { CTL_INT, VM_LAPTOP_MODE, "laptop_mode" },
  139. { CTL_INT, VM_BLOCK_DUMP, "block_dump" },
  140. { CTL_INT, VM_HUGETLB_GROUP, "hugetlb_shm_group" },
  141. { CTL_INT, VM_VFS_CACHE_PRESSURE, "vfs_cache_pressure" },
  142. { CTL_INT, VM_LEGACY_VA_LAYOUT, "legacy_va_layout" },
  143. /* VM_SWAP_TOKEN_TIMEOUT unused */
  144. { CTL_INT, VM_DROP_PAGECACHE, "drop_caches" },
  145. { CTL_INT, VM_PERCPU_PAGELIST_FRACTION, "percpu_pagelist_fraction" },
  146. { CTL_INT, VM_ZONE_RECLAIM_MODE, "zone_reclaim_mode" },
  147. { CTL_INT, VM_MIN_UNMAPPED, "min_unmapped_ratio" },
  148. { CTL_INT, VM_PANIC_ON_OOM, "panic_on_oom" },
  149. { CTL_INT, VM_VDSO_ENABLED, "vdso_enabled" },
  150. { CTL_INT, VM_MIN_SLAB, "min_slab_ratio" },
  151. {}
  152. };
  153. static const struct bin_table bin_net_core_table[] = {
  154. { CTL_INT, NET_CORE_WMEM_MAX, "wmem_max" },
  155. { CTL_INT, NET_CORE_RMEM_MAX, "rmem_max" },
  156. { CTL_INT, NET_CORE_WMEM_DEFAULT, "wmem_default" },
  157. { CTL_INT, NET_CORE_RMEM_DEFAULT, "rmem_default" },
  158. /* NET_CORE_DESTROY_DELAY unused */
  159. { CTL_INT, NET_CORE_MAX_BACKLOG, "netdev_max_backlog" },
  160. /* NET_CORE_FASTROUTE unused */
  161. { CTL_INT, NET_CORE_MSG_COST, "message_cost" },
  162. { CTL_INT, NET_CORE_MSG_BURST, "message_burst" },
  163. { CTL_INT, NET_CORE_OPTMEM_MAX, "optmem_max" },
  164. /* NET_CORE_HOT_LIST_LENGTH unused */
  165. /* NET_CORE_DIVERT_VERSION unused */
  166. /* NET_CORE_NO_CONG_THRESH unused */
  167. /* NET_CORE_NO_CONG unused */
  168. /* NET_CORE_LO_CONG unused */
  169. /* NET_CORE_MOD_CONG unused */
  170. { CTL_INT, NET_CORE_DEV_WEIGHT, "dev_weight" },
  171. { CTL_INT, NET_CORE_SOMAXCONN, "somaxconn" },
  172. { CTL_INT, NET_CORE_BUDGET, "netdev_budget" },
  173. { CTL_INT, NET_CORE_AEVENT_ETIME, "xfrm_aevent_etime" },
  174. { CTL_INT, NET_CORE_AEVENT_RSEQTH, "xfrm_aevent_rseqth" },
  175. { CTL_INT, NET_CORE_WARNINGS, "warnings" },
  176. {},
  177. };
  178. static const struct bin_table bin_net_unix_table[] = {
  179. /* NET_UNIX_DESTROY_DELAY unused */
  180. /* NET_UNIX_DELETE_DELAY unused */
  181. { CTL_INT, NET_UNIX_MAX_DGRAM_QLEN, "max_dgram_qlen" },
  182. {}
  183. };
  184. static const struct bin_table bin_net_ipv4_route_table[] = {
  185. { CTL_INT, NET_IPV4_ROUTE_FLUSH, "flush" },
  186. /* NET_IPV4_ROUTE_MIN_DELAY "min_delay" no longer used */
  187. /* NET_IPV4_ROUTE_MAX_DELAY "max_delay" no longer used */
  188. { CTL_INT, NET_IPV4_ROUTE_GC_THRESH, "gc_thresh" },
  189. { CTL_INT, NET_IPV4_ROUTE_MAX_SIZE, "max_size" },
  190. { CTL_INT, NET_IPV4_ROUTE_GC_MIN_INTERVAL, "gc_min_interval" },
  191. { CTL_INT, NET_IPV4_ROUTE_GC_MIN_INTERVAL_MS, "gc_min_interval_ms" },
  192. { CTL_INT, NET_IPV4_ROUTE_GC_TIMEOUT, "gc_timeout" },
  193. /* NET_IPV4_ROUTE_GC_INTERVAL "gc_interval" no longer used */
  194. { CTL_INT, NET_IPV4_ROUTE_REDIRECT_LOAD, "redirect_load" },
  195. { CTL_INT, NET_IPV4_ROUTE_REDIRECT_NUMBER, "redirect_number" },
  196. { CTL_INT, NET_IPV4_ROUTE_REDIRECT_SILENCE, "redirect_silence" },
  197. { CTL_INT, NET_IPV4_ROUTE_ERROR_COST, "error_cost" },
  198. { CTL_INT, NET_IPV4_ROUTE_ERROR_BURST, "error_burst" },
  199. { CTL_INT, NET_IPV4_ROUTE_GC_ELASTICITY, "gc_elasticity" },
  200. { CTL_INT, NET_IPV4_ROUTE_MTU_EXPIRES, "mtu_expires" },
  201. { CTL_INT, NET_IPV4_ROUTE_MIN_PMTU, "min_pmtu" },
  202. { CTL_INT, NET_IPV4_ROUTE_MIN_ADVMSS, "min_adv_mss" },
  203. {}
  204. };
  205. static const struct bin_table bin_net_ipv4_conf_vars_table[] = {
  206. { CTL_INT, NET_IPV4_CONF_FORWARDING, "forwarding" },
  207. { CTL_INT, NET_IPV4_CONF_MC_FORWARDING, "mc_forwarding" },
  208. { CTL_INT, NET_IPV4_CONF_ACCEPT_REDIRECTS, "accept_redirects" },
  209. { CTL_INT, NET_IPV4_CONF_SECURE_REDIRECTS, "secure_redirects" },
  210. { CTL_INT, NET_IPV4_CONF_SEND_REDIRECTS, "send_redirects" },
  211. { CTL_INT, NET_IPV4_CONF_SHARED_MEDIA, "shared_media" },
  212. { CTL_INT, NET_IPV4_CONF_RP_FILTER, "rp_filter" },
  213. { CTL_INT, NET_IPV4_CONF_ACCEPT_SOURCE_ROUTE, "accept_source_route" },
  214. { CTL_INT, NET_IPV4_CONF_PROXY_ARP, "proxy_arp" },
  215. { CTL_INT, NET_IPV4_CONF_MEDIUM_ID, "medium_id" },
  216. { CTL_INT, NET_IPV4_CONF_BOOTP_RELAY, "bootp_relay" },
  217. { CTL_INT, NET_IPV4_CONF_LOG_MARTIANS, "log_martians" },
  218. { CTL_INT, NET_IPV4_CONF_TAG, "tag" },
  219. { CTL_INT, NET_IPV4_CONF_ARPFILTER, "arp_filter" },
  220. { CTL_INT, NET_IPV4_CONF_ARP_ANNOUNCE, "arp_announce" },
  221. { CTL_INT, NET_IPV4_CONF_ARP_IGNORE, "arp_ignore" },
  222. { CTL_INT, NET_IPV4_CONF_ARP_ACCEPT, "arp_accept" },
  223. { CTL_INT, NET_IPV4_CONF_ARP_NOTIFY, "arp_notify" },
  224. { CTL_INT, NET_IPV4_CONF_NOXFRM, "disable_xfrm" },
  225. { CTL_INT, NET_IPV4_CONF_NOPOLICY, "disable_policy" },
  226. { CTL_INT, NET_IPV4_CONF_FORCE_IGMP_VERSION, "force_igmp_version" },
  227. { CTL_INT, NET_IPV4_CONF_PROMOTE_SECONDARIES, "promote_secondaries" },
  228. {}
  229. };
  230. static const struct bin_table bin_net_ipv4_conf_table[] = {
  231. { CTL_DIR, NET_PROTO_CONF_ALL, "all", bin_net_ipv4_conf_vars_table },
  232. { CTL_DIR, NET_PROTO_CONF_DEFAULT, "default", bin_net_ipv4_conf_vars_table },
  233. { CTL_DIR, 0, NULL, bin_net_ipv4_conf_vars_table },
  234. {}
  235. };
  236. static const struct bin_table bin_net_neigh_vars_table[] = {
  237. { CTL_INT, NET_NEIGH_MCAST_SOLICIT, "mcast_solicit" },
  238. { CTL_INT, NET_NEIGH_UCAST_SOLICIT, "ucast_solicit" },
  239. { CTL_INT, NET_NEIGH_APP_SOLICIT, "app_solicit" },
  240. /* NET_NEIGH_RETRANS_TIME "retrans_time" no longer used */
  241. { CTL_INT, NET_NEIGH_REACHABLE_TIME, "base_reachable_time" },
  242. { CTL_INT, NET_NEIGH_DELAY_PROBE_TIME, "delay_first_probe_time" },
  243. { CTL_INT, NET_NEIGH_GC_STALE_TIME, "gc_stale_time" },
  244. { CTL_INT, NET_NEIGH_UNRES_QLEN, "unres_qlen" },
  245. { CTL_INT, NET_NEIGH_PROXY_QLEN, "proxy_qlen" },
  246. /* NET_NEIGH_ANYCAST_DELAY "anycast_delay" no longer used */
  247. /* NET_NEIGH_PROXY_DELAY "proxy_delay" no longer used */
  248. /* NET_NEIGH_LOCKTIME "locktime" no longer used */
  249. { CTL_INT, NET_NEIGH_GC_INTERVAL, "gc_interval" },
  250. { CTL_INT, NET_NEIGH_GC_THRESH1, "gc_thresh1" },
  251. { CTL_INT, NET_NEIGH_GC_THRESH2, "gc_thresh2" },
  252. { CTL_INT, NET_NEIGH_GC_THRESH3, "gc_thresh3" },
  253. { CTL_INT, NET_NEIGH_RETRANS_TIME_MS, "retrans_time_ms" },
  254. { CTL_INT, NET_NEIGH_REACHABLE_TIME_MS, "base_reachable_time_ms" },
  255. {}
  256. };
  257. static const struct bin_table bin_net_neigh_table[] = {
  258. { CTL_DIR, NET_PROTO_CONF_DEFAULT, "default", bin_net_neigh_vars_table },
  259. { CTL_DIR, 0, NULL, bin_net_neigh_vars_table },
  260. {}
  261. };
  262. static const struct bin_table bin_net_ipv4_netfilter_table[] = {
  263. { CTL_INT, NET_IPV4_NF_CONNTRACK_MAX, "ip_conntrack_max" },
  264. /* NET_IPV4_NF_CONNTRACK_TCP_TIMEOUT_SYN_SENT "ip_conntrack_tcp_timeout_syn_sent" no longer used */
  265. /* NET_IPV4_NF_CONNTRACK_TCP_TIMEOUT_SYN_RECV "ip_conntrack_tcp_timeout_syn_recv" no longer used */
  266. /* NET_IPV4_NF_CONNTRACK_TCP_TIMEOUT_ESTABLISHED "ip_conntrack_tcp_timeout_established" no longer used */
  267. /* NET_IPV4_NF_CONNTRACK_TCP_TIMEOUT_FIN_WAIT "ip_conntrack_tcp_timeout_fin_wait" no longer used */
  268. /* NET_IPV4_NF_CONNTRACK_TCP_TIMEOUT_CLOSE_WAIT "ip_conntrack_tcp_timeout_close_wait" no longer used */
  269. /* NET_IPV4_NF_CONNTRACK_TCP_TIMEOUT_LAST_ACK "ip_conntrack_tcp_timeout_last_ack" no longer used */
  270. /* NET_IPV4_NF_CONNTRACK_TCP_TIMEOUT_TIME_WAIT "ip_conntrack_tcp_timeout_time_wait" no longer used */
  271. /* NET_IPV4_NF_CONNTRACK_TCP_TIMEOUT_CLOSE "ip_conntrack_tcp_timeout_close" no longer used */
  272. /* NET_IPV4_NF_CONNTRACK_UDP_TIMEOUT "ip_conntrack_udp_timeout" no longer used */
  273. /* NET_IPV4_NF_CONNTRACK_UDP_TIMEOUT_STREAM "ip_conntrack_udp_timeout_stream" no longer used */
  274. /* NET_IPV4_NF_CONNTRACK_ICMP_TIMEOUT "ip_conntrack_icmp_timeout" no longer used */
  275. /* NET_IPV4_NF_CONNTRACK_GENERIC_TIMEOUT "ip_conntrack_generic_timeout" no longer used */
  276. { CTL_INT, NET_IPV4_NF_CONNTRACK_BUCKETS, "ip_conntrack_buckets" },
  277. { CTL_INT, NET_IPV4_NF_CONNTRACK_LOG_INVALID, "ip_conntrack_log_invalid" },
  278. /* NET_IPV4_NF_CONNTRACK_TCP_TIMEOUT_MAX_RETRANS "ip_conntrack_tcp_timeout_max_retrans" no longer used */
  279. { CTL_INT, NET_IPV4_NF_CONNTRACK_TCP_LOOSE, "ip_conntrack_tcp_loose" },
  280. { CTL_INT, NET_IPV4_NF_CONNTRACK_TCP_BE_LIBERAL, "ip_conntrack_tcp_be_liberal" },
  281. { CTL_INT, NET_IPV4_NF_CONNTRACK_TCP_MAX_RETRANS, "ip_conntrack_tcp_max_retrans" },
  282. /* NET_IPV4_NF_CONNTRACK_SCTP_TIMEOUT_CLOSED "ip_conntrack_sctp_timeout_closed" no longer used */
  283. /* NET_IPV4_NF_CONNTRACK_SCTP_TIMEOUT_COOKIE_WAIT "ip_conntrack_sctp_timeout_cookie_wait" no longer used */
  284. /* NET_IPV4_NF_CONNTRACK_SCTP_TIMEOUT_COOKIE_ECHOED "ip_conntrack_sctp_timeout_cookie_echoed" no longer used */
  285. /* NET_IPV4_NF_CONNTRACK_SCTP_TIMEOUT_ESTABLISHED "ip_conntrack_sctp_timeout_established" no longer used */
  286. /* NET_IPV4_NF_CONNTRACK_SCTP_TIMEOUT_SHUTDOWN_SENT "ip_conntrack_sctp_timeout_shutdown_sent" no longer used */
  287. /* NET_IPV4_NF_CONNTRACK_SCTP_TIMEOUT_SHUTDOWN_RECD "ip_conntrack_sctp_timeout_shutdown_recd" no longer used */
  288. /* NET_IPV4_NF_CONNTRACK_SCTP_TIMEOUT_SHUTDOWN_ACK_SENT "ip_conntrack_sctp_timeout_shutdown_ack_sent" no longer used */
  289. { CTL_INT, NET_IPV4_NF_CONNTRACK_COUNT, "ip_conntrack_count" },
  290. { CTL_INT, NET_IPV4_NF_CONNTRACK_CHECKSUM, "ip_conntrack_checksum" },
  291. {}
  292. };
  293. static const struct bin_table bin_net_ipv4_table[] = {
  294. {CTL_INT, NET_IPV4_FORWARD, "ip_forward" },
  295. { CTL_DIR, NET_IPV4_CONF, "conf", bin_net_ipv4_conf_table },
  296. { CTL_DIR, NET_IPV4_NEIGH, "neigh", bin_net_neigh_table },
  297. { CTL_DIR, NET_IPV4_ROUTE, "route", bin_net_ipv4_route_table },
  298. /* NET_IPV4_FIB_HASH unused */
  299. { CTL_DIR, NET_IPV4_NETFILTER, "netfilter", bin_net_ipv4_netfilter_table },
  300. { CTL_INT, NET_IPV4_TCP_TIMESTAMPS, "tcp_timestamps" },
  301. { CTL_INT, NET_IPV4_TCP_WINDOW_SCALING, "tcp_window_scaling" },
  302. { CTL_INT, NET_IPV4_TCP_SACK, "tcp_sack" },
  303. { CTL_INT, NET_IPV4_TCP_RETRANS_COLLAPSE, "tcp_retrans_collapse" },
  304. { CTL_INT, NET_IPV4_DEFAULT_TTL, "ip_default_ttl" },
  305. /* NET_IPV4_AUTOCONFIG unused */
  306. { CTL_INT, NET_IPV4_NO_PMTU_DISC, "ip_no_pmtu_disc" },
  307. { CTL_INT, NET_IPV4_NONLOCAL_BIND, "ip_nonlocal_bind" },
  308. { CTL_INT, NET_IPV4_TCP_SYN_RETRIES, "tcp_syn_retries" },
  309. { CTL_INT, NET_TCP_SYNACK_RETRIES, "tcp_synack_retries" },
  310. { CTL_INT, NET_TCP_MAX_ORPHANS, "tcp_max_orphans" },
  311. { CTL_INT, NET_TCP_MAX_TW_BUCKETS, "tcp_max_tw_buckets" },
  312. { CTL_INT, NET_IPV4_DYNADDR, "ip_dynaddr" },
  313. { CTL_INT, NET_IPV4_TCP_KEEPALIVE_TIME, "tcp_keepalive_time" },
  314. { CTL_INT, NET_IPV4_TCP_KEEPALIVE_PROBES, "tcp_keepalive_probes" },
  315. { CTL_INT, NET_IPV4_TCP_KEEPALIVE_INTVL, "tcp_keepalive_intvl" },
  316. { CTL_INT, NET_IPV4_TCP_RETRIES1, "tcp_retries1" },
  317. { CTL_INT, NET_IPV4_TCP_RETRIES2, "tcp_retries2" },
  318. { CTL_INT, NET_IPV4_TCP_FIN_TIMEOUT, "tcp_fin_timeout" },
  319. { CTL_INT, NET_TCP_SYNCOOKIES, "tcp_syncookies" },
  320. { CTL_INT, NET_TCP_TW_RECYCLE, "tcp_tw_recycle" },
  321. { CTL_INT, NET_TCP_ABORT_ON_OVERFLOW, "tcp_abort_on_overflow" },
  322. { CTL_INT, NET_TCP_STDURG, "tcp_stdurg" },
  323. { CTL_INT, NET_TCP_RFC1337, "tcp_rfc1337" },
  324. { CTL_INT, NET_TCP_MAX_SYN_BACKLOG, "tcp_max_syn_backlog" },
  325. { CTL_INT, NET_IPV4_LOCAL_PORT_RANGE, "ip_local_port_range" },
  326. { CTL_INT, NET_IPV4_IGMP_MAX_MEMBERSHIPS, "igmp_max_memberships" },
  327. { CTL_INT, NET_IPV4_IGMP_MAX_MSF, "igmp_max_msf" },
  328. { CTL_INT, NET_IPV4_INET_PEER_THRESHOLD, "inet_peer_threshold" },
  329. { CTL_INT, NET_IPV4_INET_PEER_MINTTL, "inet_peer_minttl" },
  330. { CTL_INT, NET_IPV4_INET_PEER_MAXTTL, "inet_peer_maxttl" },
  331. { CTL_INT, NET_IPV4_INET_PEER_GC_MINTIME, "inet_peer_gc_mintime" },
  332. { CTL_INT, NET_IPV4_INET_PEER_GC_MAXTIME, "inet_peer_gc_maxtime" },
  333. { CTL_INT, NET_TCP_ORPHAN_RETRIES, "tcp_orphan_retries" },
  334. { CTL_INT, NET_TCP_FACK, "tcp_fack" },
  335. { CTL_INT, NET_TCP_REORDERING, "tcp_reordering" },
  336. { CTL_INT, NET_TCP_ECN, "tcp_ecn" },
  337. { CTL_INT, NET_TCP_DSACK, "tcp_dsack" },
  338. { CTL_INT, NET_TCP_MEM, "tcp_mem" },
  339. { CTL_INT, NET_TCP_WMEM, "tcp_wmem" },
  340. { CTL_INT, NET_TCP_RMEM, "tcp_rmem" },
  341. { CTL_INT, NET_TCP_APP_WIN, "tcp_app_win" },
  342. { CTL_INT, NET_TCP_ADV_WIN_SCALE, "tcp_adv_win_scale" },
  343. { CTL_INT, NET_TCP_TW_REUSE, "tcp_tw_reuse" },
  344. { CTL_INT, NET_TCP_FRTO, "tcp_frto" },
  345. { CTL_INT, NET_TCP_FRTO_RESPONSE, "tcp_frto_response" },
  346. { CTL_INT, NET_TCP_LOW_LATENCY, "tcp_low_latency" },
  347. { CTL_INT, NET_TCP_NO_METRICS_SAVE, "tcp_no_metrics_save" },
  348. { CTL_INT, NET_TCP_MODERATE_RCVBUF, "tcp_moderate_rcvbuf" },
  349. { CTL_INT, NET_TCP_TSO_WIN_DIVISOR, "tcp_tso_win_divisor" },
  350. { CTL_STR, NET_TCP_CONG_CONTROL, "tcp_congestion_control" },
  351. { CTL_INT, NET_TCP_MTU_PROBING, "tcp_mtu_probing" },
  352. { CTL_INT, NET_TCP_BASE_MSS, "tcp_base_mss" },
  353. { CTL_INT, NET_IPV4_TCP_WORKAROUND_SIGNED_WINDOWS, "tcp_workaround_signed_windows" },
  354. { CTL_INT, NET_TCP_DMA_COPYBREAK, "tcp_dma_copybreak" },
  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_PREFIX_ROUTE, "accept_ra_prefix_route" },
  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_irda_table[] = {
  637. { CTL_INT, NET_IRDA_DISCOVERY, "discovery" },
  638. { CTL_STR, NET_IRDA_DEVNAME, "devname" },
  639. { CTL_INT, NET_IRDA_DEBUG, "debug" },
  640. { CTL_INT, NET_IRDA_FAST_POLL, "fast_poll_increase" },
  641. { CTL_INT, NET_IRDA_DISCOVERY_SLOTS, "discovery_slots" },
  642. { CTL_INT, NET_IRDA_DISCOVERY_TIMEOUT, "discovery_timeout" },
  643. { CTL_INT, NET_IRDA_SLOT_TIMEOUT, "slot_timeout" },
  644. { CTL_INT, NET_IRDA_MAX_BAUD_RATE, "max_baud_rate" },
  645. { CTL_INT, NET_IRDA_MIN_TX_TURN_TIME, "min_tx_turn_time" },
  646. { CTL_INT, NET_IRDA_MAX_TX_DATA_SIZE, "max_tx_data_size" },
  647. { CTL_INT, NET_IRDA_MAX_TX_WINDOW, "max_tx_window" },
  648. { CTL_INT, NET_IRDA_MAX_NOREPLY_TIME, "max_noreply_time" },
  649. { CTL_INT, NET_IRDA_WARN_NOREPLY_TIME, "warn_noreply_time" },
  650. { CTL_INT, NET_IRDA_LAP_KEEPALIVE_TIME, "lap_keepalive_time" },
  651. {}
  652. };
  653. static const struct bin_table bin_net_table[] = {
  654. { CTL_DIR, NET_CORE, "core", bin_net_core_table },
  655. /* NET_ETHER not used */
  656. /* NET_802 not used */
  657. { CTL_DIR, NET_UNIX, "unix", bin_net_unix_table },
  658. { CTL_DIR, NET_IPV4, "ipv4", bin_net_ipv4_table },
  659. { CTL_DIR, NET_IPX, "ipx", bin_net_ipx_table },
  660. { CTL_DIR, NET_ATALK, "appletalk", bin_net_atalk_table },
  661. { CTL_DIR, NET_NETROM, "netrom", bin_net_netrom_table },
  662. { CTL_DIR, NET_AX25, "ax25", bin_net_ax25_table },
  663. /* NET_BRIDGE "bridge" no longer used */
  664. { CTL_DIR, NET_ROSE, "rose", bin_net_rose_table },
  665. { CTL_DIR, NET_IPV6, "ipv6", bin_net_ipv6_table },
  666. { CTL_DIR, NET_X25, "x25", bin_net_x25_table },
  667. { CTL_DIR, NET_TR, "token-ring", bin_net_tr_table },
  668. { CTL_DIR, NET_DECNET, "decnet", bin_net_decnet_table },
  669. /* NET_ECONET not used */
  670. { CTL_DIR, NET_SCTP, "sctp", bin_net_sctp_table },
  671. { CTL_DIR, NET_LLC, "llc", bin_net_llc_table },
  672. { CTL_DIR, NET_NETFILTER, "netfilter", bin_net_netfilter_table },
  673. /* NET_DCCP "dccp" no longer used */
  674. { CTL_DIR, NET_IRDA, "irda", bin_net_irda_table },
  675. { CTL_INT, 2089, "nf_conntrack_max" },
  676. {}
  677. };
  678. static const struct bin_table bin_fs_quota_table[] = {
  679. { CTL_INT, FS_DQ_LOOKUPS, "lookups" },
  680. { CTL_INT, FS_DQ_DROPS, "drops" },
  681. { CTL_INT, FS_DQ_READS, "reads" },
  682. { CTL_INT, FS_DQ_WRITES, "writes" },
  683. { CTL_INT, FS_DQ_CACHE_HITS, "cache_hits" },
  684. { CTL_INT, FS_DQ_ALLOCATED, "allocated_dquots" },
  685. { CTL_INT, FS_DQ_FREE, "free_dquots" },
  686. { CTL_INT, FS_DQ_SYNCS, "syncs" },
  687. { CTL_INT, FS_DQ_WARNINGS, "warnings" },
  688. {}
  689. };
  690. static const struct bin_table bin_fs_xfs_table[] = {
  691. { CTL_INT, XFS_SGID_INHERIT, "irix_sgid_inherit" },
  692. { CTL_INT, XFS_SYMLINK_MODE, "irix_symlink_mode" },
  693. { CTL_INT, XFS_PANIC_MASK, "panic_mask" },
  694. { CTL_INT, XFS_ERRLEVEL, "error_level" },
  695. { CTL_INT, XFS_SYNCD_TIMER, "xfssyncd_centisecs" },
  696. { CTL_INT, XFS_INHERIT_SYNC, "inherit_sync" },
  697. { CTL_INT, XFS_INHERIT_NODUMP, "inherit_nodump" },
  698. { CTL_INT, XFS_INHERIT_NOATIME, "inherit_noatime" },
  699. { CTL_INT, XFS_BUF_TIMER, "xfsbufd_centisecs" },
  700. { CTL_INT, XFS_BUF_AGE, "age_buffer_centisecs" },
  701. { CTL_INT, XFS_INHERIT_NOSYM, "inherit_nosymlinks" },
  702. { CTL_INT, XFS_ROTORSTEP, "rotorstep" },
  703. { CTL_INT, XFS_INHERIT_NODFRG, "inherit_nodefrag" },
  704. { CTL_INT, XFS_FILESTREAM_TIMER, "filestream_centisecs" },
  705. { CTL_INT, XFS_STATS_CLEAR, "stats_clear" },
  706. {}
  707. };
  708. static const struct bin_table bin_fs_ocfs2_nm_table[] = {
  709. { CTL_STR, 1, "hb_ctl_path" },
  710. {}
  711. };
  712. static const struct bin_table bin_fs_ocfs2_table[] = {
  713. { CTL_DIR, 1, "nm", bin_fs_ocfs2_nm_table },
  714. {}
  715. };
  716. static const struct bin_table bin_inotify_table[] = {
  717. { CTL_INT, INOTIFY_MAX_USER_INSTANCES, "max_user_instances" },
  718. { CTL_INT, INOTIFY_MAX_USER_WATCHES, "max_user_watches" },
  719. { CTL_INT, INOTIFY_MAX_QUEUED_EVENTS, "max_queued_events" },
  720. {}
  721. };
  722. static const struct bin_table bin_fs_table[] = {
  723. { CTL_INT, FS_NRINODE, "inode-nr" },
  724. { CTL_INT, FS_STATINODE, "inode-state" },
  725. /* FS_MAXINODE unused */
  726. /* FS_NRDQUOT unused */
  727. /* FS_MAXDQUOT unused */
  728. /* FS_NRFILE "file-nr" no longer used */
  729. { CTL_INT, FS_MAXFILE, "file-max" },
  730. { CTL_INT, FS_DENTRY, "dentry-state" },
  731. /* FS_NRSUPER unused */
  732. /* FS_MAXUPSER unused */
  733. { CTL_INT, FS_OVERFLOWUID, "overflowuid" },
  734. { CTL_INT, FS_OVERFLOWGID, "overflowgid" },
  735. { CTL_INT, FS_LEASES, "leases-enable" },
  736. { CTL_INT, FS_DIR_NOTIFY, "dir-notify-enable" },
  737. { CTL_INT, FS_LEASE_TIME, "lease-break-time" },
  738. { CTL_DIR, FS_DQSTATS, "quota", bin_fs_quota_table },
  739. { CTL_DIR, FS_XFS, "xfs", bin_fs_xfs_table },
  740. { CTL_ULONG, FS_AIO_NR, "aio-nr" },
  741. { CTL_ULONG, FS_AIO_MAX_NR, "aio-max-nr" },
  742. { CTL_DIR, FS_INOTIFY, "inotify", bin_inotify_table },
  743. { CTL_DIR, FS_OCFS2, "ocfs2", bin_fs_ocfs2_table },
  744. { CTL_INT, KERN_SETUID_DUMPABLE, "suid_dumpable" },
  745. {}
  746. };
  747. static const struct bin_table bin_ipmi_table[] = {
  748. { CTL_INT, DEV_IPMI_POWEROFF_POWERCYCLE, "poweroff_powercycle" },
  749. {}
  750. };
  751. static const struct bin_table bin_mac_hid_files[] = {
  752. /* DEV_MAC_HID_KEYBOARD_SENDS_LINUX_KEYCODES unused */
  753. /* DEV_MAC_HID_KEYBOARD_LOCK_KEYCODES unused */
  754. { CTL_INT, DEV_MAC_HID_MOUSE_BUTTON_EMULATION, "mouse_button_emulation" },
  755. { CTL_INT, DEV_MAC_HID_MOUSE_BUTTON2_KEYCODE, "mouse_button2_keycode" },
  756. { CTL_INT, DEV_MAC_HID_MOUSE_BUTTON3_KEYCODE, "mouse_button3_keycode" },
  757. /* DEV_MAC_HID_ADB_MOUSE_SENDS_KEYCODES unused */
  758. {}
  759. };
  760. static const struct bin_table bin_raid_table[] = {
  761. { CTL_INT, DEV_RAID_SPEED_LIMIT_MIN, "speed_limit_min" },
  762. { CTL_INT, DEV_RAID_SPEED_LIMIT_MAX, "speed_limit_max" },
  763. {}
  764. };
  765. static const struct bin_table bin_scsi_table[] = {
  766. { CTL_INT, DEV_SCSI_LOGGING_LEVEL, "logging_level" },
  767. {}
  768. };
  769. static const struct bin_table bin_dev_table[] = {
  770. /* DEV_CDROM "cdrom" no longer used */
  771. /* DEV_HWMON unused */
  772. /* DEV_PARPORT "parport" no longer used */
  773. { CTL_DIR, DEV_RAID, "raid", bin_raid_table },
  774. { CTL_DIR, DEV_MAC_HID, "mac_hid", bin_mac_hid_files },
  775. { CTL_DIR, DEV_SCSI, "scsi", bin_scsi_table },
  776. { CTL_DIR, DEV_IPMI, "ipmi", bin_ipmi_table },
  777. {}
  778. };
  779. static const struct bin_table bin_bus_isa_table[] = {
  780. { CTL_INT, BUS_ISA_MEM_BASE, "membase" },
  781. { CTL_INT, BUS_ISA_PORT_BASE, "portbase" },
  782. { CTL_INT, BUS_ISA_PORT_SHIFT, "portshift" },
  783. {}
  784. };
  785. static const struct bin_table bin_bus_table[] = {
  786. { CTL_DIR, CTL_BUS_ISA, "isa", bin_bus_isa_table },
  787. {}
  788. };
  789. static const struct bin_table bin_s390dbf_table[] = {
  790. { CTL_INT, 5678 /* CTL_S390DBF_STOPPABLE */, "debug_stoppable" },
  791. { CTL_INT, 5679 /* CTL_S390DBF_ACTIVE */, "debug_active" },
  792. {}
  793. };
  794. static const struct bin_table bin_sunrpc_table[] = {
  795. /* CTL_RPCDEBUG "rpc_debug" no longer used */
  796. /* CTL_NFSDEBUG "nfs_debug" no longer used */
  797. /* CTL_NFSDDEBUG "nfsd_debug" no longer used */
  798. /* CTL_NLMDEBUG "nlm_debug" no longer used */
  799. { CTL_INT, CTL_SLOTTABLE_UDP, "udp_slot_table_entries" },
  800. { CTL_INT, CTL_SLOTTABLE_TCP, "tcp_slot_table_entries" },
  801. { CTL_INT, CTL_MIN_RESVPORT, "min_resvport" },
  802. { CTL_INT, CTL_MAX_RESVPORT, "max_resvport" },
  803. {}
  804. };
  805. static const struct bin_table bin_pm_table[] = {
  806. /* frv specific */
  807. /* 1 == CTL_PM_SUSPEND "suspend" no longer used" */
  808. { CTL_INT, 2 /* CTL_PM_CMODE */, "cmode" },
  809. { CTL_INT, 3 /* CTL_PM_P0 */, "p0" },
  810. { CTL_INT, 4 /* CTL_PM_CM */, "cm" },
  811. {}
  812. };
  813. static const struct bin_table bin_root_table[] = {
  814. { CTL_DIR, CTL_KERN, "kernel", bin_kern_table },
  815. { CTL_DIR, CTL_VM, "vm", bin_vm_table },
  816. { CTL_DIR, CTL_NET, "net", bin_net_table },
  817. /* CTL_PROC not used */
  818. { CTL_DIR, CTL_FS, "fs", bin_fs_table },
  819. /* CTL_DEBUG "debug" no longer used */
  820. { CTL_DIR, CTL_DEV, "dev", bin_dev_table },
  821. { CTL_DIR, CTL_BUS, "bus", bin_bus_table },
  822. { CTL_DIR, CTL_ABI, "abi" },
  823. /* CTL_CPU not used */
  824. /* CTL_ARLAN "arlan" no longer used */
  825. { CTL_DIR, CTL_S390DBF, "s390dbf", bin_s390dbf_table },
  826. { CTL_DIR, CTL_SUNRPC, "sunrpc", bin_sunrpc_table },
  827. { CTL_DIR, CTL_PM, "pm", bin_pm_table },
  828. {}
  829. };
  830. static ssize_t bin_dir(struct file *file,
  831. void __user *oldval, size_t oldlen, void __user *newval, size_t newlen)
  832. {
  833. return -ENOTDIR;
  834. }
  835. static ssize_t bin_string(struct file *file,
  836. void __user *oldval, size_t oldlen, void __user *newval, size_t newlen)
  837. {
  838. ssize_t result, copied = 0;
  839. if (oldval && oldlen) {
  840. char __user *lastp;
  841. loff_t pos = 0;
  842. int ch;
  843. result = vfs_read(file, oldval, oldlen, &pos);
  844. if (result < 0)
  845. goto out;
  846. copied = result;
  847. lastp = oldval + copied - 1;
  848. result = -EFAULT;
  849. if (get_user(ch, lastp))
  850. goto out;
  851. /* Trim off the trailing newline */
  852. if (ch == '\n') {
  853. result = -EFAULT;
  854. if (put_user('\0', lastp))
  855. goto out;
  856. copied -= 1;
  857. }
  858. }
  859. if (newval && newlen) {
  860. loff_t pos = 0;
  861. result = vfs_write(file, newval, newlen, &pos);
  862. if (result < 0)
  863. goto out;
  864. }
  865. result = copied;
  866. out:
  867. return result;
  868. }
  869. static ssize_t bin_intvec(struct file *file,
  870. void __user *oldval, size_t oldlen, void __user *newval, size_t newlen)
  871. {
  872. mm_segment_t old_fs = get_fs();
  873. ssize_t copied = 0;
  874. char *buffer;
  875. ssize_t result;
  876. result = -ENOMEM;
  877. buffer = kmalloc(BUFSZ, GFP_KERNEL);
  878. if (!buffer)
  879. goto out;
  880. if (oldval && oldlen) {
  881. unsigned __user *vec = oldval;
  882. size_t length = oldlen / sizeof(*vec);
  883. loff_t pos = 0;
  884. char *str, *end;
  885. int i;
  886. set_fs(KERNEL_DS);
  887. result = vfs_read(file, buffer, BUFSZ - 1, &pos);
  888. set_fs(old_fs);
  889. if (result < 0)
  890. goto out_kfree;
  891. str = buffer;
  892. end = str + result;
  893. *end++ = '\0';
  894. for (i = 0; i < length; i++) {
  895. unsigned long value;
  896. value = simple_strtoul(str, &str, 10);
  897. while (isspace(*str))
  898. str++;
  899. result = -EFAULT;
  900. if (put_user(value, vec + i))
  901. goto out_kfree;
  902. copied += sizeof(*vec);
  903. if (!isdigit(*str))
  904. break;
  905. }
  906. }
  907. if (newval && newlen) {
  908. unsigned __user *vec = newval;
  909. size_t length = newlen / sizeof(*vec);
  910. loff_t pos = 0;
  911. char *str, *end;
  912. int i;
  913. str = buffer;
  914. end = str + BUFSZ;
  915. for (i = 0; i < length; i++) {
  916. unsigned long value;
  917. result = -EFAULT;
  918. if (get_user(value, vec + i))
  919. goto out_kfree;
  920. str += snprintf(str, end - str, "%lu\t", value);
  921. }
  922. set_fs(KERNEL_DS);
  923. result = vfs_write(file, buffer, str - buffer, &pos);
  924. set_fs(old_fs);
  925. if (result < 0)
  926. goto out_kfree;
  927. }
  928. result = copied;
  929. out_kfree:
  930. kfree(buffer);
  931. out:
  932. return result;
  933. }
  934. static ssize_t bin_ulongvec(struct file *file,
  935. void __user *oldval, size_t oldlen, void __user *newval, size_t newlen)
  936. {
  937. mm_segment_t old_fs = get_fs();
  938. ssize_t copied = 0;
  939. char *buffer;
  940. ssize_t result;
  941. result = -ENOMEM;
  942. buffer = kmalloc(BUFSZ, GFP_KERNEL);
  943. if (!buffer)
  944. goto out;
  945. if (oldval && oldlen) {
  946. unsigned long __user *vec = oldval;
  947. size_t length = oldlen / sizeof(*vec);
  948. loff_t pos = 0;
  949. char *str, *end;
  950. int i;
  951. set_fs(KERNEL_DS);
  952. result = vfs_read(file, buffer, BUFSZ - 1, &pos);
  953. set_fs(old_fs);
  954. if (result < 0)
  955. goto out_kfree;
  956. str = buffer;
  957. end = str + result;
  958. *end++ = '\0';
  959. for (i = 0; i < length; i++) {
  960. unsigned long value;
  961. value = simple_strtoul(str, &str, 10);
  962. while (isspace(*str))
  963. str++;
  964. result = -EFAULT;
  965. if (put_user(value, vec + i))
  966. goto out_kfree;
  967. copied += sizeof(*vec);
  968. if (!isdigit(*str))
  969. break;
  970. }
  971. }
  972. if (newval && newlen) {
  973. unsigned long __user *vec = newval;
  974. size_t length = newlen / sizeof(*vec);
  975. loff_t pos = 0;
  976. char *str, *end;
  977. int i;
  978. str = buffer;
  979. end = str + BUFSZ;
  980. for (i = 0; i < length; i++) {
  981. unsigned long value;
  982. result = -EFAULT;
  983. if (get_user(value, vec + i))
  984. goto out_kfree;
  985. str += snprintf(str, end - str, "%lu\t", value);
  986. }
  987. set_fs(KERNEL_DS);
  988. result = vfs_write(file, buffer, str - buffer, &pos);
  989. set_fs(old_fs);
  990. if (result < 0)
  991. goto out_kfree;
  992. }
  993. result = copied;
  994. out_kfree:
  995. kfree(buffer);
  996. out:
  997. return result;
  998. }
  999. static ssize_t bin_uuid(struct file *file,
  1000. void __user *oldval, size_t oldlen, void __user *newval, size_t newlen)
  1001. {
  1002. mm_segment_t old_fs = get_fs();
  1003. ssize_t result, copied = 0;
  1004. /* Only supports reads */
  1005. if (oldval && oldlen) {
  1006. loff_t pos = 0;
  1007. char buf[40], *str = buf;
  1008. unsigned char uuid[16];
  1009. int i;
  1010. set_fs(KERNEL_DS);
  1011. result = vfs_read(file, buf, sizeof(buf) - 1, &pos);
  1012. set_fs(old_fs);
  1013. if (result < 0)
  1014. goto out;
  1015. buf[result] = '\0';
  1016. /* Convert the uuid to from a string to binary */
  1017. for (i = 0; i < 16; i++) {
  1018. result = -EIO;
  1019. if (!isxdigit(str[0]) || !isxdigit(str[1]))
  1020. goto out;
  1021. uuid[i] = (hex_to_bin(str[0]) << 4) |
  1022. hex_to_bin(str[1]);
  1023. str += 2;
  1024. if (*str == '-')
  1025. str++;
  1026. }
  1027. if (oldlen > 16)
  1028. oldlen = 16;
  1029. result = -EFAULT;
  1030. if (copy_to_user(oldval, uuid, oldlen))
  1031. goto out;
  1032. copied = oldlen;
  1033. }
  1034. result = copied;
  1035. out:
  1036. return result;
  1037. }
  1038. static ssize_t bin_dn_node_address(struct file *file,
  1039. void __user *oldval, size_t oldlen, void __user *newval, size_t newlen)
  1040. {
  1041. mm_segment_t old_fs = get_fs();
  1042. ssize_t result, copied = 0;
  1043. if (oldval && oldlen) {
  1044. loff_t pos = 0;
  1045. char buf[15], *nodep;
  1046. unsigned long area, node;
  1047. __le16 dnaddr;
  1048. set_fs(KERNEL_DS);
  1049. result = vfs_read(file, buf, sizeof(buf) - 1, &pos);
  1050. set_fs(old_fs);
  1051. if (result < 0)
  1052. goto out;
  1053. buf[result] = '\0';
  1054. /* Convert the decnet address to binary */
  1055. result = -EIO;
  1056. nodep = strchr(buf, '.');
  1057. if (!nodep)
  1058. goto out;
  1059. ++nodep;
  1060. area = simple_strtoul(buf, NULL, 10);
  1061. node = simple_strtoul(nodep, NULL, 10);
  1062. result = -EIO;
  1063. if ((area > 63)||(node > 1023))
  1064. goto out;
  1065. dnaddr = cpu_to_le16((area << 10) | node);
  1066. result = -EFAULT;
  1067. if (put_user(dnaddr, (__le16 __user *)oldval))
  1068. goto out;
  1069. copied = sizeof(dnaddr);
  1070. }
  1071. if (newval && newlen) {
  1072. loff_t pos = 0;
  1073. __le16 dnaddr;
  1074. char buf[15];
  1075. int len;
  1076. result = -EINVAL;
  1077. if (newlen != sizeof(dnaddr))
  1078. goto out;
  1079. result = -EFAULT;
  1080. if (get_user(dnaddr, (__le16 __user *)newval))
  1081. goto out;
  1082. len = snprintf(buf, sizeof(buf), "%hu.%hu",
  1083. le16_to_cpu(dnaddr) >> 10,
  1084. le16_to_cpu(dnaddr) & 0x3ff);
  1085. set_fs(KERNEL_DS);
  1086. result = vfs_write(file, buf, len, &pos);
  1087. set_fs(old_fs);
  1088. if (result < 0)
  1089. goto out;
  1090. }
  1091. result = copied;
  1092. out:
  1093. return result;
  1094. }
  1095. static const struct bin_table *get_sysctl(const int *name, int nlen, char *path)
  1096. {
  1097. const struct bin_table *table = &bin_root_table[0];
  1098. int ctl_name;
  1099. /* The binary sysctl tables have a small maximum depth so
  1100. * there is no danger of overflowing our path as it PATH_MAX
  1101. * bytes long.
  1102. */
  1103. memcpy(path, "sys/", 4);
  1104. path += 4;
  1105. repeat:
  1106. if (!nlen)
  1107. return ERR_PTR(-ENOTDIR);
  1108. ctl_name = *name;
  1109. name++;
  1110. nlen--;
  1111. for ( ; table->convert; table++) {
  1112. int len = 0;
  1113. /*
  1114. * For a wild card entry map from ifindex to network
  1115. * device name.
  1116. */
  1117. if (!table->ctl_name) {
  1118. #ifdef CONFIG_NET
  1119. struct net *net = current->nsproxy->net_ns;
  1120. struct net_device *dev;
  1121. dev = dev_get_by_index(net, ctl_name);
  1122. if (dev) {
  1123. len = strlen(dev->name);
  1124. memcpy(path, dev->name, len);
  1125. dev_put(dev);
  1126. }
  1127. #endif
  1128. /* Use the well known sysctl number to proc name mapping */
  1129. } else if (ctl_name == table->ctl_name) {
  1130. len = strlen(table->procname);
  1131. memcpy(path, table->procname, len);
  1132. }
  1133. if (len) {
  1134. path += len;
  1135. if (table->child) {
  1136. *path++ = '/';
  1137. table = table->child;
  1138. goto repeat;
  1139. }
  1140. *path = '\0';
  1141. return table;
  1142. }
  1143. }
  1144. return ERR_PTR(-ENOTDIR);
  1145. }
  1146. static char *sysctl_getname(const int *name, int nlen, const struct bin_table **tablep)
  1147. {
  1148. char *tmp, *result;
  1149. result = ERR_PTR(-ENOMEM);
  1150. tmp = __getname();
  1151. if (tmp) {
  1152. const struct bin_table *table = get_sysctl(name, nlen, tmp);
  1153. result = tmp;
  1154. *tablep = table;
  1155. if (IS_ERR(table)) {
  1156. __putname(tmp);
  1157. result = ERR_CAST(table);
  1158. }
  1159. }
  1160. return result;
  1161. }
  1162. static ssize_t binary_sysctl(const int *name, int nlen,
  1163. void __user *oldval, size_t oldlen, void __user *newval, size_t newlen)
  1164. {
  1165. const struct bin_table *table = NULL;
  1166. struct vfsmount *mnt;
  1167. struct file *file;
  1168. ssize_t result;
  1169. char *pathname;
  1170. int flags;
  1171. pathname = sysctl_getname(name, nlen, &table);
  1172. result = PTR_ERR(pathname);
  1173. if (IS_ERR(pathname))
  1174. goto out;
  1175. /* How should the sysctl be accessed? */
  1176. if (oldval && oldlen && newval && newlen) {
  1177. flags = O_RDWR;
  1178. } else if (newval && newlen) {
  1179. flags = O_WRONLY;
  1180. } else if (oldval && oldlen) {
  1181. flags = O_RDONLY;
  1182. } else {
  1183. result = 0;
  1184. goto out_putname;
  1185. }
  1186. mnt = current->nsproxy->pid_ns->proc_mnt;
  1187. file = file_open_root(mnt->mnt_root, mnt, pathname, flags);
  1188. result = PTR_ERR(file);
  1189. if (IS_ERR(file))
  1190. goto out_putname;
  1191. result = table->convert(file, oldval, oldlen, newval, newlen);
  1192. fput(file);
  1193. out_putname:
  1194. __putname(pathname);
  1195. out:
  1196. return result;
  1197. }
  1198. #else /* CONFIG_SYSCTL_SYSCALL */
  1199. static ssize_t binary_sysctl(const int *name, int nlen,
  1200. void __user *oldval, size_t oldlen, void __user *newval, size_t newlen)
  1201. {
  1202. return -ENOSYS;
  1203. }
  1204. #endif /* CONFIG_SYSCTL_SYSCALL */
  1205. static void deprecated_sysctl_warning(const int *name, int nlen)
  1206. {
  1207. int i;
  1208. /*
  1209. * CTL_KERN/KERN_VERSION is used by older glibc and cannot
  1210. * ever go away.
  1211. */
  1212. if (nlen >= 2 && name[0] == CTL_KERN && name[1] == KERN_VERSION)
  1213. return;
  1214. if (printk_ratelimit()) {
  1215. printk(KERN_INFO
  1216. "warning: process `%s' used the deprecated sysctl "
  1217. "system call with ", current->comm);
  1218. for (i = 0; i < nlen; i++)
  1219. printk("%d.", name[i]);
  1220. printk("\n");
  1221. }
  1222. return;
  1223. }
  1224. #define WARN_ONCE_HASH_BITS 8
  1225. #define WARN_ONCE_HASH_SIZE (1<<WARN_ONCE_HASH_BITS)
  1226. static DECLARE_BITMAP(warn_once_bitmap, WARN_ONCE_HASH_SIZE);
  1227. #define FNV32_OFFSET 2166136261U
  1228. #define FNV32_PRIME 0x01000193
  1229. /*
  1230. * Print each legacy sysctl (approximately) only once.
  1231. * To avoid making the tables non-const use a external
  1232. * hash-table instead.
  1233. * Worst case hash collision: 6, but very rarely.
  1234. * NOTE! We don't use the SMP-safe bit tests. We simply
  1235. * don't care enough.
  1236. */
  1237. static void warn_on_bintable(const int *name, int nlen)
  1238. {
  1239. int i;
  1240. u32 hash = FNV32_OFFSET;
  1241. for (i = 0; i < nlen; i++)
  1242. hash = (hash ^ name[i]) * FNV32_PRIME;
  1243. hash %= WARN_ONCE_HASH_SIZE;
  1244. if (__test_and_set_bit(hash, warn_once_bitmap))
  1245. return;
  1246. deprecated_sysctl_warning(name, nlen);
  1247. }
  1248. static ssize_t do_sysctl(int __user *args_name, int nlen,
  1249. void __user *oldval, size_t oldlen, void __user *newval, size_t newlen)
  1250. {
  1251. int name[CTL_MAXNAME];
  1252. int i;
  1253. /* Check args->nlen. */
  1254. if (nlen < 0 || nlen > CTL_MAXNAME)
  1255. return -ENOTDIR;
  1256. /* Read in the sysctl name for simplicity */
  1257. for (i = 0; i < nlen; i++)
  1258. if (get_user(name[i], args_name + i))
  1259. return -EFAULT;
  1260. warn_on_bintable(name, nlen);
  1261. return binary_sysctl(name, nlen, oldval, oldlen, newval, newlen);
  1262. }
  1263. SYSCALL_DEFINE1(sysctl, struct __sysctl_args __user *, args)
  1264. {
  1265. struct __sysctl_args tmp;
  1266. size_t oldlen = 0;
  1267. ssize_t result;
  1268. if (copy_from_user(&tmp, args, sizeof(tmp)))
  1269. return -EFAULT;
  1270. if (tmp.oldval && !tmp.oldlenp)
  1271. return -EFAULT;
  1272. if (tmp.oldlenp && get_user(oldlen, tmp.oldlenp))
  1273. return -EFAULT;
  1274. result = do_sysctl(tmp.name, tmp.nlen, tmp.oldval, oldlen,
  1275. tmp.newval, tmp.newlen);
  1276. if (result >= 0) {
  1277. oldlen = result;
  1278. result = 0;
  1279. }
  1280. if (tmp.oldlenp && put_user(oldlen, tmp.oldlenp))
  1281. return -EFAULT;
  1282. return result;
  1283. }
  1284. #ifdef CONFIG_COMPAT
  1285. #include <asm/compat.h>
  1286. struct compat_sysctl_args {
  1287. compat_uptr_t name;
  1288. int nlen;
  1289. compat_uptr_t oldval;
  1290. compat_uptr_t oldlenp;
  1291. compat_uptr_t newval;
  1292. compat_size_t newlen;
  1293. compat_ulong_t __unused[4];
  1294. };
  1295. asmlinkage long compat_sys_sysctl(struct compat_sysctl_args __user *args)
  1296. {
  1297. struct compat_sysctl_args tmp;
  1298. compat_size_t __user *compat_oldlenp;
  1299. size_t oldlen = 0;
  1300. ssize_t result;
  1301. if (copy_from_user(&tmp, args, sizeof(tmp)))
  1302. return -EFAULT;
  1303. if (tmp.oldval && !tmp.oldlenp)
  1304. return -EFAULT;
  1305. compat_oldlenp = compat_ptr(tmp.oldlenp);
  1306. if (compat_oldlenp && get_user(oldlen, compat_oldlenp))
  1307. return -EFAULT;
  1308. result = do_sysctl(compat_ptr(tmp.name), tmp.nlen,
  1309. compat_ptr(tmp.oldval), oldlen,
  1310. compat_ptr(tmp.newval), tmp.newlen);
  1311. if (result >= 0) {
  1312. oldlen = result;
  1313. result = 0;
  1314. }
  1315. if (compat_oldlenp && put_user(oldlen, compat_oldlenp))
  1316. return -EFAULT;
  1317. return result;
  1318. }
  1319. #endif /* CONFIG_COMPAT */