sysctl_binary.c 51 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486
  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 <linux/syscalls.h>
  7. #include <linux/namei.h>
  8. #include <linux/mount.h>
  9. #include <linux/fs.h>
  10. #include <linux/nsproxy.h>
  11. #include <linux/pid_namespace.h>
  12. #include <linux/file.h>
  13. #include <linux/ctype.h>
  14. #include <linux/netdevice.h>
  15. #include <linux/kernel.h>
  16. #include <linux/uuid.h>
  17. #include <linux/slab.h>
  18. #include <linux/compat.h>
  19. #ifdef CONFIG_SYSCTL_SYSCALL
  20. struct bin_table;
  21. typedef ssize_t bin_convert_t(struct file *file,
  22. void __user *oldval, size_t oldlen, void __user *newval, size_t newlen);
  23. static bin_convert_t bin_dir;
  24. static bin_convert_t bin_string;
  25. static bin_convert_t bin_intvec;
  26. static bin_convert_t bin_ulongvec;
  27. static bin_convert_t bin_uuid;
  28. static bin_convert_t bin_dn_node_address;
  29. #define CTL_DIR bin_dir
  30. #define CTL_STR bin_string
  31. #define CTL_INT bin_intvec
  32. #define CTL_ULONG bin_ulongvec
  33. #define CTL_UUID bin_uuid
  34. #define CTL_DNADR bin_dn_node_address
  35. #define BUFSZ 256
  36. struct bin_table {
  37. bin_convert_t *convert;
  38. int ctl_name;
  39. const char *procname;
  40. const struct bin_table *child;
  41. };
  42. static const struct bin_table bin_random_table[] = {
  43. { CTL_INT, RANDOM_POOLSIZE, "poolsize" },
  44. { CTL_INT, RANDOM_ENTROPY_COUNT, "entropy_avail" },
  45. { CTL_INT, RANDOM_READ_THRESH, "read_wakeup_threshold" },
  46. { CTL_INT, RANDOM_WRITE_THRESH, "write_wakeup_threshold" },
  47. { CTL_UUID, RANDOM_BOOT_ID, "boot_id" },
  48. { CTL_UUID, RANDOM_UUID, "uuid" },
  49. {}
  50. };
  51. static const struct bin_table bin_pty_table[] = {
  52. { CTL_INT, PTY_MAX, "max" },
  53. { CTL_INT, PTY_NR, "nr" },
  54. {}
  55. };
  56. static const struct bin_table bin_kern_table[] = {
  57. { CTL_STR, KERN_OSTYPE, "ostype" },
  58. { CTL_STR, KERN_OSRELEASE, "osrelease" },
  59. /* KERN_OSREV not used */
  60. { CTL_STR, KERN_VERSION, "version" },
  61. /* KERN_SECUREMASK not used */
  62. /* KERN_PROF not used */
  63. { CTL_STR, KERN_NODENAME, "hostname" },
  64. { CTL_STR, KERN_DOMAINNAME, "domainname" },
  65. { CTL_INT, KERN_PANIC, "panic" },
  66. { CTL_INT, KERN_REALROOTDEV, "real-root-dev" },
  67. { CTL_STR, KERN_SPARC_REBOOT, "reboot-cmd" },
  68. { CTL_INT, KERN_CTLALTDEL, "ctrl-alt-del" },
  69. { CTL_INT, KERN_PRINTK, "printk" },
  70. /* KERN_NAMETRANS not used */
  71. /* KERN_PPC_HTABRECLAIM not used */
  72. /* KERN_PPC_ZEROPAGED not used */
  73. { CTL_INT, KERN_PPC_POWERSAVE_NAP, "powersave-nap" },
  74. { CTL_STR, KERN_MODPROBE, "modprobe" },
  75. { CTL_INT, KERN_SG_BIG_BUFF, "sg-big-buff" },
  76. { CTL_INT, KERN_ACCT, "acct" },
  77. /* KERN_PPC_L2CR "l2cr" no longer used */
  78. /* KERN_RTSIGNR not used */
  79. /* KERN_RTSIGMAX not used */
  80. { CTL_ULONG, KERN_SHMMAX, "shmmax" },
  81. { CTL_INT, KERN_MSGMAX, "msgmax" },
  82. { CTL_INT, KERN_MSGMNB, "msgmnb" },
  83. /* KERN_MSGPOOL not used*/
  84. { CTL_INT, KERN_SYSRQ, "sysrq" },
  85. { CTL_INT, KERN_MAX_THREADS, "threads-max" },
  86. { CTL_DIR, KERN_RANDOM, "random", bin_random_table },
  87. { CTL_ULONG, KERN_SHMALL, "shmall" },
  88. { CTL_INT, KERN_MSGMNI, "msgmni" },
  89. { CTL_INT, KERN_SEM, "sem" },
  90. { CTL_INT, KERN_SPARC_STOP_A, "stop-a" },
  91. { CTL_INT, KERN_SHMMNI, "shmmni" },
  92. { CTL_INT, KERN_OVERFLOWUID, "overflowuid" },
  93. { CTL_INT, KERN_OVERFLOWGID, "overflowgid" },
  94. { CTL_STR, KERN_HOTPLUG, "hotplug", },
  95. { CTL_INT, KERN_IEEE_EMULATION_WARNINGS, "ieee_emulation_warnings" },
  96. { CTL_INT, KERN_S390_USER_DEBUG_LOGGING, "userprocess_debug" },
  97. { CTL_INT, KERN_CORE_USES_PID, "core_uses_pid" },
  98. /* KERN_TAINTED "tainted" no longer used */
  99. { CTL_INT, KERN_CADPID, "cad_pid" },
  100. { CTL_INT, KERN_PIDMAX, "pid_max" },
  101. { CTL_STR, KERN_CORE_PATTERN, "core_pattern" },
  102. { CTL_INT, KERN_PANIC_ON_OOPS, "panic_on_oops" },
  103. { CTL_INT, KERN_HPPA_PWRSW, "soft-power" },
  104. { CTL_INT, KERN_HPPA_UNALIGNED, "unaligned-trap" },
  105. { CTL_INT, KERN_PRINTK_RATELIMIT, "printk_ratelimit" },
  106. { CTL_INT, KERN_PRINTK_RATELIMIT_BURST, "printk_ratelimit_burst" },
  107. { CTL_DIR, KERN_PTY, "pty", bin_pty_table },
  108. { CTL_INT, KERN_NGROUPS_MAX, "ngroups_max" },
  109. { CTL_INT, KERN_SPARC_SCONS_PWROFF, "scons-poweroff" },
  110. /* KERN_HZ_TIMER "hz_timer" no longer used */
  111. { CTL_INT, KERN_UNKNOWN_NMI_PANIC, "unknown_nmi_panic" },
  112. { CTL_INT, KERN_BOOTLOADER_TYPE, "bootloader_type" },
  113. { CTL_INT, KERN_RANDOMIZE, "randomize_va_space" },
  114. { CTL_INT, KERN_SPIN_RETRY, "spin_retry" },
  115. /* KERN_ACPI_VIDEO_FLAGS "acpi_video_flags" no longer used */
  116. { CTL_INT, KERN_IA64_UNALIGNED, "ignore-unaligned-usertrap" },
  117. { CTL_INT, KERN_COMPAT_LOG, "compat-log" },
  118. { CTL_INT, KERN_MAX_LOCK_DEPTH, "max_lock_depth" },
  119. { CTL_INT, KERN_PANIC_ON_NMI, "panic_on_unrecovered_nmi" },
  120. { CTL_INT, KERN_PANIC_ON_WARN, "panic_on_warn" },
  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. /* VM_NR_PDFLUSH_THREADS "nr_pdflush_threads" no longer used */
  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_SLOW_START_AFTER_IDLE, "tcp_slow_start_after_idle" },
  355. { CTL_INT, NET_CIPSOV4_CACHE_ENABLE, "cipso_cache_enable" },
  356. { CTL_INT, NET_CIPSOV4_CACHE_BUCKET_SIZE, "cipso_cache_bucket_size" },
  357. { CTL_INT, NET_CIPSOV4_RBM_OPTFMT, "cipso_rbm_optfmt" },
  358. { CTL_INT, NET_CIPSOV4_RBM_STRICTVALID, "cipso_rbm_strictvalid" },
  359. /* NET_TCP_AVAIL_CONG_CONTROL "tcp_available_congestion_control" no longer used */
  360. { CTL_STR, NET_TCP_ALLOWED_CONG_CONTROL, "tcp_allowed_congestion_control" },
  361. { CTL_INT, NET_TCP_MAX_SSTHRESH, "tcp_max_ssthresh" },
  362. { CTL_INT, NET_IPV4_ICMP_ECHO_IGNORE_ALL, "icmp_echo_ignore_all" },
  363. { CTL_INT, NET_IPV4_ICMP_ECHO_IGNORE_BROADCASTS, "icmp_echo_ignore_broadcasts" },
  364. { CTL_INT, NET_IPV4_ICMP_IGNORE_BOGUS_ERROR_RESPONSES, "icmp_ignore_bogus_error_responses" },
  365. { CTL_INT, NET_IPV4_ICMP_ERRORS_USE_INBOUND_IFADDR, "icmp_errors_use_inbound_ifaddr" },
  366. { CTL_INT, NET_IPV4_ICMP_RATELIMIT, "icmp_ratelimit" },
  367. { CTL_INT, NET_IPV4_ICMP_RATEMASK, "icmp_ratemask" },
  368. { CTL_INT, NET_IPV4_IPFRAG_HIGH_THRESH, "ipfrag_high_thresh" },
  369. { CTL_INT, NET_IPV4_IPFRAG_LOW_THRESH, "ipfrag_low_thresh" },
  370. { CTL_INT, NET_IPV4_IPFRAG_TIME, "ipfrag_time" },
  371. { CTL_INT, NET_IPV4_IPFRAG_SECRET_INTERVAL, "ipfrag_secret_interval" },
  372. /* NET_IPV4_IPFRAG_MAX_DIST "ipfrag_max_dist" no longer used */
  373. { CTL_INT, 2088 /* NET_IPQ_QMAX */, "ip_queue_maxlen" },
  374. /* NET_TCP_DEFAULT_WIN_SCALE unused */
  375. /* NET_TCP_BIC_BETA unused */
  376. /* NET_IPV4_TCP_MAX_KA_PROBES unused */
  377. /* NET_IPV4_IP_MASQ_DEBUG unused */
  378. /* NET_TCP_SYN_TAILDROP unused */
  379. /* NET_IPV4_ICMP_SOURCEQUENCH_RATE unused */
  380. /* NET_IPV4_ICMP_DESTUNREACH_RATE unused */
  381. /* NET_IPV4_ICMP_TIMEEXCEED_RATE unused */
  382. /* NET_IPV4_ICMP_PARAMPROB_RATE unused */
  383. /* NET_IPV4_ICMP_ECHOREPLY_RATE unused */
  384. /* NET_IPV4_ALWAYS_DEFRAG unused */
  385. {}
  386. };
  387. static const struct bin_table bin_net_ipx_table[] = {
  388. { CTL_INT, NET_IPX_PPROP_BROADCASTING, "ipx_pprop_broadcasting" },
  389. /* NET_IPX_FORWARDING unused */
  390. {}
  391. };
  392. static const struct bin_table bin_net_atalk_table[] = {
  393. { CTL_INT, NET_ATALK_AARP_EXPIRY_TIME, "aarp-expiry-time" },
  394. { CTL_INT, NET_ATALK_AARP_TICK_TIME, "aarp-tick-time" },
  395. { CTL_INT, NET_ATALK_AARP_RETRANSMIT_LIMIT, "aarp-retransmit-limit" },
  396. { CTL_INT, NET_ATALK_AARP_RESOLVE_TIME, "aarp-resolve-time" },
  397. {},
  398. };
  399. static const struct bin_table bin_net_netrom_table[] = {
  400. { CTL_INT, NET_NETROM_DEFAULT_PATH_QUALITY, "default_path_quality" },
  401. { CTL_INT, NET_NETROM_OBSOLESCENCE_COUNT_INITIALISER, "obsolescence_count_initialiser" },
  402. { CTL_INT, NET_NETROM_NETWORK_TTL_INITIALISER, "network_ttl_initialiser" },
  403. { CTL_INT, NET_NETROM_TRANSPORT_TIMEOUT, "transport_timeout" },
  404. { CTL_INT, NET_NETROM_TRANSPORT_MAXIMUM_TRIES, "transport_maximum_tries" },
  405. { CTL_INT, NET_NETROM_TRANSPORT_ACKNOWLEDGE_DELAY, "transport_acknowledge_delay" },
  406. { CTL_INT, NET_NETROM_TRANSPORT_BUSY_DELAY, "transport_busy_delay" },
  407. { CTL_INT, NET_NETROM_TRANSPORT_REQUESTED_WINDOW_SIZE, "transport_requested_window_size" },
  408. { CTL_INT, NET_NETROM_TRANSPORT_NO_ACTIVITY_TIMEOUT, "transport_no_activity_timeout" },
  409. { CTL_INT, NET_NETROM_ROUTING_CONTROL, "routing_control" },
  410. { CTL_INT, NET_NETROM_LINK_FAILS_COUNT, "link_fails_count" },
  411. { CTL_INT, NET_NETROM_RESET, "reset" },
  412. {}
  413. };
  414. static const struct bin_table bin_net_ax25_param_table[] = {
  415. { CTL_INT, NET_AX25_IP_DEFAULT_MODE, "ip_default_mode" },
  416. { CTL_INT, NET_AX25_DEFAULT_MODE, "ax25_default_mode" },
  417. { CTL_INT, NET_AX25_BACKOFF_TYPE, "backoff_type" },
  418. { CTL_INT, NET_AX25_CONNECT_MODE, "connect_mode" },
  419. { CTL_INT, NET_AX25_STANDARD_WINDOW, "standard_window_size" },
  420. { CTL_INT, NET_AX25_EXTENDED_WINDOW, "extended_window_size" },
  421. { CTL_INT, NET_AX25_T1_TIMEOUT, "t1_timeout" },
  422. { CTL_INT, NET_AX25_T2_TIMEOUT, "t2_timeout" },
  423. { CTL_INT, NET_AX25_T3_TIMEOUT, "t3_timeout" },
  424. { CTL_INT, NET_AX25_IDLE_TIMEOUT, "idle_timeout" },
  425. { CTL_INT, NET_AX25_N2, "maximum_retry_count" },
  426. { CTL_INT, NET_AX25_PACLEN, "maximum_packet_length" },
  427. { CTL_INT, NET_AX25_PROTOCOL, "protocol" },
  428. { CTL_INT, NET_AX25_DAMA_SLAVE_TIMEOUT, "dama_slave_timeout" },
  429. {}
  430. };
  431. static const struct bin_table bin_net_ax25_table[] = {
  432. { CTL_DIR, 0, NULL, bin_net_ax25_param_table },
  433. {}
  434. };
  435. static const struct bin_table bin_net_rose_table[] = {
  436. { CTL_INT, NET_ROSE_RESTART_REQUEST_TIMEOUT, "restart_request_timeout" },
  437. { CTL_INT, NET_ROSE_CALL_REQUEST_TIMEOUT, "call_request_timeout" },
  438. { CTL_INT, NET_ROSE_RESET_REQUEST_TIMEOUT, "reset_request_timeout" },
  439. { CTL_INT, NET_ROSE_CLEAR_REQUEST_TIMEOUT, "clear_request_timeout" },
  440. { CTL_INT, NET_ROSE_ACK_HOLD_BACK_TIMEOUT, "acknowledge_hold_back_timeout" },
  441. { CTL_INT, NET_ROSE_ROUTING_CONTROL, "routing_control" },
  442. { CTL_INT, NET_ROSE_LINK_FAIL_TIMEOUT, "link_fail_timeout" },
  443. { CTL_INT, NET_ROSE_MAX_VCS, "maximum_virtual_circuits" },
  444. { CTL_INT, NET_ROSE_WINDOW_SIZE, "window_size" },
  445. { CTL_INT, NET_ROSE_NO_ACTIVITY_TIMEOUT, "no_activity_timeout" },
  446. {}
  447. };
  448. static const struct bin_table bin_net_ipv6_conf_var_table[] = {
  449. { CTL_INT, NET_IPV6_FORWARDING, "forwarding" },
  450. { CTL_INT, NET_IPV6_HOP_LIMIT, "hop_limit" },
  451. { CTL_INT, NET_IPV6_MTU, "mtu" },
  452. { CTL_INT, NET_IPV6_ACCEPT_RA, "accept_ra" },
  453. { CTL_INT, NET_IPV6_ACCEPT_REDIRECTS, "accept_redirects" },
  454. { CTL_INT, NET_IPV6_AUTOCONF, "autoconf" },
  455. { CTL_INT, NET_IPV6_DAD_TRANSMITS, "dad_transmits" },
  456. { CTL_INT, NET_IPV6_RTR_SOLICITS, "router_solicitations" },
  457. { CTL_INT, NET_IPV6_RTR_SOLICIT_INTERVAL, "router_solicitation_interval" },
  458. { CTL_INT, NET_IPV6_RTR_SOLICIT_DELAY, "router_solicitation_delay" },
  459. { CTL_INT, NET_IPV6_USE_TEMPADDR, "use_tempaddr" },
  460. { CTL_INT, NET_IPV6_TEMP_VALID_LFT, "temp_valid_lft" },
  461. { CTL_INT, NET_IPV6_TEMP_PREFERED_LFT, "temp_prefered_lft" },
  462. { CTL_INT, NET_IPV6_REGEN_MAX_RETRY, "regen_max_retry" },
  463. { CTL_INT, NET_IPV6_MAX_DESYNC_FACTOR, "max_desync_factor" },
  464. { CTL_INT, NET_IPV6_MAX_ADDRESSES, "max_addresses" },
  465. { CTL_INT, NET_IPV6_FORCE_MLD_VERSION, "force_mld_version" },
  466. { CTL_INT, NET_IPV6_ACCEPT_RA_DEFRTR, "accept_ra_defrtr" },
  467. { CTL_INT, NET_IPV6_ACCEPT_RA_PINFO, "accept_ra_pinfo" },
  468. { CTL_INT, NET_IPV6_ACCEPT_RA_RTR_PREF, "accept_ra_rtr_pref" },
  469. { CTL_INT, NET_IPV6_RTR_PROBE_INTERVAL, "router_probe_interval" },
  470. { CTL_INT, NET_IPV6_ACCEPT_RA_RT_INFO_MAX_PLEN, "accept_ra_rt_info_max_plen" },
  471. { CTL_INT, NET_IPV6_PROXY_NDP, "proxy_ndp" },
  472. { CTL_INT, NET_IPV6_ACCEPT_SOURCE_ROUTE, "accept_source_route" },
  473. { CTL_INT, NET_IPV6_ACCEPT_RA_FROM_LOCAL, "accept_ra_from_local" },
  474. {}
  475. };
  476. static const struct bin_table bin_net_ipv6_conf_table[] = {
  477. { CTL_DIR, NET_PROTO_CONF_ALL, "all", bin_net_ipv6_conf_var_table },
  478. { CTL_DIR, NET_PROTO_CONF_DEFAULT, "default", bin_net_ipv6_conf_var_table },
  479. { CTL_DIR, 0, NULL, bin_net_ipv6_conf_var_table },
  480. {}
  481. };
  482. static const struct bin_table bin_net_ipv6_route_table[] = {
  483. /* NET_IPV6_ROUTE_FLUSH "flush" no longer used */
  484. { CTL_INT, NET_IPV6_ROUTE_GC_THRESH, "gc_thresh" },
  485. { CTL_INT, NET_IPV6_ROUTE_MAX_SIZE, "max_size" },
  486. { CTL_INT, NET_IPV6_ROUTE_GC_MIN_INTERVAL, "gc_min_interval" },
  487. { CTL_INT, NET_IPV6_ROUTE_GC_TIMEOUT, "gc_timeout" },
  488. { CTL_INT, NET_IPV6_ROUTE_GC_INTERVAL, "gc_interval" },
  489. { CTL_INT, NET_IPV6_ROUTE_GC_ELASTICITY, "gc_elasticity" },
  490. { CTL_INT, NET_IPV6_ROUTE_MTU_EXPIRES, "mtu_expires" },
  491. { CTL_INT, NET_IPV6_ROUTE_MIN_ADVMSS, "min_adv_mss" },
  492. { CTL_INT, NET_IPV6_ROUTE_GC_MIN_INTERVAL_MS, "gc_min_interval_ms" },
  493. {}
  494. };
  495. static const struct bin_table bin_net_ipv6_icmp_table[] = {
  496. { CTL_INT, NET_IPV6_ICMP_RATELIMIT, "ratelimit" },
  497. {}
  498. };
  499. static const struct bin_table bin_net_ipv6_table[] = {
  500. { CTL_DIR, NET_IPV6_CONF, "conf", bin_net_ipv6_conf_table },
  501. { CTL_DIR, NET_IPV6_NEIGH, "neigh", bin_net_neigh_table },
  502. { CTL_DIR, NET_IPV6_ROUTE, "route", bin_net_ipv6_route_table },
  503. { CTL_DIR, NET_IPV6_ICMP, "icmp", bin_net_ipv6_icmp_table },
  504. { CTL_INT, NET_IPV6_BINDV6ONLY, "bindv6only" },
  505. { CTL_INT, NET_IPV6_IP6FRAG_HIGH_THRESH, "ip6frag_high_thresh" },
  506. { CTL_INT, NET_IPV6_IP6FRAG_LOW_THRESH, "ip6frag_low_thresh" },
  507. { CTL_INT, NET_IPV6_IP6FRAG_TIME, "ip6frag_time" },
  508. { CTL_INT, NET_IPV6_IP6FRAG_SECRET_INTERVAL, "ip6frag_secret_interval" },
  509. { CTL_INT, NET_IPV6_MLD_MAX_MSF, "mld_max_msf" },
  510. { CTL_INT, 2088 /* IPQ_QMAX */, "ip6_queue_maxlen" },
  511. {}
  512. };
  513. static const struct bin_table bin_net_x25_table[] = {
  514. { CTL_INT, NET_X25_RESTART_REQUEST_TIMEOUT, "restart_request_timeout" },
  515. { CTL_INT, NET_X25_CALL_REQUEST_TIMEOUT, "call_request_timeout" },
  516. { CTL_INT, NET_X25_RESET_REQUEST_TIMEOUT, "reset_request_timeout" },
  517. { CTL_INT, NET_X25_CLEAR_REQUEST_TIMEOUT, "clear_request_timeout" },
  518. { CTL_INT, NET_X25_ACK_HOLD_BACK_TIMEOUT, "acknowledgement_hold_back_timeout" },
  519. { CTL_INT, NET_X25_FORWARD, "x25_forward" },
  520. {}
  521. };
  522. static const struct bin_table bin_net_tr_table[] = {
  523. { CTL_INT, NET_TR_RIF_TIMEOUT, "rif_timeout" },
  524. {}
  525. };
  526. static const struct bin_table bin_net_decnet_conf_vars[] = {
  527. { CTL_INT, NET_DECNET_CONF_DEV_FORWARDING, "forwarding" },
  528. { CTL_INT, NET_DECNET_CONF_DEV_PRIORITY, "priority" },
  529. { CTL_INT, NET_DECNET_CONF_DEV_T2, "t2" },
  530. { CTL_INT, NET_DECNET_CONF_DEV_T3, "t3" },
  531. {}
  532. };
  533. static const struct bin_table bin_net_decnet_conf[] = {
  534. { CTL_DIR, NET_DECNET_CONF_ETHER, "ethernet", bin_net_decnet_conf_vars },
  535. { CTL_DIR, NET_DECNET_CONF_GRE, "ipgre", bin_net_decnet_conf_vars },
  536. { CTL_DIR, NET_DECNET_CONF_X25, "x25", bin_net_decnet_conf_vars },
  537. { CTL_DIR, NET_DECNET_CONF_PPP, "ppp", bin_net_decnet_conf_vars },
  538. { CTL_DIR, NET_DECNET_CONF_DDCMP, "ddcmp", bin_net_decnet_conf_vars },
  539. { CTL_DIR, NET_DECNET_CONF_LOOPBACK, "loopback", bin_net_decnet_conf_vars },
  540. { CTL_DIR, 0, NULL, bin_net_decnet_conf_vars },
  541. {}
  542. };
  543. static const struct bin_table bin_net_decnet_table[] = {
  544. { CTL_DIR, NET_DECNET_CONF, "conf", bin_net_decnet_conf },
  545. { CTL_DNADR, NET_DECNET_NODE_ADDRESS, "node_address" },
  546. { CTL_STR, NET_DECNET_NODE_NAME, "node_name" },
  547. { CTL_STR, NET_DECNET_DEFAULT_DEVICE, "default_device" },
  548. { CTL_INT, NET_DECNET_TIME_WAIT, "time_wait" },
  549. { CTL_INT, NET_DECNET_DN_COUNT, "dn_count" },
  550. { CTL_INT, NET_DECNET_DI_COUNT, "di_count" },
  551. { CTL_INT, NET_DECNET_DR_COUNT, "dr_count" },
  552. { CTL_INT, NET_DECNET_DST_GC_INTERVAL, "dst_gc_interval" },
  553. { CTL_INT, NET_DECNET_NO_FC_MAX_CWND, "no_fc_max_cwnd" },
  554. { CTL_INT, NET_DECNET_MEM, "decnet_mem" },
  555. { CTL_INT, NET_DECNET_RMEM, "decnet_rmem" },
  556. { CTL_INT, NET_DECNET_WMEM, "decnet_wmem" },
  557. { CTL_INT, NET_DECNET_DEBUG_LEVEL, "debug" },
  558. {}
  559. };
  560. static const struct bin_table bin_net_sctp_table[] = {
  561. { CTL_INT, NET_SCTP_RTO_INITIAL, "rto_initial" },
  562. { CTL_INT, NET_SCTP_RTO_MIN, "rto_min" },
  563. { CTL_INT, NET_SCTP_RTO_MAX, "rto_max" },
  564. { CTL_INT, NET_SCTP_RTO_ALPHA, "rto_alpha_exp_divisor" },
  565. { CTL_INT, NET_SCTP_RTO_BETA, "rto_beta_exp_divisor" },
  566. { CTL_INT, NET_SCTP_VALID_COOKIE_LIFE, "valid_cookie_life" },
  567. { CTL_INT, NET_SCTP_ASSOCIATION_MAX_RETRANS, "association_max_retrans" },
  568. { CTL_INT, NET_SCTP_PATH_MAX_RETRANS, "path_max_retrans" },
  569. { CTL_INT, NET_SCTP_MAX_INIT_RETRANSMITS, "max_init_retransmits" },
  570. { CTL_INT, NET_SCTP_HB_INTERVAL, "hb_interval" },
  571. { CTL_INT, NET_SCTP_PRESERVE_ENABLE, "cookie_preserve_enable" },
  572. { CTL_INT, NET_SCTP_MAX_BURST, "max_burst" },
  573. { CTL_INT, NET_SCTP_ADDIP_ENABLE, "addip_enable" },
  574. { CTL_INT, NET_SCTP_PRSCTP_ENABLE, "prsctp_enable" },
  575. { CTL_INT, NET_SCTP_SNDBUF_POLICY, "sndbuf_policy" },
  576. { CTL_INT, NET_SCTP_SACK_TIMEOUT, "sack_timeout" },
  577. { CTL_INT, NET_SCTP_RCVBUF_POLICY, "rcvbuf_policy" },
  578. {}
  579. };
  580. static const struct bin_table bin_net_llc_llc2_timeout_table[] = {
  581. { CTL_INT, NET_LLC2_ACK_TIMEOUT, "ack" },
  582. { CTL_INT, NET_LLC2_P_TIMEOUT, "p" },
  583. { CTL_INT, NET_LLC2_REJ_TIMEOUT, "rej" },
  584. { CTL_INT, NET_LLC2_BUSY_TIMEOUT, "busy" },
  585. {}
  586. };
  587. static const struct bin_table bin_net_llc_station_table[] = {
  588. { CTL_INT, NET_LLC_STATION_ACK_TIMEOUT, "ack_timeout" },
  589. {}
  590. };
  591. static const struct bin_table bin_net_llc_llc2_table[] = {
  592. { CTL_DIR, NET_LLC2, "timeout", bin_net_llc_llc2_timeout_table },
  593. {}
  594. };
  595. static const struct bin_table bin_net_llc_table[] = {
  596. { CTL_DIR, NET_LLC2, "llc2", bin_net_llc_llc2_table },
  597. { CTL_DIR, NET_LLC_STATION, "station", bin_net_llc_station_table },
  598. {}
  599. };
  600. static const struct bin_table bin_net_netfilter_table[] = {
  601. { CTL_INT, NET_NF_CONNTRACK_MAX, "nf_conntrack_max" },
  602. /* NET_NF_CONNTRACK_TCP_TIMEOUT_SYN_SENT "nf_conntrack_tcp_timeout_syn_sent" no longer used */
  603. /* NET_NF_CONNTRACK_TCP_TIMEOUT_SYN_RECV "nf_conntrack_tcp_timeout_syn_recv" no longer used */
  604. /* NET_NF_CONNTRACK_TCP_TIMEOUT_ESTABLISHED "nf_conntrack_tcp_timeout_established" no longer used */
  605. /* NET_NF_CONNTRACK_TCP_TIMEOUT_FIN_WAIT "nf_conntrack_tcp_timeout_fin_wait" no longer used */
  606. /* NET_NF_CONNTRACK_TCP_TIMEOUT_CLOSE_WAIT "nf_conntrack_tcp_timeout_close_wait" no longer used */
  607. /* NET_NF_CONNTRACK_TCP_TIMEOUT_LAST_ACK "nf_conntrack_tcp_timeout_last_ack" no longer used */
  608. /* NET_NF_CONNTRACK_TCP_TIMEOUT_TIME_WAIT "nf_conntrack_tcp_timeout_time_wait" no longer used */
  609. /* NET_NF_CONNTRACK_TCP_TIMEOUT_CLOSE "nf_conntrack_tcp_timeout_close" no longer used */
  610. /* NET_NF_CONNTRACK_UDP_TIMEOUT "nf_conntrack_udp_timeout" no longer used */
  611. /* NET_NF_CONNTRACK_UDP_TIMEOUT_STREAM "nf_conntrack_udp_timeout_stream" no longer used */
  612. /* NET_NF_CONNTRACK_ICMP_TIMEOUT "nf_conntrack_icmp_timeout" no longer used */
  613. /* NET_NF_CONNTRACK_GENERIC_TIMEOUT "nf_conntrack_generic_timeout" no longer used */
  614. { CTL_INT, NET_NF_CONNTRACK_BUCKETS, "nf_conntrack_buckets" },
  615. { CTL_INT, NET_NF_CONNTRACK_LOG_INVALID, "nf_conntrack_log_invalid" },
  616. /* NET_NF_CONNTRACK_TCP_TIMEOUT_MAX_RETRANS "nf_conntrack_tcp_timeout_max_retrans" no longer used */
  617. { CTL_INT, NET_NF_CONNTRACK_TCP_LOOSE, "nf_conntrack_tcp_loose" },
  618. { CTL_INT, NET_NF_CONNTRACK_TCP_BE_LIBERAL, "nf_conntrack_tcp_be_liberal" },
  619. { CTL_INT, NET_NF_CONNTRACK_TCP_MAX_RETRANS, "nf_conntrack_tcp_max_retrans" },
  620. /* NET_NF_CONNTRACK_SCTP_TIMEOUT_CLOSED "nf_conntrack_sctp_timeout_closed" no longer used */
  621. /* NET_NF_CONNTRACK_SCTP_TIMEOUT_COOKIE_WAIT "nf_conntrack_sctp_timeout_cookie_wait" no longer used */
  622. /* NET_NF_CONNTRACK_SCTP_TIMEOUT_COOKIE_ECHOED "nf_conntrack_sctp_timeout_cookie_echoed" no longer used */
  623. /* NET_NF_CONNTRACK_SCTP_TIMEOUT_ESTABLISHED "nf_conntrack_sctp_timeout_established" no longer used */
  624. /* NET_NF_CONNTRACK_SCTP_TIMEOUT_SHUTDOWN_SENT "nf_conntrack_sctp_timeout_shutdown_sent" no longer used */
  625. /* NET_NF_CONNTRACK_SCTP_TIMEOUT_SHUTDOWN_RECD "nf_conntrack_sctp_timeout_shutdown_recd" no longer used */
  626. /* NET_NF_CONNTRACK_SCTP_TIMEOUT_SHUTDOWN_ACK_SENT "nf_conntrack_sctp_timeout_shutdown_ack_sent" no longer used */
  627. { CTL_INT, NET_NF_CONNTRACK_COUNT, "nf_conntrack_count" },
  628. /* NET_NF_CONNTRACK_ICMPV6_TIMEOUT "nf_conntrack_icmpv6_timeout" no longer used */
  629. /* NET_NF_CONNTRACK_FRAG6_TIMEOUT "nf_conntrack_frag6_timeout" no longer used */
  630. { CTL_INT, NET_NF_CONNTRACK_FRAG6_LOW_THRESH, "nf_conntrack_frag6_low_thresh" },
  631. { CTL_INT, NET_NF_CONNTRACK_FRAG6_HIGH_THRESH, "nf_conntrack_frag6_high_thresh" },
  632. { CTL_INT, NET_NF_CONNTRACK_CHECKSUM, "nf_conntrack_checksum" },
  633. {}
  634. };
  635. static const struct bin_table bin_net_irda_table[] = {
  636. { CTL_INT, NET_IRDA_DISCOVERY, "discovery" },
  637. { CTL_STR, NET_IRDA_DEVNAME, "devname" },
  638. { CTL_INT, NET_IRDA_DEBUG, "debug" },
  639. { CTL_INT, NET_IRDA_FAST_POLL, "fast_poll_increase" },
  640. { CTL_INT, NET_IRDA_DISCOVERY_SLOTS, "discovery_slots" },
  641. { CTL_INT, NET_IRDA_DISCOVERY_TIMEOUT, "discovery_timeout" },
  642. { CTL_INT, NET_IRDA_SLOT_TIMEOUT, "slot_timeout" },
  643. { CTL_INT, NET_IRDA_MAX_BAUD_RATE, "max_baud_rate" },
  644. { CTL_INT, NET_IRDA_MIN_TX_TURN_TIME, "min_tx_turn_time" },
  645. { CTL_INT, NET_IRDA_MAX_TX_DATA_SIZE, "max_tx_data_size" },
  646. { CTL_INT, NET_IRDA_MAX_TX_WINDOW, "max_tx_window" },
  647. { CTL_INT, NET_IRDA_MAX_NOREPLY_TIME, "max_noreply_time" },
  648. { CTL_INT, NET_IRDA_WARN_NOREPLY_TIME, "warn_noreply_time" },
  649. { CTL_INT, NET_IRDA_LAP_KEEPALIVE_TIME, "lap_keepalive_time" },
  650. {}
  651. };
  652. static const struct bin_table bin_net_table[] = {
  653. { CTL_DIR, NET_CORE, "core", bin_net_core_table },
  654. /* NET_ETHER not used */
  655. /* NET_802 not used */
  656. { CTL_DIR, NET_UNIX, "unix", bin_net_unix_table },
  657. { CTL_DIR, NET_IPV4, "ipv4", bin_net_ipv4_table },
  658. { CTL_DIR, NET_IPX, "ipx", bin_net_ipx_table },
  659. { CTL_DIR, NET_ATALK, "appletalk", bin_net_atalk_table },
  660. { CTL_DIR, NET_NETROM, "netrom", bin_net_netrom_table },
  661. { CTL_DIR, NET_AX25, "ax25", bin_net_ax25_table },
  662. /* NET_BRIDGE "bridge" no longer used */
  663. { CTL_DIR, NET_ROSE, "rose", bin_net_rose_table },
  664. { CTL_DIR, NET_IPV6, "ipv6", bin_net_ipv6_table },
  665. { CTL_DIR, NET_X25, "x25", bin_net_x25_table },
  666. { CTL_DIR, NET_TR, "token-ring", bin_net_tr_table },
  667. { CTL_DIR, NET_DECNET, "decnet", bin_net_decnet_table },
  668. /* NET_ECONET not used */
  669. { CTL_DIR, NET_SCTP, "sctp", bin_net_sctp_table },
  670. { CTL_DIR, NET_LLC, "llc", bin_net_llc_table },
  671. { CTL_DIR, NET_NETFILTER, "netfilter", bin_net_netfilter_table },
  672. /* NET_DCCP "dccp" no longer used */
  673. { CTL_DIR, NET_IRDA, "irda", bin_net_irda_table },
  674. { CTL_INT, 2089, "nf_conntrack_max" },
  675. {}
  676. };
  677. static const struct bin_table bin_fs_quota_table[] = {
  678. { CTL_INT, FS_DQ_LOOKUPS, "lookups" },
  679. { CTL_INT, FS_DQ_DROPS, "drops" },
  680. { CTL_INT, FS_DQ_READS, "reads" },
  681. { CTL_INT, FS_DQ_WRITES, "writes" },
  682. { CTL_INT, FS_DQ_CACHE_HITS, "cache_hits" },
  683. { CTL_INT, FS_DQ_ALLOCATED, "allocated_dquots" },
  684. { CTL_INT, FS_DQ_FREE, "free_dquots" },
  685. { CTL_INT, FS_DQ_SYNCS, "syncs" },
  686. { CTL_INT, FS_DQ_WARNINGS, "warnings" },
  687. {}
  688. };
  689. static const struct bin_table bin_fs_xfs_table[] = {
  690. { CTL_INT, XFS_SGID_INHERIT, "irix_sgid_inherit" },
  691. { CTL_INT, XFS_SYMLINK_MODE, "irix_symlink_mode" },
  692. { CTL_INT, XFS_PANIC_MASK, "panic_mask" },
  693. { CTL_INT, XFS_ERRLEVEL, "error_level" },
  694. { CTL_INT, XFS_SYNCD_TIMER, "xfssyncd_centisecs" },
  695. { CTL_INT, XFS_INHERIT_SYNC, "inherit_sync" },
  696. { CTL_INT, XFS_INHERIT_NODUMP, "inherit_nodump" },
  697. { CTL_INT, XFS_INHERIT_NOATIME, "inherit_noatime" },
  698. { CTL_INT, XFS_BUF_TIMER, "xfsbufd_centisecs" },
  699. { CTL_INT, XFS_BUF_AGE, "age_buffer_centisecs" },
  700. { CTL_INT, XFS_INHERIT_NOSYM, "inherit_nosymlinks" },
  701. { CTL_INT, XFS_ROTORSTEP, "rotorstep" },
  702. { CTL_INT, XFS_INHERIT_NODFRG, "inherit_nodefrag" },
  703. { CTL_INT, XFS_FILESTREAM_TIMER, "filestream_centisecs" },
  704. { CTL_INT, XFS_STATS_CLEAR, "stats_clear" },
  705. {}
  706. };
  707. static const struct bin_table bin_fs_ocfs2_nm_table[] = {
  708. { CTL_STR, 1, "hb_ctl_path" },
  709. {}
  710. };
  711. static const struct bin_table bin_fs_ocfs2_table[] = {
  712. { CTL_DIR, 1, "nm", bin_fs_ocfs2_nm_table },
  713. {}
  714. };
  715. static const struct bin_table bin_inotify_table[] = {
  716. { CTL_INT, INOTIFY_MAX_USER_INSTANCES, "max_user_instances" },
  717. { CTL_INT, INOTIFY_MAX_USER_WATCHES, "max_user_watches" },
  718. { CTL_INT, INOTIFY_MAX_QUEUED_EVENTS, "max_queued_events" },
  719. {}
  720. };
  721. static const struct bin_table bin_fs_table[] = {
  722. { CTL_INT, FS_NRINODE, "inode-nr" },
  723. { CTL_INT, FS_STATINODE, "inode-state" },
  724. /* FS_MAXINODE unused */
  725. /* FS_NRDQUOT unused */
  726. /* FS_MAXDQUOT unused */
  727. /* FS_NRFILE "file-nr" no longer used */
  728. { CTL_INT, FS_MAXFILE, "file-max" },
  729. { CTL_INT, FS_DENTRY, "dentry-state" },
  730. /* FS_NRSUPER unused */
  731. /* FS_MAXUPSER unused */
  732. { CTL_INT, FS_OVERFLOWUID, "overflowuid" },
  733. { CTL_INT, FS_OVERFLOWGID, "overflowgid" },
  734. { CTL_INT, FS_LEASES, "leases-enable" },
  735. { CTL_INT, FS_DIR_NOTIFY, "dir-notify-enable" },
  736. { CTL_INT, FS_LEASE_TIME, "lease-break-time" },
  737. { CTL_DIR, FS_DQSTATS, "quota", bin_fs_quota_table },
  738. { CTL_DIR, FS_XFS, "xfs", bin_fs_xfs_table },
  739. { CTL_ULONG, FS_AIO_NR, "aio-nr" },
  740. { CTL_ULONG, FS_AIO_MAX_NR, "aio-max-nr" },
  741. { CTL_DIR, FS_INOTIFY, "inotify", bin_inotify_table },
  742. { CTL_DIR, FS_OCFS2, "ocfs2", bin_fs_ocfs2_table },
  743. { CTL_INT, KERN_SETUID_DUMPABLE, "suid_dumpable" },
  744. {}
  745. };
  746. static const struct bin_table bin_ipmi_table[] = {
  747. { CTL_INT, DEV_IPMI_POWEROFF_POWERCYCLE, "poweroff_powercycle" },
  748. {}
  749. };
  750. static const struct bin_table bin_mac_hid_files[] = {
  751. /* DEV_MAC_HID_KEYBOARD_SENDS_LINUX_KEYCODES unused */
  752. /* DEV_MAC_HID_KEYBOARD_LOCK_KEYCODES unused */
  753. { CTL_INT, DEV_MAC_HID_MOUSE_BUTTON_EMULATION, "mouse_button_emulation" },
  754. { CTL_INT, DEV_MAC_HID_MOUSE_BUTTON2_KEYCODE, "mouse_button2_keycode" },
  755. { CTL_INT, DEV_MAC_HID_MOUSE_BUTTON3_KEYCODE, "mouse_button3_keycode" },
  756. /* DEV_MAC_HID_ADB_MOUSE_SENDS_KEYCODES unused */
  757. {}
  758. };
  759. static const struct bin_table bin_raid_table[] = {
  760. { CTL_INT, DEV_RAID_SPEED_LIMIT_MIN, "speed_limit_min" },
  761. { CTL_INT, DEV_RAID_SPEED_LIMIT_MAX, "speed_limit_max" },
  762. {}
  763. };
  764. static const struct bin_table bin_scsi_table[] = {
  765. { CTL_INT, DEV_SCSI_LOGGING_LEVEL, "logging_level" },
  766. {}
  767. };
  768. static const struct bin_table bin_dev_table[] = {
  769. /* DEV_CDROM "cdrom" no longer used */
  770. /* DEV_HWMON unused */
  771. /* DEV_PARPORT "parport" no longer used */
  772. { CTL_DIR, DEV_RAID, "raid", bin_raid_table },
  773. { CTL_DIR, DEV_MAC_HID, "mac_hid", bin_mac_hid_files },
  774. { CTL_DIR, DEV_SCSI, "scsi", bin_scsi_table },
  775. { CTL_DIR, DEV_IPMI, "ipmi", bin_ipmi_table },
  776. {}
  777. };
  778. static const struct bin_table bin_bus_isa_table[] = {
  779. { CTL_INT, BUS_ISA_MEM_BASE, "membase" },
  780. { CTL_INT, BUS_ISA_PORT_BASE, "portbase" },
  781. { CTL_INT, BUS_ISA_PORT_SHIFT, "portshift" },
  782. {}
  783. };
  784. static const struct bin_table bin_bus_table[] = {
  785. { CTL_DIR, CTL_BUS_ISA, "isa", bin_bus_isa_table },
  786. {}
  787. };
  788. static const struct bin_table bin_s390dbf_table[] = {
  789. { CTL_INT, 5678 /* CTL_S390DBF_STOPPABLE */, "debug_stoppable" },
  790. { CTL_INT, 5679 /* CTL_S390DBF_ACTIVE */, "debug_active" },
  791. {}
  792. };
  793. static const struct bin_table bin_sunrpc_table[] = {
  794. /* CTL_RPCDEBUG "rpc_debug" no longer used */
  795. /* CTL_NFSDEBUG "nfs_debug" no longer used */
  796. /* CTL_NFSDDEBUG "nfsd_debug" no longer used */
  797. /* CTL_NLMDEBUG "nlm_debug" no longer used */
  798. { CTL_INT, CTL_SLOTTABLE_UDP, "udp_slot_table_entries" },
  799. { CTL_INT, CTL_SLOTTABLE_TCP, "tcp_slot_table_entries" },
  800. { CTL_INT, CTL_MIN_RESVPORT, "min_resvport" },
  801. { CTL_INT, CTL_MAX_RESVPORT, "max_resvport" },
  802. {}
  803. };
  804. static const struct bin_table bin_pm_table[] = {
  805. /* frv specific */
  806. /* 1 == CTL_PM_SUSPEND "suspend" no longer used" */
  807. { CTL_INT, 2 /* CTL_PM_CMODE */, "cmode" },
  808. { CTL_INT, 3 /* CTL_PM_P0 */, "p0" },
  809. { CTL_INT, 4 /* CTL_PM_CM */, "cm" },
  810. {}
  811. };
  812. static const struct bin_table bin_root_table[] = {
  813. { CTL_DIR, CTL_KERN, "kernel", bin_kern_table },
  814. { CTL_DIR, CTL_VM, "vm", bin_vm_table },
  815. { CTL_DIR, CTL_NET, "net", bin_net_table },
  816. /* CTL_PROC not used */
  817. { CTL_DIR, CTL_FS, "fs", bin_fs_table },
  818. /* CTL_DEBUG "debug" no longer used */
  819. { CTL_DIR, CTL_DEV, "dev", bin_dev_table },
  820. { CTL_DIR, CTL_BUS, "bus", bin_bus_table },
  821. { CTL_DIR, CTL_ABI, "abi" },
  822. /* CTL_CPU not used */
  823. /* CTL_ARLAN "arlan" no longer used */
  824. { CTL_DIR, CTL_S390DBF, "s390dbf", bin_s390dbf_table },
  825. { CTL_DIR, CTL_SUNRPC, "sunrpc", bin_sunrpc_table },
  826. { CTL_DIR, CTL_PM, "pm", bin_pm_table },
  827. {}
  828. };
  829. static ssize_t bin_dir(struct file *file,
  830. void __user *oldval, size_t oldlen, void __user *newval, size_t newlen)
  831. {
  832. return -ENOTDIR;
  833. }
  834. static ssize_t bin_string(struct file *file,
  835. void __user *oldval, size_t oldlen, void __user *newval, size_t newlen)
  836. {
  837. ssize_t result, copied = 0;
  838. if (oldval && oldlen) {
  839. char __user *lastp;
  840. loff_t pos = 0;
  841. int ch;
  842. result = vfs_read(file, oldval, oldlen, &pos);
  843. if (result < 0)
  844. goto out;
  845. copied = result;
  846. lastp = oldval + copied - 1;
  847. result = -EFAULT;
  848. if (get_user(ch, lastp))
  849. goto out;
  850. /* Trim off the trailing newline */
  851. if (ch == '\n') {
  852. result = -EFAULT;
  853. if (put_user('\0', lastp))
  854. goto out;
  855. copied -= 1;
  856. }
  857. }
  858. if (newval && newlen) {
  859. loff_t pos = 0;
  860. result = vfs_write(file, newval, newlen, &pos);
  861. if (result < 0)
  862. goto out;
  863. }
  864. result = copied;
  865. out:
  866. return result;
  867. }
  868. static ssize_t bin_intvec(struct file *file,
  869. void __user *oldval, size_t oldlen, void __user *newval, size_t newlen)
  870. {
  871. ssize_t copied = 0;
  872. char *buffer;
  873. ssize_t result;
  874. result = -ENOMEM;
  875. buffer = kmalloc(BUFSZ, GFP_KERNEL);
  876. if (!buffer)
  877. goto out;
  878. if (oldval && oldlen) {
  879. unsigned __user *vec = oldval;
  880. size_t length = oldlen / sizeof(*vec);
  881. char *str, *end;
  882. int i;
  883. result = kernel_read(file, 0, buffer, BUFSZ - 1);
  884. if (result < 0)
  885. goto out_kfree;
  886. str = buffer;
  887. end = str + result;
  888. *end++ = '\0';
  889. for (i = 0; i < length; i++) {
  890. unsigned long value;
  891. value = simple_strtoul(str, &str, 10);
  892. while (isspace(*str))
  893. str++;
  894. result = -EFAULT;
  895. if (put_user(value, vec + i))
  896. goto out_kfree;
  897. copied += sizeof(*vec);
  898. if (!isdigit(*str))
  899. break;
  900. }
  901. }
  902. if (newval && newlen) {
  903. unsigned __user *vec = newval;
  904. size_t length = newlen / sizeof(*vec);
  905. char *str, *end;
  906. int i;
  907. str = buffer;
  908. end = str + BUFSZ;
  909. for (i = 0; i < length; i++) {
  910. unsigned long value;
  911. result = -EFAULT;
  912. if (get_user(value, vec + i))
  913. goto out_kfree;
  914. str += scnprintf(str, end - str, "%lu\t", value);
  915. }
  916. result = kernel_write(file, buffer, str - buffer, 0);
  917. if (result < 0)
  918. goto out_kfree;
  919. }
  920. result = copied;
  921. out_kfree:
  922. kfree(buffer);
  923. out:
  924. return result;
  925. }
  926. static ssize_t bin_ulongvec(struct file *file,
  927. void __user *oldval, size_t oldlen, void __user *newval, size_t newlen)
  928. {
  929. ssize_t copied = 0;
  930. char *buffer;
  931. ssize_t result;
  932. result = -ENOMEM;
  933. buffer = kmalloc(BUFSZ, GFP_KERNEL);
  934. if (!buffer)
  935. goto out;
  936. if (oldval && oldlen) {
  937. unsigned long __user *vec = oldval;
  938. size_t length = oldlen / sizeof(*vec);
  939. char *str, *end;
  940. int i;
  941. result = kernel_read(file, 0, buffer, BUFSZ - 1);
  942. if (result < 0)
  943. goto out_kfree;
  944. str = buffer;
  945. end = str + result;
  946. *end++ = '\0';
  947. for (i = 0; i < length; i++) {
  948. unsigned long value;
  949. value = simple_strtoul(str, &str, 10);
  950. while (isspace(*str))
  951. str++;
  952. result = -EFAULT;
  953. if (put_user(value, vec + i))
  954. goto out_kfree;
  955. copied += sizeof(*vec);
  956. if (!isdigit(*str))
  957. break;
  958. }
  959. }
  960. if (newval && newlen) {
  961. unsigned long __user *vec = newval;
  962. size_t length = newlen / sizeof(*vec);
  963. char *str, *end;
  964. int i;
  965. str = buffer;
  966. end = str + BUFSZ;
  967. for (i = 0; i < length; i++) {
  968. unsigned long value;
  969. result = -EFAULT;
  970. if (get_user(value, vec + i))
  971. goto out_kfree;
  972. str += scnprintf(str, end - str, "%lu\t", value);
  973. }
  974. result = kernel_write(file, buffer, str - buffer, 0);
  975. if (result < 0)
  976. goto out_kfree;
  977. }
  978. result = copied;
  979. out_kfree:
  980. kfree(buffer);
  981. out:
  982. return result;
  983. }
  984. static ssize_t bin_uuid(struct file *file,
  985. void __user *oldval, size_t oldlen, void __user *newval, size_t newlen)
  986. {
  987. ssize_t result, copied = 0;
  988. /* Only supports reads */
  989. if (oldval && oldlen) {
  990. char buf[UUID_STRING_LEN + 1];
  991. uuid_be uuid;
  992. result = kernel_read(file, 0, buf, sizeof(buf) - 1);
  993. if (result < 0)
  994. goto out;
  995. buf[result] = '\0';
  996. result = -EIO;
  997. if (uuid_be_to_bin(buf, &uuid))
  998. goto out;
  999. if (oldlen > 16)
  1000. oldlen = 16;
  1001. result = -EFAULT;
  1002. if (copy_to_user(oldval, &uuid, oldlen))
  1003. goto out;
  1004. copied = oldlen;
  1005. }
  1006. result = copied;
  1007. out:
  1008. return result;
  1009. }
  1010. static ssize_t bin_dn_node_address(struct file *file,
  1011. void __user *oldval, size_t oldlen, void __user *newval, size_t newlen)
  1012. {
  1013. ssize_t result, copied = 0;
  1014. if (oldval && oldlen) {
  1015. char buf[15], *nodep;
  1016. unsigned long area, node;
  1017. __le16 dnaddr;
  1018. result = kernel_read(file, 0, buf, sizeof(buf) - 1);
  1019. if (result < 0)
  1020. goto out;
  1021. buf[result] = '\0';
  1022. /* Convert the decnet address to binary */
  1023. result = -EIO;
  1024. nodep = strchr(buf, '.');
  1025. if (!nodep)
  1026. goto out;
  1027. ++nodep;
  1028. area = simple_strtoul(buf, NULL, 10);
  1029. node = simple_strtoul(nodep, NULL, 10);
  1030. result = -EIO;
  1031. if ((area > 63)||(node > 1023))
  1032. goto out;
  1033. dnaddr = cpu_to_le16((area << 10) | node);
  1034. result = -EFAULT;
  1035. if (put_user(dnaddr, (__le16 __user *)oldval))
  1036. goto out;
  1037. copied = sizeof(dnaddr);
  1038. }
  1039. if (newval && newlen) {
  1040. __le16 dnaddr;
  1041. char buf[15];
  1042. int len;
  1043. result = -EINVAL;
  1044. if (newlen != sizeof(dnaddr))
  1045. goto out;
  1046. result = -EFAULT;
  1047. if (get_user(dnaddr, (__le16 __user *)newval))
  1048. goto out;
  1049. len = scnprintf(buf, sizeof(buf), "%hu.%hu",
  1050. le16_to_cpu(dnaddr) >> 10,
  1051. le16_to_cpu(dnaddr) & 0x3ff);
  1052. result = kernel_write(file, buf, len, 0);
  1053. if (result < 0)
  1054. goto out;
  1055. }
  1056. result = copied;
  1057. out:
  1058. return result;
  1059. }
  1060. static const struct bin_table *get_sysctl(const int *name, int nlen, char *path)
  1061. {
  1062. const struct bin_table *table = &bin_root_table[0];
  1063. int ctl_name;
  1064. /* The binary sysctl tables have a small maximum depth so
  1065. * there is no danger of overflowing our path as it PATH_MAX
  1066. * bytes long.
  1067. */
  1068. memcpy(path, "sys/", 4);
  1069. path += 4;
  1070. repeat:
  1071. if (!nlen)
  1072. return ERR_PTR(-ENOTDIR);
  1073. ctl_name = *name;
  1074. name++;
  1075. nlen--;
  1076. for ( ; table->convert; table++) {
  1077. int len = 0;
  1078. /*
  1079. * For a wild card entry map from ifindex to network
  1080. * device name.
  1081. */
  1082. if (!table->ctl_name) {
  1083. #ifdef CONFIG_NET
  1084. struct net *net = current->nsproxy->net_ns;
  1085. struct net_device *dev;
  1086. dev = dev_get_by_index(net, ctl_name);
  1087. if (dev) {
  1088. len = strlen(dev->name);
  1089. memcpy(path, dev->name, len);
  1090. dev_put(dev);
  1091. }
  1092. #endif
  1093. /* Use the well known sysctl number to proc name mapping */
  1094. } else if (ctl_name == table->ctl_name) {
  1095. len = strlen(table->procname);
  1096. memcpy(path, table->procname, len);
  1097. }
  1098. if (len) {
  1099. path += len;
  1100. if (table->child) {
  1101. *path++ = '/';
  1102. table = table->child;
  1103. goto repeat;
  1104. }
  1105. *path = '\0';
  1106. return table;
  1107. }
  1108. }
  1109. return ERR_PTR(-ENOTDIR);
  1110. }
  1111. static char *sysctl_getname(const int *name, int nlen, const struct bin_table **tablep)
  1112. {
  1113. char *tmp, *result;
  1114. result = ERR_PTR(-ENOMEM);
  1115. tmp = __getname();
  1116. if (tmp) {
  1117. const struct bin_table *table = get_sysctl(name, nlen, tmp);
  1118. result = tmp;
  1119. *tablep = table;
  1120. if (IS_ERR(table)) {
  1121. __putname(tmp);
  1122. result = ERR_CAST(table);
  1123. }
  1124. }
  1125. return result;
  1126. }
  1127. static ssize_t binary_sysctl(const int *name, int nlen,
  1128. void __user *oldval, size_t oldlen, void __user *newval, size_t newlen)
  1129. {
  1130. const struct bin_table *table = NULL;
  1131. struct vfsmount *mnt;
  1132. struct file *file;
  1133. ssize_t result;
  1134. char *pathname;
  1135. int flags;
  1136. pathname = sysctl_getname(name, nlen, &table);
  1137. result = PTR_ERR(pathname);
  1138. if (IS_ERR(pathname))
  1139. goto out;
  1140. /* How should the sysctl be accessed? */
  1141. if (oldval && oldlen && newval && newlen) {
  1142. flags = O_RDWR;
  1143. } else if (newval && newlen) {
  1144. flags = O_WRONLY;
  1145. } else if (oldval && oldlen) {
  1146. flags = O_RDONLY;
  1147. } else {
  1148. result = 0;
  1149. goto out_putname;
  1150. }
  1151. mnt = task_active_pid_ns(current)->proc_mnt;
  1152. file = file_open_root(mnt->mnt_root, mnt, pathname, flags, 0);
  1153. result = PTR_ERR(file);
  1154. if (IS_ERR(file))
  1155. goto out_putname;
  1156. result = table->convert(file, oldval, oldlen, newval, newlen);
  1157. fput(file);
  1158. out_putname:
  1159. __putname(pathname);
  1160. out:
  1161. return result;
  1162. }
  1163. #else /* CONFIG_SYSCTL_SYSCALL */
  1164. static ssize_t binary_sysctl(const int *name, int nlen,
  1165. void __user *oldval, size_t oldlen, void __user *newval, size_t newlen)
  1166. {
  1167. return -ENOSYS;
  1168. }
  1169. #endif /* CONFIG_SYSCTL_SYSCALL */
  1170. static void deprecated_sysctl_warning(const int *name, int nlen)
  1171. {
  1172. int i;
  1173. /*
  1174. * CTL_KERN/KERN_VERSION is used by older glibc and cannot
  1175. * ever go away.
  1176. */
  1177. if (name[0] == CTL_KERN && name[1] == KERN_VERSION)
  1178. return;
  1179. if (printk_ratelimit()) {
  1180. printk(KERN_INFO
  1181. "warning: process `%s' used the deprecated sysctl "
  1182. "system call with ", current->comm);
  1183. for (i = 0; i < nlen; i++)
  1184. printk("%d.", name[i]);
  1185. printk("\n");
  1186. }
  1187. return;
  1188. }
  1189. #define WARN_ONCE_HASH_BITS 8
  1190. #define WARN_ONCE_HASH_SIZE (1<<WARN_ONCE_HASH_BITS)
  1191. static DECLARE_BITMAP(warn_once_bitmap, WARN_ONCE_HASH_SIZE);
  1192. #define FNV32_OFFSET 2166136261U
  1193. #define FNV32_PRIME 0x01000193
  1194. /*
  1195. * Print each legacy sysctl (approximately) only once.
  1196. * To avoid making the tables non-const use a external
  1197. * hash-table instead.
  1198. * Worst case hash collision: 6, but very rarely.
  1199. * NOTE! We don't use the SMP-safe bit tests. We simply
  1200. * don't care enough.
  1201. */
  1202. static void warn_on_bintable(const int *name, int nlen)
  1203. {
  1204. int i;
  1205. u32 hash = FNV32_OFFSET;
  1206. for (i = 0; i < nlen; i++)
  1207. hash = (hash ^ name[i]) * FNV32_PRIME;
  1208. hash %= WARN_ONCE_HASH_SIZE;
  1209. if (__test_and_set_bit(hash, warn_once_bitmap))
  1210. return;
  1211. deprecated_sysctl_warning(name, nlen);
  1212. }
  1213. static ssize_t do_sysctl(int __user *args_name, int nlen,
  1214. void __user *oldval, size_t oldlen, void __user *newval, size_t newlen)
  1215. {
  1216. int name[CTL_MAXNAME];
  1217. int i;
  1218. /* Check args->nlen. */
  1219. if (nlen < 0 || nlen > CTL_MAXNAME)
  1220. return -ENOTDIR;
  1221. /* Read in the sysctl name for simplicity */
  1222. for (i = 0; i < nlen; i++)
  1223. if (get_user(name[i], args_name + i))
  1224. return -EFAULT;
  1225. warn_on_bintable(name, nlen);
  1226. return binary_sysctl(name, nlen, oldval, oldlen, newval, newlen);
  1227. }
  1228. SYSCALL_DEFINE1(sysctl, struct __sysctl_args __user *, args)
  1229. {
  1230. struct __sysctl_args tmp;
  1231. size_t oldlen = 0;
  1232. ssize_t result;
  1233. if (copy_from_user(&tmp, args, sizeof(tmp)))
  1234. return -EFAULT;
  1235. if (tmp.oldval && !tmp.oldlenp)
  1236. return -EFAULT;
  1237. if (tmp.oldlenp && get_user(oldlen, tmp.oldlenp))
  1238. return -EFAULT;
  1239. result = do_sysctl(tmp.name, tmp.nlen, tmp.oldval, oldlen,
  1240. tmp.newval, tmp.newlen);
  1241. if (result >= 0) {
  1242. oldlen = result;
  1243. result = 0;
  1244. }
  1245. if (tmp.oldlenp && put_user(oldlen, tmp.oldlenp))
  1246. return -EFAULT;
  1247. return result;
  1248. }
  1249. #ifdef CONFIG_COMPAT
  1250. struct compat_sysctl_args {
  1251. compat_uptr_t name;
  1252. int nlen;
  1253. compat_uptr_t oldval;
  1254. compat_uptr_t oldlenp;
  1255. compat_uptr_t newval;
  1256. compat_size_t newlen;
  1257. compat_ulong_t __unused[4];
  1258. };
  1259. COMPAT_SYSCALL_DEFINE1(sysctl, struct compat_sysctl_args __user *, args)
  1260. {
  1261. struct compat_sysctl_args tmp;
  1262. compat_size_t __user *compat_oldlenp;
  1263. size_t oldlen = 0;
  1264. ssize_t result;
  1265. if (copy_from_user(&tmp, args, sizeof(tmp)))
  1266. return -EFAULT;
  1267. if (tmp.oldval && !tmp.oldlenp)
  1268. return -EFAULT;
  1269. compat_oldlenp = compat_ptr(tmp.oldlenp);
  1270. if (compat_oldlenp && get_user(oldlen, compat_oldlenp))
  1271. return -EFAULT;
  1272. result = do_sysctl(compat_ptr(tmp.name), tmp.nlen,
  1273. compat_ptr(tmp.oldval), oldlen,
  1274. compat_ptr(tmp.newval), tmp.newlen);
  1275. if (result >= 0) {
  1276. oldlen = result;
  1277. result = 0;
  1278. }
  1279. if (compat_oldlenp && put_user(oldlen, compat_oldlenp))
  1280. return -EFAULT;
  1281. return result;
  1282. }
  1283. #endif /* CONFIG_COMPAT */