sysctl.c 60 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573
  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. #endif
  930. #ifdef CONFIG_X86_32
  931. {
  932. .ctl_name = VM_VDSO_ENABLED,
  933. .procname = "vdso_enabled",
  934. .data = &vdso_enabled,
  935. .maxlen = sizeof(vdso_enabled),
  936. .mode = 0644,
  937. .proc_handler = &proc_dointvec,
  938. .strategy = &sysctl_intvec,
  939. .extra1 = &zero,
  940. },
  941. #endif
  942. { .ctl_name = 0 }
  943. };
  944. static ctl_table fs_table[] = {
  945. {
  946. .ctl_name = FS_NRINODE,
  947. .procname = "inode-nr",
  948. .data = &inodes_stat,
  949. .maxlen = 2*sizeof(int),
  950. .mode = 0444,
  951. .proc_handler = &proc_dointvec,
  952. },
  953. {
  954. .ctl_name = FS_STATINODE,
  955. .procname = "inode-state",
  956. .data = &inodes_stat,
  957. .maxlen = 7*sizeof(int),
  958. .mode = 0444,
  959. .proc_handler = &proc_dointvec,
  960. },
  961. {
  962. .ctl_name = FS_NRFILE,
  963. .procname = "file-nr",
  964. .data = &files_stat,
  965. .maxlen = 3*sizeof(int),
  966. .mode = 0444,
  967. .proc_handler = &proc_nr_files,
  968. },
  969. {
  970. .ctl_name = FS_MAXFILE,
  971. .procname = "file-max",
  972. .data = &files_stat.max_files,
  973. .maxlen = sizeof(int),
  974. .mode = 0644,
  975. .proc_handler = &proc_dointvec,
  976. },
  977. {
  978. .ctl_name = FS_DENTRY,
  979. .procname = "dentry-state",
  980. .data = &dentry_stat,
  981. .maxlen = 6*sizeof(int),
  982. .mode = 0444,
  983. .proc_handler = &proc_dointvec,
  984. },
  985. {
  986. .ctl_name = FS_OVERFLOWUID,
  987. .procname = "overflowuid",
  988. .data = &fs_overflowuid,
  989. .maxlen = sizeof(int),
  990. .mode = 0644,
  991. .proc_handler = &proc_dointvec_minmax,
  992. .strategy = &sysctl_intvec,
  993. .extra1 = &minolduid,
  994. .extra2 = &maxolduid,
  995. },
  996. {
  997. .ctl_name = FS_OVERFLOWGID,
  998. .procname = "overflowgid",
  999. .data = &fs_overflowgid,
  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_LEASES,
  1009. .procname = "leases-enable",
  1010. .data = &leases_enable,
  1011. .maxlen = sizeof(int),
  1012. .mode = 0644,
  1013. .proc_handler = &proc_dointvec,
  1014. },
  1015. #ifdef CONFIG_DNOTIFY
  1016. {
  1017. .ctl_name = FS_DIR_NOTIFY,
  1018. .procname = "dir-notify-enable",
  1019. .data = &dir_notify_enable,
  1020. .maxlen = sizeof(int),
  1021. .mode = 0644,
  1022. .proc_handler = &proc_dointvec,
  1023. },
  1024. #endif
  1025. #ifdef CONFIG_MMU
  1026. {
  1027. .ctl_name = FS_LEASE_TIME,
  1028. .procname = "lease-break-time",
  1029. .data = &lease_break_time,
  1030. .maxlen = sizeof(int),
  1031. .mode = 0644,
  1032. .proc_handler = &proc_dointvec,
  1033. },
  1034. {
  1035. .ctl_name = FS_AIO_NR,
  1036. .procname = "aio-nr",
  1037. .data = &aio_nr,
  1038. .maxlen = sizeof(aio_nr),
  1039. .mode = 0444,
  1040. .proc_handler = &proc_doulongvec_minmax,
  1041. },
  1042. {
  1043. .ctl_name = FS_AIO_MAX_NR,
  1044. .procname = "aio-max-nr",
  1045. .data = &aio_max_nr,
  1046. .maxlen = sizeof(aio_max_nr),
  1047. .mode = 0644,
  1048. .proc_handler = &proc_doulongvec_minmax,
  1049. },
  1050. #ifdef CONFIG_INOTIFY_USER
  1051. {
  1052. .ctl_name = FS_INOTIFY,
  1053. .procname = "inotify",
  1054. .mode = 0555,
  1055. .child = inotify_table,
  1056. },
  1057. #endif
  1058. #endif
  1059. {
  1060. .ctl_name = KERN_SETUID_DUMPABLE,
  1061. .procname = "suid_dumpable",
  1062. .data = &suid_dumpable,
  1063. .maxlen = sizeof(int),
  1064. .mode = 0644,
  1065. .proc_handler = &proc_dointvec,
  1066. },
  1067. { .ctl_name = 0 }
  1068. };
  1069. static ctl_table debug_table[] = {
  1070. { .ctl_name = 0 }
  1071. };
  1072. static ctl_table dev_table[] = {
  1073. { .ctl_name = 0 }
  1074. };
  1075. extern void init_irq_proc (void);
  1076. static DEFINE_SPINLOCK(sysctl_lock);
  1077. /* called under sysctl_lock */
  1078. static int use_table(struct ctl_table_header *p)
  1079. {
  1080. if (unlikely(p->unregistering))
  1081. return 0;
  1082. p->used++;
  1083. return 1;
  1084. }
  1085. /* called under sysctl_lock */
  1086. static void unuse_table(struct ctl_table_header *p)
  1087. {
  1088. if (!--p->used)
  1089. if (unlikely(p->unregistering))
  1090. complete(p->unregistering);
  1091. }
  1092. /* called under sysctl_lock, will reacquire if has to wait */
  1093. static void start_unregistering(struct ctl_table_header *p)
  1094. {
  1095. /*
  1096. * if p->used is 0, nobody will ever touch that entry again;
  1097. * we'll eliminate all paths to it before dropping sysctl_lock
  1098. */
  1099. if (unlikely(p->used)) {
  1100. struct completion wait;
  1101. init_completion(&wait);
  1102. p->unregistering = &wait;
  1103. spin_unlock(&sysctl_lock);
  1104. wait_for_completion(&wait);
  1105. spin_lock(&sysctl_lock);
  1106. }
  1107. /*
  1108. * do not remove from the list until nobody holds it; walking the
  1109. * list in do_sysctl() relies on that.
  1110. */
  1111. list_del_init(&p->ctl_entry);
  1112. }
  1113. void __init sysctl_init(void)
  1114. {
  1115. #ifdef CONFIG_PROC_FS
  1116. register_proc_table(root_table, proc_sys_root, &root_table_header);
  1117. init_irq_proc();
  1118. #endif
  1119. }
  1120. int do_sysctl(int __user *name, int nlen, void __user *oldval, size_t __user *oldlenp,
  1121. void __user *newval, size_t newlen)
  1122. {
  1123. struct list_head *tmp;
  1124. int error = -ENOTDIR;
  1125. if (nlen <= 0 || nlen >= CTL_MAXNAME)
  1126. return -ENOTDIR;
  1127. if (oldval) {
  1128. int old_len;
  1129. if (!oldlenp || get_user(old_len, oldlenp))
  1130. return -EFAULT;
  1131. }
  1132. spin_lock(&sysctl_lock);
  1133. tmp = &root_table_header.ctl_entry;
  1134. do {
  1135. struct ctl_table_header *head =
  1136. list_entry(tmp, struct ctl_table_header, ctl_entry);
  1137. void *context = NULL;
  1138. if (!use_table(head))
  1139. continue;
  1140. spin_unlock(&sysctl_lock);
  1141. error = parse_table(name, nlen, oldval, oldlenp,
  1142. newval, newlen, head->ctl_table,
  1143. &context);
  1144. kfree(context);
  1145. spin_lock(&sysctl_lock);
  1146. unuse_table(head);
  1147. if (error != -ENOTDIR)
  1148. break;
  1149. } while ((tmp = tmp->next) != &root_table_header.ctl_entry);
  1150. spin_unlock(&sysctl_lock);
  1151. return error;
  1152. }
  1153. asmlinkage long sys_sysctl(struct __sysctl_args __user *args)
  1154. {
  1155. struct __sysctl_args tmp;
  1156. int error;
  1157. if (copy_from_user(&tmp, args, sizeof(tmp)))
  1158. return -EFAULT;
  1159. lock_kernel();
  1160. error = do_sysctl(tmp.name, tmp.nlen, tmp.oldval, tmp.oldlenp,
  1161. tmp.newval, tmp.newlen);
  1162. unlock_kernel();
  1163. return error;
  1164. }
  1165. /*
  1166. * ctl_perm does NOT grant the superuser all rights automatically, because
  1167. * some sysctl variables are readonly even to root.
  1168. */
  1169. static int test_perm(int mode, int op)
  1170. {
  1171. if (!current->euid)
  1172. mode >>= 6;
  1173. else if (in_egroup_p(0))
  1174. mode >>= 3;
  1175. if ((mode & op & 0007) == op)
  1176. return 0;
  1177. return -EACCES;
  1178. }
  1179. static inline int ctl_perm(ctl_table *table, int op)
  1180. {
  1181. int error;
  1182. error = security_sysctl(table, op);
  1183. if (error)
  1184. return error;
  1185. return test_perm(table->mode, op);
  1186. }
  1187. static int parse_table(int __user *name, int nlen,
  1188. void __user *oldval, size_t __user *oldlenp,
  1189. void __user *newval, size_t newlen,
  1190. ctl_table *table, void **context)
  1191. {
  1192. int n;
  1193. repeat:
  1194. if (!nlen)
  1195. return -ENOTDIR;
  1196. if (get_user(n, name))
  1197. return -EFAULT;
  1198. for ( ; table->ctl_name; table++) {
  1199. if (n == table->ctl_name || table->ctl_name == CTL_ANY) {
  1200. int error;
  1201. if (table->child) {
  1202. if (ctl_perm(table, 001))
  1203. return -EPERM;
  1204. if (table->strategy) {
  1205. error = table->strategy(
  1206. table, name, nlen,
  1207. oldval, oldlenp,
  1208. newval, newlen, context);
  1209. if (error)
  1210. return error;
  1211. }
  1212. name++;
  1213. nlen--;
  1214. table = table->child;
  1215. goto repeat;
  1216. }
  1217. error = do_sysctl_strategy(table, name, nlen,
  1218. oldval, oldlenp,
  1219. newval, newlen, context);
  1220. return error;
  1221. }
  1222. }
  1223. return -ENOTDIR;
  1224. }
  1225. /* Perform the actual read/write of a sysctl table entry. */
  1226. int do_sysctl_strategy (ctl_table *table,
  1227. int __user *name, int nlen,
  1228. void __user *oldval, size_t __user *oldlenp,
  1229. void __user *newval, size_t newlen, void **context)
  1230. {
  1231. int op = 0, rc;
  1232. size_t len;
  1233. if (oldval)
  1234. op |= 004;
  1235. if (newval)
  1236. op |= 002;
  1237. if (ctl_perm(table, op))
  1238. return -EPERM;
  1239. if (table->strategy) {
  1240. rc = table->strategy(table, name, nlen, oldval, oldlenp,
  1241. newval, newlen, context);
  1242. if (rc < 0)
  1243. return rc;
  1244. if (rc > 0)
  1245. return 0;
  1246. }
  1247. /* If there is no strategy routine, or if the strategy returns
  1248. * zero, proceed with automatic r/w */
  1249. if (table->data && table->maxlen) {
  1250. if (oldval && oldlenp) {
  1251. if (get_user(len, oldlenp))
  1252. return -EFAULT;
  1253. if (len) {
  1254. if (len > table->maxlen)
  1255. len = table->maxlen;
  1256. if(copy_to_user(oldval, table->data, len))
  1257. return -EFAULT;
  1258. if(put_user(len, oldlenp))
  1259. return -EFAULT;
  1260. }
  1261. }
  1262. if (newval && newlen) {
  1263. len = newlen;
  1264. if (len > table->maxlen)
  1265. len = table->maxlen;
  1266. if(copy_from_user(table->data, newval, len))
  1267. return -EFAULT;
  1268. }
  1269. }
  1270. return 0;
  1271. }
  1272. /**
  1273. * register_sysctl_table - register a sysctl hierarchy
  1274. * @table: the top-level table structure
  1275. * @insert_at_head: whether the entry should be inserted in front or at the end
  1276. *
  1277. * Register a sysctl table hierarchy. @table should be a filled in ctl_table
  1278. * array. An entry with a ctl_name of 0 terminates the table.
  1279. *
  1280. * The members of the &ctl_table structure are used as follows:
  1281. *
  1282. * ctl_name - This is the numeric sysctl value used by sysctl(2). The number
  1283. * must be unique within that level of sysctl
  1284. *
  1285. * procname - the name of the sysctl file under /proc/sys. Set to %NULL to not
  1286. * enter a sysctl file
  1287. *
  1288. * data - a pointer to data for use by proc_handler
  1289. *
  1290. * maxlen - the maximum size in bytes of the data
  1291. *
  1292. * mode - the file permissions for the /proc/sys file, and for sysctl(2)
  1293. *
  1294. * child - a pointer to the child sysctl table if this entry is a directory, or
  1295. * %NULL.
  1296. *
  1297. * proc_handler - the text handler routine (described below)
  1298. *
  1299. * strategy - the strategy routine (described below)
  1300. *
  1301. * de - for internal use by the sysctl routines
  1302. *
  1303. * extra1, extra2 - extra pointers usable by the proc handler routines
  1304. *
  1305. * Leaf nodes in the sysctl tree will be represented by a single file
  1306. * under /proc; non-leaf nodes will be represented by directories.
  1307. *
  1308. * sysctl(2) can automatically manage read and write requests through
  1309. * the sysctl table. The data and maxlen fields of the ctl_table
  1310. * struct enable minimal validation of the values being written to be
  1311. * performed, and the mode field allows minimal authentication.
  1312. *
  1313. * More sophisticated management can be enabled by the provision of a
  1314. * strategy routine with the table entry. This will be called before
  1315. * any automatic read or write of the data is performed.
  1316. *
  1317. * The strategy routine may return
  1318. *
  1319. * < 0 - Error occurred (error is passed to user process)
  1320. *
  1321. * 0 - OK - proceed with automatic read or write.
  1322. *
  1323. * > 0 - OK - read or write has been done by the strategy routine, so
  1324. * return immediately.
  1325. *
  1326. * There must be a proc_handler routine for any terminal nodes
  1327. * mirrored under /proc/sys (non-terminals are handled by a built-in
  1328. * directory handler). Several default handlers are available to
  1329. * cover common cases -
  1330. *
  1331. * proc_dostring(), proc_dointvec(), proc_dointvec_jiffies(),
  1332. * proc_dointvec_userhz_jiffies(), proc_dointvec_minmax(),
  1333. * proc_doulongvec_ms_jiffies_minmax(), proc_doulongvec_minmax()
  1334. *
  1335. * It is the handler's job to read the input buffer from user memory
  1336. * and process it. The handler should return 0 on success.
  1337. *
  1338. * This routine returns %NULL on a failure to register, and a pointer
  1339. * to the table header on success.
  1340. */
  1341. struct ctl_table_header *register_sysctl_table(ctl_table * table,
  1342. int insert_at_head)
  1343. {
  1344. struct ctl_table_header *tmp;
  1345. tmp = kmalloc(sizeof(struct ctl_table_header), GFP_KERNEL);
  1346. if (!tmp)
  1347. return NULL;
  1348. tmp->ctl_table = table;
  1349. INIT_LIST_HEAD(&tmp->ctl_entry);
  1350. tmp->used = 0;
  1351. tmp->unregistering = NULL;
  1352. spin_lock(&sysctl_lock);
  1353. if (insert_at_head)
  1354. list_add(&tmp->ctl_entry, &root_table_header.ctl_entry);
  1355. else
  1356. list_add_tail(&tmp->ctl_entry, &root_table_header.ctl_entry);
  1357. spin_unlock(&sysctl_lock);
  1358. #ifdef CONFIG_PROC_FS
  1359. register_proc_table(table, proc_sys_root, tmp);
  1360. #endif
  1361. return tmp;
  1362. }
  1363. /**
  1364. * unregister_sysctl_table - unregister a sysctl table hierarchy
  1365. * @header: the header returned from register_sysctl_table
  1366. *
  1367. * Unregisters the sysctl table and all children. proc entries may not
  1368. * actually be removed until they are no longer used by anyone.
  1369. */
  1370. void unregister_sysctl_table(struct ctl_table_header * header)
  1371. {
  1372. might_sleep();
  1373. spin_lock(&sysctl_lock);
  1374. start_unregistering(header);
  1375. #ifdef CONFIG_PROC_FS
  1376. unregister_proc_table(header->ctl_table, proc_sys_root);
  1377. #endif
  1378. spin_unlock(&sysctl_lock);
  1379. kfree(header);
  1380. }
  1381. /*
  1382. * /proc/sys support
  1383. */
  1384. #ifdef CONFIG_PROC_FS
  1385. /* Scan the sysctl entries in table and add them all into /proc */
  1386. static void register_proc_table(ctl_table * table, struct proc_dir_entry *root, void *set)
  1387. {
  1388. struct proc_dir_entry *de;
  1389. int len;
  1390. mode_t mode;
  1391. for (; table->ctl_name; table++) {
  1392. /* Can't do anything without a proc name. */
  1393. if (!table->procname)
  1394. continue;
  1395. /* Maybe we can't do anything with it... */
  1396. if (!table->proc_handler && !table->child) {
  1397. printk(KERN_WARNING "SYSCTL: Can't register %s\n",
  1398. table->procname);
  1399. continue;
  1400. }
  1401. len = strlen(table->procname);
  1402. mode = table->mode;
  1403. de = NULL;
  1404. if (table->proc_handler)
  1405. mode |= S_IFREG;
  1406. else {
  1407. mode |= S_IFDIR;
  1408. for (de = root->subdir; de; de = de->next) {
  1409. if (proc_match(len, table->procname, de))
  1410. break;
  1411. }
  1412. /* If the subdir exists already, de is non-NULL */
  1413. }
  1414. if (!de) {
  1415. de = create_proc_entry(table->procname, mode, root);
  1416. if (!de)
  1417. continue;
  1418. de->set = set;
  1419. de->data = (void *) table;
  1420. if (table->proc_handler)
  1421. de->proc_fops = &proc_sys_file_operations;
  1422. }
  1423. table->de = de;
  1424. if (de->mode & S_IFDIR)
  1425. register_proc_table(table->child, de, set);
  1426. }
  1427. }
  1428. /*
  1429. * Unregister a /proc sysctl table and any subdirectories.
  1430. */
  1431. static void unregister_proc_table(ctl_table * table, struct proc_dir_entry *root)
  1432. {
  1433. struct proc_dir_entry *de;
  1434. for (; table->ctl_name; table++) {
  1435. if (!(de = table->de))
  1436. continue;
  1437. if (de->mode & S_IFDIR) {
  1438. if (!table->child) {
  1439. printk (KERN_ALERT "Help - malformed sysctl tree on free\n");
  1440. continue;
  1441. }
  1442. unregister_proc_table(table->child, de);
  1443. /* Don't unregister directories which still have entries.. */
  1444. if (de->subdir)
  1445. continue;
  1446. }
  1447. /*
  1448. * In any case, mark the entry as goner; we'll keep it
  1449. * around if it's busy, but we'll know to do nothing with
  1450. * its fields. We are under sysctl_lock here.
  1451. */
  1452. de->data = NULL;
  1453. /* Don't unregister proc entries that are still being used.. */
  1454. if (atomic_read(&de->count))
  1455. continue;
  1456. table->de = NULL;
  1457. remove_proc_entry(table->procname, root);
  1458. }
  1459. }
  1460. static ssize_t do_rw_proc(int write, struct file * file, char __user * buf,
  1461. size_t count, loff_t *ppos)
  1462. {
  1463. int op;
  1464. struct proc_dir_entry *de = PDE(file->f_dentry->d_inode);
  1465. struct ctl_table *table;
  1466. size_t res;
  1467. ssize_t error = -ENOTDIR;
  1468. spin_lock(&sysctl_lock);
  1469. if (de && de->data && use_table(de->set)) {
  1470. /*
  1471. * at that point we know that sysctl was not unregistered
  1472. * and won't be until we finish
  1473. */
  1474. spin_unlock(&sysctl_lock);
  1475. table = (struct ctl_table *) de->data;
  1476. if (!table || !table->proc_handler)
  1477. goto out;
  1478. error = -EPERM;
  1479. op = (write ? 002 : 004);
  1480. if (ctl_perm(table, op))
  1481. goto out;
  1482. /* careful: calling conventions are nasty here */
  1483. res = count;
  1484. error = (*table->proc_handler)(table, write, file,
  1485. buf, &res, ppos);
  1486. if (!error)
  1487. error = res;
  1488. out:
  1489. spin_lock(&sysctl_lock);
  1490. unuse_table(de->set);
  1491. }
  1492. spin_unlock(&sysctl_lock);
  1493. return error;
  1494. }
  1495. static int proc_opensys(struct inode *inode, struct file *file)
  1496. {
  1497. if (file->f_mode & FMODE_WRITE) {
  1498. /*
  1499. * sysctl entries that are not writable,
  1500. * are _NOT_ writable, capabilities or not.
  1501. */
  1502. if (!(inode->i_mode & S_IWUSR))
  1503. return -EPERM;
  1504. }
  1505. return 0;
  1506. }
  1507. static ssize_t proc_readsys(struct file * file, char __user * buf,
  1508. size_t count, loff_t *ppos)
  1509. {
  1510. return do_rw_proc(0, file, buf, count, ppos);
  1511. }
  1512. static ssize_t proc_writesys(struct file * file, const char __user * buf,
  1513. size_t count, loff_t *ppos)
  1514. {
  1515. return do_rw_proc(1, file, (char __user *) buf, count, ppos);
  1516. }
  1517. /**
  1518. * proc_dostring - read a string sysctl
  1519. * @table: the sysctl table
  1520. * @write: %TRUE if this is a write to the sysctl file
  1521. * @filp: the file structure
  1522. * @buffer: the user buffer
  1523. * @lenp: the size of the user buffer
  1524. * @ppos: file position
  1525. *
  1526. * Reads/writes a string from/to the user buffer. If the kernel
  1527. * buffer provided is not large enough to hold the string, the
  1528. * string is truncated. The copied string is %NULL-terminated.
  1529. * If the string is being read by the user process, it is copied
  1530. * and a newline '\n' is added. It is truncated if the buffer is
  1531. * not large enough.
  1532. *
  1533. * Returns 0 on success.
  1534. */
  1535. int proc_dostring(ctl_table *table, int write, struct file *filp,
  1536. void __user *buffer, size_t *lenp, loff_t *ppos)
  1537. {
  1538. size_t len;
  1539. char __user *p;
  1540. char c;
  1541. if (!table->data || !table->maxlen || !*lenp ||
  1542. (*ppos && !write)) {
  1543. *lenp = 0;
  1544. return 0;
  1545. }
  1546. if (write) {
  1547. len = 0;
  1548. p = buffer;
  1549. while (len < *lenp) {
  1550. if (get_user(c, p++))
  1551. return -EFAULT;
  1552. if (c == 0 || c == '\n')
  1553. break;
  1554. len++;
  1555. }
  1556. if (len >= table->maxlen)
  1557. len = table->maxlen-1;
  1558. if(copy_from_user(table->data, buffer, len))
  1559. return -EFAULT;
  1560. ((char *) table->data)[len] = 0;
  1561. *ppos += *lenp;
  1562. } else {
  1563. len = strlen(table->data);
  1564. if (len > table->maxlen)
  1565. len = table->maxlen;
  1566. if (len > *lenp)
  1567. len = *lenp;
  1568. if (len)
  1569. if(copy_to_user(buffer, table->data, len))
  1570. return -EFAULT;
  1571. if (len < *lenp) {
  1572. if(put_user('\n', ((char __user *) buffer) + len))
  1573. return -EFAULT;
  1574. len++;
  1575. }
  1576. *lenp = len;
  1577. *ppos += len;
  1578. }
  1579. return 0;
  1580. }
  1581. /*
  1582. * Special case of dostring for the UTS structure. This has locks
  1583. * to observe. Should this be in kernel/sys.c ????
  1584. */
  1585. static int proc_doutsstring(ctl_table *table, int write, struct file *filp,
  1586. void __user *buffer, size_t *lenp, loff_t *ppos)
  1587. {
  1588. int r;
  1589. if (!write) {
  1590. down_read(&uts_sem);
  1591. r=proc_dostring(table,0,filp,buffer,lenp, ppos);
  1592. up_read(&uts_sem);
  1593. } else {
  1594. down_write(&uts_sem);
  1595. r=proc_dostring(table,1,filp,buffer,lenp, ppos);
  1596. up_write(&uts_sem);
  1597. }
  1598. return r;
  1599. }
  1600. static int do_proc_dointvec_conv(int *negp, unsigned long *lvalp,
  1601. int *valp,
  1602. int write, void *data)
  1603. {
  1604. if (write) {
  1605. *valp = *negp ? -*lvalp : *lvalp;
  1606. } else {
  1607. int val = *valp;
  1608. if (val < 0) {
  1609. *negp = -1;
  1610. *lvalp = (unsigned long)-val;
  1611. } else {
  1612. *negp = 0;
  1613. *lvalp = (unsigned long)val;
  1614. }
  1615. }
  1616. return 0;
  1617. }
  1618. static int do_proc_dointvec(ctl_table *table, int write, struct file *filp,
  1619. void __user *buffer, size_t *lenp, loff_t *ppos,
  1620. int (*conv)(int *negp, unsigned long *lvalp, int *valp,
  1621. int write, void *data),
  1622. void *data)
  1623. {
  1624. #define TMPBUFLEN 21
  1625. int *i, vleft, first=1, neg, val;
  1626. unsigned long lval;
  1627. size_t left, len;
  1628. char buf[TMPBUFLEN], *p;
  1629. char __user *s = buffer;
  1630. if (!table->data || !table->maxlen || !*lenp ||
  1631. (*ppos && !write)) {
  1632. *lenp = 0;
  1633. return 0;
  1634. }
  1635. i = (int *) table->data;
  1636. vleft = table->maxlen / sizeof(*i);
  1637. left = *lenp;
  1638. if (!conv)
  1639. conv = do_proc_dointvec_conv;
  1640. for (; left && vleft--; i++, first=0) {
  1641. if (write) {
  1642. while (left) {
  1643. char c;
  1644. if (get_user(c, s))
  1645. return -EFAULT;
  1646. if (!isspace(c))
  1647. break;
  1648. left--;
  1649. s++;
  1650. }
  1651. if (!left)
  1652. break;
  1653. neg = 0;
  1654. len = left;
  1655. if (len > sizeof(buf) - 1)
  1656. len = sizeof(buf) - 1;
  1657. if (copy_from_user(buf, s, len))
  1658. return -EFAULT;
  1659. buf[len] = 0;
  1660. p = buf;
  1661. if (*p == '-' && left > 1) {
  1662. neg = 1;
  1663. left--, p++;
  1664. }
  1665. if (*p < '0' || *p > '9')
  1666. break;
  1667. lval = simple_strtoul(p, &p, 0);
  1668. len = p-buf;
  1669. if ((len < left) && *p && !isspace(*p))
  1670. break;
  1671. if (neg)
  1672. val = -val;
  1673. s += len;
  1674. left -= len;
  1675. if (conv(&neg, &lval, i, 1, data))
  1676. break;
  1677. } else {
  1678. p = buf;
  1679. if (!first)
  1680. *p++ = '\t';
  1681. if (conv(&neg, &lval, i, 0, data))
  1682. break;
  1683. sprintf(p, "%s%lu", neg ? "-" : "", lval);
  1684. len = strlen(buf);
  1685. if (len > left)
  1686. len = left;
  1687. if(copy_to_user(s, buf, len))
  1688. return -EFAULT;
  1689. left -= len;
  1690. s += len;
  1691. }
  1692. }
  1693. if (!write && !first && left) {
  1694. if(put_user('\n', s))
  1695. return -EFAULT;
  1696. left--, s++;
  1697. }
  1698. if (write) {
  1699. while (left) {
  1700. char c;
  1701. if (get_user(c, s++))
  1702. return -EFAULT;
  1703. if (!isspace(c))
  1704. break;
  1705. left--;
  1706. }
  1707. }
  1708. if (write && first)
  1709. return -EINVAL;
  1710. *lenp -= left;
  1711. *ppos += *lenp;
  1712. return 0;
  1713. #undef TMPBUFLEN
  1714. }
  1715. /**
  1716. * proc_dointvec - read a vector of integers
  1717. * @table: the sysctl table
  1718. * @write: %TRUE if this is a write to the sysctl file
  1719. * @filp: the file structure
  1720. * @buffer: the user buffer
  1721. * @lenp: the size of the user buffer
  1722. * @ppos: file position
  1723. *
  1724. * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
  1725. * values from/to the user buffer, treated as an ASCII string.
  1726. *
  1727. * Returns 0 on success.
  1728. */
  1729. int proc_dointvec(ctl_table *table, int write, struct file *filp,
  1730. void __user *buffer, size_t *lenp, loff_t *ppos)
  1731. {
  1732. return do_proc_dointvec(table,write,filp,buffer,lenp,ppos,
  1733. NULL,NULL);
  1734. }
  1735. #define OP_SET 0
  1736. #define OP_AND 1
  1737. #define OP_OR 2
  1738. #define OP_MAX 3
  1739. #define OP_MIN 4
  1740. static int do_proc_dointvec_bset_conv(int *negp, unsigned long *lvalp,
  1741. int *valp,
  1742. int write, void *data)
  1743. {
  1744. int op = *(int *)data;
  1745. if (write) {
  1746. int val = *negp ? -*lvalp : *lvalp;
  1747. switch(op) {
  1748. case OP_SET: *valp = val; break;
  1749. case OP_AND: *valp &= val; break;
  1750. case OP_OR: *valp |= val; break;
  1751. case OP_MAX: if(*valp < val)
  1752. *valp = val;
  1753. break;
  1754. case OP_MIN: if(*valp > val)
  1755. *valp = val;
  1756. break;
  1757. }
  1758. } else {
  1759. int val = *valp;
  1760. if (val < 0) {
  1761. *negp = -1;
  1762. *lvalp = (unsigned long)-val;
  1763. } else {
  1764. *negp = 0;
  1765. *lvalp = (unsigned long)val;
  1766. }
  1767. }
  1768. return 0;
  1769. }
  1770. /*
  1771. * init may raise the set.
  1772. */
  1773. int proc_dointvec_bset(ctl_table *table, int write, struct file *filp,
  1774. void __user *buffer, size_t *lenp, loff_t *ppos)
  1775. {
  1776. int op;
  1777. if (!capable(CAP_SYS_MODULE)) {
  1778. return -EPERM;
  1779. }
  1780. op = (current->pid == 1) ? OP_SET : OP_AND;
  1781. return do_proc_dointvec(table,write,filp,buffer,lenp,ppos,
  1782. do_proc_dointvec_bset_conv,&op);
  1783. }
  1784. struct do_proc_dointvec_minmax_conv_param {
  1785. int *min;
  1786. int *max;
  1787. };
  1788. static int do_proc_dointvec_minmax_conv(int *negp, unsigned long *lvalp,
  1789. int *valp,
  1790. int write, void *data)
  1791. {
  1792. struct do_proc_dointvec_minmax_conv_param *param = data;
  1793. if (write) {
  1794. int val = *negp ? -*lvalp : *lvalp;
  1795. if ((param->min && *param->min > val) ||
  1796. (param->max && *param->max < val))
  1797. return -EINVAL;
  1798. *valp = val;
  1799. } else {
  1800. int val = *valp;
  1801. if (val < 0) {
  1802. *negp = -1;
  1803. *lvalp = (unsigned long)-val;
  1804. } else {
  1805. *negp = 0;
  1806. *lvalp = (unsigned long)val;
  1807. }
  1808. }
  1809. return 0;
  1810. }
  1811. /**
  1812. * proc_dointvec_minmax - read a vector of integers with min/max values
  1813. * @table: the sysctl table
  1814. * @write: %TRUE if this is a write to the sysctl file
  1815. * @filp: the file structure
  1816. * @buffer: the user buffer
  1817. * @lenp: the size of the user buffer
  1818. * @ppos: file position
  1819. *
  1820. * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
  1821. * values from/to the user buffer, treated as an ASCII string.
  1822. *
  1823. * This routine will ensure the values are within the range specified by
  1824. * table->extra1 (min) and table->extra2 (max).
  1825. *
  1826. * Returns 0 on success.
  1827. */
  1828. int proc_dointvec_minmax(ctl_table *table, int write, struct file *filp,
  1829. void __user *buffer, size_t *lenp, loff_t *ppos)
  1830. {
  1831. struct do_proc_dointvec_minmax_conv_param param = {
  1832. .min = (int *) table->extra1,
  1833. .max = (int *) table->extra2,
  1834. };
  1835. return do_proc_dointvec(table, write, filp, buffer, lenp, ppos,
  1836. do_proc_dointvec_minmax_conv, &param);
  1837. }
  1838. static int do_proc_doulongvec_minmax(ctl_table *table, int write,
  1839. struct file *filp,
  1840. void __user *buffer,
  1841. size_t *lenp, loff_t *ppos,
  1842. unsigned long convmul,
  1843. unsigned long convdiv)
  1844. {
  1845. #define TMPBUFLEN 21
  1846. unsigned long *i, *min, *max, val;
  1847. int vleft, first=1, neg;
  1848. size_t len, left;
  1849. char buf[TMPBUFLEN], *p;
  1850. char __user *s = buffer;
  1851. if (!table->data || !table->maxlen || !*lenp ||
  1852. (*ppos && !write)) {
  1853. *lenp = 0;
  1854. return 0;
  1855. }
  1856. i = (unsigned long *) table->data;
  1857. min = (unsigned long *) table->extra1;
  1858. max = (unsigned long *) table->extra2;
  1859. vleft = table->maxlen / sizeof(unsigned long);
  1860. left = *lenp;
  1861. for (; left && vleft--; i++, min++, max++, first=0) {
  1862. if (write) {
  1863. while (left) {
  1864. char c;
  1865. if (get_user(c, s))
  1866. return -EFAULT;
  1867. if (!isspace(c))
  1868. break;
  1869. left--;
  1870. s++;
  1871. }
  1872. if (!left)
  1873. break;
  1874. neg = 0;
  1875. len = left;
  1876. if (len > TMPBUFLEN-1)
  1877. len = TMPBUFLEN-1;
  1878. if (copy_from_user(buf, s, len))
  1879. return -EFAULT;
  1880. buf[len] = 0;
  1881. p = buf;
  1882. if (*p == '-' && left > 1) {
  1883. neg = 1;
  1884. left--, p++;
  1885. }
  1886. if (*p < '0' || *p > '9')
  1887. break;
  1888. val = simple_strtoul(p, &p, 0) * convmul / convdiv ;
  1889. len = p-buf;
  1890. if ((len < left) && *p && !isspace(*p))
  1891. break;
  1892. if (neg)
  1893. val = -val;
  1894. s += len;
  1895. left -= len;
  1896. if(neg)
  1897. continue;
  1898. if ((min && val < *min) || (max && val > *max))
  1899. continue;
  1900. *i = val;
  1901. } else {
  1902. p = buf;
  1903. if (!first)
  1904. *p++ = '\t';
  1905. sprintf(p, "%lu", convdiv * (*i) / convmul);
  1906. len = strlen(buf);
  1907. if (len > left)
  1908. len = left;
  1909. if(copy_to_user(s, buf, len))
  1910. return -EFAULT;
  1911. left -= len;
  1912. s += len;
  1913. }
  1914. }
  1915. if (!write && !first && left) {
  1916. if(put_user('\n', s))
  1917. return -EFAULT;
  1918. left--, s++;
  1919. }
  1920. if (write) {
  1921. while (left) {
  1922. char c;
  1923. if (get_user(c, s++))
  1924. return -EFAULT;
  1925. if (!isspace(c))
  1926. break;
  1927. left--;
  1928. }
  1929. }
  1930. if (write && first)
  1931. return -EINVAL;
  1932. *lenp -= left;
  1933. *ppos += *lenp;
  1934. return 0;
  1935. #undef TMPBUFLEN
  1936. }
  1937. /**
  1938. * proc_doulongvec_minmax - read a vector of long integers with min/max values
  1939. * @table: the sysctl table
  1940. * @write: %TRUE if this is a write to the sysctl file
  1941. * @filp: the file structure
  1942. * @buffer: the user buffer
  1943. * @lenp: the size of the user buffer
  1944. * @ppos: file position
  1945. *
  1946. * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
  1947. * values from/to the user buffer, treated as an ASCII string.
  1948. *
  1949. * This routine will ensure the values are within the range specified by
  1950. * table->extra1 (min) and table->extra2 (max).
  1951. *
  1952. * Returns 0 on success.
  1953. */
  1954. int proc_doulongvec_minmax(ctl_table *table, int write, struct file *filp,
  1955. void __user *buffer, size_t *lenp, loff_t *ppos)
  1956. {
  1957. return do_proc_doulongvec_minmax(table, write, filp, buffer, lenp, ppos, 1l, 1l);
  1958. }
  1959. /**
  1960. * proc_doulongvec_ms_jiffies_minmax - read a vector of millisecond values with min/max values
  1961. * @table: the sysctl table
  1962. * @write: %TRUE if this is a write to the sysctl file
  1963. * @filp: the file structure
  1964. * @buffer: the user buffer
  1965. * @lenp: the size of the user buffer
  1966. * @ppos: file position
  1967. *
  1968. * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
  1969. * values from/to the user buffer, treated as an ASCII string. The values
  1970. * are treated as milliseconds, and converted to jiffies when they are stored.
  1971. *
  1972. * This routine will ensure the values are within the range specified by
  1973. * table->extra1 (min) and table->extra2 (max).
  1974. *
  1975. * Returns 0 on success.
  1976. */
  1977. int proc_doulongvec_ms_jiffies_minmax(ctl_table *table, int write,
  1978. struct file *filp,
  1979. void __user *buffer,
  1980. size_t *lenp, loff_t *ppos)
  1981. {
  1982. return do_proc_doulongvec_minmax(table, write, filp, buffer,
  1983. lenp, ppos, HZ, 1000l);
  1984. }
  1985. static int do_proc_dointvec_jiffies_conv(int *negp, unsigned long *lvalp,
  1986. int *valp,
  1987. int write, void *data)
  1988. {
  1989. if (write) {
  1990. if (*lvalp > LONG_MAX / HZ)
  1991. return 1;
  1992. *valp = *negp ? -(*lvalp*HZ) : (*lvalp*HZ);
  1993. } else {
  1994. int val = *valp;
  1995. unsigned long lval;
  1996. if (val < 0) {
  1997. *negp = -1;
  1998. lval = (unsigned long)-val;
  1999. } else {
  2000. *negp = 0;
  2001. lval = (unsigned long)val;
  2002. }
  2003. *lvalp = lval / HZ;
  2004. }
  2005. return 0;
  2006. }
  2007. static int do_proc_dointvec_userhz_jiffies_conv(int *negp, unsigned long *lvalp,
  2008. int *valp,
  2009. int write, void *data)
  2010. {
  2011. if (write) {
  2012. if (USER_HZ < HZ && *lvalp > (LONG_MAX / HZ) * USER_HZ)
  2013. return 1;
  2014. *valp = clock_t_to_jiffies(*negp ? -*lvalp : *lvalp);
  2015. } else {
  2016. int val = *valp;
  2017. unsigned long lval;
  2018. if (val < 0) {
  2019. *negp = -1;
  2020. lval = (unsigned long)-val;
  2021. } else {
  2022. *negp = 0;
  2023. lval = (unsigned long)val;
  2024. }
  2025. *lvalp = jiffies_to_clock_t(lval);
  2026. }
  2027. return 0;
  2028. }
  2029. static int do_proc_dointvec_ms_jiffies_conv(int *negp, unsigned long *lvalp,
  2030. int *valp,
  2031. int write, void *data)
  2032. {
  2033. if (write) {
  2034. *valp = msecs_to_jiffies(*negp ? -*lvalp : *lvalp);
  2035. } else {
  2036. int val = *valp;
  2037. unsigned long lval;
  2038. if (val < 0) {
  2039. *negp = -1;
  2040. lval = (unsigned long)-val;
  2041. } else {
  2042. *negp = 0;
  2043. lval = (unsigned long)val;
  2044. }
  2045. *lvalp = jiffies_to_msecs(lval);
  2046. }
  2047. return 0;
  2048. }
  2049. /**
  2050. * proc_dointvec_jiffies - read a vector of integers as seconds
  2051. * @table: the sysctl table
  2052. * @write: %TRUE if this is a write to the sysctl file
  2053. * @filp: the file structure
  2054. * @buffer: the user buffer
  2055. * @lenp: the size of the user buffer
  2056. * @ppos: file position
  2057. *
  2058. * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
  2059. * values from/to the user buffer, treated as an ASCII string.
  2060. * The values read are assumed to be in seconds, and are converted into
  2061. * jiffies.
  2062. *
  2063. * Returns 0 on success.
  2064. */
  2065. int proc_dointvec_jiffies(ctl_table *table, int write, struct file *filp,
  2066. void __user *buffer, size_t *lenp, loff_t *ppos)
  2067. {
  2068. return do_proc_dointvec(table,write,filp,buffer,lenp,ppos,
  2069. do_proc_dointvec_jiffies_conv,NULL);
  2070. }
  2071. /**
  2072. * proc_dointvec_userhz_jiffies - read a vector of integers as 1/USER_HZ seconds
  2073. * @table: the sysctl table
  2074. * @write: %TRUE if this is a write to the sysctl file
  2075. * @filp: the file structure
  2076. * @buffer: the user buffer
  2077. * @lenp: the size of the user buffer
  2078. * @ppos: pointer to the file position
  2079. *
  2080. * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
  2081. * values from/to the user buffer, treated as an ASCII string.
  2082. * The values read are assumed to be in 1/USER_HZ seconds, and
  2083. * are converted into jiffies.
  2084. *
  2085. * Returns 0 on success.
  2086. */
  2087. int proc_dointvec_userhz_jiffies(ctl_table *table, int write, struct file *filp,
  2088. void __user *buffer, size_t *lenp, loff_t *ppos)
  2089. {
  2090. return do_proc_dointvec(table,write,filp,buffer,lenp,ppos,
  2091. do_proc_dointvec_userhz_jiffies_conv,NULL);
  2092. }
  2093. /**
  2094. * proc_dointvec_ms_jiffies - read a vector of integers as 1 milliseconds
  2095. * @table: the sysctl table
  2096. * @write: %TRUE if this is a write to the sysctl file
  2097. * @filp: the file structure
  2098. * @buffer: the user buffer
  2099. * @lenp: the size of the user buffer
  2100. * @ppos: file position
  2101. * @ppos: the current position in the file
  2102. *
  2103. * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
  2104. * values from/to the user buffer, treated as an ASCII string.
  2105. * The values read are assumed to be in 1/1000 seconds, and
  2106. * are converted into jiffies.
  2107. *
  2108. * Returns 0 on success.
  2109. */
  2110. int proc_dointvec_ms_jiffies(ctl_table *table, int write, struct file *filp,
  2111. void __user *buffer, size_t *lenp, loff_t *ppos)
  2112. {
  2113. return do_proc_dointvec(table, write, filp, buffer, lenp, ppos,
  2114. do_proc_dointvec_ms_jiffies_conv, NULL);
  2115. }
  2116. #else /* CONFIG_PROC_FS */
  2117. int proc_dostring(ctl_table *table, int write, struct file *filp,
  2118. void __user *buffer, size_t *lenp, loff_t *ppos)
  2119. {
  2120. return -ENOSYS;
  2121. }
  2122. static int proc_doutsstring(ctl_table *table, int write, struct file *filp,
  2123. void __user *buffer, size_t *lenp, loff_t *ppos)
  2124. {
  2125. return -ENOSYS;
  2126. }
  2127. int proc_dointvec(ctl_table *table, int write, struct file *filp,
  2128. void __user *buffer, size_t *lenp, loff_t *ppos)
  2129. {
  2130. return -ENOSYS;
  2131. }
  2132. int proc_dointvec_bset(ctl_table *table, int write, struct file *filp,
  2133. void __user *buffer, size_t *lenp, loff_t *ppos)
  2134. {
  2135. return -ENOSYS;
  2136. }
  2137. int proc_dointvec_minmax(ctl_table *table, int write, struct file *filp,
  2138. void __user *buffer, size_t *lenp, loff_t *ppos)
  2139. {
  2140. return -ENOSYS;
  2141. }
  2142. int proc_dointvec_jiffies(ctl_table *table, int write, struct file *filp,
  2143. void __user *buffer, size_t *lenp, loff_t *ppos)
  2144. {
  2145. return -ENOSYS;
  2146. }
  2147. int proc_dointvec_userhz_jiffies(ctl_table *table, int write, struct file *filp,
  2148. void __user *buffer, size_t *lenp, loff_t *ppos)
  2149. {
  2150. return -ENOSYS;
  2151. }
  2152. int proc_dointvec_ms_jiffies(ctl_table *table, int write, struct file *filp,
  2153. void __user *buffer, size_t *lenp, loff_t *ppos)
  2154. {
  2155. return -ENOSYS;
  2156. }
  2157. int proc_doulongvec_minmax(ctl_table *table, int write, struct file *filp,
  2158. void __user *buffer, size_t *lenp, loff_t *ppos)
  2159. {
  2160. return -ENOSYS;
  2161. }
  2162. int proc_doulongvec_ms_jiffies_minmax(ctl_table *table, int write,
  2163. struct file *filp,
  2164. void __user *buffer,
  2165. size_t *lenp, loff_t *ppos)
  2166. {
  2167. return -ENOSYS;
  2168. }
  2169. #endif /* CONFIG_PROC_FS */
  2170. /*
  2171. * General sysctl support routines
  2172. */
  2173. /* The generic string strategy routine: */
  2174. int sysctl_string(ctl_table *table, int __user *name, int nlen,
  2175. void __user *oldval, size_t __user *oldlenp,
  2176. void __user *newval, size_t newlen, void **context)
  2177. {
  2178. if (!table->data || !table->maxlen)
  2179. return -ENOTDIR;
  2180. if (oldval && oldlenp) {
  2181. size_t bufsize;
  2182. if (get_user(bufsize, oldlenp))
  2183. return -EFAULT;
  2184. if (bufsize) {
  2185. size_t len = strlen(table->data), copied;
  2186. /* This shouldn't trigger for a well-formed sysctl */
  2187. if (len > table->maxlen)
  2188. len = table->maxlen;
  2189. /* Copy up to a max of bufsize-1 bytes of the string */
  2190. copied = (len >= bufsize) ? bufsize - 1 : len;
  2191. if (copy_to_user(oldval, table->data, copied) ||
  2192. put_user(0, (char __user *)(oldval + copied)))
  2193. return -EFAULT;
  2194. if (put_user(len, oldlenp))
  2195. return -EFAULT;
  2196. }
  2197. }
  2198. if (newval && newlen) {
  2199. size_t len = newlen;
  2200. if (len > table->maxlen)
  2201. len = table->maxlen;
  2202. if(copy_from_user(table->data, newval, len))
  2203. return -EFAULT;
  2204. if (len == table->maxlen)
  2205. len--;
  2206. ((char *) table->data)[len] = 0;
  2207. }
  2208. return 1;
  2209. }
  2210. /*
  2211. * This function makes sure that all of the integers in the vector
  2212. * are between the minimum and maximum values given in the arrays
  2213. * table->extra1 and table->extra2, respectively.
  2214. */
  2215. int sysctl_intvec(ctl_table *table, int __user *name, int nlen,
  2216. void __user *oldval, size_t __user *oldlenp,
  2217. void __user *newval, size_t newlen, void **context)
  2218. {
  2219. if (newval && newlen) {
  2220. int __user *vec = (int __user *) newval;
  2221. int *min = (int *) table->extra1;
  2222. int *max = (int *) table->extra2;
  2223. size_t length;
  2224. int i;
  2225. if (newlen % sizeof(int) != 0)
  2226. return -EINVAL;
  2227. if (!table->extra1 && !table->extra2)
  2228. return 0;
  2229. if (newlen > table->maxlen)
  2230. newlen = table->maxlen;
  2231. length = newlen / sizeof(int);
  2232. for (i = 0; i < length; i++) {
  2233. int value;
  2234. if (get_user(value, vec + i))
  2235. return -EFAULT;
  2236. if (min && value < min[i])
  2237. return -EINVAL;
  2238. if (max && value > max[i])
  2239. return -EINVAL;
  2240. }
  2241. }
  2242. return 0;
  2243. }
  2244. /* Strategy function to convert jiffies to seconds */
  2245. int sysctl_jiffies(ctl_table *table, int __user *name, int nlen,
  2246. void __user *oldval, size_t __user *oldlenp,
  2247. void __user *newval, size_t newlen, void **context)
  2248. {
  2249. if (oldval) {
  2250. size_t olen;
  2251. if (oldlenp) {
  2252. if (get_user(olen, oldlenp))
  2253. return -EFAULT;
  2254. if (olen!=sizeof(int))
  2255. return -EINVAL;
  2256. }
  2257. if (put_user(*(int *)(table->data)/HZ, (int __user *)oldval) ||
  2258. (oldlenp && put_user(sizeof(int),oldlenp)))
  2259. return -EFAULT;
  2260. }
  2261. if (newval && newlen) {
  2262. int new;
  2263. if (newlen != sizeof(int))
  2264. return -EINVAL;
  2265. if (get_user(new, (int __user *)newval))
  2266. return -EFAULT;
  2267. *(int *)(table->data) = new*HZ;
  2268. }
  2269. return 1;
  2270. }
  2271. /* Strategy function to convert jiffies to seconds */
  2272. int sysctl_ms_jiffies(ctl_table *table, int __user *name, int nlen,
  2273. void __user *oldval, size_t __user *oldlenp,
  2274. void __user *newval, size_t newlen, void **context)
  2275. {
  2276. if (oldval) {
  2277. size_t olen;
  2278. if (oldlenp) {
  2279. if (get_user(olen, oldlenp))
  2280. return -EFAULT;
  2281. if (olen!=sizeof(int))
  2282. return -EINVAL;
  2283. }
  2284. if (put_user(jiffies_to_msecs(*(int *)(table->data)), (int __user *)oldval) ||
  2285. (oldlenp && put_user(sizeof(int),oldlenp)))
  2286. return -EFAULT;
  2287. }
  2288. if (newval && newlen) {
  2289. int new;
  2290. if (newlen != sizeof(int))
  2291. return -EINVAL;
  2292. if (get_user(new, (int __user *)newval))
  2293. return -EFAULT;
  2294. *(int *)(table->data) = msecs_to_jiffies(new);
  2295. }
  2296. return 1;
  2297. }
  2298. #else /* CONFIG_SYSCTL */
  2299. asmlinkage long sys_sysctl(struct __sysctl_args __user *args)
  2300. {
  2301. return -ENOSYS;
  2302. }
  2303. int sysctl_string(ctl_table *table, int __user *name, int nlen,
  2304. void __user *oldval, size_t __user *oldlenp,
  2305. void __user *newval, size_t newlen, void **context)
  2306. {
  2307. return -ENOSYS;
  2308. }
  2309. int sysctl_intvec(ctl_table *table, int __user *name, int nlen,
  2310. void __user *oldval, size_t __user *oldlenp,
  2311. void __user *newval, size_t newlen, void **context)
  2312. {
  2313. return -ENOSYS;
  2314. }
  2315. int sysctl_jiffies(ctl_table *table, int __user *name, int nlen,
  2316. void __user *oldval, size_t __user *oldlenp,
  2317. void __user *newval, size_t newlen, void **context)
  2318. {
  2319. return -ENOSYS;
  2320. }
  2321. int sysctl_ms_jiffies(ctl_table *table, int __user *name, int nlen,
  2322. void __user *oldval, size_t __user *oldlenp,
  2323. void __user *newval, size_t newlen, void **context)
  2324. {
  2325. return -ENOSYS;
  2326. }
  2327. int proc_dostring(ctl_table *table, int write, struct file *filp,
  2328. void __user *buffer, size_t *lenp, loff_t *ppos)
  2329. {
  2330. return -ENOSYS;
  2331. }
  2332. int proc_dointvec(ctl_table *table, int write, struct file *filp,
  2333. void __user *buffer, size_t *lenp, loff_t *ppos)
  2334. {
  2335. return -ENOSYS;
  2336. }
  2337. int proc_dointvec_bset(ctl_table *table, int write, struct file *filp,
  2338. void __user *buffer, size_t *lenp, loff_t *ppos)
  2339. {
  2340. return -ENOSYS;
  2341. }
  2342. int proc_dointvec_minmax(ctl_table *table, int write, struct file *filp,
  2343. void __user *buffer, size_t *lenp, loff_t *ppos)
  2344. {
  2345. return -ENOSYS;
  2346. }
  2347. int proc_dointvec_jiffies(ctl_table *table, int write, struct file *filp,
  2348. void __user *buffer, size_t *lenp, loff_t *ppos)
  2349. {
  2350. return -ENOSYS;
  2351. }
  2352. int proc_dointvec_userhz_jiffies(ctl_table *table, int write, struct file *filp,
  2353. void __user *buffer, size_t *lenp, loff_t *ppos)
  2354. {
  2355. return -ENOSYS;
  2356. }
  2357. int proc_dointvec_ms_jiffies(ctl_table *table, int write, struct file *filp,
  2358. void __user *buffer, size_t *lenp, loff_t *ppos)
  2359. {
  2360. return -ENOSYS;
  2361. }
  2362. int proc_doulongvec_minmax(ctl_table *table, int write, struct file *filp,
  2363. void __user *buffer, size_t *lenp, loff_t *ppos)
  2364. {
  2365. return -ENOSYS;
  2366. }
  2367. int proc_doulongvec_ms_jiffies_minmax(ctl_table *table, int write,
  2368. struct file *filp,
  2369. void __user *buffer,
  2370. size_t *lenp, loff_t *ppos)
  2371. {
  2372. return -ENOSYS;
  2373. }
  2374. struct ctl_table_header * register_sysctl_table(ctl_table * table,
  2375. int insert_at_head)
  2376. {
  2377. return NULL;
  2378. }
  2379. void unregister_sysctl_table(struct ctl_table_header * table)
  2380. {
  2381. }
  2382. #endif /* CONFIG_SYSCTL */
  2383. /*
  2384. * No sense putting this after each symbol definition, twice,
  2385. * exception granted :-)
  2386. */
  2387. EXPORT_SYMBOL(proc_dointvec);
  2388. EXPORT_SYMBOL(proc_dointvec_jiffies);
  2389. EXPORT_SYMBOL(proc_dointvec_minmax);
  2390. EXPORT_SYMBOL(proc_dointvec_userhz_jiffies);
  2391. EXPORT_SYMBOL(proc_dointvec_ms_jiffies);
  2392. EXPORT_SYMBOL(proc_dostring);
  2393. EXPORT_SYMBOL(proc_doulongvec_minmax);
  2394. EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax);
  2395. EXPORT_SYMBOL(register_sysctl_table);
  2396. EXPORT_SYMBOL(sysctl_intvec);
  2397. EXPORT_SYMBOL(sysctl_jiffies);
  2398. EXPORT_SYMBOL(sysctl_ms_jiffies);
  2399. EXPORT_SYMBOL(sysctl_string);
  2400. EXPORT_SYMBOL(unregister_sysctl_table);