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