sysctl.c 61 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663
  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/security.h>
  27. #include <linux/ctype.h>
  28. #include <linux/kmemcheck.h>
  29. #include <linux/fs.h>
  30. #include <linux/init.h>
  31. #include <linux/kernel.h>
  32. #include <linux/kobject.h>
  33. #include <linux/net.h>
  34. #include <linux/sysrq.h>
  35. #include <linux/highuid.h>
  36. #include <linux/writeback.h>
  37. #include <linux/ratelimit.h>
  38. #include <linux/hugetlb.h>
  39. #include <linux/initrd.h>
  40. #include <linux/key.h>
  41. #include <linux/times.h>
  42. #include <linux/limits.h>
  43. #include <linux/dcache.h>
  44. #include <linux/syscalls.h>
  45. #include <linux/vmstat.h>
  46. #include <linux/nfs_fs.h>
  47. #include <linux/acpi.h>
  48. #include <linux/reboot.h>
  49. #include <linux/ftrace.h>
  50. #include <linux/slow-work.h>
  51. #include <linux/perf_event.h>
  52. #include <asm/uaccess.h>
  53. #include <asm/processor.h>
  54. #ifdef CONFIG_X86
  55. #include <asm/nmi.h>
  56. #include <asm/stacktrace.h>
  57. #include <asm/io.h>
  58. #endif
  59. #if defined(CONFIG_SYSCTL)
  60. /* External variables not in a header file. */
  61. extern int C_A_D;
  62. extern int print_fatal_signals;
  63. extern int sysctl_overcommit_memory;
  64. extern int sysctl_overcommit_ratio;
  65. extern int sysctl_panic_on_oom;
  66. extern int sysctl_oom_kill_allocating_task;
  67. extern int sysctl_oom_dump_tasks;
  68. extern int max_threads;
  69. extern int core_uses_pid;
  70. extern int suid_dumpable;
  71. extern char core_pattern[];
  72. extern unsigned int core_pipe_limit;
  73. extern int pid_max;
  74. extern int min_free_kbytes;
  75. extern int pid_max_min, pid_max_max;
  76. extern int sysctl_drop_caches;
  77. extern int percpu_pagelist_fraction;
  78. extern int compat_log;
  79. extern int latencytop_enabled;
  80. extern int sysctl_nr_open_min, sysctl_nr_open_max;
  81. #ifndef CONFIG_MMU
  82. extern int sysctl_nr_trim_pages;
  83. #endif
  84. #ifdef CONFIG_RCU_TORTURE_TEST
  85. extern int rcutorture_runnable;
  86. #endif /* #ifdef CONFIG_RCU_TORTURE_TEST */
  87. #ifdef CONFIG_BLOCK
  88. extern int blk_iopoll_enabled;
  89. #endif
  90. /* Constants used for minimum and maximum */
  91. #ifdef CONFIG_DETECT_SOFTLOCKUP
  92. static int sixty = 60;
  93. static int neg_one = -1;
  94. #endif
  95. static int zero;
  96. static int __maybe_unused one = 1;
  97. static int __maybe_unused two = 2;
  98. static unsigned long one_ul = 1;
  99. static int one_hundred = 100;
  100. #ifdef CONFIG_PRINTK
  101. static int ten_thousand = 10000;
  102. #endif
  103. /* this is needed for the proc_doulongvec_minmax of vm_dirty_bytes */
  104. static unsigned long dirty_bytes_min = 2 * PAGE_SIZE;
  105. /* this is needed for the proc_dointvec_minmax for [fs_]overflow UID and GID */
  106. static int maxolduid = 65535;
  107. static int minolduid;
  108. static int min_percpu_pagelist_fract = 8;
  109. static int ngroups_max = NGROUPS_MAX;
  110. #ifdef CONFIG_MODULES
  111. extern char modprobe_path[];
  112. extern int modules_disabled;
  113. #endif
  114. #ifdef CONFIG_CHR_DEV_SG
  115. extern int sg_big_buff;
  116. #endif
  117. #ifdef CONFIG_SPARC
  118. #include <asm/system.h>
  119. #endif
  120. #ifdef CONFIG_SPARC64
  121. extern int sysctl_tsb_ratio;
  122. #endif
  123. #ifdef __hppa__
  124. extern int pwrsw_enabled;
  125. extern int unaligned_enabled;
  126. #endif
  127. #ifdef CONFIG_S390
  128. #ifdef CONFIG_MATHEMU
  129. extern int sysctl_ieee_emulation_warnings;
  130. #endif
  131. extern int sysctl_userprocess_debug;
  132. extern int spin_retry;
  133. #endif
  134. #ifdef CONFIG_BSD_PROCESS_ACCT
  135. extern int acct_parm[];
  136. #endif
  137. #ifdef CONFIG_IA64
  138. extern int no_unaligned_warning;
  139. extern int unaligned_dump_stack;
  140. #endif
  141. extern struct ratelimit_state printk_ratelimit_state;
  142. #ifdef CONFIG_RT_MUTEXES
  143. extern int max_lock_depth;
  144. #endif
  145. #ifdef CONFIG_PROC_SYSCTL
  146. static int proc_do_cad_pid(struct ctl_table *table, int write,
  147. void __user *buffer, size_t *lenp, loff_t *ppos);
  148. static int proc_taint(struct ctl_table *table, int write,
  149. void __user *buffer, size_t *lenp, loff_t *ppos);
  150. #endif
  151. static struct ctl_table root_table[];
  152. static struct ctl_table_root sysctl_table_root;
  153. static struct ctl_table_header root_table_header = {
  154. .count = 1,
  155. .ctl_table = root_table,
  156. .ctl_entry = LIST_HEAD_INIT(sysctl_table_root.default_set.list),
  157. .root = &sysctl_table_root,
  158. .set = &sysctl_table_root.default_set,
  159. };
  160. static struct ctl_table_root sysctl_table_root = {
  161. .root_list = LIST_HEAD_INIT(sysctl_table_root.root_list),
  162. .default_set.list = LIST_HEAD_INIT(root_table_header.ctl_entry),
  163. };
  164. static struct ctl_table kern_table[];
  165. static struct ctl_table vm_table[];
  166. static struct ctl_table fs_table[];
  167. static struct ctl_table debug_table[];
  168. static struct ctl_table dev_table[];
  169. extern struct ctl_table random_table[];
  170. #ifdef CONFIG_INOTIFY_USER
  171. extern struct ctl_table inotify_table[];
  172. #endif
  173. #ifdef CONFIG_EPOLL
  174. extern struct ctl_table epoll_table[];
  175. #endif
  176. #ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
  177. int sysctl_legacy_va_layout;
  178. #endif
  179. extern int prove_locking;
  180. extern int lock_stat;
  181. /* The default sysctl tables: */
  182. static struct ctl_table root_table[] = {
  183. {
  184. .procname = "kernel",
  185. .mode = 0555,
  186. .child = kern_table,
  187. },
  188. {
  189. .procname = "vm",
  190. .mode = 0555,
  191. .child = vm_table,
  192. },
  193. {
  194. .procname = "fs",
  195. .mode = 0555,
  196. .child = fs_table,
  197. },
  198. {
  199. .procname = "debug",
  200. .mode = 0555,
  201. .child = debug_table,
  202. },
  203. {
  204. .procname = "dev",
  205. .mode = 0555,
  206. .child = dev_table,
  207. },
  208. /*
  209. * NOTE: do not add new entries to this table unless you have read
  210. * Documentation/sysctl/ctl_unnumbered.txt
  211. */
  212. { }
  213. };
  214. #ifdef CONFIG_SCHED_DEBUG
  215. static int min_sched_granularity_ns = 100000; /* 100 usecs */
  216. static int max_sched_granularity_ns = NSEC_PER_SEC; /* 1 second */
  217. static int min_wakeup_granularity_ns; /* 0 usecs */
  218. static int max_wakeup_granularity_ns = NSEC_PER_SEC; /* 1 second */
  219. static int min_sched_tunable_scaling = SCHED_TUNABLESCALING_NONE;
  220. static int max_sched_tunable_scaling = SCHED_TUNABLESCALING_END-1;
  221. static int min_sched_shares_ratelimit = 100000; /* 100 usec */
  222. static int max_sched_shares_ratelimit = NSEC_PER_SEC; /* 1 second */
  223. #endif
  224. static struct ctl_table kern_table[] = {
  225. {
  226. .procname = "sched_child_runs_first",
  227. .data = &sysctl_sched_child_runs_first,
  228. .maxlen = sizeof(unsigned int),
  229. .mode = 0644,
  230. .proc_handler = proc_dointvec,
  231. },
  232. #ifdef CONFIG_SCHED_DEBUG
  233. {
  234. .procname = "sched_min_granularity_ns",
  235. .data = &sysctl_sched_min_granularity,
  236. .maxlen = sizeof(unsigned int),
  237. .mode = 0644,
  238. .proc_handler = sched_proc_update_handler,
  239. .extra1 = &min_sched_granularity_ns,
  240. .extra2 = &max_sched_granularity_ns,
  241. },
  242. {
  243. .procname = "sched_latency_ns",
  244. .data = &sysctl_sched_latency,
  245. .maxlen = sizeof(unsigned int),
  246. .mode = 0644,
  247. .proc_handler = sched_proc_update_handler,
  248. .extra1 = &min_sched_granularity_ns,
  249. .extra2 = &max_sched_granularity_ns,
  250. },
  251. {
  252. .procname = "sched_wakeup_granularity_ns",
  253. .data = &sysctl_sched_wakeup_granularity,
  254. .maxlen = sizeof(unsigned int),
  255. .mode = 0644,
  256. .proc_handler = sched_proc_update_handler,
  257. .extra1 = &min_wakeup_granularity_ns,
  258. .extra2 = &max_wakeup_granularity_ns,
  259. },
  260. {
  261. .procname = "sched_shares_ratelimit",
  262. .data = &sysctl_sched_shares_ratelimit,
  263. .maxlen = sizeof(unsigned int),
  264. .mode = 0644,
  265. .proc_handler = sched_proc_update_handler,
  266. .extra1 = &min_sched_shares_ratelimit,
  267. .extra2 = &max_sched_shares_ratelimit,
  268. },
  269. {
  270. .procname = "sched_tunable_scaling",
  271. .data = &sysctl_sched_tunable_scaling,
  272. .maxlen = sizeof(enum sched_tunable_scaling),
  273. .mode = 0644,
  274. .proc_handler = sched_proc_update_handler,
  275. .extra1 = &min_sched_tunable_scaling,
  276. .extra2 = &max_sched_tunable_scaling,
  277. },
  278. {
  279. .procname = "sched_shares_thresh",
  280. .data = &sysctl_sched_shares_thresh,
  281. .maxlen = sizeof(unsigned int),
  282. .mode = 0644,
  283. .proc_handler = proc_dointvec_minmax,
  284. .extra1 = &zero,
  285. },
  286. {
  287. .procname = "sched_migration_cost",
  288. .data = &sysctl_sched_migration_cost,
  289. .maxlen = sizeof(unsigned int),
  290. .mode = 0644,
  291. .proc_handler = proc_dointvec,
  292. },
  293. {
  294. .procname = "sched_nr_migrate",
  295. .data = &sysctl_sched_nr_migrate,
  296. .maxlen = sizeof(unsigned int),
  297. .mode = 0644,
  298. .proc_handler = proc_dointvec,
  299. },
  300. {
  301. .procname = "sched_time_avg",
  302. .data = &sysctl_sched_time_avg,
  303. .maxlen = sizeof(unsigned int),
  304. .mode = 0644,
  305. .proc_handler = proc_dointvec,
  306. },
  307. {
  308. .procname = "timer_migration",
  309. .data = &sysctl_timer_migration,
  310. .maxlen = sizeof(unsigned int),
  311. .mode = 0644,
  312. .proc_handler = proc_dointvec_minmax,
  313. .extra1 = &zero,
  314. .extra2 = &one,
  315. },
  316. #endif
  317. {
  318. .procname = "sched_rt_period_us",
  319. .data = &sysctl_sched_rt_period,
  320. .maxlen = sizeof(unsigned int),
  321. .mode = 0644,
  322. .proc_handler = sched_rt_handler,
  323. },
  324. {
  325. .procname = "sched_rt_runtime_us",
  326. .data = &sysctl_sched_rt_runtime,
  327. .maxlen = sizeof(int),
  328. .mode = 0644,
  329. .proc_handler = sched_rt_handler,
  330. },
  331. {
  332. .procname = "sched_compat_yield",
  333. .data = &sysctl_sched_compat_yield,
  334. .maxlen = sizeof(unsigned int),
  335. .mode = 0644,
  336. .proc_handler = proc_dointvec,
  337. },
  338. #ifdef CONFIG_PROVE_LOCKING
  339. {
  340. .procname = "prove_locking",
  341. .data = &prove_locking,
  342. .maxlen = sizeof(int),
  343. .mode = 0644,
  344. .proc_handler = proc_dointvec,
  345. },
  346. #endif
  347. #ifdef CONFIG_LOCK_STAT
  348. {
  349. .procname = "lock_stat",
  350. .data = &lock_stat,
  351. .maxlen = sizeof(int),
  352. .mode = 0644,
  353. .proc_handler = proc_dointvec,
  354. },
  355. #endif
  356. {
  357. .procname = "panic",
  358. .data = &panic_timeout,
  359. .maxlen = sizeof(int),
  360. .mode = 0644,
  361. .proc_handler = proc_dointvec,
  362. },
  363. {
  364. .procname = "core_uses_pid",
  365. .data = &core_uses_pid,
  366. .maxlen = sizeof(int),
  367. .mode = 0644,
  368. .proc_handler = proc_dointvec,
  369. },
  370. {
  371. .procname = "core_pattern",
  372. .data = core_pattern,
  373. .maxlen = CORENAME_MAX_SIZE,
  374. .mode = 0644,
  375. .proc_handler = proc_dostring,
  376. },
  377. {
  378. .procname = "core_pipe_limit",
  379. .data = &core_pipe_limit,
  380. .maxlen = sizeof(unsigned int),
  381. .mode = 0644,
  382. .proc_handler = proc_dointvec,
  383. },
  384. #ifdef CONFIG_PROC_SYSCTL
  385. {
  386. .procname = "tainted",
  387. .maxlen = sizeof(long),
  388. .mode = 0644,
  389. .proc_handler = proc_taint,
  390. },
  391. #endif
  392. #ifdef CONFIG_LATENCYTOP
  393. {
  394. .procname = "latencytop",
  395. .data = &latencytop_enabled,
  396. .maxlen = sizeof(int),
  397. .mode = 0644,
  398. .proc_handler = proc_dointvec,
  399. },
  400. #endif
  401. #ifdef CONFIG_BLK_DEV_INITRD
  402. {
  403. .procname = "real-root-dev",
  404. .data = &real_root_dev,
  405. .maxlen = sizeof(int),
  406. .mode = 0644,
  407. .proc_handler = proc_dointvec,
  408. },
  409. #endif
  410. {
  411. .procname = "print-fatal-signals",
  412. .data = &print_fatal_signals,
  413. .maxlen = sizeof(int),
  414. .mode = 0644,
  415. .proc_handler = proc_dointvec,
  416. },
  417. #ifdef CONFIG_SPARC
  418. {
  419. .procname = "reboot-cmd",
  420. .data = reboot_command,
  421. .maxlen = 256,
  422. .mode = 0644,
  423. .proc_handler = proc_dostring,
  424. },
  425. {
  426. .procname = "stop-a",
  427. .data = &stop_a_enabled,
  428. .maxlen = sizeof (int),
  429. .mode = 0644,
  430. .proc_handler = proc_dointvec,
  431. },
  432. {
  433. .procname = "scons-poweroff",
  434. .data = &scons_pwroff,
  435. .maxlen = sizeof (int),
  436. .mode = 0644,
  437. .proc_handler = proc_dointvec,
  438. },
  439. #endif
  440. #ifdef CONFIG_SPARC64
  441. {
  442. .procname = "tsb-ratio",
  443. .data = &sysctl_tsb_ratio,
  444. .maxlen = sizeof (int),
  445. .mode = 0644,
  446. .proc_handler = proc_dointvec,
  447. },
  448. #endif
  449. #ifdef __hppa__
  450. {
  451. .procname = "soft-power",
  452. .data = &pwrsw_enabled,
  453. .maxlen = sizeof (int),
  454. .mode = 0644,
  455. .proc_handler = proc_dointvec,
  456. },
  457. {
  458. .procname = "unaligned-trap",
  459. .data = &unaligned_enabled,
  460. .maxlen = sizeof (int),
  461. .mode = 0644,
  462. .proc_handler = proc_dointvec,
  463. },
  464. #endif
  465. {
  466. .procname = "ctrl-alt-del",
  467. .data = &C_A_D,
  468. .maxlen = sizeof(int),
  469. .mode = 0644,
  470. .proc_handler = proc_dointvec,
  471. },
  472. #ifdef CONFIG_FUNCTION_TRACER
  473. {
  474. .procname = "ftrace_enabled",
  475. .data = &ftrace_enabled,
  476. .maxlen = sizeof(int),
  477. .mode = 0644,
  478. .proc_handler = ftrace_enable_sysctl,
  479. },
  480. #endif
  481. #ifdef CONFIG_STACK_TRACER
  482. {
  483. .procname = "stack_tracer_enabled",
  484. .data = &stack_tracer_enabled,
  485. .maxlen = sizeof(int),
  486. .mode = 0644,
  487. .proc_handler = stack_trace_sysctl,
  488. },
  489. #endif
  490. #ifdef CONFIG_TRACING
  491. {
  492. .procname = "ftrace_dump_on_oops",
  493. .data = &ftrace_dump_on_oops,
  494. .maxlen = sizeof(int),
  495. .mode = 0644,
  496. .proc_handler = proc_dointvec,
  497. },
  498. #endif
  499. #ifdef CONFIG_MODULES
  500. {
  501. .procname = "modprobe",
  502. .data = &modprobe_path,
  503. .maxlen = KMOD_PATH_LEN,
  504. .mode = 0644,
  505. .proc_handler = proc_dostring,
  506. },
  507. {
  508. .procname = "modules_disabled",
  509. .data = &modules_disabled,
  510. .maxlen = sizeof(int),
  511. .mode = 0644,
  512. /* only handle a transition from default "0" to "1" */
  513. .proc_handler = proc_dointvec_minmax,
  514. .extra1 = &one,
  515. .extra2 = &one,
  516. },
  517. #endif
  518. #if defined(CONFIG_HOTPLUG) && defined(CONFIG_NET)
  519. {
  520. .procname = "hotplug",
  521. .data = &uevent_helper,
  522. .maxlen = UEVENT_HELPER_PATH_LEN,
  523. .mode = 0644,
  524. .proc_handler = proc_dostring,
  525. },
  526. #endif
  527. #ifdef CONFIG_CHR_DEV_SG
  528. {
  529. .procname = "sg-big-buff",
  530. .data = &sg_big_buff,
  531. .maxlen = sizeof (int),
  532. .mode = 0444,
  533. .proc_handler = proc_dointvec,
  534. },
  535. #endif
  536. #ifdef CONFIG_BSD_PROCESS_ACCT
  537. {
  538. .procname = "acct",
  539. .data = &acct_parm,
  540. .maxlen = 3*sizeof(int),
  541. .mode = 0644,
  542. .proc_handler = proc_dointvec,
  543. },
  544. #endif
  545. #ifdef CONFIG_MAGIC_SYSRQ
  546. {
  547. .procname = "sysrq",
  548. .data = &__sysrq_enabled,
  549. .maxlen = sizeof (int),
  550. .mode = 0644,
  551. .proc_handler = proc_dointvec,
  552. },
  553. #endif
  554. #ifdef CONFIG_PROC_SYSCTL
  555. {
  556. .procname = "cad_pid",
  557. .data = NULL,
  558. .maxlen = sizeof (int),
  559. .mode = 0600,
  560. .proc_handler = proc_do_cad_pid,
  561. },
  562. #endif
  563. {
  564. .procname = "threads-max",
  565. .data = &max_threads,
  566. .maxlen = sizeof(int),
  567. .mode = 0644,
  568. .proc_handler = proc_dointvec,
  569. },
  570. {
  571. .procname = "random",
  572. .mode = 0555,
  573. .child = random_table,
  574. },
  575. {
  576. .procname = "overflowuid",
  577. .data = &overflowuid,
  578. .maxlen = sizeof(int),
  579. .mode = 0644,
  580. .proc_handler = proc_dointvec_minmax,
  581. .extra1 = &minolduid,
  582. .extra2 = &maxolduid,
  583. },
  584. {
  585. .procname = "overflowgid",
  586. .data = &overflowgid,
  587. .maxlen = sizeof(int),
  588. .mode = 0644,
  589. .proc_handler = proc_dointvec_minmax,
  590. .extra1 = &minolduid,
  591. .extra2 = &maxolduid,
  592. },
  593. #ifdef CONFIG_S390
  594. #ifdef CONFIG_MATHEMU
  595. {
  596. .procname = "ieee_emulation_warnings",
  597. .data = &sysctl_ieee_emulation_warnings,
  598. .maxlen = sizeof(int),
  599. .mode = 0644,
  600. .proc_handler = proc_dointvec,
  601. },
  602. #endif
  603. {
  604. .procname = "userprocess_debug",
  605. .data = &sysctl_userprocess_debug,
  606. .maxlen = sizeof(int),
  607. .mode = 0644,
  608. .proc_handler = proc_dointvec,
  609. },
  610. #endif
  611. {
  612. .procname = "pid_max",
  613. .data = &pid_max,
  614. .maxlen = sizeof (int),
  615. .mode = 0644,
  616. .proc_handler = proc_dointvec_minmax,
  617. .extra1 = &pid_max_min,
  618. .extra2 = &pid_max_max,
  619. },
  620. {
  621. .procname = "panic_on_oops",
  622. .data = &panic_on_oops,
  623. .maxlen = sizeof(int),
  624. .mode = 0644,
  625. .proc_handler = proc_dointvec,
  626. },
  627. #if defined CONFIG_PRINTK
  628. {
  629. .procname = "printk",
  630. .data = &console_loglevel,
  631. .maxlen = 4*sizeof(int),
  632. .mode = 0644,
  633. .proc_handler = proc_dointvec,
  634. },
  635. {
  636. .procname = "printk_ratelimit",
  637. .data = &printk_ratelimit_state.interval,
  638. .maxlen = sizeof(int),
  639. .mode = 0644,
  640. .proc_handler = proc_dointvec_jiffies,
  641. },
  642. {
  643. .procname = "printk_ratelimit_burst",
  644. .data = &printk_ratelimit_state.burst,
  645. .maxlen = sizeof(int),
  646. .mode = 0644,
  647. .proc_handler = proc_dointvec,
  648. },
  649. {
  650. .procname = "printk_delay",
  651. .data = &printk_delay_msec,
  652. .maxlen = sizeof(int),
  653. .mode = 0644,
  654. .proc_handler = proc_dointvec_minmax,
  655. .extra1 = &zero,
  656. .extra2 = &ten_thousand,
  657. },
  658. #endif
  659. {
  660. .procname = "ngroups_max",
  661. .data = &ngroups_max,
  662. .maxlen = sizeof (int),
  663. .mode = 0444,
  664. .proc_handler = proc_dointvec,
  665. },
  666. #if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86)
  667. {
  668. .procname = "unknown_nmi_panic",
  669. .data = &unknown_nmi_panic,
  670. .maxlen = sizeof (int),
  671. .mode = 0644,
  672. .proc_handler = proc_dointvec,
  673. },
  674. {
  675. .procname = "nmi_watchdog",
  676. .data = &nmi_watchdog_enabled,
  677. .maxlen = sizeof (int),
  678. .mode = 0644,
  679. .proc_handler = proc_nmi_enabled,
  680. },
  681. #endif
  682. #if defined(CONFIG_X86)
  683. {
  684. .procname = "panic_on_unrecovered_nmi",
  685. .data = &panic_on_unrecovered_nmi,
  686. .maxlen = sizeof(int),
  687. .mode = 0644,
  688. .proc_handler = proc_dointvec,
  689. },
  690. {
  691. .procname = "panic_on_io_nmi",
  692. .data = &panic_on_io_nmi,
  693. .maxlen = sizeof(int),
  694. .mode = 0644,
  695. .proc_handler = proc_dointvec,
  696. },
  697. {
  698. .procname = "bootloader_type",
  699. .data = &bootloader_type,
  700. .maxlen = sizeof (int),
  701. .mode = 0444,
  702. .proc_handler = proc_dointvec,
  703. },
  704. {
  705. .procname = "bootloader_version",
  706. .data = &bootloader_version,
  707. .maxlen = sizeof (int),
  708. .mode = 0444,
  709. .proc_handler = proc_dointvec,
  710. },
  711. {
  712. .procname = "kstack_depth_to_print",
  713. .data = &kstack_depth_to_print,
  714. .maxlen = sizeof(int),
  715. .mode = 0644,
  716. .proc_handler = proc_dointvec,
  717. },
  718. {
  719. .procname = "io_delay_type",
  720. .data = &io_delay_type,
  721. .maxlen = sizeof(int),
  722. .mode = 0644,
  723. .proc_handler = proc_dointvec,
  724. },
  725. #endif
  726. #if defined(CONFIG_MMU)
  727. {
  728. .procname = "randomize_va_space",
  729. .data = &randomize_va_space,
  730. .maxlen = sizeof(int),
  731. .mode = 0644,
  732. .proc_handler = proc_dointvec,
  733. },
  734. #endif
  735. #if defined(CONFIG_S390) && defined(CONFIG_SMP)
  736. {
  737. .procname = "spin_retry",
  738. .data = &spin_retry,
  739. .maxlen = sizeof (int),
  740. .mode = 0644,
  741. .proc_handler = proc_dointvec,
  742. },
  743. #endif
  744. #if defined(CONFIG_ACPI_SLEEP) && defined(CONFIG_X86)
  745. {
  746. .procname = "acpi_video_flags",
  747. .data = &acpi_realmode_flags,
  748. .maxlen = sizeof (unsigned long),
  749. .mode = 0644,
  750. .proc_handler = proc_doulongvec_minmax,
  751. },
  752. #endif
  753. #ifdef CONFIG_IA64
  754. {
  755. .procname = "ignore-unaligned-usertrap",
  756. .data = &no_unaligned_warning,
  757. .maxlen = sizeof (int),
  758. .mode = 0644,
  759. .proc_handler = proc_dointvec,
  760. },
  761. {
  762. .procname = "unaligned-dump-stack",
  763. .data = &unaligned_dump_stack,
  764. .maxlen = sizeof (int),
  765. .mode = 0644,
  766. .proc_handler = proc_dointvec,
  767. },
  768. #endif
  769. #ifdef CONFIG_DETECT_SOFTLOCKUP
  770. {
  771. .procname = "softlockup_panic",
  772. .data = &softlockup_panic,
  773. .maxlen = sizeof(int),
  774. .mode = 0644,
  775. .proc_handler = proc_dointvec_minmax,
  776. .extra1 = &zero,
  777. .extra2 = &one,
  778. },
  779. {
  780. .procname = "softlockup_thresh",
  781. .data = &softlockup_thresh,
  782. .maxlen = sizeof(int),
  783. .mode = 0644,
  784. .proc_handler = proc_dosoftlockup_thresh,
  785. .extra1 = &neg_one,
  786. .extra2 = &sixty,
  787. },
  788. #endif
  789. #ifdef CONFIG_DETECT_HUNG_TASK
  790. {
  791. .procname = "hung_task_panic",
  792. .data = &sysctl_hung_task_panic,
  793. .maxlen = sizeof(int),
  794. .mode = 0644,
  795. .proc_handler = proc_dointvec_minmax,
  796. .extra1 = &zero,
  797. .extra2 = &one,
  798. },
  799. {
  800. .procname = "hung_task_check_count",
  801. .data = &sysctl_hung_task_check_count,
  802. .maxlen = sizeof(unsigned long),
  803. .mode = 0644,
  804. .proc_handler = proc_doulongvec_minmax,
  805. },
  806. {
  807. .procname = "hung_task_timeout_secs",
  808. .data = &sysctl_hung_task_timeout_secs,
  809. .maxlen = sizeof(unsigned long),
  810. .mode = 0644,
  811. .proc_handler = proc_dohung_task_timeout_secs,
  812. },
  813. {
  814. .procname = "hung_task_warnings",
  815. .data = &sysctl_hung_task_warnings,
  816. .maxlen = sizeof(unsigned long),
  817. .mode = 0644,
  818. .proc_handler = proc_doulongvec_minmax,
  819. },
  820. #endif
  821. #ifdef CONFIG_COMPAT
  822. {
  823. .procname = "compat-log",
  824. .data = &compat_log,
  825. .maxlen = sizeof (int),
  826. .mode = 0644,
  827. .proc_handler = proc_dointvec,
  828. },
  829. #endif
  830. #ifdef CONFIG_RT_MUTEXES
  831. {
  832. .procname = "max_lock_depth",
  833. .data = &max_lock_depth,
  834. .maxlen = sizeof(int),
  835. .mode = 0644,
  836. .proc_handler = proc_dointvec,
  837. },
  838. #endif
  839. {
  840. .procname = "poweroff_cmd",
  841. .data = &poweroff_cmd,
  842. .maxlen = POWEROFF_CMD_PATH_LEN,
  843. .mode = 0644,
  844. .proc_handler = proc_dostring,
  845. },
  846. #ifdef CONFIG_KEYS
  847. {
  848. .procname = "keys",
  849. .mode = 0555,
  850. .child = key_sysctls,
  851. },
  852. #endif
  853. #ifdef CONFIG_RCU_TORTURE_TEST
  854. {
  855. .procname = "rcutorture_runnable",
  856. .data = &rcutorture_runnable,
  857. .maxlen = sizeof(int),
  858. .mode = 0644,
  859. .proc_handler = proc_dointvec,
  860. },
  861. #endif
  862. #ifdef CONFIG_SLOW_WORK
  863. {
  864. .procname = "slow-work",
  865. .mode = 0555,
  866. .child = slow_work_sysctls,
  867. },
  868. #endif
  869. #ifdef CONFIG_PERF_EVENTS
  870. {
  871. .procname = "perf_event_paranoid",
  872. .data = &sysctl_perf_event_paranoid,
  873. .maxlen = sizeof(sysctl_perf_event_paranoid),
  874. .mode = 0644,
  875. .proc_handler = proc_dointvec,
  876. },
  877. {
  878. .procname = "perf_event_mlock_kb",
  879. .data = &sysctl_perf_event_mlock,
  880. .maxlen = sizeof(sysctl_perf_event_mlock),
  881. .mode = 0644,
  882. .proc_handler = proc_dointvec,
  883. },
  884. {
  885. .procname = "perf_event_max_sample_rate",
  886. .data = &sysctl_perf_event_sample_rate,
  887. .maxlen = sizeof(sysctl_perf_event_sample_rate),
  888. .mode = 0644,
  889. .proc_handler = proc_dointvec,
  890. },
  891. #endif
  892. #ifdef CONFIG_KMEMCHECK
  893. {
  894. .procname = "kmemcheck",
  895. .data = &kmemcheck_enabled,
  896. .maxlen = sizeof(int),
  897. .mode = 0644,
  898. .proc_handler = proc_dointvec,
  899. },
  900. #endif
  901. #ifdef CONFIG_BLOCK
  902. {
  903. .procname = "blk_iopoll",
  904. .data = &blk_iopoll_enabled,
  905. .maxlen = sizeof(int),
  906. .mode = 0644,
  907. .proc_handler = proc_dointvec,
  908. },
  909. #endif
  910. /*
  911. * NOTE: do not add new entries to this table unless you have read
  912. * Documentation/sysctl/ctl_unnumbered.txt
  913. */
  914. { }
  915. };
  916. static struct ctl_table vm_table[] = {
  917. {
  918. .procname = "overcommit_memory",
  919. .data = &sysctl_overcommit_memory,
  920. .maxlen = sizeof(sysctl_overcommit_memory),
  921. .mode = 0644,
  922. .proc_handler = proc_dointvec,
  923. },
  924. {
  925. .procname = "panic_on_oom",
  926. .data = &sysctl_panic_on_oom,
  927. .maxlen = sizeof(sysctl_panic_on_oom),
  928. .mode = 0644,
  929. .proc_handler = proc_dointvec,
  930. },
  931. {
  932. .procname = "oom_kill_allocating_task",
  933. .data = &sysctl_oom_kill_allocating_task,
  934. .maxlen = sizeof(sysctl_oom_kill_allocating_task),
  935. .mode = 0644,
  936. .proc_handler = proc_dointvec,
  937. },
  938. {
  939. .procname = "oom_dump_tasks",
  940. .data = &sysctl_oom_dump_tasks,
  941. .maxlen = sizeof(sysctl_oom_dump_tasks),
  942. .mode = 0644,
  943. .proc_handler = proc_dointvec,
  944. },
  945. {
  946. .procname = "overcommit_ratio",
  947. .data = &sysctl_overcommit_ratio,
  948. .maxlen = sizeof(sysctl_overcommit_ratio),
  949. .mode = 0644,
  950. .proc_handler = proc_dointvec,
  951. },
  952. {
  953. .procname = "page-cluster",
  954. .data = &page_cluster,
  955. .maxlen = sizeof(int),
  956. .mode = 0644,
  957. .proc_handler = proc_dointvec,
  958. },
  959. {
  960. .procname = "dirty_background_ratio",
  961. .data = &dirty_background_ratio,
  962. .maxlen = sizeof(dirty_background_ratio),
  963. .mode = 0644,
  964. .proc_handler = dirty_background_ratio_handler,
  965. .extra1 = &zero,
  966. .extra2 = &one_hundred,
  967. },
  968. {
  969. .procname = "dirty_background_bytes",
  970. .data = &dirty_background_bytes,
  971. .maxlen = sizeof(dirty_background_bytes),
  972. .mode = 0644,
  973. .proc_handler = dirty_background_bytes_handler,
  974. .extra1 = &one_ul,
  975. },
  976. {
  977. .procname = "dirty_ratio",
  978. .data = &vm_dirty_ratio,
  979. .maxlen = sizeof(vm_dirty_ratio),
  980. .mode = 0644,
  981. .proc_handler = dirty_ratio_handler,
  982. .extra1 = &zero,
  983. .extra2 = &one_hundred,
  984. },
  985. {
  986. .procname = "dirty_bytes",
  987. .data = &vm_dirty_bytes,
  988. .maxlen = sizeof(vm_dirty_bytes),
  989. .mode = 0644,
  990. .proc_handler = dirty_bytes_handler,
  991. .extra1 = &dirty_bytes_min,
  992. },
  993. {
  994. .procname = "dirty_writeback_centisecs",
  995. .data = &dirty_writeback_interval,
  996. .maxlen = sizeof(dirty_writeback_interval),
  997. .mode = 0644,
  998. .proc_handler = dirty_writeback_centisecs_handler,
  999. },
  1000. {
  1001. .procname = "dirty_expire_centisecs",
  1002. .data = &dirty_expire_interval,
  1003. .maxlen = sizeof(dirty_expire_interval),
  1004. .mode = 0644,
  1005. .proc_handler = proc_dointvec,
  1006. },
  1007. {
  1008. .procname = "nr_pdflush_threads",
  1009. .data = &nr_pdflush_threads,
  1010. .maxlen = sizeof nr_pdflush_threads,
  1011. .mode = 0444 /* read-only*/,
  1012. .proc_handler = proc_dointvec,
  1013. },
  1014. {
  1015. .procname = "swappiness",
  1016. .data = &vm_swappiness,
  1017. .maxlen = sizeof(vm_swappiness),
  1018. .mode = 0644,
  1019. .proc_handler = proc_dointvec_minmax,
  1020. .extra1 = &zero,
  1021. .extra2 = &one_hundred,
  1022. },
  1023. #ifdef CONFIG_HUGETLB_PAGE
  1024. {
  1025. .procname = "nr_hugepages",
  1026. .data = NULL,
  1027. .maxlen = sizeof(unsigned long),
  1028. .mode = 0644,
  1029. .proc_handler = hugetlb_sysctl_handler,
  1030. .extra1 = (void *)&hugetlb_zero,
  1031. .extra2 = (void *)&hugetlb_infinity,
  1032. },
  1033. {
  1034. .procname = "hugetlb_shm_group",
  1035. .data = &sysctl_hugetlb_shm_group,
  1036. .maxlen = sizeof(gid_t),
  1037. .mode = 0644,
  1038. .proc_handler = proc_dointvec,
  1039. },
  1040. {
  1041. .procname = "hugepages_treat_as_movable",
  1042. .data = &hugepages_treat_as_movable,
  1043. .maxlen = sizeof(int),
  1044. .mode = 0644,
  1045. .proc_handler = hugetlb_treat_movable_handler,
  1046. },
  1047. {
  1048. .procname = "nr_overcommit_hugepages",
  1049. .data = NULL,
  1050. .maxlen = sizeof(unsigned long),
  1051. .mode = 0644,
  1052. .proc_handler = hugetlb_overcommit_handler,
  1053. .extra1 = (void *)&hugetlb_zero,
  1054. .extra2 = (void *)&hugetlb_infinity,
  1055. },
  1056. #endif
  1057. {
  1058. .procname = "lowmem_reserve_ratio",
  1059. .data = &sysctl_lowmem_reserve_ratio,
  1060. .maxlen = sizeof(sysctl_lowmem_reserve_ratio),
  1061. .mode = 0644,
  1062. .proc_handler = lowmem_reserve_ratio_sysctl_handler,
  1063. },
  1064. {
  1065. .procname = "drop_caches",
  1066. .data = &sysctl_drop_caches,
  1067. .maxlen = sizeof(int),
  1068. .mode = 0644,
  1069. .proc_handler = drop_caches_sysctl_handler,
  1070. },
  1071. {
  1072. .procname = "min_free_kbytes",
  1073. .data = &min_free_kbytes,
  1074. .maxlen = sizeof(min_free_kbytes),
  1075. .mode = 0644,
  1076. .proc_handler = min_free_kbytes_sysctl_handler,
  1077. .extra1 = &zero,
  1078. },
  1079. {
  1080. .procname = "percpu_pagelist_fraction",
  1081. .data = &percpu_pagelist_fraction,
  1082. .maxlen = sizeof(percpu_pagelist_fraction),
  1083. .mode = 0644,
  1084. .proc_handler = percpu_pagelist_fraction_sysctl_handler,
  1085. .extra1 = &min_percpu_pagelist_fract,
  1086. },
  1087. #ifdef CONFIG_MMU
  1088. {
  1089. .procname = "max_map_count",
  1090. .data = &sysctl_max_map_count,
  1091. .maxlen = sizeof(sysctl_max_map_count),
  1092. .mode = 0644,
  1093. .proc_handler = proc_dointvec
  1094. },
  1095. #else
  1096. {
  1097. .procname = "nr_trim_pages",
  1098. .data = &sysctl_nr_trim_pages,
  1099. .maxlen = sizeof(sysctl_nr_trim_pages),
  1100. .mode = 0644,
  1101. .proc_handler = proc_dointvec_minmax,
  1102. .extra1 = &zero,
  1103. },
  1104. #endif
  1105. {
  1106. .procname = "laptop_mode",
  1107. .data = &laptop_mode,
  1108. .maxlen = sizeof(laptop_mode),
  1109. .mode = 0644,
  1110. .proc_handler = proc_dointvec_jiffies,
  1111. },
  1112. {
  1113. .procname = "block_dump",
  1114. .data = &block_dump,
  1115. .maxlen = sizeof(block_dump),
  1116. .mode = 0644,
  1117. .proc_handler = proc_dointvec,
  1118. .extra1 = &zero,
  1119. },
  1120. {
  1121. .procname = "vfs_cache_pressure",
  1122. .data = &sysctl_vfs_cache_pressure,
  1123. .maxlen = sizeof(sysctl_vfs_cache_pressure),
  1124. .mode = 0644,
  1125. .proc_handler = proc_dointvec,
  1126. .extra1 = &zero,
  1127. },
  1128. #ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
  1129. {
  1130. .procname = "legacy_va_layout",
  1131. .data = &sysctl_legacy_va_layout,
  1132. .maxlen = sizeof(sysctl_legacy_va_layout),
  1133. .mode = 0644,
  1134. .proc_handler = proc_dointvec,
  1135. .extra1 = &zero,
  1136. },
  1137. #endif
  1138. #ifdef CONFIG_NUMA
  1139. {
  1140. .procname = "zone_reclaim_mode",
  1141. .data = &zone_reclaim_mode,
  1142. .maxlen = sizeof(zone_reclaim_mode),
  1143. .mode = 0644,
  1144. .proc_handler = proc_dointvec,
  1145. .extra1 = &zero,
  1146. },
  1147. {
  1148. .procname = "min_unmapped_ratio",
  1149. .data = &sysctl_min_unmapped_ratio,
  1150. .maxlen = sizeof(sysctl_min_unmapped_ratio),
  1151. .mode = 0644,
  1152. .proc_handler = sysctl_min_unmapped_ratio_sysctl_handler,
  1153. .extra1 = &zero,
  1154. .extra2 = &one_hundred,
  1155. },
  1156. {
  1157. .procname = "min_slab_ratio",
  1158. .data = &sysctl_min_slab_ratio,
  1159. .maxlen = sizeof(sysctl_min_slab_ratio),
  1160. .mode = 0644,
  1161. .proc_handler = sysctl_min_slab_ratio_sysctl_handler,
  1162. .extra1 = &zero,
  1163. .extra2 = &one_hundred,
  1164. },
  1165. #endif
  1166. #ifdef CONFIG_SMP
  1167. {
  1168. .procname = "stat_interval",
  1169. .data = &sysctl_stat_interval,
  1170. .maxlen = sizeof(sysctl_stat_interval),
  1171. .mode = 0644,
  1172. .proc_handler = proc_dointvec_jiffies,
  1173. },
  1174. #endif
  1175. {
  1176. .procname = "mmap_min_addr",
  1177. .data = &dac_mmap_min_addr,
  1178. .maxlen = sizeof(unsigned long),
  1179. .mode = 0644,
  1180. .proc_handler = mmap_min_addr_handler,
  1181. },
  1182. #ifdef CONFIG_NUMA
  1183. {
  1184. .procname = "numa_zonelist_order",
  1185. .data = &numa_zonelist_order,
  1186. .maxlen = NUMA_ZONELIST_ORDER_LEN,
  1187. .mode = 0644,
  1188. .proc_handler = numa_zonelist_order_handler,
  1189. },
  1190. #endif
  1191. #if (defined(CONFIG_X86_32) && !defined(CONFIG_UML))|| \
  1192. (defined(CONFIG_SUPERH) && defined(CONFIG_VSYSCALL))
  1193. {
  1194. .procname = "vdso_enabled",
  1195. .data = &vdso_enabled,
  1196. .maxlen = sizeof(vdso_enabled),
  1197. .mode = 0644,
  1198. .proc_handler = proc_dointvec,
  1199. .extra1 = &zero,
  1200. },
  1201. #endif
  1202. #ifdef CONFIG_HIGHMEM
  1203. {
  1204. .procname = "highmem_is_dirtyable",
  1205. .data = &vm_highmem_is_dirtyable,
  1206. .maxlen = sizeof(vm_highmem_is_dirtyable),
  1207. .mode = 0644,
  1208. .proc_handler = proc_dointvec_minmax,
  1209. .extra1 = &zero,
  1210. .extra2 = &one,
  1211. },
  1212. #endif
  1213. {
  1214. .procname = "scan_unevictable_pages",
  1215. .data = &scan_unevictable_pages,
  1216. .maxlen = sizeof(scan_unevictable_pages),
  1217. .mode = 0644,
  1218. .proc_handler = scan_unevictable_handler,
  1219. },
  1220. #ifdef CONFIG_MEMORY_FAILURE
  1221. {
  1222. .procname = "memory_failure_early_kill",
  1223. .data = &sysctl_memory_failure_early_kill,
  1224. .maxlen = sizeof(sysctl_memory_failure_early_kill),
  1225. .mode = 0644,
  1226. .proc_handler = proc_dointvec_minmax,
  1227. .extra1 = &zero,
  1228. .extra2 = &one,
  1229. },
  1230. {
  1231. .procname = "memory_failure_recovery",
  1232. .data = &sysctl_memory_failure_recovery,
  1233. .maxlen = sizeof(sysctl_memory_failure_recovery),
  1234. .mode = 0644,
  1235. .proc_handler = proc_dointvec_minmax,
  1236. .extra1 = &zero,
  1237. .extra2 = &one,
  1238. },
  1239. #endif
  1240. /*
  1241. * NOTE: do not add new entries to this table unless you have read
  1242. * Documentation/sysctl/ctl_unnumbered.txt
  1243. */
  1244. { }
  1245. };
  1246. #if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE)
  1247. static struct ctl_table binfmt_misc_table[] = {
  1248. { }
  1249. };
  1250. #endif
  1251. static struct ctl_table fs_table[] = {
  1252. {
  1253. .procname = "inode-nr",
  1254. .data = &inodes_stat,
  1255. .maxlen = 2*sizeof(int),
  1256. .mode = 0444,
  1257. .proc_handler = proc_dointvec,
  1258. },
  1259. {
  1260. .procname = "inode-state",
  1261. .data = &inodes_stat,
  1262. .maxlen = 7*sizeof(int),
  1263. .mode = 0444,
  1264. .proc_handler = proc_dointvec,
  1265. },
  1266. {
  1267. .procname = "file-nr",
  1268. .data = &files_stat,
  1269. .maxlen = 3*sizeof(int),
  1270. .mode = 0444,
  1271. .proc_handler = proc_nr_files,
  1272. },
  1273. {
  1274. .procname = "file-max",
  1275. .data = &files_stat.max_files,
  1276. .maxlen = sizeof(int),
  1277. .mode = 0644,
  1278. .proc_handler = proc_dointvec,
  1279. },
  1280. {
  1281. .procname = "nr_open",
  1282. .data = &sysctl_nr_open,
  1283. .maxlen = sizeof(int),
  1284. .mode = 0644,
  1285. .proc_handler = proc_dointvec_minmax,
  1286. .extra1 = &sysctl_nr_open_min,
  1287. .extra2 = &sysctl_nr_open_max,
  1288. },
  1289. {
  1290. .procname = "dentry-state",
  1291. .data = &dentry_stat,
  1292. .maxlen = 6*sizeof(int),
  1293. .mode = 0444,
  1294. .proc_handler = proc_dointvec,
  1295. },
  1296. {
  1297. .procname = "overflowuid",
  1298. .data = &fs_overflowuid,
  1299. .maxlen = sizeof(int),
  1300. .mode = 0644,
  1301. .proc_handler = proc_dointvec_minmax,
  1302. .extra1 = &minolduid,
  1303. .extra2 = &maxolduid,
  1304. },
  1305. {
  1306. .procname = "overflowgid",
  1307. .data = &fs_overflowgid,
  1308. .maxlen = sizeof(int),
  1309. .mode = 0644,
  1310. .proc_handler = proc_dointvec_minmax,
  1311. .extra1 = &minolduid,
  1312. .extra2 = &maxolduid,
  1313. },
  1314. #ifdef CONFIG_FILE_LOCKING
  1315. {
  1316. .procname = "leases-enable",
  1317. .data = &leases_enable,
  1318. .maxlen = sizeof(int),
  1319. .mode = 0644,
  1320. .proc_handler = proc_dointvec,
  1321. },
  1322. #endif
  1323. #ifdef CONFIG_DNOTIFY
  1324. {
  1325. .procname = "dir-notify-enable",
  1326. .data = &dir_notify_enable,
  1327. .maxlen = sizeof(int),
  1328. .mode = 0644,
  1329. .proc_handler = proc_dointvec,
  1330. },
  1331. #endif
  1332. #ifdef CONFIG_MMU
  1333. #ifdef CONFIG_FILE_LOCKING
  1334. {
  1335. .procname = "lease-break-time",
  1336. .data = &lease_break_time,
  1337. .maxlen = sizeof(int),
  1338. .mode = 0644,
  1339. .proc_handler = proc_dointvec,
  1340. },
  1341. #endif
  1342. #ifdef CONFIG_AIO
  1343. {
  1344. .procname = "aio-nr",
  1345. .data = &aio_nr,
  1346. .maxlen = sizeof(aio_nr),
  1347. .mode = 0444,
  1348. .proc_handler = proc_doulongvec_minmax,
  1349. },
  1350. {
  1351. .procname = "aio-max-nr",
  1352. .data = &aio_max_nr,
  1353. .maxlen = sizeof(aio_max_nr),
  1354. .mode = 0644,
  1355. .proc_handler = proc_doulongvec_minmax,
  1356. },
  1357. #endif /* CONFIG_AIO */
  1358. #ifdef CONFIG_INOTIFY_USER
  1359. {
  1360. .procname = "inotify",
  1361. .mode = 0555,
  1362. .child = inotify_table,
  1363. },
  1364. #endif
  1365. #ifdef CONFIG_EPOLL
  1366. {
  1367. .procname = "epoll",
  1368. .mode = 0555,
  1369. .child = epoll_table,
  1370. },
  1371. #endif
  1372. #endif
  1373. {
  1374. .procname = "suid_dumpable",
  1375. .data = &suid_dumpable,
  1376. .maxlen = sizeof(int),
  1377. .mode = 0644,
  1378. .proc_handler = proc_dointvec_minmax,
  1379. .extra1 = &zero,
  1380. .extra2 = &two,
  1381. },
  1382. #if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE)
  1383. {
  1384. .procname = "binfmt_misc",
  1385. .mode = 0555,
  1386. .child = binfmt_misc_table,
  1387. },
  1388. #endif
  1389. /*
  1390. * NOTE: do not add new entries to this table unless you have read
  1391. * Documentation/sysctl/ctl_unnumbered.txt
  1392. */
  1393. { }
  1394. };
  1395. static struct ctl_table debug_table[] = {
  1396. #if defined(CONFIG_X86) || defined(CONFIG_PPC)
  1397. {
  1398. .procname = "exception-trace",
  1399. .data = &show_unhandled_signals,
  1400. .maxlen = sizeof(int),
  1401. .mode = 0644,
  1402. .proc_handler = proc_dointvec
  1403. },
  1404. #endif
  1405. { }
  1406. };
  1407. static struct ctl_table dev_table[] = {
  1408. { }
  1409. };
  1410. static DEFINE_SPINLOCK(sysctl_lock);
  1411. /* called under sysctl_lock */
  1412. static int use_table(struct ctl_table_header *p)
  1413. {
  1414. if (unlikely(p->unregistering))
  1415. return 0;
  1416. p->used++;
  1417. return 1;
  1418. }
  1419. /* called under sysctl_lock */
  1420. static void unuse_table(struct ctl_table_header *p)
  1421. {
  1422. if (!--p->used)
  1423. if (unlikely(p->unregistering))
  1424. complete(p->unregistering);
  1425. }
  1426. /* called under sysctl_lock, will reacquire if has to wait */
  1427. static void start_unregistering(struct ctl_table_header *p)
  1428. {
  1429. /*
  1430. * if p->used is 0, nobody will ever touch that entry again;
  1431. * we'll eliminate all paths to it before dropping sysctl_lock
  1432. */
  1433. if (unlikely(p->used)) {
  1434. struct completion wait;
  1435. init_completion(&wait);
  1436. p->unregistering = &wait;
  1437. spin_unlock(&sysctl_lock);
  1438. wait_for_completion(&wait);
  1439. spin_lock(&sysctl_lock);
  1440. } else {
  1441. /* anything non-NULL; we'll never dereference it */
  1442. p->unregistering = ERR_PTR(-EINVAL);
  1443. }
  1444. /*
  1445. * do not remove from the list until nobody holds it; walking the
  1446. * list in do_sysctl() relies on that.
  1447. */
  1448. list_del_init(&p->ctl_entry);
  1449. }
  1450. void sysctl_head_get(struct ctl_table_header *head)
  1451. {
  1452. spin_lock(&sysctl_lock);
  1453. head->count++;
  1454. spin_unlock(&sysctl_lock);
  1455. }
  1456. void sysctl_head_put(struct ctl_table_header *head)
  1457. {
  1458. spin_lock(&sysctl_lock);
  1459. if (!--head->count)
  1460. kfree(head);
  1461. spin_unlock(&sysctl_lock);
  1462. }
  1463. struct ctl_table_header *sysctl_head_grab(struct ctl_table_header *head)
  1464. {
  1465. if (!head)
  1466. BUG();
  1467. spin_lock(&sysctl_lock);
  1468. if (!use_table(head))
  1469. head = ERR_PTR(-ENOENT);
  1470. spin_unlock(&sysctl_lock);
  1471. return head;
  1472. }
  1473. void sysctl_head_finish(struct ctl_table_header *head)
  1474. {
  1475. if (!head)
  1476. return;
  1477. spin_lock(&sysctl_lock);
  1478. unuse_table(head);
  1479. spin_unlock(&sysctl_lock);
  1480. }
  1481. static struct ctl_table_set *
  1482. lookup_header_set(struct ctl_table_root *root, struct nsproxy *namespaces)
  1483. {
  1484. struct ctl_table_set *set = &root->default_set;
  1485. if (root->lookup)
  1486. set = root->lookup(root, namespaces);
  1487. return set;
  1488. }
  1489. static struct list_head *
  1490. lookup_header_list(struct ctl_table_root *root, struct nsproxy *namespaces)
  1491. {
  1492. struct ctl_table_set *set = lookup_header_set(root, namespaces);
  1493. return &set->list;
  1494. }
  1495. struct ctl_table_header *__sysctl_head_next(struct nsproxy *namespaces,
  1496. struct ctl_table_header *prev)
  1497. {
  1498. struct ctl_table_root *root;
  1499. struct list_head *header_list;
  1500. struct ctl_table_header *head;
  1501. struct list_head *tmp;
  1502. spin_lock(&sysctl_lock);
  1503. if (prev) {
  1504. head = prev;
  1505. tmp = &prev->ctl_entry;
  1506. unuse_table(prev);
  1507. goto next;
  1508. }
  1509. tmp = &root_table_header.ctl_entry;
  1510. for (;;) {
  1511. head = list_entry(tmp, struct ctl_table_header, ctl_entry);
  1512. if (!use_table(head))
  1513. goto next;
  1514. spin_unlock(&sysctl_lock);
  1515. return head;
  1516. next:
  1517. root = head->root;
  1518. tmp = tmp->next;
  1519. header_list = lookup_header_list(root, namespaces);
  1520. if (tmp != header_list)
  1521. continue;
  1522. do {
  1523. root = list_entry(root->root_list.next,
  1524. struct ctl_table_root, root_list);
  1525. if (root == &sysctl_table_root)
  1526. goto out;
  1527. header_list = lookup_header_list(root, namespaces);
  1528. } while (list_empty(header_list));
  1529. tmp = header_list->next;
  1530. }
  1531. out:
  1532. spin_unlock(&sysctl_lock);
  1533. return NULL;
  1534. }
  1535. struct ctl_table_header *sysctl_head_next(struct ctl_table_header *prev)
  1536. {
  1537. return __sysctl_head_next(current->nsproxy, prev);
  1538. }
  1539. void register_sysctl_root(struct ctl_table_root *root)
  1540. {
  1541. spin_lock(&sysctl_lock);
  1542. list_add_tail(&root->root_list, &sysctl_table_root.root_list);
  1543. spin_unlock(&sysctl_lock);
  1544. }
  1545. /*
  1546. * sysctl_perm does NOT grant the superuser all rights automatically, because
  1547. * some sysctl variables are readonly even to root.
  1548. */
  1549. static int test_perm(int mode, int op)
  1550. {
  1551. if (!current_euid())
  1552. mode >>= 6;
  1553. else if (in_egroup_p(0))
  1554. mode >>= 3;
  1555. if ((op & ~mode & (MAY_READ|MAY_WRITE|MAY_EXEC)) == 0)
  1556. return 0;
  1557. return -EACCES;
  1558. }
  1559. int sysctl_perm(struct ctl_table_root *root, struct ctl_table *table, int op)
  1560. {
  1561. int error;
  1562. int mode;
  1563. error = security_sysctl(table, op & (MAY_READ | MAY_WRITE | MAY_EXEC));
  1564. if (error)
  1565. return error;
  1566. if (root->permissions)
  1567. mode = root->permissions(root, current->nsproxy, table);
  1568. else
  1569. mode = table->mode;
  1570. return test_perm(mode, op);
  1571. }
  1572. static void sysctl_set_parent(struct ctl_table *parent, struct ctl_table *table)
  1573. {
  1574. for (; table->procname; table++) {
  1575. table->parent = parent;
  1576. if (table->child)
  1577. sysctl_set_parent(table, table->child);
  1578. }
  1579. }
  1580. static __init int sysctl_init(void)
  1581. {
  1582. sysctl_set_parent(NULL, root_table);
  1583. #ifdef CONFIG_SYSCTL_SYSCALL_CHECK
  1584. {
  1585. int err;
  1586. err = sysctl_check_table(current->nsproxy, root_table);
  1587. }
  1588. #endif
  1589. return 0;
  1590. }
  1591. core_initcall(sysctl_init);
  1592. static struct ctl_table *is_branch_in(struct ctl_table *branch,
  1593. struct ctl_table *table)
  1594. {
  1595. struct ctl_table *p;
  1596. const char *s = branch->procname;
  1597. /* branch should have named subdirectory as its first element */
  1598. if (!s || !branch->child)
  1599. return NULL;
  1600. /* ... and nothing else */
  1601. if (branch[1].procname)
  1602. return NULL;
  1603. /* table should contain subdirectory with the same name */
  1604. for (p = table; p->procname; p++) {
  1605. if (!p->child)
  1606. continue;
  1607. if (p->procname && strcmp(p->procname, s) == 0)
  1608. return p;
  1609. }
  1610. return NULL;
  1611. }
  1612. /* see if attaching q to p would be an improvement */
  1613. static void try_attach(struct ctl_table_header *p, struct ctl_table_header *q)
  1614. {
  1615. struct ctl_table *to = p->ctl_table, *by = q->ctl_table;
  1616. struct ctl_table *next;
  1617. int is_better = 0;
  1618. int not_in_parent = !p->attached_by;
  1619. while ((next = is_branch_in(by, to)) != NULL) {
  1620. if (by == q->attached_by)
  1621. is_better = 1;
  1622. if (to == p->attached_by)
  1623. not_in_parent = 1;
  1624. by = by->child;
  1625. to = next->child;
  1626. }
  1627. if (is_better && not_in_parent) {
  1628. q->attached_by = by;
  1629. q->attached_to = to;
  1630. q->parent = p;
  1631. }
  1632. }
  1633. /**
  1634. * __register_sysctl_paths - register a sysctl hierarchy
  1635. * @root: List of sysctl headers to register on
  1636. * @namespaces: Data to compute which lists of sysctl entries are visible
  1637. * @path: The path to the directory the sysctl table is in.
  1638. * @table: the top-level table structure
  1639. *
  1640. * Register a sysctl table hierarchy. @table should be a filled in ctl_table
  1641. * array. A completely 0 filled entry terminates the table.
  1642. *
  1643. * The members of the &struct ctl_table structure are used as follows:
  1644. *
  1645. * procname - the name of the sysctl file under /proc/sys. Set to %NULL to not
  1646. * enter a sysctl file
  1647. *
  1648. * data - a pointer to data for use by proc_handler
  1649. *
  1650. * maxlen - the maximum size in bytes of the data
  1651. *
  1652. * mode - the file permissions for the /proc/sys file, and for sysctl(2)
  1653. *
  1654. * child - a pointer to the child sysctl table if this entry is a directory, or
  1655. * %NULL.
  1656. *
  1657. * proc_handler - the text handler routine (described below)
  1658. *
  1659. * de - for internal use by the sysctl routines
  1660. *
  1661. * extra1, extra2 - extra pointers usable by the proc handler routines
  1662. *
  1663. * Leaf nodes in the sysctl tree will be represented by a single file
  1664. * under /proc; non-leaf nodes will be represented by directories.
  1665. *
  1666. * sysctl(2) can automatically manage read and write requests through
  1667. * the sysctl table. The data and maxlen fields of the ctl_table
  1668. * struct enable minimal validation of the values being written to be
  1669. * performed, and the mode field allows minimal authentication.
  1670. *
  1671. * There must be a proc_handler routine for any terminal nodes
  1672. * mirrored under /proc/sys (non-terminals are handled by a built-in
  1673. * directory handler). Several default handlers are available to
  1674. * cover common cases -
  1675. *
  1676. * proc_dostring(), proc_dointvec(), proc_dointvec_jiffies(),
  1677. * proc_dointvec_userhz_jiffies(), proc_dointvec_minmax(),
  1678. * proc_doulongvec_ms_jiffies_minmax(), proc_doulongvec_minmax()
  1679. *
  1680. * It is the handler's job to read the input buffer from user memory
  1681. * and process it. The handler should return 0 on success.
  1682. *
  1683. * This routine returns %NULL on a failure to register, and a pointer
  1684. * to the table header on success.
  1685. */
  1686. struct ctl_table_header *__register_sysctl_paths(
  1687. struct ctl_table_root *root,
  1688. struct nsproxy *namespaces,
  1689. const struct ctl_path *path, struct ctl_table *table)
  1690. {
  1691. struct ctl_table_header *header;
  1692. struct ctl_table *new, **prevp;
  1693. unsigned int n, npath;
  1694. struct ctl_table_set *set;
  1695. /* Count the path components */
  1696. for (npath = 0; path[npath].procname; ++npath)
  1697. ;
  1698. /*
  1699. * For each path component, allocate a 2-element ctl_table array.
  1700. * The first array element will be filled with the sysctl entry
  1701. * for this, the second will be the sentinel (procname == 0).
  1702. *
  1703. * We allocate everything in one go so that we don't have to
  1704. * worry about freeing additional memory in unregister_sysctl_table.
  1705. */
  1706. header = kzalloc(sizeof(struct ctl_table_header) +
  1707. (2 * npath * sizeof(struct ctl_table)), GFP_KERNEL);
  1708. if (!header)
  1709. return NULL;
  1710. new = (struct ctl_table *) (header + 1);
  1711. /* Now connect the dots */
  1712. prevp = &header->ctl_table;
  1713. for (n = 0; n < npath; ++n, ++path) {
  1714. /* Copy the procname */
  1715. new->procname = path->procname;
  1716. new->mode = 0555;
  1717. *prevp = new;
  1718. prevp = &new->child;
  1719. new += 2;
  1720. }
  1721. *prevp = table;
  1722. header->ctl_table_arg = table;
  1723. INIT_LIST_HEAD(&header->ctl_entry);
  1724. header->used = 0;
  1725. header->unregistering = NULL;
  1726. header->root = root;
  1727. sysctl_set_parent(NULL, header->ctl_table);
  1728. header->count = 1;
  1729. #ifdef CONFIG_SYSCTL_SYSCALL_CHECK
  1730. if (sysctl_check_table(namespaces, header->ctl_table)) {
  1731. kfree(header);
  1732. return NULL;
  1733. }
  1734. #endif
  1735. spin_lock(&sysctl_lock);
  1736. header->set = lookup_header_set(root, namespaces);
  1737. header->attached_by = header->ctl_table;
  1738. header->attached_to = root_table;
  1739. header->parent = &root_table_header;
  1740. for (set = header->set; set; set = set->parent) {
  1741. struct ctl_table_header *p;
  1742. list_for_each_entry(p, &set->list, ctl_entry) {
  1743. if (p->unregistering)
  1744. continue;
  1745. try_attach(p, header);
  1746. }
  1747. }
  1748. header->parent->count++;
  1749. list_add_tail(&header->ctl_entry, &header->set->list);
  1750. spin_unlock(&sysctl_lock);
  1751. return header;
  1752. }
  1753. /**
  1754. * register_sysctl_table_path - register a sysctl table hierarchy
  1755. * @path: The path to the directory the sysctl table is in.
  1756. * @table: the top-level table structure
  1757. *
  1758. * Register a sysctl table hierarchy. @table should be a filled in ctl_table
  1759. * array. A completely 0 filled entry terminates the table.
  1760. *
  1761. * See __register_sysctl_paths for more details.
  1762. */
  1763. struct ctl_table_header *register_sysctl_paths(const struct ctl_path *path,
  1764. struct ctl_table *table)
  1765. {
  1766. return __register_sysctl_paths(&sysctl_table_root, current->nsproxy,
  1767. path, table);
  1768. }
  1769. /**
  1770. * register_sysctl_table - register a sysctl table hierarchy
  1771. * @table: the top-level table structure
  1772. *
  1773. * Register a sysctl table hierarchy. @table should be a filled in ctl_table
  1774. * array. A completely 0 filled entry terminates the table.
  1775. *
  1776. * See register_sysctl_paths for more details.
  1777. */
  1778. struct ctl_table_header *register_sysctl_table(struct ctl_table *table)
  1779. {
  1780. static const struct ctl_path null_path[] = { {} };
  1781. return register_sysctl_paths(null_path, table);
  1782. }
  1783. /**
  1784. * unregister_sysctl_table - unregister a sysctl table hierarchy
  1785. * @header: the header returned from register_sysctl_table
  1786. *
  1787. * Unregisters the sysctl table and all children. proc entries may not
  1788. * actually be removed until they are no longer used by anyone.
  1789. */
  1790. void unregister_sysctl_table(struct ctl_table_header * header)
  1791. {
  1792. might_sleep();
  1793. if (header == NULL)
  1794. return;
  1795. spin_lock(&sysctl_lock);
  1796. start_unregistering(header);
  1797. if (!--header->parent->count) {
  1798. WARN_ON(1);
  1799. kfree(header->parent);
  1800. }
  1801. if (!--header->count)
  1802. kfree(header);
  1803. spin_unlock(&sysctl_lock);
  1804. }
  1805. int sysctl_is_seen(struct ctl_table_header *p)
  1806. {
  1807. struct ctl_table_set *set = p->set;
  1808. int res;
  1809. spin_lock(&sysctl_lock);
  1810. if (p->unregistering)
  1811. res = 0;
  1812. else if (!set->is_seen)
  1813. res = 1;
  1814. else
  1815. res = set->is_seen(set);
  1816. spin_unlock(&sysctl_lock);
  1817. return res;
  1818. }
  1819. void setup_sysctl_set(struct ctl_table_set *p,
  1820. struct ctl_table_set *parent,
  1821. int (*is_seen)(struct ctl_table_set *))
  1822. {
  1823. INIT_LIST_HEAD(&p->list);
  1824. p->parent = parent ? parent : &sysctl_table_root.default_set;
  1825. p->is_seen = is_seen;
  1826. }
  1827. #else /* !CONFIG_SYSCTL */
  1828. struct ctl_table_header *register_sysctl_table(struct ctl_table * table)
  1829. {
  1830. return NULL;
  1831. }
  1832. struct ctl_table_header *register_sysctl_paths(const struct ctl_path *path,
  1833. struct ctl_table *table)
  1834. {
  1835. return NULL;
  1836. }
  1837. void unregister_sysctl_table(struct ctl_table_header * table)
  1838. {
  1839. }
  1840. void setup_sysctl_set(struct ctl_table_set *p,
  1841. struct ctl_table_set *parent,
  1842. int (*is_seen)(struct ctl_table_set *))
  1843. {
  1844. }
  1845. void sysctl_head_put(struct ctl_table_header *head)
  1846. {
  1847. }
  1848. #endif /* CONFIG_SYSCTL */
  1849. /*
  1850. * /proc/sys support
  1851. */
  1852. #ifdef CONFIG_PROC_SYSCTL
  1853. static int _proc_do_string(void* data, int maxlen, int write,
  1854. void __user *buffer,
  1855. size_t *lenp, loff_t *ppos)
  1856. {
  1857. size_t len;
  1858. char __user *p;
  1859. char c;
  1860. if (!data || !maxlen || !*lenp) {
  1861. *lenp = 0;
  1862. return 0;
  1863. }
  1864. if (write) {
  1865. len = 0;
  1866. p = buffer;
  1867. while (len < *lenp) {
  1868. if (get_user(c, p++))
  1869. return -EFAULT;
  1870. if (c == 0 || c == '\n')
  1871. break;
  1872. len++;
  1873. }
  1874. if (len >= maxlen)
  1875. len = maxlen-1;
  1876. if(copy_from_user(data, buffer, len))
  1877. return -EFAULT;
  1878. ((char *) data)[len] = 0;
  1879. *ppos += *lenp;
  1880. } else {
  1881. len = strlen(data);
  1882. if (len > maxlen)
  1883. len = maxlen;
  1884. if (*ppos > len) {
  1885. *lenp = 0;
  1886. return 0;
  1887. }
  1888. data += *ppos;
  1889. len -= *ppos;
  1890. if (len > *lenp)
  1891. len = *lenp;
  1892. if (len)
  1893. if(copy_to_user(buffer, data, len))
  1894. return -EFAULT;
  1895. if (len < *lenp) {
  1896. if(put_user('\n', ((char __user *) buffer) + len))
  1897. return -EFAULT;
  1898. len++;
  1899. }
  1900. *lenp = len;
  1901. *ppos += len;
  1902. }
  1903. return 0;
  1904. }
  1905. /**
  1906. * proc_dostring - read a string sysctl
  1907. * @table: the sysctl table
  1908. * @write: %TRUE if this is a write to the sysctl file
  1909. * @buffer: the user buffer
  1910. * @lenp: the size of the user buffer
  1911. * @ppos: file position
  1912. *
  1913. * Reads/writes a string from/to the user buffer. If the kernel
  1914. * buffer provided is not large enough to hold the string, the
  1915. * string is truncated. The copied string is %NULL-terminated.
  1916. * If the string is being read by the user process, it is copied
  1917. * and a newline '\n' is added. It is truncated if the buffer is
  1918. * not large enough.
  1919. *
  1920. * Returns 0 on success.
  1921. */
  1922. int proc_dostring(struct ctl_table *table, int write,
  1923. void __user *buffer, size_t *lenp, loff_t *ppos)
  1924. {
  1925. return _proc_do_string(table->data, table->maxlen, write,
  1926. buffer, lenp, ppos);
  1927. }
  1928. static int do_proc_dointvec_conv(int *negp, unsigned long *lvalp,
  1929. int *valp,
  1930. int write, void *data)
  1931. {
  1932. if (write) {
  1933. *valp = *negp ? -*lvalp : *lvalp;
  1934. } else {
  1935. int val = *valp;
  1936. if (val < 0) {
  1937. *negp = -1;
  1938. *lvalp = (unsigned long)-val;
  1939. } else {
  1940. *negp = 0;
  1941. *lvalp = (unsigned long)val;
  1942. }
  1943. }
  1944. return 0;
  1945. }
  1946. static int __do_proc_dointvec(void *tbl_data, struct ctl_table *table,
  1947. int write, void __user *buffer,
  1948. size_t *lenp, loff_t *ppos,
  1949. int (*conv)(int *negp, unsigned long *lvalp, int *valp,
  1950. int write, void *data),
  1951. void *data)
  1952. {
  1953. #define TMPBUFLEN 21
  1954. int *i, vleft, first = 1, neg;
  1955. unsigned long lval;
  1956. size_t left, len;
  1957. char buf[TMPBUFLEN], *p;
  1958. char __user *s = buffer;
  1959. if (!tbl_data || !table->maxlen || !*lenp ||
  1960. (*ppos && !write)) {
  1961. *lenp = 0;
  1962. return 0;
  1963. }
  1964. i = (int *) tbl_data;
  1965. vleft = table->maxlen / sizeof(*i);
  1966. left = *lenp;
  1967. if (!conv)
  1968. conv = do_proc_dointvec_conv;
  1969. for (; left && vleft--; i++, first=0) {
  1970. if (write) {
  1971. while (left) {
  1972. char c;
  1973. if (get_user(c, s))
  1974. return -EFAULT;
  1975. if (!isspace(c))
  1976. break;
  1977. left--;
  1978. s++;
  1979. }
  1980. if (!left)
  1981. break;
  1982. neg = 0;
  1983. len = left;
  1984. if (len > sizeof(buf) - 1)
  1985. len = sizeof(buf) - 1;
  1986. if (copy_from_user(buf, s, len))
  1987. return -EFAULT;
  1988. buf[len] = 0;
  1989. p = buf;
  1990. if (*p == '-' && left > 1) {
  1991. neg = 1;
  1992. p++;
  1993. }
  1994. if (*p < '0' || *p > '9')
  1995. break;
  1996. lval = simple_strtoul(p, &p, 0);
  1997. len = p-buf;
  1998. if ((len < left) && *p && !isspace(*p))
  1999. break;
  2000. s += len;
  2001. left -= len;
  2002. if (conv(&neg, &lval, i, 1, data))
  2003. break;
  2004. } else {
  2005. p = buf;
  2006. if (!first)
  2007. *p++ = '\t';
  2008. if (conv(&neg, &lval, i, 0, data))
  2009. break;
  2010. sprintf(p, "%s%lu", neg ? "-" : "", lval);
  2011. len = strlen(buf);
  2012. if (len > left)
  2013. len = left;
  2014. if(copy_to_user(s, buf, len))
  2015. return -EFAULT;
  2016. left -= len;
  2017. s += len;
  2018. }
  2019. }
  2020. if (!write && !first && left) {
  2021. if(put_user('\n', s))
  2022. return -EFAULT;
  2023. left--, s++;
  2024. }
  2025. if (write) {
  2026. while (left) {
  2027. char c;
  2028. if (get_user(c, s++))
  2029. return -EFAULT;
  2030. if (!isspace(c))
  2031. break;
  2032. left--;
  2033. }
  2034. }
  2035. if (write && first)
  2036. return -EINVAL;
  2037. *lenp -= left;
  2038. *ppos += *lenp;
  2039. return 0;
  2040. #undef TMPBUFLEN
  2041. }
  2042. static int do_proc_dointvec(struct ctl_table *table, int write,
  2043. void __user *buffer, size_t *lenp, loff_t *ppos,
  2044. int (*conv)(int *negp, unsigned long *lvalp, int *valp,
  2045. int write, void *data),
  2046. void *data)
  2047. {
  2048. return __do_proc_dointvec(table->data, table, write,
  2049. buffer, lenp, ppos, conv, data);
  2050. }
  2051. /**
  2052. * proc_dointvec - read a vector of integers
  2053. * @table: the sysctl table
  2054. * @write: %TRUE if this is a write to the sysctl file
  2055. * @buffer: the user buffer
  2056. * @lenp: the size of the user buffer
  2057. * @ppos: file position
  2058. *
  2059. * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
  2060. * values from/to the user buffer, treated as an ASCII string.
  2061. *
  2062. * Returns 0 on success.
  2063. */
  2064. int proc_dointvec(struct ctl_table *table, int write,
  2065. void __user *buffer, size_t *lenp, loff_t *ppos)
  2066. {
  2067. return do_proc_dointvec(table,write,buffer,lenp,ppos,
  2068. NULL,NULL);
  2069. }
  2070. /*
  2071. * Taint values can only be increased
  2072. * This means we can safely use a temporary.
  2073. */
  2074. static int proc_taint(struct ctl_table *table, int write,
  2075. void __user *buffer, size_t *lenp, loff_t *ppos)
  2076. {
  2077. struct ctl_table t;
  2078. unsigned long tmptaint = get_taint();
  2079. int err;
  2080. if (write && !capable(CAP_SYS_ADMIN))
  2081. return -EPERM;
  2082. t = *table;
  2083. t.data = &tmptaint;
  2084. err = proc_doulongvec_minmax(&t, write, buffer, lenp, ppos);
  2085. if (err < 0)
  2086. return err;
  2087. if (write) {
  2088. /*
  2089. * Poor man's atomic or. Not worth adding a primitive
  2090. * to everyone's atomic.h for this
  2091. */
  2092. int i;
  2093. for (i = 0; i < BITS_PER_LONG && tmptaint >> i; i++) {
  2094. if ((tmptaint >> i) & 1)
  2095. add_taint(i);
  2096. }
  2097. }
  2098. return err;
  2099. }
  2100. struct do_proc_dointvec_minmax_conv_param {
  2101. int *min;
  2102. int *max;
  2103. };
  2104. static int do_proc_dointvec_minmax_conv(int *negp, unsigned long *lvalp,
  2105. int *valp,
  2106. int write, void *data)
  2107. {
  2108. struct do_proc_dointvec_minmax_conv_param *param = data;
  2109. if (write) {
  2110. int val = *negp ? -*lvalp : *lvalp;
  2111. if ((param->min && *param->min > val) ||
  2112. (param->max && *param->max < val))
  2113. return -EINVAL;
  2114. *valp = val;
  2115. } else {
  2116. int val = *valp;
  2117. if (val < 0) {
  2118. *negp = -1;
  2119. *lvalp = (unsigned long)-val;
  2120. } else {
  2121. *negp = 0;
  2122. *lvalp = (unsigned long)val;
  2123. }
  2124. }
  2125. return 0;
  2126. }
  2127. /**
  2128. * proc_dointvec_minmax - read a vector of integers with min/max values
  2129. * @table: the sysctl table
  2130. * @write: %TRUE if this is a write to the sysctl file
  2131. * @buffer: the user buffer
  2132. * @lenp: the size of the user buffer
  2133. * @ppos: file position
  2134. *
  2135. * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
  2136. * values from/to the user buffer, treated as an ASCII string.
  2137. *
  2138. * This routine will ensure the values are within the range specified by
  2139. * table->extra1 (min) and table->extra2 (max).
  2140. *
  2141. * Returns 0 on success.
  2142. */
  2143. int proc_dointvec_minmax(struct ctl_table *table, int write,
  2144. void __user *buffer, size_t *lenp, loff_t *ppos)
  2145. {
  2146. struct do_proc_dointvec_minmax_conv_param param = {
  2147. .min = (int *) table->extra1,
  2148. .max = (int *) table->extra2,
  2149. };
  2150. return do_proc_dointvec(table, write, buffer, lenp, ppos,
  2151. do_proc_dointvec_minmax_conv, &param);
  2152. }
  2153. static int __do_proc_doulongvec_minmax(void *data, struct ctl_table *table, int write,
  2154. void __user *buffer,
  2155. size_t *lenp, loff_t *ppos,
  2156. unsigned long convmul,
  2157. unsigned long convdiv)
  2158. {
  2159. #define TMPBUFLEN 21
  2160. unsigned long *i, *min, *max, val;
  2161. int vleft, first=1, neg;
  2162. size_t len, left;
  2163. char buf[TMPBUFLEN], *p;
  2164. char __user *s = buffer;
  2165. if (!data || !table->maxlen || !*lenp ||
  2166. (*ppos && !write)) {
  2167. *lenp = 0;
  2168. return 0;
  2169. }
  2170. i = (unsigned long *) data;
  2171. min = (unsigned long *) table->extra1;
  2172. max = (unsigned long *) table->extra2;
  2173. vleft = table->maxlen / sizeof(unsigned long);
  2174. left = *lenp;
  2175. for (; left && vleft--; i++, min++, max++, first=0) {
  2176. if (write) {
  2177. while (left) {
  2178. char c;
  2179. if (get_user(c, s))
  2180. return -EFAULT;
  2181. if (!isspace(c))
  2182. break;
  2183. left--;
  2184. s++;
  2185. }
  2186. if (!left)
  2187. break;
  2188. neg = 0;
  2189. len = left;
  2190. if (len > TMPBUFLEN-1)
  2191. len = TMPBUFLEN-1;
  2192. if (copy_from_user(buf, s, len))
  2193. return -EFAULT;
  2194. buf[len] = 0;
  2195. p = buf;
  2196. if (*p == '-' && left > 1) {
  2197. neg = 1;
  2198. p++;
  2199. }
  2200. if (*p < '0' || *p > '9')
  2201. break;
  2202. val = simple_strtoul(p, &p, 0) * convmul / convdiv ;
  2203. len = p-buf;
  2204. if ((len < left) && *p && !isspace(*p))
  2205. break;
  2206. if (neg)
  2207. val = -val;
  2208. s += len;
  2209. left -= len;
  2210. if(neg)
  2211. continue;
  2212. if ((min && val < *min) || (max && val > *max))
  2213. continue;
  2214. *i = val;
  2215. } else {
  2216. p = buf;
  2217. if (!first)
  2218. *p++ = '\t';
  2219. sprintf(p, "%lu", convdiv * (*i) / convmul);
  2220. len = strlen(buf);
  2221. if (len > left)
  2222. len = left;
  2223. if(copy_to_user(s, buf, len))
  2224. return -EFAULT;
  2225. left -= len;
  2226. s += len;
  2227. }
  2228. }
  2229. if (!write && !first && left) {
  2230. if(put_user('\n', s))
  2231. return -EFAULT;
  2232. left--, s++;
  2233. }
  2234. if (write) {
  2235. while (left) {
  2236. char c;
  2237. if (get_user(c, s++))
  2238. return -EFAULT;
  2239. if (!isspace(c))
  2240. break;
  2241. left--;
  2242. }
  2243. }
  2244. if (write && first)
  2245. return -EINVAL;
  2246. *lenp -= left;
  2247. *ppos += *lenp;
  2248. return 0;
  2249. #undef TMPBUFLEN
  2250. }
  2251. static int do_proc_doulongvec_minmax(struct ctl_table *table, int write,
  2252. void __user *buffer,
  2253. size_t *lenp, loff_t *ppos,
  2254. unsigned long convmul,
  2255. unsigned long convdiv)
  2256. {
  2257. return __do_proc_doulongvec_minmax(table->data, table, write,
  2258. buffer, lenp, ppos, convmul, convdiv);
  2259. }
  2260. /**
  2261. * proc_doulongvec_minmax - read a vector of long integers with min/max values
  2262. * @table: the sysctl table
  2263. * @write: %TRUE if this is a write to the sysctl file
  2264. * @buffer: the user buffer
  2265. * @lenp: the size of the user buffer
  2266. * @ppos: file position
  2267. *
  2268. * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
  2269. * values from/to the user buffer, treated as an ASCII string.
  2270. *
  2271. * This routine will ensure the values are within the range specified by
  2272. * table->extra1 (min) and table->extra2 (max).
  2273. *
  2274. * Returns 0 on success.
  2275. */
  2276. int proc_doulongvec_minmax(struct ctl_table *table, int write,
  2277. void __user *buffer, size_t *lenp, loff_t *ppos)
  2278. {
  2279. return do_proc_doulongvec_minmax(table, write, buffer, lenp, ppos, 1l, 1l);
  2280. }
  2281. /**
  2282. * proc_doulongvec_ms_jiffies_minmax - read a vector of millisecond values with min/max values
  2283. * @table: the sysctl table
  2284. * @write: %TRUE if this is a write to the sysctl file
  2285. * @buffer: the user buffer
  2286. * @lenp: the size of the user buffer
  2287. * @ppos: file position
  2288. *
  2289. * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
  2290. * values from/to the user buffer, treated as an ASCII string. The values
  2291. * are treated as milliseconds, and converted to jiffies when they are stored.
  2292. *
  2293. * This routine will ensure the values are within the range specified by
  2294. * table->extra1 (min) and table->extra2 (max).
  2295. *
  2296. * Returns 0 on success.
  2297. */
  2298. int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
  2299. void __user *buffer,
  2300. size_t *lenp, loff_t *ppos)
  2301. {
  2302. return do_proc_doulongvec_minmax(table, write, buffer,
  2303. lenp, ppos, HZ, 1000l);
  2304. }
  2305. static int do_proc_dointvec_jiffies_conv(int *negp, unsigned long *lvalp,
  2306. int *valp,
  2307. int write, void *data)
  2308. {
  2309. if (write) {
  2310. if (*lvalp > LONG_MAX / HZ)
  2311. return 1;
  2312. *valp = *negp ? -(*lvalp*HZ) : (*lvalp*HZ);
  2313. } else {
  2314. int val = *valp;
  2315. unsigned long lval;
  2316. if (val < 0) {
  2317. *negp = -1;
  2318. lval = (unsigned long)-val;
  2319. } else {
  2320. *negp = 0;
  2321. lval = (unsigned long)val;
  2322. }
  2323. *lvalp = lval / HZ;
  2324. }
  2325. return 0;
  2326. }
  2327. static int do_proc_dointvec_userhz_jiffies_conv(int *negp, unsigned long *lvalp,
  2328. int *valp,
  2329. int write, void *data)
  2330. {
  2331. if (write) {
  2332. if (USER_HZ < HZ && *lvalp > (LONG_MAX / HZ) * USER_HZ)
  2333. return 1;
  2334. *valp = clock_t_to_jiffies(*negp ? -*lvalp : *lvalp);
  2335. } else {
  2336. int val = *valp;
  2337. unsigned long lval;
  2338. if (val < 0) {
  2339. *negp = -1;
  2340. lval = (unsigned long)-val;
  2341. } else {
  2342. *negp = 0;
  2343. lval = (unsigned long)val;
  2344. }
  2345. *lvalp = jiffies_to_clock_t(lval);
  2346. }
  2347. return 0;
  2348. }
  2349. static int do_proc_dointvec_ms_jiffies_conv(int *negp, unsigned long *lvalp,
  2350. int *valp,
  2351. int write, void *data)
  2352. {
  2353. if (write) {
  2354. *valp = msecs_to_jiffies(*negp ? -*lvalp : *lvalp);
  2355. } else {
  2356. int val = *valp;
  2357. unsigned long lval;
  2358. if (val < 0) {
  2359. *negp = -1;
  2360. lval = (unsigned long)-val;
  2361. } else {
  2362. *negp = 0;
  2363. lval = (unsigned long)val;
  2364. }
  2365. *lvalp = jiffies_to_msecs(lval);
  2366. }
  2367. return 0;
  2368. }
  2369. /**
  2370. * proc_dointvec_jiffies - read a vector of integers as seconds
  2371. * @table: the sysctl table
  2372. * @write: %TRUE if this is a write to the sysctl file
  2373. * @buffer: the user buffer
  2374. * @lenp: the size of the user buffer
  2375. * @ppos: file position
  2376. *
  2377. * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
  2378. * values from/to the user buffer, treated as an ASCII string.
  2379. * The values read are assumed to be in seconds, and are converted into
  2380. * jiffies.
  2381. *
  2382. * Returns 0 on success.
  2383. */
  2384. int proc_dointvec_jiffies(struct ctl_table *table, int write,
  2385. void __user *buffer, size_t *lenp, loff_t *ppos)
  2386. {
  2387. return do_proc_dointvec(table,write,buffer,lenp,ppos,
  2388. do_proc_dointvec_jiffies_conv,NULL);
  2389. }
  2390. /**
  2391. * proc_dointvec_userhz_jiffies - read a vector of integers as 1/USER_HZ seconds
  2392. * @table: the sysctl table
  2393. * @write: %TRUE if this is a write to the sysctl file
  2394. * @buffer: the user buffer
  2395. * @lenp: the size of the user buffer
  2396. * @ppos: pointer to the file position
  2397. *
  2398. * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
  2399. * values from/to the user buffer, treated as an ASCII string.
  2400. * The values read are assumed to be in 1/USER_HZ seconds, and
  2401. * are converted into jiffies.
  2402. *
  2403. * Returns 0 on success.
  2404. */
  2405. int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write,
  2406. void __user *buffer, size_t *lenp, loff_t *ppos)
  2407. {
  2408. return do_proc_dointvec(table,write,buffer,lenp,ppos,
  2409. do_proc_dointvec_userhz_jiffies_conv,NULL);
  2410. }
  2411. /**
  2412. * proc_dointvec_ms_jiffies - read a vector of integers as 1 milliseconds
  2413. * @table: the sysctl table
  2414. * @write: %TRUE if this is a write to the sysctl file
  2415. * @buffer: the user buffer
  2416. * @lenp: the size of the user buffer
  2417. * @ppos: file position
  2418. * @ppos: the current position in the file
  2419. *
  2420. * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
  2421. * values from/to the user buffer, treated as an ASCII string.
  2422. * The values read are assumed to be in 1/1000 seconds, and
  2423. * are converted into jiffies.
  2424. *
  2425. * Returns 0 on success.
  2426. */
  2427. int proc_dointvec_ms_jiffies(struct ctl_table *table, int write,
  2428. void __user *buffer, size_t *lenp, loff_t *ppos)
  2429. {
  2430. return do_proc_dointvec(table, write, buffer, lenp, ppos,
  2431. do_proc_dointvec_ms_jiffies_conv, NULL);
  2432. }
  2433. static int proc_do_cad_pid(struct ctl_table *table, int write,
  2434. void __user *buffer, size_t *lenp, loff_t *ppos)
  2435. {
  2436. struct pid *new_pid;
  2437. pid_t tmp;
  2438. int r;
  2439. tmp = pid_vnr(cad_pid);
  2440. r = __do_proc_dointvec(&tmp, table, write, buffer,
  2441. lenp, ppos, NULL, NULL);
  2442. if (r || !write)
  2443. return r;
  2444. new_pid = find_get_pid(tmp);
  2445. if (!new_pid)
  2446. return -ESRCH;
  2447. put_pid(xchg(&cad_pid, new_pid));
  2448. return 0;
  2449. }
  2450. #else /* CONFIG_PROC_FS */
  2451. int proc_dostring(struct ctl_table *table, int write,
  2452. void __user *buffer, size_t *lenp, loff_t *ppos)
  2453. {
  2454. return -ENOSYS;
  2455. }
  2456. int proc_dointvec(struct ctl_table *table, int write,
  2457. void __user *buffer, size_t *lenp, loff_t *ppos)
  2458. {
  2459. return -ENOSYS;
  2460. }
  2461. int proc_dointvec_minmax(struct ctl_table *table, int write,
  2462. void __user *buffer, size_t *lenp, loff_t *ppos)
  2463. {
  2464. return -ENOSYS;
  2465. }
  2466. int proc_dointvec_jiffies(struct ctl_table *table, int write,
  2467. void __user *buffer, size_t *lenp, loff_t *ppos)
  2468. {
  2469. return -ENOSYS;
  2470. }
  2471. int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write,
  2472. void __user *buffer, size_t *lenp, loff_t *ppos)
  2473. {
  2474. return -ENOSYS;
  2475. }
  2476. int proc_dointvec_ms_jiffies(struct ctl_table *table, int write,
  2477. void __user *buffer, size_t *lenp, loff_t *ppos)
  2478. {
  2479. return -ENOSYS;
  2480. }
  2481. int proc_doulongvec_minmax(struct ctl_table *table, int write,
  2482. void __user *buffer, size_t *lenp, loff_t *ppos)
  2483. {
  2484. return -ENOSYS;
  2485. }
  2486. int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
  2487. void __user *buffer,
  2488. size_t *lenp, loff_t *ppos)
  2489. {
  2490. return -ENOSYS;
  2491. }
  2492. #endif /* CONFIG_PROC_FS */
  2493. /*
  2494. * No sense putting this after each symbol definition, twice,
  2495. * exception granted :-)
  2496. */
  2497. EXPORT_SYMBOL(proc_dointvec);
  2498. EXPORT_SYMBOL(proc_dointvec_jiffies);
  2499. EXPORT_SYMBOL(proc_dointvec_minmax);
  2500. EXPORT_SYMBOL(proc_dointvec_userhz_jiffies);
  2501. EXPORT_SYMBOL(proc_dointvec_ms_jiffies);
  2502. EXPORT_SYMBOL(proc_dostring);
  2503. EXPORT_SYMBOL(proc_doulongvec_minmax);
  2504. EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax);
  2505. EXPORT_SYMBOL(register_sysctl_table);
  2506. EXPORT_SYMBOL(register_sysctl_paths);
  2507. EXPORT_SYMBOL(unregister_sysctl_table);