sysctl.c 60 KB

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