sysctl.c 60 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584
  1. /*
  2. * sysctl.c: General linux system control interface
  3. *
  4. * Begun 24 March 1995, Stephen Tweedie
  5. * Added /proc support, Dec 1995
  6. * Added bdflush entry and intvec min/max checking, 2/23/96, Tom Dyas.
  7. * Added hooks for /proc/sys/net (minor, minor patch), 96/4/1, Mike Shaver.
  8. * Added kernel/java-{interpreter,appletviewer}, 96/5/10, Mike Shaver.
  9. * Dynamic registration fixes, Stephen Tweedie.
  10. * Added kswapd-interval, ctrl-alt-del, printk stuff, 1/8/97, Chris Horn.
  11. * Made sysctl support optional via CONFIG_SYSCTL, 1/10/97, Chris
  12. * Horn.
  13. * Added proc_doulongvec_ms_jiffies_minmax, 09/08/99, Carlos H. Bauer.
  14. * Added proc_doulongvec_minmax, 09/08/99, Carlos H. Bauer.
  15. * Changed linked lists to use list.h instead of lists.h, 02/24/00, Bill
  16. * Wendling.
  17. * The list_for_each() macro wasn't appropriate for the sysctl loop.
  18. * Removed it and replaced it with older style, 03/23/00, Bill Wendling
  19. */
  20. #include <linux/module.h>
  21. #include <linux/mm.h>
  22. #include <linux/swap.h>
  23. #include <linux/slab.h>
  24. #include <linux/sysctl.h>
  25. #include <linux/proc_fs.h>
  26. #include <linux/capability.h>
  27. #include <linux/ctype.h>
  28. #include <linux/utsname.h>
  29. #include <linux/capability.h>
  30. #include <linux/smp_lock.h>
  31. #include <linux/init.h>
  32. #include <linux/kernel.h>
  33. #include <linux/kobject.h>
  34. #include <linux/net.h>
  35. #include <linux/sysrq.h>
  36. #include <linux/highuid.h>
  37. #include <linux/writeback.h>
  38. #include <linux/hugetlb.h>
  39. #include <linux/security.h>
  40. #include <linux/initrd.h>
  41. #include <linux/times.h>
  42. #include <linux/limits.h>
  43. #include <linux/dcache.h>
  44. #include <linux/syscalls.h>
  45. #include <linux/nfs_fs.h>
  46. #include <linux/acpi.h>
  47. #include <asm/uaccess.h>
  48. #include <asm/processor.h>
  49. extern int proc_nr_files(ctl_table *table, int write, struct file *filp,
  50. void __user *buffer, size_t *lenp, loff_t *ppos);
  51. #if defined(CONFIG_SYSCTL)
  52. /* External variables not in a header file. */
  53. extern int C_A_D;
  54. extern int sysctl_overcommit_memory;
  55. extern int sysctl_overcommit_ratio;
  56. extern int sysctl_panic_on_oom;
  57. extern int max_threads;
  58. extern int sysrq_enabled;
  59. extern int core_uses_pid;
  60. extern int suid_dumpable;
  61. extern char core_pattern[];
  62. extern int cad_pid;
  63. extern int pid_max;
  64. extern int min_free_kbytes;
  65. extern int printk_ratelimit_jiffies;
  66. extern int printk_ratelimit_burst;
  67. extern int pid_max_min, pid_max_max;
  68. extern int sysctl_drop_caches;
  69. extern int percpu_pagelist_fraction;
  70. extern int compat_log;
  71. #if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86)
  72. int unknown_nmi_panic;
  73. int nmi_watchdog_enabled;
  74. extern int proc_nmi_enabled(struct ctl_table *, int , struct file *,
  75. void __user *, size_t *, loff_t *);
  76. #endif
  77. /* this is needed for the proc_dointvec_minmax for [fs_]overflow UID and GID */
  78. static int maxolduid = 65535;
  79. static int minolduid;
  80. static int min_percpu_pagelist_fract = 8;
  81. static int ngroups_max = NGROUPS_MAX;
  82. #ifdef CONFIG_KMOD
  83. extern char modprobe_path[];
  84. #endif
  85. #ifdef CONFIG_CHR_DEV_SG
  86. extern int sg_big_buff;
  87. #endif
  88. #ifdef CONFIG_SYSVIPC
  89. extern size_t shm_ctlmax;
  90. extern size_t shm_ctlall;
  91. extern int shm_ctlmni;
  92. extern int msg_ctlmax;
  93. extern int msg_ctlmnb;
  94. extern int msg_ctlmni;
  95. extern int sem_ctls[];
  96. #endif
  97. #ifdef __sparc__
  98. extern char reboot_command [];
  99. extern int stop_a_enabled;
  100. extern int scons_pwroff;
  101. #endif
  102. #ifdef __hppa__
  103. extern int pwrsw_enabled;
  104. extern int unaligned_enabled;
  105. #endif
  106. #ifdef CONFIG_S390
  107. #ifdef CONFIG_MATHEMU
  108. extern int sysctl_ieee_emulation_warnings;
  109. #endif
  110. extern int sysctl_userprocess_debug;
  111. extern int spin_retry;
  112. #endif
  113. extern int sysctl_hz_timer;
  114. #ifdef CONFIG_BSD_PROCESS_ACCT
  115. extern int acct_parm[];
  116. #endif
  117. #ifdef CONFIG_IA64
  118. extern int no_unaligned_warning;
  119. #endif
  120. #ifdef CONFIG_RT_MUTEXES
  121. extern int max_lock_depth;
  122. #endif
  123. static int parse_table(int __user *, int, void __user *, size_t __user *, void __user *, size_t,
  124. ctl_table *, void **);
  125. static int proc_doutsstring(ctl_table *table, int write, struct file *filp,
  126. void __user *buffer, size_t *lenp, loff_t *ppos);
  127. static ctl_table root_table[];
  128. static struct ctl_table_header root_table_header =
  129. { root_table, LIST_HEAD_INIT(root_table_header.ctl_entry) };
  130. static ctl_table kern_table[];
  131. static ctl_table vm_table[];
  132. static ctl_table fs_table[];
  133. static ctl_table debug_table[];
  134. static ctl_table dev_table[];
  135. extern ctl_table random_table[];
  136. #ifdef CONFIG_UNIX98_PTYS
  137. extern ctl_table pty_table[];
  138. #endif
  139. #ifdef CONFIG_INOTIFY_USER
  140. extern ctl_table inotify_table[];
  141. #endif
  142. #ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
  143. int sysctl_legacy_va_layout;
  144. #endif
  145. /* /proc declarations: */
  146. #ifdef CONFIG_PROC_FS
  147. static ssize_t proc_readsys(struct file *, char __user *, size_t, loff_t *);
  148. static ssize_t proc_writesys(struct file *, const char __user *, size_t, loff_t *);
  149. static int proc_opensys(struct inode *, struct file *);
  150. struct file_operations proc_sys_file_operations = {
  151. .open = proc_opensys,
  152. .read = proc_readsys,
  153. .write = proc_writesys,
  154. };
  155. extern struct proc_dir_entry *proc_sys_root;
  156. static void register_proc_table(ctl_table *, struct proc_dir_entry *, void *);
  157. static void unregister_proc_table(ctl_table *, struct proc_dir_entry *);
  158. #endif
  159. /* The default sysctl tables: */
  160. static ctl_table root_table[] = {
  161. {
  162. .ctl_name = CTL_KERN,
  163. .procname = "kernel",
  164. .mode = 0555,
  165. .child = kern_table,
  166. },
  167. {
  168. .ctl_name = CTL_VM,
  169. .procname = "vm",
  170. .mode = 0555,
  171. .child = vm_table,
  172. },
  173. #ifdef CONFIG_NET
  174. {
  175. .ctl_name = CTL_NET,
  176. .procname = "net",
  177. .mode = 0555,
  178. .child = net_table,
  179. },
  180. #endif
  181. {
  182. .ctl_name = CTL_FS,
  183. .procname = "fs",
  184. .mode = 0555,
  185. .child = fs_table,
  186. },
  187. {
  188. .ctl_name = CTL_DEBUG,
  189. .procname = "debug",
  190. .mode = 0555,
  191. .child = debug_table,
  192. },
  193. {
  194. .ctl_name = CTL_DEV,
  195. .procname = "dev",
  196. .mode = 0555,
  197. .child = dev_table,
  198. },
  199. { .ctl_name = 0 }
  200. };
  201. static ctl_table kern_table[] = {
  202. {
  203. .ctl_name = KERN_OSTYPE,
  204. .procname = "ostype",
  205. .data = system_utsname.sysname,
  206. .maxlen = sizeof(system_utsname.sysname),
  207. .mode = 0444,
  208. .proc_handler = &proc_doutsstring,
  209. .strategy = &sysctl_string,
  210. },
  211. {
  212. .ctl_name = KERN_OSRELEASE,
  213. .procname = "osrelease",
  214. .data = system_utsname.release,
  215. .maxlen = sizeof(system_utsname.release),
  216. .mode = 0444,
  217. .proc_handler = &proc_doutsstring,
  218. .strategy = &sysctl_string,
  219. },
  220. {
  221. .ctl_name = KERN_VERSION,
  222. .procname = "version",
  223. .data = system_utsname.version,
  224. .maxlen = sizeof(system_utsname.version),
  225. .mode = 0444,
  226. .proc_handler = &proc_doutsstring,
  227. .strategy = &sysctl_string,
  228. },
  229. {
  230. .ctl_name = KERN_NODENAME,
  231. .procname = "hostname",
  232. .data = system_utsname.nodename,
  233. .maxlen = sizeof(system_utsname.nodename),
  234. .mode = 0644,
  235. .proc_handler = &proc_doutsstring,
  236. .strategy = &sysctl_string,
  237. },
  238. {
  239. .ctl_name = KERN_DOMAINNAME,
  240. .procname = "domainname",
  241. .data = system_utsname.domainname,
  242. .maxlen = sizeof(system_utsname.domainname),
  243. .mode = 0644,
  244. .proc_handler = &proc_doutsstring,
  245. .strategy = &sysctl_string,
  246. },
  247. {
  248. .ctl_name = KERN_PANIC,
  249. .procname = "panic",
  250. .data = &panic_timeout,
  251. .maxlen = sizeof(int),
  252. .mode = 0644,
  253. .proc_handler = &proc_dointvec,
  254. },
  255. {
  256. .ctl_name = KERN_CORE_USES_PID,
  257. .procname = "core_uses_pid",
  258. .data = &core_uses_pid,
  259. .maxlen = sizeof(int),
  260. .mode = 0644,
  261. .proc_handler = &proc_dointvec,
  262. },
  263. {
  264. .ctl_name = KERN_CORE_PATTERN,
  265. .procname = "core_pattern",
  266. .data = core_pattern,
  267. .maxlen = 64,
  268. .mode = 0644,
  269. .proc_handler = &proc_dostring,
  270. .strategy = &sysctl_string,
  271. },
  272. {
  273. .ctl_name = KERN_TAINTED,
  274. .procname = "tainted",
  275. .data = &tainted,
  276. .maxlen = sizeof(int),
  277. .mode = 0444,
  278. .proc_handler = &proc_dointvec,
  279. },
  280. {
  281. .ctl_name = KERN_CAP_BSET,
  282. .procname = "cap-bound",
  283. .data = &cap_bset,
  284. .maxlen = sizeof(kernel_cap_t),
  285. .mode = 0600,
  286. .proc_handler = &proc_dointvec_bset,
  287. },
  288. #ifdef CONFIG_BLK_DEV_INITRD
  289. {
  290. .ctl_name = KERN_REALROOTDEV,
  291. .procname = "real-root-dev",
  292. .data = &real_root_dev,
  293. .maxlen = sizeof(int),
  294. .mode = 0644,
  295. .proc_handler = &proc_dointvec,
  296. },
  297. #endif
  298. #ifdef __sparc__
  299. {
  300. .ctl_name = KERN_SPARC_REBOOT,
  301. .procname = "reboot-cmd",
  302. .data = reboot_command,
  303. .maxlen = 256,
  304. .mode = 0644,
  305. .proc_handler = &proc_dostring,
  306. .strategy = &sysctl_string,
  307. },
  308. {
  309. .ctl_name = KERN_SPARC_STOP_A,
  310. .procname = "stop-a",
  311. .data = &stop_a_enabled,
  312. .maxlen = sizeof (int),
  313. .mode = 0644,
  314. .proc_handler = &proc_dointvec,
  315. },
  316. {
  317. .ctl_name = KERN_SPARC_SCONS_PWROFF,
  318. .procname = "scons-poweroff",
  319. .data = &scons_pwroff,
  320. .maxlen = sizeof (int),
  321. .mode = 0644,
  322. .proc_handler = &proc_dointvec,
  323. },
  324. #endif
  325. #ifdef __hppa__
  326. {
  327. .ctl_name = KERN_HPPA_PWRSW,
  328. .procname = "soft-power",
  329. .data = &pwrsw_enabled,
  330. .maxlen = sizeof (int),
  331. .mode = 0644,
  332. .proc_handler = &proc_dointvec,
  333. },
  334. {
  335. .ctl_name = KERN_HPPA_UNALIGNED,
  336. .procname = "unaligned-trap",
  337. .data = &unaligned_enabled,
  338. .maxlen = sizeof (int),
  339. .mode = 0644,
  340. .proc_handler = &proc_dointvec,
  341. },
  342. #endif
  343. {
  344. .ctl_name = KERN_CTLALTDEL,
  345. .procname = "ctrl-alt-del",
  346. .data = &C_A_D,
  347. .maxlen = sizeof(int),
  348. .mode = 0644,
  349. .proc_handler = &proc_dointvec,
  350. },
  351. {
  352. .ctl_name = KERN_PRINTK,
  353. .procname = "printk",
  354. .data = &console_loglevel,
  355. .maxlen = 4*sizeof(int),
  356. .mode = 0644,
  357. .proc_handler = &proc_dointvec,
  358. },
  359. #ifdef CONFIG_KMOD
  360. {
  361. .ctl_name = KERN_MODPROBE,
  362. .procname = "modprobe",
  363. .data = &modprobe_path,
  364. .maxlen = KMOD_PATH_LEN,
  365. .mode = 0644,
  366. .proc_handler = &proc_dostring,
  367. .strategy = &sysctl_string,
  368. },
  369. #endif
  370. #if defined(CONFIG_HOTPLUG) && defined(CONFIG_NET)
  371. {
  372. .ctl_name = KERN_HOTPLUG,
  373. .procname = "hotplug",
  374. .data = &uevent_helper,
  375. .maxlen = UEVENT_HELPER_PATH_LEN,
  376. .mode = 0644,
  377. .proc_handler = &proc_dostring,
  378. .strategy = &sysctl_string,
  379. },
  380. #endif
  381. #ifdef CONFIG_CHR_DEV_SG
  382. {
  383. .ctl_name = KERN_SG_BIG_BUFF,
  384. .procname = "sg-big-buff",
  385. .data = &sg_big_buff,
  386. .maxlen = sizeof (int),
  387. .mode = 0444,
  388. .proc_handler = &proc_dointvec,
  389. },
  390. #endif
  391. #ifdef CONFIG_BSD_PROCESS_ACCT
  392. {
  393. .ctl_name = KERN_ACCT,
  394. .procname = "acct",
  395. .data = &acct_parm,
  396. .maxlen = 3*sizeof(int),
  397. .mode = 0644,
  398. .proc_handler = &proc_dointvec,
  399. },
  400. #endif
  401. #ifdef CONFIG_SYSVIPC
  402. {
  403. .ctl_name = KERN_SHMMAX,
  404. .procname = "shmmax",
  405. .data = &shm_ctlmax,
  406. .maxlen = sizeof (size_t),
  407. .mode = 0644,
  408. .proc_handler = &proc_doulongvec_minmax,
  409. },
  410. {
  411. .ctl_name = KERN_SHMALL,
  412. .procname = "shmall",
  413. .data = &shm_ctlall,
  414. .maxlen = sizeof (size_t),
  415. .mode = 0644,
  416. .proc_handler = &proc_doulongvec_minmax,
  417. },
  418. {
  419. .ctl_name = KERN_SHMMNI,
  420. .procname = "shmmni",
  421. .data = &shm_ctlmni,
  422. .maxlen = sizeof (int),
  423. .mode = 0644,
  424. .proc_handler = &proc_dointvec,
  425. },
  426. {
  427. .ctl_name = KERN_MSGMAX,
  428. .procname = "msgmax",
  429. .data = &msg_ctlmax,
  430. .maxlen = sizeof (int),
  431. .mode = 0644,
  432. .proc_handler = &proc_dointvec,
  433. },
  434. {
  435. .ctl_name = KERN_MSGMNI,
  436. .procname = "msgmni",
  437. .data = &msg_ctlmni,
  438. .maxlen = sizeof (int),
  439. .mode = 0644,
  440. .proc_handler = &proc_dointvec,
  441. },
  442. {
  443. .ctl_name = KERN_MSGMNB,
  444. .procname = "msgmnb",
  445. .data = &msg_ctlmnb,
  446. .maxlen = sizeof (int),
  447. .mode = 0644,
  448. .proc_handler = &proc_dointvec,
  449. },
  450. {
  451. .ctl_name = KERN_SEM,
  452. .procname = "sem",
  453. .data = &sem_ctls,
  454. .maxlen = 4*sizeof (int),
  455. .mode = 0644,
  456. .proc_handler = &proc_dointvec,
  457. },
  458. #endif
  459. #ifdef CONFIG_MAGIC_SYSRQ
  460. {
  461. .ctl_name = KERN_SYSRQ,
  462. .procname = "sysrq",
  463. .data = &sysrq_enabled,
  464. .maxlen = sizeof (int),
  465. .mode = 0644,
  466. .proc_handler = &proc_dointvec,
  467. },
  468. #endif
  469. {
  470. .ctl_name = KERN_CADPID,
  471. .procname = "cad_pid",
  472. .data = &cad_pid,
  473. .maxlen = sizeof (int),
  474. .mode = 0600,
  475. .proc_handler = &proc_dointvec,
  476. },
  477. {
  478. .ctl_name = KERN_MAX_THREADS,
  479. .procname = "threads-max",
  480. .data = &max_threads,
  481. .maxlen = sizeof(int),
  482. .mode = 0644,
  483. .proc_handler = &proc_dointvec,
  484. },
  485. {
  486. .ctl_name = KERN_RANDOM,
  487. .procname = "random",
  488. .mode = 0555,
  489. .child = random_table,
  490. },
  491. #ifdef CONFIG_UNIX98_PTYS
  492. {
  493. .ctl_name = KERN_PTY,
  494. .procname = "pty",
  495. .mode = 0555,
  496. .child = pty_table,
  497. },
  498. #endif
  499. {
  500. .ctl_name = KERN_OVERFLOWUID,
  501. .procname = "overflowuid",
  502. .data = &overflowuid,
  503. .maxlen = sizeof(int),
  504. .mode = 0644,
  505. .proc_handler = &proc_dointvec_minmax,
  506. .strategy = &sysctl_intvec,
  507. .extra1 = &minolduid,
  508. .extra2 = &maxolduid,
  509. },
  510. {
  511. .ctl_name = KERN_OVERFLOWGID,
  512. .procname = "overflowgid",
  513. .data = &overflowgid,
  514. .maxlen = sizeof(int),
  515. .mode = 0644,
  516. .proc_handler = &proc_dointvec_minmax,
  517. .strategy = &sysctl_intvec,
  518. .extra1 = &minolduid,
  519. .extra2 = &maxolduid,
  520. },
  521. #ifdef CONFIG_S390
  522. #ifdef CONFIG_MATHEMU
  523. {
  524. .ctl_name = KERN_IEEE_EMULATION_WARNINGS,
  525. .procname = "ieee_emulation_warnings",
  526. .data = &sysctl_ieee_emulation_warnings,
  527. .maxlen = sizeof(int),
  528. .mode = 0644,
  529. .proc_handler = &proc_dointvec,
  530. },
  531. #endif
  532. #ifdef CONFIG_NO_IDLE_HZ
  533. {
  534. .ctl_name = KERN_HZ_TIMER,
  535. .procname = "hz_timer",
  536. .data = &sysctl_hz_timer,
  537. .maxlen = sizeof(int),
  538. .mode = 0644,
  539. .proc_handler = &proc_dointvec,
  540. },
  541. #endif
  542. {
  543. .ctl_name = KERN_S390_USER_DEBUG_LOGGING,
  544. .procname = "userprocess_debug",
  545. .data = &sysctl_userprocess_debug,
  546. .maxlen = sizeof(int),
  547. .mode = 0644,
  548. .proc_handler = &proc_dointvec,
  549. },
  550. #endif
  551. {
  552. .ctl_name = KERN_PIDMAX,
  553. .procname = "pid_max",
  554. .data = &pid_max,
  555. .maxlen = sizeof (int),
  556. .mode = 0644,
  557. .proc_handler = &proc_dointvec_minmax,
  558. .strategy = sysctl_intvec,
  559. .extra1 = &pid_max_min,
  560. .extra2 = &pid_max_max,
  561. },
  562. {
  563. .ctl_name = KERN_PANIC_ON_OOPS,
  564. .procname = "panic_on_oops",
  565. .data = &panic_on_oops,
  566. .maxlen = sizeof(int),
  567. .mode = 0644,
  568. .proc_handler = &proc_dointvec,
  569. },
  570. {
  571. .ctl_name = KERN_PRINTK_RATELIMIT,
  572. .procname = "printk_ratelimit",
  573. .data = &printk_ratelimit_jiffies,
  574. .maxlen = sizeof(int),
  575. .mode = 0644,
  576. .proc_handler = &proc_dointvec_jiffies,
  577. .strategy = &sysctl_jiffies,
  578. },
  579. {
  580. .ctl_name = KERN_PRINTK_RATELIMIT_BURST,
  581. .procname = "printk_ratelimit_burst",
  582. .data = &printk_ratelimit_burst,
  583. .maxlen = sizeof(int),
  584. .mode = 0644,
  585. .proc_handler = &proc_dointvec,
  586. },
  587. {
  588. .ctl_name = KERN_NGROUPS_MAX,
  589. .procname = "ngroups_max",
  590. .data = &ngroups_max,
  591. .maxlen = sizeof (int),
  592. .mode = 0444,
  593. .proc_handler = &proc_dointvec,
  594. },
  595. #if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86)
  596. {
  597. .ctl_name = KERN_UNKNOWN_NMI_PANIC,
  598. .procname = "unknown_nmi_panic",
  599. .data = &unknown_nmi_panic,
  600. .maxlen = sizeof (int),
  601. .mode = 0644,
  602. .proc_handler = &proc_dointvec,
  603. },
  604. {
  605. .ctl_name = KERN_NMI_WATCHDOG,
  606. .procname = "nmi_watchdog",
  607. .data = &nmi_watchdog_enabled,
  608. .maxlen = sizeof (int),
  609. .mode = 0644,
  610. .proc_handler = &proc_nmi_enabled,
  611. },
  612. #endif
  613. #if defined(CONFIG_X86)
  614. {
  615. .ctl_name = KERN_PANIC_ON_NMI,
  616. .procname = "panic_on_unrecovered_nmi",
  617. .data = &panic_on_unrecovered_nmi,
  618. .maxlen = sizeof(int),
  619. .mode = 0644,
  620. .proc_handler = &proc_dointvec,
  621. },
  622. {
  623. .ctl_name = KERN_BOOTLOADER_TYPE,
  624. .procname = "bootloader_type",
  625. .data = &bootloader_type,
  626. .maxlen = sizeof (int),
  627. .mode = 0444,
  628. .proc_handler = &proc_dointvec,
  629. },
  630. #endif
  631. #if defined(CONFIG_MMU)
  632. {
  633. .ctl_name = KERN_RANDOMIZE,
  634. .procname = "randomize_va_space",
  635. .data = &randomize_va_space,
  636. .maxlen = sizeof(int),
  637. .mode = 0644,
  638. .proc_handler = &proc_dointvec,
  639. },
  640. #endif
  641. #if defined(CONFIG_S390) && defined(CONFIG_SMP)
  642. {
  643. .ctl_name = KERN_SPIN_RETRY,
  644. .procname = "spin_retry",
  645. .data = &spin_retry,
  646. .maxlen = sizeof (int),
  647. .mode = 0644,
  648. .proc_handler = &proc_dointvec,
  649. },
  650. #endif
  651. #ifdef CONFIG_ACPI_SLEEP
  652. {
  653. .ctl_name = KERN_ACPI_VIDEO_FLAGS,
  654. .procname = "acpi_video_flags",
  655. .data = &acpi_video_flags,
  656. .maxlen = sizeof (unsigned long),
  657. .mode = 0644,
  658. .proc_handler = &proc_doulongvec_minmax,
  659. },
  660. #endif
  661. #ifdef CONFIG_IA64
  662. {
  663. .ctl_name = KERN_IA64_UNALIGNED,
  664. .procname = "ignore-unaligned-usertrap",
  665. .data = &no_unaligned_warning,
  666. .maxlen = sizeof (int),
  667. .mode = 0644,
  668. .proc_handler = &proc_dointvec,
  669. },
  670. #endif
  671. #ifdef CONFIG_COMPAT
  672. {
  673. .ctl_name = KERN_COMPAT_LOG,
  674. .procname = "compat-log",
  675. .data = &compat_log,
  676. .maxlen = sizeof (int),
  677. .mode = 0644,
  678. .proc_handler = &proc_dointvec,
  679. },
  680. #endif
  681. #ifdef CONFIG_RT_MUTEXES
  682. {
  683. .ctl_name = KERN_MAX_LOCK_DEPTH,
  684. .procname = "max_lock_depth",
  685. .data = &max_lock_depth,
  686. .maxlen = sizeof(int),
  687. .mode = 0644,
  688. .proc_handler = &proc_dointvec,
  689. },
  690. #endif
  691. { .ctl_name = 0 }
  692. };
  693. /* Constants for minimum and maximum testing in vm_table.
  694. We use these as one-element integer vectors. */
  695. static int zero;
  696. static int one_hundred = 100;
  697. static ctl_table vm_table[] = {
  698. {
  699. .ctl_name = VM_OVERCOMMIT_MEMORY,
  700. .procname = "overcommit_memory",
  701. .data = &sysctl_overcommit_memory,
  702. .maxlen = sizeof(sysctl_overcommit_memory),
  703. .mode = 0644,
  704. .proc_handler = &proc_dointvec,
  705. },
  706. {
  707. .ctl_name = VM_PANIC_ON_OOM,
  708. .procname = "panic_on_oom",
  709. .data = &sysctl_panic_on_oom,
  710. .maxlen = sizeof(sysctl_panic_on_oom),
  711. .mode = 0644,
  712. .proc_handler = &proc_dointvec,
  713. },
  714. {
  715. .ctl_name = VM_OVERCOMMIT_RATIO,
  716. .procname = "overcommit_ratio",
  717. .data = &sysctl_overcommit_ratio,
  718. .maxlen = sizeof(sysctl_overcommit_ratio),
  719. .mode = 0644,
  720. .proc_handler = &proc_dointvec,
  721. },
  722. {
  723. .ctl_name = VM_PAGE_CLUSTER,
  724. .procname = "page-cluster",
  725. .data = &page_cluster,
  726. .maxlen = sizeof(int),
  727. .mode = 0644,
  728. .proc_handler = &proc_dointvec,
  729. },
  730. {
  731. .ctl_name = VM_DIRTY_BACKGROUND,
  732. .procname = "dirty_background_ratio",
  733. .data = &dirty_background_ratio,
  734. .maxlen = sizeof(dirty_background_ratio),
  735. .mode = 0644,
  736. .proc_handler = &proc_dointvec_minmax,
  737. .strategy = &sysctl_intvec,
  738. .extra1 = &zero,
  739. .extra2 = &one_hundred,
  740. },
  741. {
  742. .ctl_name = VM_DIRTY_RATIO,
  743. .procname = "dirty_ratio",
  744. .data = &vm_dirty_ratio,
  745. .maxlen = sizeof(vm_dirty_ratio),
  746. .mode = 0644,
  747. .proc_handler = &proc_dointvec_minmax,
  748. .strategy = &sysctl_intvec,
  749. .extra1 = &zero,
  750. .extra2 = &one_hundred,
  751. },
  752. {
  753. .ctl_name = VM_DIRTY_WB_CS,
  754. .procname = "dirty_writeback_centisecs",
  755. .data = &dirty_writeback_interval,
  756. .maxlen = sizeof(dirty_writeback_interval),
  757. .mode = 0644,
  758. .proc_handler = &dirty_writeback_centisecs_handler,
  759. },
  760. {
  761. .ctl_name = VM_DIRTY_EXPIRE_CS,
  762. .procname = "dirty_expire_centisecs",
  763. .data = &dirty_expire_interval,
  764. .maxlen = sizeof(dirty_expire_interval),
  765. .mode = 0644,
  766. .proc_handler = &proc_dointvec_userhz_jiffies,
  767. },
  768. {
  769. .ctl_name = VM_NR_PDFLUSH_THREADS,
  770. .procname = "nr_pdflush_threads",
  771. .data = &nr_pdflush_threads,
  772. .maxlen = sizeof nr_pdflush_threads,
  773. .mode = 0444 /* read-only*/,
  774. .proc_handler = &proc_dointvec,
  775. },
  776. {
  777. .ctl_name = VM_SWAPPINESS,
  778. .procname = "swappiness",
  779. .data = &vm_swappiness,
  780. .maxlen = sizeof(vm_swappiness),
  781. .mode = 0644,
  782. .proc_handler = &proc_dointvec_minmax,
  783. .strategy = &sysctl_intvec,
  784. .extra1 = &zero,
  785. .extra2 = &one_hundred,
  786. },
  787. #ifdef CONFIG_HUGETLB_PAGE
  788. {
  789. .ctl_name = VM_HUGETLB_PAGES,
  790. .procname = "nr_hugepages",
  791. .data = &max_huge_pages,
  792. .maxlen = sizeof(unsigned long),
  793. .mode = 0644,
  794. .proc_handler = &hugetlb_sysctl_handler,
  795. .extra1 = (void *)&hugetlb_zero,
  796. .extra2 = (void *)&hugetlb_infinity,
  797. },
  798. {
  799. .ctl_name = VM_HUGETLB_GROUP,
  800. .procname = "hugetlb_shm_group",
  801. .data = &sysctl_hugetlb_shm_group,
  802. .maxlen = sizeof(gid_t),
  803. .mode = 0644,
  804. .proc_handler = &proc_dointvec,
  805. },
  806. #endif
  807. {
  808. .ctl_name = VM_LOWMEM_RESERVE_RATIO,
  809. .procname = "lowmem_reserve_ratio",
  810. .data = &sysctl_lowmem_reserve_ratio,
  811. .maxlen = sizeof(sysctl_lowmem_reserve_ratio),
  812. .mode = 0644,
  813. .proc_handler = &lowmem_reserve_ratio_sysctl_handler,
  814. .strategy = &sysctl_intvec,
  815. },
  816. {
  817. .ctl_name = VM_DROP_PAGECACHE,
  818. .procname = "drop_caches",
  819. .data = &sysctl_drop_caches,
  820. .maxlen = sizeof(int),
  821. .mode = 0644,
  822. .proc_handler = drop_caches_sysctl_handler,
  823. .strategy = &sysctl_intvec,
  824. },
  825. {
  826. .ctl_name = VM_MIN_FREE_KBYTES,
  827. .procname = "min_free_kbytes",
  828. .data = &min_free_kbytes,
  829. .maxlen = sizeof(min_free_kbytes),
  830. .mode = 0644,
  831. .proc_handler = &min_free_kbytes_sysctl_handler,
  832. .strategy = &sysctl_intvec,
  833. .extra1 = &zero,
  834. },
  835. {
  836. .ctl_name = VM_PERCPU_PAGELIST_FRACTION,
  837. .procname = "percpu_pagelist_fraction",
  838. .data = &percpu_pagelist_fraction,
  839. .maxlen = sizeof(percpu_pagelist_fraction),
  840. .mode = 0644,
  841. .proc_handler = &percpu_pagelist_fraction_sysctl_handler,
  842. .strategy = &sysctl_intvec,
  843. .extra1 = &min_percpu_pagelist_fract,
  844. },
  845. #ifdef CONFIG_MMU
  846. {
  847. .ctl_name = VM_MAX_MAP_COUNT,
  848. .procname = "max_map_count",
  849. .data = &sysctl_max_map_count,
  850. .maxlen = sizeof(sysctl_max_map_count),
  851. .mode = 0644,
  852. .proc_handler = &proc_dointvec
  853. },
  854. #endif
  855. {
  856. .ctl_name = VM_LAPTOP_MODE,
  857. .procname = "laptop_mode",
  858. .data = &laptop_mode,
  859. .maxlen = sizeof(laptop_mode),
  860. .mode = 0644,
  861. .proc_handler = &proc_dointvec_jiffies,
  862. .strategy = &sysctl_jiffies,
  863. },
  864. {
  865. .ctl_name = VM_BLOCK_DUMP,
  866. .procname = "block_dump",
  867. .data = &block_dump,
  868. .maxlen = sizeof(block_dump),
  869. .mode = 0644,
  870. .proc_handler = &proc_dointvec,
  871. .strategy = &sysctl_intvec,
  872. .extra1 = &zero,
  873. },
  874. {
  875. .ctl_name = VM_VFS_CACHE_PRESSURE,
  876. .procname = "vfs_cache_pressure",
  877. .data = &sysctl_vfs_cache_pressure,
  878. .maxlen = sizeof(sysctl_vfs_cache_pressure),
  879. .mode = 0644,
  880. .proc_handler = &proc_dointvec,
  881. .strategy = &sysctl_intvec,
  882. .extra1 = &zero,
  883. },
  884. #ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
  885. {
  886. .ctl_name = VM_LEGACY_VA_LAYOUT,
  887. .procname = "legacy_va_layout",
  888. .data = &sysctl_legacy_va_layout,
  889. .maxlen = sizeof(sysctl_legacy_va_layout),
  890. .mode = 0644,
  891. .proc_handler = &proc_dointvec,
  892. .strategy = &sysctl_intvec,
  893. .extra1 = &zero,
  894. },
  895. #endif
  896. #ifdef CONFIG_SWAP
  897. {
  898. .ctl_name = VM_SWAP_TOKEN_TIMEOUT,
  899. .procname = "swap_token_timeout",
  900. .data = &swap_token_default_timeout,
  901. .maxlen = sizeof(swap_token_default_timeout),
  902. .mode = 0644,
  903. .proc_handler = &proc_dointvec_jiffies,
  904. .strategy = &sysctl_jiffies,
  905. },
  906. #endif
  907. #ifdef CONFIG_NUMA
  908. {
  909. .ctl_name = VM_ZONE_RECLAIM_MODE,
  910. .procname = "zone_reclaim_mode",
  911. .data = &zone_reclaim_mode,
  912. .maxlen = sizeof(zone_reclaim_mode),
  913. .mode = 0644,
  914. .proc_handler = &proc_dointvec,
  915. .strategy = &sysctl_intvec,
  916. .extra1 = &zero,
  917. },
  918. {
  919. .ctl_name = VM_MIN_UNMAPPED,
  920. .procname = "min_unmapped_ratio",
  921. .data = &sysctl_min_unmapped_ratio,
  922. .maxlen = sizeof(sysctl_min_unmapped_ratio),
  923. .mode = 0644,
  924. .proc_handler = &sysctl_min_unmapped_ratio_sysctl_handler,
  925. .strategy = &sysctl_intvec,
  926. .extra1 = &zero,
  927. .extra2 = &one_hundred,
  928. },
  929. {
  930. .ctl_name = VM_MIN_SLAB,
  931. .procname = "min_slab_ratio",
  932. .data = &sysctl_min_slab_ratio,
  933. .maxlen = sizeof(sysctl_min_slab_ratio),
  934. .mode = 0644,
  935. .proc_handler = &sysctl_min_slab_ratio_sysctl_handler,
  936. .strategy = &sysctl_intvec,
  937. .extra1 = &zero,
  938. .extra2 = &one_hundred,
  939. },
  940. #endif
  941. #ifdef CONFIG_X86_32
  942. {
  943. .ctl_name = VM_VDSO_ENABLED,
  944. .procname = "vdso_enabled",
  945. .data = &vdso_enabled,
  946. .maxlen = sizeof(vdso_enabled),
  947. .mode = 0644,
  948. .proc_handler = &proc_dointvec,
  949. .strategy = &sysctl_intvec,
  950. .extra1 = &zero,
  951. },
  952. #endif
  953. { .ctl_name = 0 }
  954. };
  955. static ctl_table fs_table[] = {
  956. {
  957. .ctl_name = FS_NRINODE,
  958. .procname = "inode-nr",
  959. .data = &inodes_stat,
  960. .maxlen = 2*sizeof(int),
  961. .mode = 0444,
  962. .proc_handler = &proc_dointvec,
  963. },
  964. {
  965. .ctl_name = FS_STATINODE,
  966. .procname = "inode-state",
  967. .data = &inodes_stat,
  968. .maxlen = 7*sizeof(int),
  969. .mode = 0444,
  970. .proc_handler = &proc_dointvec,
  971. },
  972. {
  973. .ctl_name = FS_NRFILE,
  974. .procname = "file-nr",
  975. .data = &files_stat,
  976. .maxlen = 3*sizeof(int),
  977. .mode = 0444,
  978. .proc_handler = &proc_nr_files,
  979. },
  980. {
  981. .ctl_name = FS_MAXFILE,
  982. .procname = "file-max",
  983. .data = &files_stat.max_files,
  984. .maxlen = sizeof(int),
  985. .mode = 0644,
  986. .proc_handler = &proc_dointvec,
  987. },
  988. {
  989. .ctl_name = FS_DENTRY,
  990. .procname = "dentry-state",
  991. .data = &dentry_stat,
  992. .maxlen = 6*sizeof(int),
  993. .mode = 0444,
  994. .proc_handler = &proc_dointvec,
  995. },
  996. {
  997. .ctl_name = FS_OVERFLOWUID,
  998. .procname = "overflowuid",
  999. .data = &fs_overflowuid,
  1000. .maxlen = sizeof(int),
  1001. .mode = 0644,
  1002. .proc_handler = &proc_dointvec_minmax,
  1003. .strategy = &sysctl_intvec,
  1004. .extra1 = &minolduid,
  1005. .extra2 = &maxolduid,
  1006. },
  1007. {
  1008. .ctl_name = FS_OVERFLOWGID,
  1009. .procname = "overflowgid",
  1010. .data = &fs_overflowgid,
  1011. .maxlen = sizeof(int),
  1012. .mode = 0644,
  1013. .proc_handler = &proc_dointvec_minmax,
  1014. .strategy = &sysctl_intvec,
  1015. .extra1 = &minolduid,
  1016. .extra2 = &maxolduid,
  1017. },
  1018. {
  1019. .ctl_name = FS_LEASES,
  1020. .procname = "leases-enable",
  1021. .data = &leases_enable,
  1022. .maxlen = sizeof(int),
  1023. .mode = 0644,
  1024. .proc_handler = &proc_dointvec,
  1025. },
  1026. #ifdef CONFIG_DNOTIFY
  1027. {
  1028. .ctl_name = FS_DIR_NOTIFY,
  1029. .procname = "dir-notify-enable",
  1030. .data = &dir_notify_enable,
  1031. .maxlen = sizeof(int),
  1032. .mode = 0644,
  1033. .proc_handler = &proc_dointvec,
  1034. },
  1035. #endif
  1036. #ifdef CONFIG_MMU
  1037. {
  1038. .ctl_name = FS_LEASE_TIME,
  1039. .procname = "lease-break-time",
  1040. .data = &lease_break_time,
  1041. .maxlen = sizeof(int),
  1042. .mode = 0644,
  1043. .proc_handler = &proc_dointvec,
  1044. },
  1045. {
  1046. .ctl_name = FS_AIO_NR,
  1047. .procname = "aio-nr",
  1048. .data = &aio_nr,
  1049. .maxlen = sizeof(aio_nr),
  1050. .mode = 0444,
  1051. .proc_handler = &proc_doulongvec_minmax,
  1052. },
  1053. {
  1054. .ctl_name = FS_AIO_MAX_NR,
  1055. .procname = "aio-max-nr",
  1056. .data = &aio_max_nr,
  1057. .maxlen = sizeof(aio_max_nr),
  1058. .mode = 0644,
  1059. .proc_handler = &proc_doulongvec_minmax,
  1060. },
  1061. #ifdef CONFIG_INOTIFY_USER
  1062. {
  1063. .ctl_name = FS_INOTIFY,
  1064. .procname = "inotify",
  1065. .mode = 0555,
  1066. .child = inotify_table,
  1067. },
  1068. #endif
  1069. #endif
  1070. {
  1071. .ctl_name = KERN_SETUID_DUMPABLE,
  1072. .procname = "suid_dumpable",
  1073. .data = &suid_dumpable,
  1074. .maxlen = sizeof(int),
  1075. .mode = 0644,
  1076. .proc_handler = &proc_dointvec,
  1077. },
  1078. { .ctl_name = 0 }
  1079. };
  1080. static ctl_table debug_table[] = {
  1081. { .ctl_name = 0 }
  1082. };
  1083. static ctl_table dev_table[] = {
  1084. { .ctl_name = 0 }
  1085. };
  1086. extern void init_irq_proc (void);
  1087. static DEFINE_SPINLOCK(sysctl_lock);
  1088. /* called under sysctl_lock */
  1089. static int use_table(struct ctl_table_header *p)
  1090. {
  1091. if (unlikely(p->unregistering))
  1092. return 0;
  1093. p->used++;
  1094. return 1;
  1095. }
  1096. /* called under sysctl_lock */
  1097. static void unuse_table(struct ctl_table_header *p)
  1098. {
  1099. if (!--p->used)
  1100. if (unlikely(p->unregistering))
  1101. complete(p->unregistering);
  1102. }
  1103. /* called under sysctl_lock, will reacquire if has to wait */
  1104. static void start_unregistering(struct ctl_table_header *p)
  1105. {
  1106. /*
  1107. * if p->used is 0, nobody will ever touch that entry again;
  1108. * we'll eliminate all paths to it before dropping sysctl_lock
  1109. */
  1110. if (unlikely(p->used)) {
  1111. struct completion wait;
  1112. init_completion(&wait);
  1113. p->unregistering = &wait;
  1114. spin_unlock(&sysctl_lock);
  1115. wait_for_completion(&wait);
  1116. spin_lock(&sysctl_lock);
  1117. }
  1118. /*
  1119. * do not remove from the list until nobody holds it; walking the
  1120. * list in do_sysctl() relies on that.
  1121. */
  1122. list_del_init(&p->ctl_entry);
  1123. }
  1124. void __init sysctl_init(void)
  1125. {
  1126. #ifdef CONFIG_PROC_FS
  1127. register_proc_table(root_table, proc_sys_root, &root_table_header);
  1128. init_irq_proc();
  1129. #endif
  1130. }
  1131. int do_sysctl(int __user *name, int nlen, void __user *oldval, size_t __user *oldlenp,
  1132. void __user *newval, size_t newlen)
  1133. {
  1134. struct list_head *tmp;
  1135. int error = -ENOTDIR;
  1136. if (nlen <= 0 || nlen >= CTL_MAXNAME)
  1137. return -ENOTDIR;
  1138. if (oldval) {
  1139. int old_len;
  1140. if (!oldlenp || get_user(old_len, oldlenp))
  1141. return -EFAULT;
  1142. }
  1143. spin_lock(&sysctl_lock);
  1144. tmp = &root_table_header.ctl_entry;
  1145. do {
  1146. struct ctl_table_header *head =
  1147. list_entry(tmp, struct ctl_table_header, ctl_entry);
  1148. void *context = NULL;
  1149. if (!use_table(head))
  1150. continue;
  1151. spin_unlock(&sysctl_lock);
  1152. error = parse_table(name, nlen, oldval, oldlenp,
  1153. newval, newlen, head->ctl_table,
  1154. &context);
  1155. kfree(context);
  1156. spin_lock(&sysctl_lock);
  1157. unuse_table(head);
  1158. if (error != -ENOTDIR)
  1159. break;
  1160. } while ((tmp = tmp->next) != &root_table_header.ctl_entry);
  1161. spin_unlock(&sysctl_lock);
  1162. return error;
  1163. }
  1164. asmlinkage long sys_sysctl(struct __sysctl_args __user *args)
  1165. {
  1166. struct __sysctl_args tmp;
  1167. int error;
  1168. if (copy_from_user(&tmp, args, sizeof(tmp)))
  1169. return -EFAULT;
  1170. lock_kernel();
  1171. error = do_sysctl(tmp.name, tmp.nlen, tmp.oldval, tmp.oldlenp,
  1172. tmp.newval, tmp.newlen);
  1173. unlock_kernel();
  1174. return error;
  1175. }
  1176. /*
  1177. * ctl_perm does NOT grant the superuser all rights automatically, because
  1178. * some sysctl variables are readonly even to root.
  1179. */
  1180. static int test_perm(int mode, int op)
  1181. {
  1182. if (!current->euid)
  1183. mode >>= 6;
  1184. else if (in_egroup_p(0))
  1185. mode >>= 3;
  1186. if ((mode & op & 0007) == op)
  1187. return 0;
  1188. return -EACCES;
  1189. }
  1190. static inline int ctl_perm(ctl_table *table, int op)
  1191. {
  1192. int error;
  1193. error = security_sysctl(table, op);
  1194. if (error)
  1195. return error;
  1196. return test_perm(table->mode, op);
  1197. }
  1198. static int parse_table(int __user *name, int nlen,
  1199. void __user *oldval, size_t __user *oldlenp,
  1200. void __user *newval, size_t newlen,
  1201. ctl_table *table, void **context)
  1202. {
  1203. int n;
  1204. repeat:
  1205. if (!nlen)
  1206. return -ENOTDIR;
  1207. if (get_user(n, name))
  1208. return -EFAULT;
  1209. for ( ; table->ctl_name; table++) {
  1210. if (n == table->ctl_name || table->ctl_name == CTL_ANY) {
  1211. int error;
  1212. if (table->child) {
  1213. if (ctl_perm(table, 001))
  1214. return -EPERM;
  1215. if (table->strategy) {
  1216. error = table->strategy(
  1217. table, name, nlen,
  1218. oldval, oldlenp,
  1219. newval, newlen, context);
  1220. if (error)
  1221. return error;
  1222. }
  1223. name++;
  1224. nlen--;
  1225. table = table->child;
  1226. goto repeat;
  1227. }
  1228. error = do_sysctl_strategy(table, name, nlen,
  1229. oldval, oldlenp,
  1230. newval, newlen, context);
  1231. return error;
  1232. }
  1233. }
  1234. return -ENOTDIR;
  1235. }
  1236. /* Perform the actual read/write of a sysctl table entry. */
  1237. int do_sysctl_strategy (ctl_table *table,
  1238. int __user *name, int nlen,
  1239. void __user *oldval, size_t __user *oldlenp,
  1240. void __user *newval, size_t newlen, void **context)
  1241. {
  1242. int op = 0, rc;
  1243. size_t len;
  1244. if (oldval)
  1245. op |= 004;
  1246. if (newval)
  1247. op |= 002;
  1248. if (ctl_perm(table, op))
  1249. return -EPERM;
  1250. if (table->strategy) {
  1251. rc = table->strategy(table, name, nlen, oldval, oldlenp,
  1252. newval, newlen, context);
  1253. if (rc < 0)
  1254. return rc;
  1255. if (rc > 0)
  1256. return 0;
  1257. }
  1258. /* If there is no strategy routine, or if the strategy returns
  1259. * zero, proceed with automatic r/w */
  1260. if (table->data && table->maxlen) {
  1261. if (oldval && oldlenp) {
  1262. if (get_user(len, oldlenp))
  1263. return -EFAULT;
  1264. if (len) {
  1265. if (len > table->maxlen)
  1266. len = table->maxlen;
  1267. if(copy_to_user(oldval, table->data, len))
  1268. return -EFAULT;
  1269. if(put_user(len, oldlenp))
  1270. return -EFAULT;
  1271. }
  1272. }
  1273. if (newval && newlen) {
  1274. len = newlen;
  1275. if (len > table->maxlen)
  1276. len = table->maxlen;
  1277. if(copy_from_user(table->data, newval, len))
  1278. return -EFAULT;
  1279. }
  1280. }
  1281. return 0;
  1282. }
  1283. /**
  1284. * register_sysctl_table - register a sysctl hierarchy
  1285. * @table: the top-level table structure
  1286. * @insert_at_head: whether the entry should be inserted in front or at the end
  1287. *
  1288. * Register a sysctl table hierarchy. @table should be a filled in ctl_table
  1289. * array. An entry with a ctl_name of 0 terminates the table.
  1290. *
  1291. * The members of the &ctl_table structure are used as follows:
  1292. *
  1293. * ctl_name - This is the numeric sysctl value used by sysctl(2). The number
  1294. * must be unique within that level of sysctl
  1295. *
  1296. * procname - the name of the sysctl file under /proc/sys. Set to %NULL to not
  1297. * enter a sysctl file
  1298. *
  1299. * data - a pointer to data for use by proc_handler
  1300. *
  1301. * maxlen - the maximum size in bytes of the data
  1302. *
  1303. * mode - the file permissions for the /proc/sys file, and for sysctl(2)
  1304. *
  1305. * child - a pointer to the child sysctl table if this entry is a directory, or
  1306. * %NULL.
  1307. *
  1308. * proc_handler - the text handler routine (described below)
  1309. *
  1310. * strategy - the strategy routine (described below)
  1311. *
  1312. * de - for internal use by the sysctl routines
  1313. *
  1314. * extra1, extra2 - extra pointers usable by the proc handler routines
  1315. *
  1316. * Leaf nodes in the sysctl tree will be represented by a single file
  1317. * under /proc; non-leaf nodes will be represented by directories.
  1318. *
  1319. * sysctl(2) can automatically manage read and write requests through
  1320. * the sysctl table. The data and maxlen fields of the ctl_table
  1321. * struct enable minimal validation of the values being written to be
  1322. * performed, and the mode field allows minimal authentication.
  1323. *
  1324. * More sophisticated management can be enabled by the provision of a
  1325. * strategy routine with the table entry. This will be called before
  1326. * any automatic read or write of the data is performed.
  1327. *
  1328. * The strategy routine may return
  1329. *
  1330. * < 0 - Error occurred (error is passed to user process)
  1331. *
  1332. * 0 - OK - proceed with automatic read or write.
  1333. *
  1334. * > 0 - OK - read or write has been done by the strategy routine, so
  1335. * return immediately.
  1336. *
  1337. * There must be a proc_handler routine for any terminal nodes
  1338. * mirrored under /proc/sys (non-terminals are handled by a built-in
  1339. * directory handler). Several default handlers are available to
  1340. * cover common cases -
  1341. *
  1342. * proc_dostring(), proc_dointvec(), proc_dointvec_jiffies(),
  1343. * proc_dointvec_userhz_jiffies(), proc_dointvec_minmax(),
  1344. * proc_doulongvec_ms_jiffies_minmax(), proc_doulongvec_minmax()
  1345. *
  1346. * It is the handler's job to read the input buffer from user memory
  1347. * and process it. The handler should return 0 on success.
  1348. *
  1349. * This routine returns %NULL on a failure to register, and a pointer
  1350. * to the table header on success.
  1351. */
  1352. struct ctl_table_header *register_sysctl_table(ctl_table * table,
  1353. int insert_at_head)
  1354. {
  1355. struct ctl_table_header *tmp;
  1356. tmp = kmalloc(sizeof(struct ctl_table_header), GFP_KERNEL);
  1357. if (!tmp)
  1358. return NULL;
  1359. tmp->ctl_table = table;
  1360. INIT_LIST_HEAD(&tmp->ctl_entry);
  1361. tmp->used = 0;
  1362. tmp->unregistering = NULL;
  1363. spin_lock(&sysctl_lock);
  1364. if (insert_at_head)
  1365. list_add(&tmp->ctl_entry, &root_table_header.ctl_entry);
  1366. else
  1367. list_add_tail(&tmp->ctl_entry, &root_table_header.ctl_entry);
  1368. spin_unlock(&sysctl_lock);
  1369. #ifdef CONFIG_PROC_FS
  1370. register_proc_table(table, proc_sys_root, tmp);
  1371. #endif
  1372. return tmp;
  1373. }
  1374. /**
  1375. * unregister_sysctl_table - unregister a sysctl table hierarchy
  1376. * @header: the header returned from register_sysctl_table
  1377. *
  1378. * Unregisters the sysctl table and all children. proc entries may not
  1379. * actually be removed until they are no longer used by anyone.
  1380. */
  1381. void unregister_sysctl_table(struct ctl_table_header * header)
  1382. {
  1383. might_sleep();
  1384. spin_lock(&sysctl_lock);
  1385. start_unregistering(header);
  1386. #ifdef CONFIG_PROC_FS
  1387. unregister_proc_table(header->ctl_table, proc_sys_root);
  1388. #endif
  1389. spin_unlock(&sysctl_lock);
  1390. kfree(header);
  1391. }
  1392. /*
  1393. * /proc/sys support
  1394. */
  1395. #ifdef CONFIG_PROC_FS
  1396. /* Scan the sysctl entries in table and add them all into /proc */
  1397. static void register_proc_table(ctl_table * table, struct proc_dir_entry *root, void *set)
  1398. {
  1399. struct proc_dir_entry *de;
  1400. int len;
  1401. mode_t mode;
  1402. for (; table->ctl_name; table++) {
  1403. /* Can't do anything without a proc name. */
  1404. if (!table->procname)
  1405. continue;
  1406. /* Maybe we can't do anything with it... */
  1407. if (!table->proc_handler && !table->child) {
  1408. printk(KERN_WARNING "SYSCTL: Can't register %s\n",
  1409. table->procname);
  1410. continue;
  1411. }
  1412. len = strlen(table->procname);
  1413. mode = table->mode;
  1414. de = NULL;
  1415. if (table->proc_handler)
  1416. mode |= S_IFREG;
  1417. else {
  1418. mode |= S_IFDIR;
  1419. for (de = root->subdir; de; de = de->next) {
  1420. if (proc_match(len, table->procname, de))
  1421. break;
  1422. }
  1423. /* If the subdir exists already, de is non-NULL */
  1424. }
  1425. if (!de) {
  1426. de = create_proc_entry(table->procname, mode, root);
  1427. if (!de)
  1428. continue;
  1429. de->set = set;
  1430. de->data = (void *) table;
  1431. if (table->proc_handler)
  1432. de->proc_fops = &proc_sys_file_operations;
  1433. }
  1434. table->de = de;
  1435. if (de->mode & S_IFDIR)
  1436. register_proc_table(table->child, de, set);
  1437. }
  1438. }
  1439. /*
  1440. * Unregister a /proc sysctl table and any subdirectories.
  1441. */
  1442. static void unregister_proc_table(ctl_table * table, struct proc_dir_entry *root)
  1443. {
  1444. struct proc_dir_entry *de;
  1445. for (; table->ctl_name; table++) {
  1446. if (!(de = table->de))
  1447. continue;
  1448. if (de->mode & S_IFDIR) {
  1449. if (!table->child) {
  1450. printk (KERN_ALERT "Help - malformed sysctl tree on free\n");
  1451. continue;
  1452. }
  1453. unregister_proc_table(table->child, de);
  1454. /* Don't unregister directories which still have entries.. */
  1455. if (de->subdir)
  1456. continue;
  1457. }
  1458. /*
  1459. * In any case, mark the entry as goner; we'll keep it
  1460. * around if it's busy, but we'll know to do nothing with
  1461. * its fields. We are under sysctl_lock here.
  1462. */
  1463. de->data = NULL;
  1464. /* Don't unregister proc entries that are still being used.. */
  1465. if (atomic_read(&de->count))
  1466. continue;
  1467. table->de = NULL;
  1468. remove_proc_entry(table->procname, root);
  1469. }
  1470. }
  1471. static ssize_t do_rw_proc(int write, struct file * file, char __user * buf,
  1472. size_t count, loff_t *ppos)
  1473. {
  1474. int op;
  1475. struct proc_dir_entry *de = PDE(file->f_dentry->d_inode);
  1476. struct ctl_table *table;
  1477. size_t res;
  1478. ssize_t error = -ENOTDIR;
  1479. spin_lock(&sysctl_lock);
  1480. if (de && de->data && use_table(de->set)) {
  1481. /*
  1482. * at that point we know that sysctl was not unregistered
  1483. * and won't be until we finish
  1484. */
  1485. spin_unlock(&sysctl_lock);
  1486. table = (struct ctl_table *) de->data;
  1487. if (!table || !table->proc_handler)
  1488. goto out;
  1489. error = -EPERM;
  1490. op = (write ? 002 : 004);
  1491. if (ctl_perm(table, op))
  1492. goto out;
  1493. /* careful: calling conventions are nasty here */
  1494. res = count;
  1495. error = (*table->proc_handler)(table, write, file,
  1496. buf, &res, ppos);
  1497. if (!error)
  1498. error = res;
  1499. out:
  1500. spin_lock(&sysctl_lock);
  1501. unuse_table(de->set);
  1502. }
  1503. spin_unlock(&sysctl_lock);
  1504. return error;
  1505. }
  1506. static int proc_opensys(struct inode *inode, struct file *file)
  1507. {
  1508. if (file->f_mode & FMODE_WRITE) {
  1509. /*
  1510. * sysctl entries that are not writable,
  1511. * are _NOT_ writable, capabilities or not.
  1512. */
  1513. if (!(inode->i_mode & S_IWUSR))
  1514. return -EPERM;
  1515. }
  1516. return 0;
  1517. }
  1518. static ssize_t proc_readsys(struct file * file, char __user * buf,
  1519. size_t count, loff_t *ppos)
  1520. {
  1521. return do_rw_proc(0, file, buf, count, ppos);
  1522. }
  1523. static ssize_t proc_writesys(struct file * file, const char __user * buf,
  1524. size_t count, loff_t *ppos)
  1525. {
  1526. return do_rw_proc(1, file, (char __user *) buf, count, ppos);
  1527. }
  1528. /**
  1529. * proc_dostring - read a string sysctl
  1530. * @table: the sysctl table
  1531. * @write: %TRUE if this is a write to the sysctl file
  1532. * @filp: the file structure
  1533. * @buffer: the user buffer
  1534. * @lenp: the size of the user buffer
  1535. * @ppos: file position
  1536. *
  1537. * Reads/writes a string from/to the user buffer. If the kernel
  1538. * buffer provided is not large enough to hold the string, the
  1539. * string is truncated. The copied string is %NULL-terminated.
  1540. * If the string is being read by the user process, it is copied
  1541. * and a newline '\n' is added. It is truncated if the buffer is
  1542. * not large enough.
  1543. *
  1544. * Returns 0 on success.
  1545. */
  1546. int proc_dostring(ctl_table *table, int write, struct file *filp,
  1547. void __user *buffer, size_t *lenp, loff_t *ppos)
  1548. {
  1549. size_t len;
  1550. char __user *p;
  1551. char c;
  1552. if (!table->data || !table->maxlen || !*lenp ||
  1553. (*ppos && !write)) {
  1554. *lenp = 0;
  1555. return 0;
  1556. }
  1557. if (write) {
  1558. len = 0;
  1559. p = buffer;
  1560. while (len < *lenp) {
  1561. if (get_user(c, p++))
  1562. return -EFAULT;
  1563. if (c == 0 || c == '\n')
  1564. break;
  1565. len++;
  1566. }
  1567. if (len >= table->maxlen)
  1568. len = table->maxlen-1;
  1569. if(copy_from_user(table->data, buffer, len))
  1570. return -EFAULT;
  1571. ((char *) table->data)[len] = 0;
  1572. *ppos += *lenp;
  1573. } else {
  1574. len = strlen(table->data);
  1575. if (len > table->maxlen)
  1576. len = table->maxlen;
  1577. if (len > *lenp)
  1578. len = *lenp;
  1579. if (len)
  1580. if(copy_to_user(buffer, table->data, len))
  1581. return -EFAULT;
  1582. if (len < *lenp) {
  1583. if(put_user('\n', ((char __user *) buffer) + len))
  1584. return -EFAULT;
  1585. len++;
  1586. }
  1587. *lenp = len;
  1588. *ppos += len;
  1589. }
  1590. return 0;
  1591. }
  1592. /*
  1593. * Special case of dostring for the UTS structure. This has locks
  1594. * to observe. Should this be in kernel/sys.c ????
  1595. */
  1596. static int proc_doutsstring(ctl_table *table, int write, struct file *filp,
  1597. void __user *buffer, size_t *lenp, loff_t *ppos)
  1598. {
  1599. int r;
  1600. if (!write) {
  1601. down_read(&uts_sem);
  1602. r=proc_dostring(table,0,filp,buffer,lenp, ppos);
  1603. up_read(&uts_sem);
  1604. } else {
  1605. down_write(&uts_sem);
  1606. r=proc_dostring(table,1,filp,buffer,lenp, ppos);
  1607. up_write(&uts_sem);
  1608. }
  1609. return r;
  1610. }
  1611. static int do_proc_dointvec_conv(int *negp, unsigned long *lvalp,
  1612. int *valp,
  1613. int write, void *data)
  1614. {
  1615. if (write) {
  1616. *valp = *negp ? -*lvalp : *lvalp;
  1617. } else {
  1618. int val = *valp;
  1619. if (val < 0) {
  1620. *negp = -1;
  1621. *lvalp = (unsigned long)-val;
  1622. } else {
  1623. *negp = 0;
  1624. *lvalp = (unsigned long)val;
  1625. }
  1626. }
  1627. return 0;
  1628. }
  1629. static int do_proc_dointvec(ctl_table *table, int write, struct file *filp,
  1630. void __user *buffer, size_t *lenp, loff_t *ppos,
  1631. int (*conv)(int *negp, unsigned long *lvalp, int *valp,
  1632. int write, void *data),
  1633. void *data)
  1634. {
  1635. #define TMPBUFLEN 21
  1636. int *i, vleft, first=1, neg, val;
  1637. unsigned long lval;
  1638. size_t left, len;
  1639. char buf[TMPBUFLEN], *p;
  1640. char __user *s = buffer;
  1641. if (!table->data || !table->maxlen || !*lenp ||
  1642. (*ppos && !write)) {
  1643. *lenp = 0;
  1644. return 0;
  1645. }
  1646. i = (int *) table->data;
  1647. vleft = table->maxlen / sizeof(*i);
  1648. left = *lenp;
  1649. if (!conv)
  1650. conv = do_proc_dointvec_conv;
  1651. for (; left && vleft--; i++, first=0) {
  1652. if (write) {
  1653. while (left) {
  1654. char c;
  1655. if (get_user(c, s))
  1656. return -EFAULT;
  1657. if (!isspace(c))
  1658. break;
  1659. left--;
  1660. s++;
  1661. }
  1662. if (!left)
  1663. break;
  1664. neg = 0;
  1665. len = left;
  1666. if (len > sizeof(buf) - 1)
  1667. len = sizeof(buf) - 1;
  1668. if (copy_from_user(buf, s, len))
  1669. return -EFAULT;
  1670. buf[len] = 0;
  1671. p = buf;
  1672. if (*p == '-' && left > 1) {
  1673. neg = 1;
  1674. left--, p++;
  1675. }
  1676. if (*p < '0' || *p > '9')
  1677. break;
  1678. lval = simple_strtoul(p, &p, 0);
  1679. len = p-buf;
  1680. if ((len < left) && *p && !isspace(*p))
  1681. break;
  1682. if (neg)
  1683. val = -val;
  1684. s += len;
  1685. left -= len;
  1686. if (conv(&neg, &lval, i, 1, data))
  1687. break;
  1688. } else {
  1689. p = buf;
  1690. if (!first)
  1691. *p++ = '\t';
  1692. if (conv(&neg, &lval, i, 0, data))
  1693. break;
  1694. sprintf(p, "%s%lu", neg ? "-" : "", lval);
  1695. len = strlen(buf);
  1696. if (len > left)
  1697. len = left;
  1698. if(copy_to_user(s, buf, len))
  1699. return -EFAULT;
  1700. left -= len;
  1701. s += len;
  1702. }
  1703. }
  1704. if (!write && !first && left) {
  1705. if(put_user('\n', s))
  1706. return -EFAULT;
  1707. left--, s++;
  1708. }
  1709. if (write) {
  1710. while (left) {
  1711. char c;
  1712. if (get_user(c, s++))
  1713. return -EFAULT;
  1714. if (!isspace(c))
  1715. break;
  1716. left--;
  1717. }
  1718. }
  1719. if (write && first)
  1720. return -EINVAL;
  1721. *lenp -= left;
  1722. *ppos += *lenp;
  1723. return 0;
  1724. #undef TMPBUFLEN
  1725. }
  1726. /**
  1727. * proc_dointvec - read a vector of integers
  1728. * @table: the sysctl table
  1729. * @write: %TRUE if this is a write to the sysctl file
  1730. * @filp: the file structure
  1731. * @buffer: the user buffer
  1732. * @lenp: the size of the user buffer
  1733. * @ppos: file position
  1734. *
  1735. * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
  1736. * values from/to the user buffer, treated as an ASCII string.
  1737. *
  1738. * Returns 0 on success.
  1739. */
  1740. int proc_dointvec(ctl_table *table, int write, struct file *filp,
  1741. void __user *buffer, size_t *lenp, loff_t *ppos)
  1742. {
  1743. return do_proc_dointvec(table,write,filp,buffer,lenp,ppos,
  1744. NULL,NULL);
  1745. }
  1746. #define OP_SET 0
  1747. #define OP_AND 1
  1748. #define OP_OR 2
  1749. #define OP_MAX 3
  1750. #define OP_MIN 4
  1751. static int do_proc_dointvec_bset_conv(int *negp, unsigned long *lvalp,
  1752. int *valp,
  1753. int write, void *data)
  1754. {
  1755. int op = *(int *)data;
  1756. if (write) {
  1757. int val = *negp ? -*lvalp : *lvalp;
  1758. switch(op) {
  1759. case OP_SET: *valp = val; break;
  1760. case OP_AND: *valp &= val; break;
  1761. case OP_OR: *valp |= val; break;
  1762. case OP_MAX: if(*valp < val)
  1763. *valp = val;
  1764. break;
  1765. case OP_MIN: if(*valp > val)
  1766. *valp = val;
  1767. break;
  1768. }
  1769. } else {
  1770. int val = *valp;
  1771. if (val < 0) {
  1772. *negp = -1;
  1773. *lvalp = (unsigned long)-val;
  1774. } else {
  1775. *negp = 0;
  1776. *lvalp = (unsigned long)val;
  1777. }
  1778. }
  1779. return 0;
  1780. }
  1781. /*
  1782. * init may raise the set.
  1783. */
  1784. int proc_dointvec_bset(ctl_table *table, int write, struct file *filp,
  1785. void __user *buffer, size_t *lenp, loff_t *ppos)
  1786. {
  1787. int op;
  1788. if (!capable(CAP_SYS_MODULE)) {
  1789. return -EPERM;
  1790. }
  1791. op = (current->pid == 1) ? OP_SET : OP_AND;
  1792. return do_proc_dointvec(table,write,filp,buffer,lenp,ppos,
  1793. do_proc_dointvec_bset_conv,&op);
  1794. }
  1795. struct do_proc_dointvec_minmax_conv_param {
  1796. int *min;
  1797. int *max;
  1798. };
  1799. static int do_proc_dointvec_minmax_conv(int *negp, unsigned long *lvalp,
  1800. int *valp,
  1801. int write, void *data)
  1802. {
  1803. struct do_proc_dointvec_minmax_conv_param *param = data;
  1804. if (write) {
  1805. int val = *negp ? -*lvalp : *lvalp;
  1806. if ((param->min && *param->min > val) ||
  1807. (param->max && *param->max < val))
  1808. return -EINVAL;
  1809. *valp = val;
  1810. } else {
  1811. int val = *valp;
  1812. if (val < 0) {
  1813. *negp = -1;
  1814. *lvalp = (unsigned long)-val;
  1815. } else {
  1816. *negp = 0;
  1817. *lvalp = (unsigned long)val;
  1818. }
  1819. }
  1820. return 0;
  1821. }
  1822. /**
  1823. * proc_dointvec_minmax - read a vector of integers with min/max values
  1824. * @table: the sysctl table
  1825. * @write: %TRUE if this is a write to the sysctl file
  1826. * @filp: the file structure
  1827. * @buffer: the user buffer
  1828. * @lenp: the size of the user buffer
  1829. * @ppos: file position
  1830. *
  1831. * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
  1832. * values from/to the user buffer, treated as an ASCII string.
  1833. *
  1834. * This routine will ensure the values are within the range specified by
  1835. * table->extra1 (min) and table->extra2 (max).
  1836. *
  1837. * Returns 0 on success.
  1838. */
  1839. int proc_dointvec_minmax(ctl_table *table, int write, struct file *filp,
  1840. void __user *buffer, size_t *lenp, loff_t *ppos)
  1841. {
  1842. struct do_proc_dointvec_minmax_conv_param param = {
  1843. .min = (int *) table->extra1,
  1844. .max = (int *) table->extra2,
  1845. };
  1846. return do_proc_dointvec(table, write, filp, buffer, lenp, ppos,
  1847. do_proc_dointvec_minmax_conv, &param);
  1848. }
  1849. static int do_proc_doulongvec_minmax(ctl_table *table, int write,
  1850. struct file *filp,
  1851. void __user *buffer,
  1852. size_t *lenp, loff_t *ppos,
  1853. unsigned long convmul,
  1854. unsigned long convdiv)
  1855. {
  1856. #define TMPBUFLEN 21
  1857. unsigned long *i, *min, *max, val;
  1858. int vleft, first=1, neg;
  1859. size_t len, left;
  1860. char buf[TMPBUFLEN], *p;
  1861. char __user *s = buffer;
  1862. if (!table->data || !table->maxlen || !*lenp ||
  1863. (*ppos && !write)) {
  1864. *lenp = 0;
  1865. return 0;
  1866. }
  1867. i = (unsigned long *) table->data;
  1868. min = (unsigned long *) table->extra1;
  1869. max = (unsigned long *) table->extra2;
  1870. vleft = table->maxlen / sizeof(unsigned long);
  1871. left = *lenp;
  1872. for (; left && vleft--; i++, min++, max++, first=0) {
  1873. if (write) {
  1874. while (left) {
  1875. char c;
  1876. if (get_user(c, s))
  1877. return -EFAULT;
  1878. if (!isspace(c))
  1879. break;
  1880. left--;
  1881. s++;
  1882. }
  1883. if (!left)
  1884. break;
  1885. neg = 0;
  1886. len = left;
  1887. if (len > TMPBUFLEN-1)
  1888. len = TMPBUFLEN-1;
  1889. if (copy_from_user(buf, s, len))
  1890. return -EFAULT;
  1891. buf[len] = 0;
  1892. p = buf;
  1893. if (*p == '-' && left > 1) {
  1894. neg = 1;
  1895. left--, p++;
  1896. }
  1897. if (*p < '0' || *p > '9')
  1898. break;
  1899. val = simple_strtoul(p, &p, 0) * convmul / convdiv ;
  1900. len = p-buf;
  1901. if ((len < left) && *p && !isspace(*p))
  1902. break;
  1903. if (neg)
  1904. val = -val;
  1905. s += len;
  1906. left -= len;
  1907. if(neg)
  1908. continue;
  1909. if ((min && val < *min) || (max && val > *max))
  1910. continue;
  1911. *i = val;
  1912. } else {
  1913. p = buf;
  1914. if (!first)
  1915. *p++ = '\t';
  1916. sprintf(p, "%lu", convdiv * (*i) / convmul);
  1917. len = strlen(buf);
  1918. if (len > left)
  1919. len = left;
  1920. if(copy_to_user(s, buf, len))
  1921. return -EFAULT;
  1922. left -= len;
  1923. s += len;
  1924. }
  1925. }
  1926. if (!write && !first && left) {
  1927. if(put_user('\n', s))
  1928. return -EFAULT;
  1929. left--, s++;
  1930. }
  1931. if (write) {
  1932. while (left) {
  1933. char c;
  1934. if (get_user(c, s++))
  1935. return -EFAULT;
  1936. if (!isspace(c))
  1937. break;
  1938. left--;
  1939. }
  1940. }
  1941. if (write && first)
  1942. return -EINVAL;
  1943. *lenp -= left;
  1944. *ppos += *lenp;
  1945. return 0;
  1946. #undef TMPBUFLEN
  1947. }
  1948. /**
  1949. * proc_doulongvec_minmax - read a vector of long integers with min/max values
  1950. * @table: the sysctl table
  1951. * @write: %TRUE if this is a write to the sysctl file
  1952. * @filp: the file structure
  1953. * @buffer: the user buffer
  1954. * @lenp: the size of the user buffer
  1955. * @ppos: file position
  1956. *
  1957. * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
  1958. * values from/to the user buffer, treated as an ASCII string.
  1959. *
  1960. * This routine will ensure the values are within the range specified by
  1961. * table->extra1 (min) and table->extra2 (max).
  1962. *
  1963. * Returns 0 on success.
  1964. */
  1965. int proc_doulongvec_minmax(ctl_table *table, int write, struct file *filp,
  1966. void __user *buffer, size_t *lenp, loff_t *ppos)
  1967. {
  1968. return do_proc_doulongvec_minmax(table, write, filp, buffer, lenp, ppos, 1l, 1l);
  1969. }
  1970. /**
  1971. * proc_doulongvec_ms_jiffies_minmax - read a vector of millisecond values with min/max values
  1972. * @table: the sysctl table
  1973. * @write: %TRUE if this is a write to the sysctl file
  1974. * @filp: the file structure
  1975. * @buffer: the user buffer
  1976. * @lenp: the size of the user buffer
  1977. * @ppos: file position
  1978. *
  1979. * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
  1980. * values from/to the user buffer, treated as an ASCII string. The values
  1981. * are treated as milliseconds, and converted to jiffies when they are stored.
  1982. *
  1983. * This routine will ensure the values are within the range specified by
  1984. * table->extra1 (min) and table->extra2 (max).
  1985. *
  1986. * Returns 0 on success.
  1987. */
  1988. int proc_doulongvec_ms_jiffies_minmax(ctl_table *table, int write,
  1989. struct file *filp,
  1990. void __user *buffer,
  1991. size_t *lenp, loff_t *ppos)
  1992. {
  1993. return do_proc_doulongvec_minmax(table, write, filp, buffer,
  1994. lenp, ppos, HZ, 1000l);
  1995. }
  1996. static int do_proc_dointvec_jiffies_conv(int *negp, unsigned long *lvalp,
  1997. int *valp,
  1998. int write, void *data)
  1999. {
  2000. if (write) {
  2001. if (*lvalp > LONG_MAX / HZ)
  2002. return 1;
  2003. *valp = *negp ? -(*lvalp*HZ) : (*lvalp*HZ);
  2004. } else {
  2005. int val = *valp;
  2006. unsigned long lval;
  2007. if (val < 0) {
  2008. *negp = -1;
  2009. lval = (unsigned long)-val;
  2010. } else {
  2011. *negp = 0;
  2012. lval = (unsigned long)val;
  2013. }
  2014. *lvalp = lval / HZ;
  2015. }
  2016. return 0;
  2017. }
  2018. static int do_proc_dointvec_userhz_jiffies_conv(int *negp, unsigned long *lvalp,
  2019. int *valp,
  2020. int write, void *data)
  2021. {
  2022. if (write) {
  2023. if (USER_HZ < HZ && *lvalp > (LONG_MAX / HZ) * USER_HZ)
  2024. return 1;
  2025. *valp = clock_t_to_jiffies(*negp ? -*lvalp : *lvalp);
  2026. } else {
  2027. int val = *valp;
  2028. unsigned long lval;
  2029. if (val < 0) {
  2030. *negp = -1;
  2031. lval = (unsigned long)-val;
  2032. } else {
  2033. *negp = 0;
  2034. lval = (unsigned long)val;
  2035. }
  2036. *lvalp = jiffies_to_clock_t(lval);
  2037. }
  2038. return 0;
  2039. }
  2040. static int do_proc_dointvec_ms_jiffies_conv(int *negp, unsigned long *lvalp,
  2041. int *valp,
  2042. int write, void *data)
  2043. {
  2044. if (write) {
  2045. *valp = msecs_to_jiffies(*negp ? -*lvalp : *lvalp);
  2046. } else {
  2047. int val = *valp;
  2048. unsigned long lval;
  2049. if (val < 0) {
  2050. *negp = -1;
  2051. lval = (unsigned long)-val;
  2052. } else {
  2053. *negp = 0;
  2054. lval = (unsigned long)val;
  2055. }
  2056. *lvalp = jiffies_to_msecs(lval);
  2057. }
  2058. return 0;
  2059. }
  2060. /**
  2061. * proc_dointvec_jiffies - read a vector of integers as seconds
  2062. * @table: the sysctl table
  2063. * @write: %TRUE if this is a write to the sysctl file
  2064. * @filp: the file structure
  2065. * @buffer: the user buffer
  2066. * @lenp: the size of the user buffer
  2067. * @ppos: file position
  2068. *
  2069. * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
  2070. * values from/to the user buffer, treated as an ASCII string.
  2071. * The values read are assumed to be in seconds, and are converted into
  2072. * jiffies.
  2073. *
  2074. * Returns 0 on success.
  2075. */
  2076. int proc_dointvec_jiffies(ctl_table *table, int write, struct file *filp,
  2077. void __user *buffer, size_t *lenp, loff_t *ppos)
  2078. {
  2079. return do_proc_dointvec(table,write,filp,buffer,lenp,ppos,
  2080. do_proc_dointvec_jiffies_conv,NULL);
  2081. }
  2082. /**
  2083. * proc_dointvec_userhz_jiffies - read a vector of integers as 1/USER_HZ seconds
  2084. * @table: the sysctl table
  2085. * @write: %TRUE if this is a write to the sysctl file
  2086. * @filp: the file structure
  2087. * @buffer: the user buffer
  2088. * @lenp: the size of the user buffer
  2089. * @ppos: pointer to the file position
  2090. *
  2091. * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
  2092. * values from/to the user buffer, treated as an ASCII string.
  2093. * The values read are assumed to be in 1/USER_HZ seconds, and
  2094. * are converted into jiffies.
  2095. *
  2096. * Returns 0 on success.
  2097. */
  2098. int proc_dointvec_userhz_jiffies(ctl_table *table, int write, struct file *filp,
  2099. void __user *buffer, size_t *lenp, loff_t *ppos)
  2100. {
  2101. return do_proc_dointvec(table,write,filp,buffer,lenp,ppos,
  2102. do_proc_dointvec_userhz_jiffies_conv,NULL);
  2103. }
  2104. /**
  2105. * proc_dointvec_ms_jiffies - read a vector of integers as 1 milliseconds
  2106. * @table: the sysctl table
  2107. * @write: %TRUE if this is a write to the sysctl file
  2108. * @filp: the file structure
  2109. * @buffer: the user buffer
  2110. * @lenp: the size of the user buffer
  2111. * @ppos: file position
  2112. * @ppos: the current position in the file
  2113. *
  2114. * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
  2115. * values from/to the user buffer, treated as an ASCII string.
  2116. * The values read are assumed to be in 1/1000 seconds, and
  2117. * are converted into jiffies.
  2118. *
  2119. * Returns 0 on success.
  2120. */
  2121. int proc_dointvec_ms_jiffies(ctl_table *table, int write, struct file *filp,
  2122. void __user *buffer, size_t *lenp, loff_t *ppos)
  2123. {
  2124. return do_proc_dointvec(table, write, filp, buffer, lenp, ppos,
  2125. do_proc_dointvec_ms_jiffies_conv, NULL);
  2126. }
  2127. #else /* CONFIG_PROC_FS */
  2128. int proc_dostring(ctl_table *table, int write, struct file *filp,
  2129. void __user *buffer, size_t *lenp, loff_t *ppos)
  2130. {
  2131. return -ENOSYS;
  2132. }
  2133. static int proc_doutsstring(ctl_table *table, int write, struct file *filp,
  2134. void __user *buffer, size_t *lenp, loff_t *ppos)
  2135. {
  2136. return -ENOSYS;
  2137. }
  2138. int proc_dointvec(ctl_table *table, int write, struct file *filp,
  2139. void __user *buffer, size_t *lenp, loff_t *ppos)
  2140. {
  2141. return -ENOSYS;
  2142. }
  2143. int proc_dointvec_bset(ctl_table *table, int write, struct file *filp,
  2144. void __user *buffer, size_t *lenp, loff_t *ppos)
  2145. {
  2146. return -ENOSYS;
  2147. }
  2148. int proc_dointvec_minmax(ctl_table *table, int write, struct file *filp,
  2149. void __user *buffer, size_t *lenp, loff_t *ppos)
  2150. {
  2151. return -ENOSYS;
  2152. }
  2153. int proc_dointvec_jiffies(ctl_table *table, int write, struct file *filp,
  2154. void __user *buffer, size_t *lenp, loff_t *ppos)
  2155. {
  2156. return -ENOSYS;
  2157. }
  2158. int proc_dointvec_userhz_jiffies(ctl_table *table, int write, struct file *filp,
  2159. void __user *buffer, size_t *lenp, loff_t *ppos)
  2160. {
  2161. return -ENOSYS;
  2162. }
  2163. int proc_dointvec_ms_jiffies(ctl_table *table, int write, struct file *filp,
  2164. void __user *buffer, size_t *lenp, loff_t *ppos)
  2165. {
  2166. return -ENOSYS;
  2167. }
  2168. int proc_doulongvec_minmax(ctl_table *table, int write, struct file *filp,
  2169. void __user *buffer, size_t *lenp, loff_t *ppos)
  2170. {
  2171. return -ENOSYS;
  2172. }
  2173. int proc_doulongvec_ms_jiffies_minmax(ctl_table *table, int write,
  2174. struct file *filp,
  2175. void __user *buffer,
  2176. size_t *lenp, loff_t *ppos)
  2177. {
  2178. return -ENOSYS;
  2179. }
  2180. #endif /* CONFIG_PROC_FS */
  2181. /*
  2182. * General sysctl support routines
  2183. */
  2184. /* The generic string strategy routine: */
  2185. int sysctl_string(ctl_table *table, int __user *name, int nlen,
  2186. void __user *oldval, size_t __user *oldlenp,
  2187. void __user *newval, size_t newlen, void **context)
  2188. {
  2189. if (!table->data || !table->maxlen)
  2190. return -ENOTDIR;
  2191. if (oldval && oldlenp) {
  2192. size_t bufsize;
  2193. if (get_user(bufsize, oldlenp))
  2194. return -EFAULT;
  2195. if (bufsize) {
  2196. size_t len = strlen(table->data), copied;
  2197. /* This shouldn't trigger for a well-formed sysctl */
  2198. if (len > table->maxlen)
  2199. len = table->maxlen;
  2200. /* Copy up to a max of bufsize-1 bytes of the string */
  2201. copied = (len >= bufsize) ? bufsize - 1 : len;
  2202. if (copy_to_user(oldval, table->data, copied) ||
  2203. put_user(0, (char __user *)(oldval + copied)))
  2204. return -EFAULT;
  2205. if (put_user(len, oldlenp))
  2206. return -EFAULT;
  2207. }
  2208. }
  2209. if (newval && newlen) {
  2210. size_t len = newlen;
  2211. if (len > table->maxlen)
  2212. len = table->maxlen;
  2213. if(copy_from_user(table->data, newval, len))
  2214. return -EFAULT;
  2215. if (len == table->maxlen)
  2216. len--;
  2217. ((char *) table->data)[len] = 0;
  2218. }
  2219. return 1;
  2220. }
  2221. /*
  2222. * This function makes sure that all of the integers in the vector
  2223. * are between the minimum and maximum values given in the arrays
  2224. * table->extra1 and table->extra2, respectively.
  2225. */
  2226. int sysctl_intvec(ctl_table *table, int __user *name, int nlen,
  2227. void __user *oldval, size_t __user *oldlenp,
  2228. void __user *newval, size_t newlen, void **context)
  2229. {
  2230. if (newval && newlen) {
  2231. int __user *vec = (int __user *) newval;
  2232. int *min = (int *) table->extra1;
  2233. int *max = (int *) table->extra2;
  2234. size_t length;
  2235. int i;
  2236. if (newlen % sizeof(int) != 0)
  2237. return -EINVAL;
  2238. if (!table->extra1 && !table->extra2)
  2239. return 0;
  2240. if (newlen > table->maxlen)
  2241. newlen = table->maxlen;
  2242. length = newlen / sizeof(int);
  2243. for (i = 0; i < length; i++) {
  2244. int value;
  2245. if (get_user(value, vec + i))
  2246. return -EFAULT;
  2247. if (min && value < min[i])
  2248. return -EINVAL;
  2249. if (max && value > max[i])
  2250. return -EINVAL;
  2251. }
  2252. }
  2253. return 0;
  2254. }
  2255. /* Strategy function to convert jiffies to seconds */
  2256. int sysctl_jiffies(ctl_table *table, int __user *name, int nlen,
  2257. void __user *oldval, size_t __user *oldlenp,
  2258. void __user *newval, size_t newlen, void **context)
  2259. {
  2260. if (oldval) {
  2261. size_t olen;
  2262. if (oldlenp) {
  2263. if (get_user(olen, oldlenp))
  2264. return -EFAULT;
  2265. if (olen!=sizeof(int))
  2266. return -EINVAL;
  2267. }
  2268. if (put_user(*(int *)(table->data)/HZ, (int __user *)oldval) ||
  2269. (oldlenp && put_user(sizeof(int),oldlenp)))
  2270. return -EFAULT;
  2271. }
  2272. if (newval && newlen) {
  2273. int new;
  2274. if (newlen != sizeof(int))
  2275. return -EINVAL;
  2276. if (get_user(new, (int __user *)newval))
  2277. return -EFAULT;
  2278. *(int *)(table->data) = new*HZ;
  2279. }
  2280. return 1;
  2281. }
  2282. /* Strategy function to convert jiffies to seconds */
  2283. int sysctl_ms_jiffies(ctl_table *table, int __user *name, int nlen,
  2284. void __user *oldval, size_t __user *oldlenp,
  2285. void __user *newval, size_t newlen, void **context)
  2286. {
  2287. if (oldval) {
  2288. size_t olen;
  2289. if (oldlenp) {
  2290. if (get_user(olen, oldlenp))
  2291. return -EFAULT;
  2292. if (olen!=sizeof(int))
  2293. return -EINVAL;
  2294. }
  2295. if (put_user(jiffies_to_msecs(*(int *)(table->data)), (int __user *)oldval) ||
  2296. (oldlenp && put_user(sizeof(int),oldlenp)))
  2297. return -EFAULT;
  2298. }
  2299. if (newval && newlen) {
  2300. int new;
  2301. if (newlen != sizeof(int))
  2302. return -EINVAL;
  2303. if (get_user(new, (int __user *)newval))
  2304. return -EFAULT;
  2305. *(int *)(table->data) = msecs_to_jiffies(new);
  2306. }
  2307. return 1;
  2308. }
  2309. #else /* CONFIG_SYSCTL */
  2310. asmlinkage long sys_sysctl(struct __sysctl_args __user *args)
  2311. {
  2312. return -ENOSYS;
  2313. }
  2314. int sysctl_string(ctl_table *table, int __user *name, int nlen,
  2315. void __user *oldval, size_t __user *oldlenp,
  2316. void __user *newval, size_t newlen, void **context)
  2317. {
  2318. return -ENOSYS;
  2319. }
  2320. int sysctl_intvec(ctl_table *table, int __user *name, int nlen,
  2321. void __user *oldval, size_t __user *oldlenp,
  2322. void __user *newval, size_t newlen, void **context)
  2323. {
  2324. return -ENOSYS;
  2325. }
  2326. int sysctl_jiffies(ctl_table *table, int __user *name, int nlen,
  2327. void __user *oldval, size_t __user *oldlenp,
  2328. void __user *newval, size_t newlen, void **context)
  2329. {
  2330. return -ENOSYS;
  2331. }
  2332. int sysctl_ms_jiffies(ctl_table *table, int __user *name, int nlen,
  2333. void __user *oldval, size_t __user *oldlenp,
  2334. void __user *newval, size_t newlen, void **context)
  2335. {
  2336. return -ENOSYS;
  2337. }
  2338. int proc_dostring(ctl_table *table, int write, struct file *filp,
  2339. void __user *buffer, size_t *lenp, loff_t *ppos)
  2340. {
  2341. return -ENOSYS;
  2342. }
  2343. int proc_dointvec(ctl_table *table, int write, struct file *filp,
  2344. void __user *buffer, size_t *lenp, loff_t *ppos)
  2345. {
  2346. return -ENOSYS;
  2347. }
  2348. int proc_dointvec_bset(ctl_table *table, int write, struct file *filp,
  2349. void __user *buffer, size_t *lenp, loff_t *ppos)
  2350. {
  2351. return -ENOSYS;
  2352. }
  2353. int proc_dointvec_minmax(ctl_table *table, int write, struct file *filp,
  2354. void __user *buffer, size_t *lenp, loff_t *ppos)
  2355. {
  2356. return -ENOSYS;
  2357. }
  2358. int proc_dointvec_jiffies(ctl_table *table, int write, struct file *filp,
  2359. void __user *buffer, size_t *lenp, loff_t *ppos)
  2360. {
  2361. return -ENOSYS;
  2362. }
  2363. int proc_dointvec_userhz_jiffies(ctl_table *table, int write, struct file *filp,
  2364. void __user *buffer, size_t *lenp, loff_t *ppos)
  2365. {
  2366. return -ENOSYS;
  2367. }
  2368. int proc_dointvec_ms_jiffies(ctl_table *table, int write, struct file *filp,
  2369. void __user *buffer, size_t *lenp, loff_t *ppos)
  2370. {
  2371. return -ENOSYS;
  2372. }
  2373. int proc_doulongvec_minmax(ctl_table *table, int write, struct file *filp,
  2374. void __user *buffer, size_t *lenp, loff_t *ppos)
  2375. {
  2376. return -ENOSYS;
  2377. }
  2378. int proc_doulongvec_ms_jiffies_minmax(ctl_table *table, int write,
  2379. struct file *filp,
  2380. void __user *buffer,
  2381. size_t *lenp, loff_t *ppos)
  2382. {
  2383. return -ENOSYS;
  2384. }
  2385. struct ctl_table_header * register_sysctl_table(ctl_table * table,
  2386. int insert_at_head)
  2387. {
  2388. return NULL;
  2389. }
  2390. void unregister_sysctl_table(struct ctl_table_header * table)
  2391. {
  2392. }
  2393. #endif /* CONFIG_SYSCTL */
  2394. /*
  2395. * No sense putting this after each symbol definition, twice,
  2396. * exception granted :-)
  2397. */
  2398. EXPORT_SYMBOL(proc_dointvec);
  2399. EXPORT_SYMBOL(proc_dointvec_jiffies);
  2400. EXPORT_SYMBOL(proc_dointvec_minmax);
  2401. EXPORT_SYMBOL(proc_dointvec_userhz_jiffies);
  2402. EXPORT_SYMBOL(proc_dointvec_ms_jiffies);
  2403. EXPORT_SYMBOL(proc_dostring);
  2404. EXPORT_SYMBOL(proc_doulongvec_minmax);
  2405. EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax);
  2406. EXPORT_SYMBOL(register_sysctl_table);
  2407. EXPORT_SYMBOL(sysctl_intvec);
  2408. EXPORT_SYMBOL(sysctl_jiffies);
  2409. EXPORT_SYMBOL(sysctl_ms_jiffies);
  2410. EXPORT_SYMBOL(sysctl_string);
  2411. EXPORT_SYMBOL(unregister_sysctl_table);