sysctl.c 61 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675
  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. #ifdef CONFIG_NUMA
  1034. {
  1035. .procname = "nr_hugepages_mempolicy",
  1036. .data = NULL,
  1037. .maxlen = sizeof(unsigned long),
  1038. .mode = 0644,
  1039. .proc_handler = &hugetlb_mempolicy_sysctl_handler,
  1040. .extra1 = (void *)&hugetlb_zero,
  1041. .extra2 = (void *)&hugetlb_infinity,
  1042. },
  1043. #endif
  1044. {
  1045. .procname = "hugetlb_shm_group",
  1046. .data = &sysctl_hugetlb_shm_group,
  1047. .maxlen = sizeof(gid_t),
  1048. .mode = 0644,
  1049. .proc_handler = proc_dointvec,
  1050. },
  1051. {
  1052. .procname = "hugepages_treat_as_movable",
  1053. .data = &hugepages_treat_as_movable,
  1054. .maxlen = sizeof(int),
  1055. .mode = 0644,
  1056. .proc_handler = hugetlb_treat_movable_handler,
  1057. },
  1058. {
  1059. .procname = "nr_overcommit_hugepages",
  1060. .data = NULL,
  1061. .maxlen = sizeof(unsigned long),
  1062. .mode = 0644,
  1063. .proc_handler = hugetlb_overcommit_handler,
  1064. .extra1 = (void *)&hugetlb_zero,
  1065. .extra2 = (void *)&hugetlb_infinity,
  1066. },
  1067. #endif
  1068. {
  1069. .procname = "lowmem_reserve_ratio",
  1070. .data = &sysctl_lowmem_reserve_ratio,
  1071. .maxlen = sizeof(sysctl_lowmem_reserve_ratio),
  1072. .mode = 0644,
  1073. .proc_handler = lowmem_reserve_ratio_sysctl_handler,
  1074. },
  1075. {
  1076. .procname = "drop_caches",
  1077. .data = &sysctl_drop_caches,
  1078. .maxlen = sizeof(int),
  1079. .mode = 0644,
  1080. .proc_handler = drop_caches_sysctl_handler,
  1081. },
  1082. {
  1083. .procname = "min_free_kbytes",
  1084. .data = &min_free_kbytes,
  1085. .maxlen = sizeof(min_free_kbytes),
  1086. .mode = 0644,
  1087. .proc_handler = min_free_kbytes_sysctl_handler,
  1088. .extra1 = &zero,
  1089. },
  1090. {
  1091. .procname = "percpu_pagelist_fraction",
  1092. .data = &percpu_pagelist_fraction,
  1093. .maxlen = sizeof(percpu_pagelist_fraction),
  1094. .mode = 0644,
  1095. .proc_handler = percpu_pagelist_fraction_sysctl_handler,
  1096. .extra1 = &min_percpu_pagelist_fract,
  1097. },
  1098. #ifdef CONFIG_MMU
  1099. {
  1100. .procname = "max_map_count",
  1101. .data = &sysctl_max_map_count,
  1102. .maxlen = sizeof(sysctl_max_map_count),
  1103. .mode = 0644,
  1104. .proc_handler = proc_dointvec,
  1105. .extra1 = &zero,
  1106. },
  1107. #else
  1108. {
  1109. .procname = "nr_trim_pages",
  1110. .data = &sysctl_nr_trim_pages,
  1111. .maxlen = sizeof(sysctl_nr_trim_pages),
  1112. .mode = 0644,
  1113. .proc_handler = proc_dointvec_minmax,
  1114. .extra1 = &zero,
  1115. },
  1116. #endif
  1117. {
  1118. .procname = "laptop_mode",
  1119. .data = &laptop_mode,
  1120. .maxlen = sizeof(laptop_mode),
  1121. .mode = 0644,
  1122. .proc_handler = proc_dointvec_jiffies,
  1123. },
  1124. {
  1125. .procname = "block_dump",
  1126. .data = &block_dump,
  1127. .maxlen = sizeof(block_dump),
  1128. .mode = 0644,
  1129. .proc_handler = proc_dointvec,
  1130. .extra1 = &zero,
  1131. },
  1132. {
  1133. .procname = "vfs_cache_pressure",
  1134. .data = &sysctl_vfs_cache_pressure,
  1135. .maxlen = sizeof(sysctl_vfs_cache_pressure),
  1136. .mode = 0644,
  1137. .proc_handler = proc_dointvec,
  1138. .extra1 = &zero,
  1139. },
  1140. #ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
  1141. {
  1142. .procname = "legacy_va_layout",
  1143. .data = &sysctl_legacy_va_layout,
  1144. .maxlen = sizeof(sysctl_legacy_va_layout),
  1145. .mode = 0644,
  1146. .proc_handler = proc_dointvec,
  1147. .extra1 = &zero,
  1148. },
  1149. #endif
  1150. #ifdef CONFIG_NUMA
  1151. {
  1152. .procname = "zone_reclaim_mode",
  1153. .data = &zone_reclaim_mode,
  1154. .maxlen = sizeof(zone_reclaim_mode),
  1155. .mode = 0644,
  1156. .proc_handler = proc_dointvec,
  1157. .extra1 = &zero,
  1158. },
  1159. {
  1160. .procname = "min_unmapped_ratio",
  1161. .data = &sysctl_min_unmapped_ratio,
  1162. .maxlen = sizeof(sysctl_min_unmapped_ratio),
  1163. .mode = 0644,
  1164. .proc_handler = sysctl_min_unmapped_ratio_sysctl_handler,
  1165. .extra1 = &zero,
  1166. .extra2 = &one_hundred,
  1167. },
  1168. {
  1169. .procname = "min_slab_ratio",
  1170. .data = &sysctl_min_slab_ratio,
  1171. .maxlen = sizeof(sysctl_min_slab_ratio),
  1172. .mode = 0644,
  1173. .proc_handler = sysctl_min_slab_ratio_sysctl_handler,
  1174. .extra1 = &zero,
  1175. .extra2 = &one_hundred,
  1176. },
  1177. #endif
  1178. #ifdef CONFIG_SMP
  1179. {
  1180. .procname = "stat_interval",
  1181. .data = &sysctl_stat_interval,
  1182. .maxlen = sizeof(sysctl_stat_interval),
  1183. .mode = 0644,
  1184. .proc_handler = proc_dointvec_jiffies,
  1185. },
  1186. #endif
  1187. {
  1188. .procname = "mmap_min_addr",
  1189. .data = &dac_mmap_min_addr,
  1190. .maxlen = sizeof(unsigned long),
  1191. .mode = 0644,
  1192. .proc_handler = mmap_min_addr_handler,
  1193. },
  1194. #ifdef CONFIG_NUMA
  1195. {
  1196. .procname = "numa_zonelist_order",
  1197. .data = &numa_zonelist_order,
  1198. .maxlen = NUMA_ZONELIST_ORDER_LEN,
  1199. .mode = 0644,
  1200. .proc_handler = numa_zonelist_order_handler,
  1201. },
  1202. #endif
  1203. #if (defined(CONFIG_X86_32) && !defined(CONFIG_UML))|| \
  1204. (defined(CONFIG_SUPERH) && defined(CONFIG_VSYSCALL))
  1205. {
  1206. .procname = "vdso_enabled",
  1207. .data = &vdso_enabled,
  1208. .maxlen = sizeof(vdso_enabled),
  1209. .mode = 0644,
  1210. .proc_handler = proc_dointvec,
  1211. .extra1 = &zero,
  1212. },
  1213. #endif
  1214. #ifdef CONFIG_HIGHMEM
  1215. {
  1216. .procname = "highmem_is_dirtyable",
  1217. .data = &vm_highmem_is_dirtyable,
  1218. .maxlen = sizeof(vm_highmem_is_dirtyable),
  1219. .mode = 0644,
  1220. .proc_handler = proc_dointvec_minmax,
  1221. .extra1 = &zero,
  1222. .extra2 = &one,
  1223. },
  1224. #endif
  1225. {
  1226. .procname = "scan_unevictable_pages",
  1227. .data = &scan_unevictable_pages,
  1228. .maxlen = sizeof(scan_unevictable_pages),
  1229. .mode = 0644,
  1230. .proc_handler = scan_unevictable_handler,
  1231. },
  1232. #ifdef CONFIG_MEMORY_FAILURE
  1233. {
  1234. .procname = "memory_failure_early_kill",
  1235. .data = &sysctl_memory_failure_early_kill,
  1236. .maxlen = sizeof(sysctl_memory_failure_early_kill),
  1237. .mode = 0644,
  1238. .proc_handler = proc_dointvec_minmax,
  1239. .extra1 = &zero,
  1240. .extra2 = &one,
  1241. },
  1242. {
  1243. .procname = "memory_failure_recovery",
  1244. .data = &sysctl_memory_failure_recovery,
  1245. .maxlen = sizeof(sysctl_memory_failure_recovery),
  1246. .mode = 0644,
  1247. .proc_handler = proc_dointvec_minmax,
  1248. .extra1 = &zero,
  1249. .extra2 = &one,
  1250. },
  1251. #endif
  1252. /*
  1253. * NOTE: do not add new entries to this table unless you have read
  1254. * Documentation/sysctl/ctl_unnumbered.txt
  1255. */
  1256. { }
  1257. };
  1258. #if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE)
  1259. static struct ctl_table binfmt_misc_table[] = {
  1260. { }
  1261. };
  1262. #endif
  1263. static struct ctl_table fs_table[] = {
  1264. {
  1265. .procname = "inode-nr",
  1266. .data = &inodes_stat,
  1267. .maxlen = 2*sizeof(int),
  1268. .mode = 0444,
  1269. .proc_handler = proc_dointvec,
  1270. },
  1271. {
  1272. .procname = "inode-state",
  1273. .data = &inodes_stat,
  1274. .maxlen = 7*sizeof(int),
  1275. .mode = 0444,
  1276. .proc_handler = proc_dointvec,
  1277. },
  1278. {
  1279. .procname = "file-nr",
  1280. .data = &files_stat,
  1281. .maxlen = 3*sizeof(int),
  1282. .mode = 0444,
  1283. .proc_handler = proc_nr_files,
  1284. },
  1285. {
  1286. .procname = "file-max",
  1287. .data = &files_stat.max_files,
  1288. .maxlen = sizeof(int),
  1289. .mode = 0644,
  1290. .proc_handler = proc_dointvec,
  1291. },
  1292. {
  1293. .procname = "nr_open",
  1294. .data = &sysctl_nr_open,
  1295. .maxlen = sizeof(int),
  1296. .mode = 0644,
  1297. .proc_handler = proc_dointvec_minmax,
  1298. .extra1 = &sysctl_nr_open_min,
  1299. .extra2 = &sysctl_nr_open_max,
  1300. },
  1301. {
  1302. .procname = "dentry-state",
  1303. .data = &dentry_stat,
  1304. .maxlen = 6*sizeof(int),
  1305. .mode = 0444,
  1306. .proc_handler = proc_dointvec,
  1307. },
  1308. {
  1309. .procname = "overflowuid",
  1310. .data = &fs_overflowuid,
  1311. .maxlen = sizeof(int),
  1312. .mode = 0644,
  1313. .proc_handler = proc_dointvec_minmax,
  1314. .extra1 = &minolduid,
  1315. .extra2 = &maxolduid,
  1316. },
  1317. {
  1318. .procname = "overflowgid",
  1319. .data = &fs_overflowgid,
  1320. .maxlen = sizeof(int),
  1321. .mode = 0644,
  1322. .proc_handler = proc_dointvec_minmax,
  1323. .extra1 = &minolduid,
  1324. .extra2 = &maxolduid,
  1325. },
  1326. #ifdef CONFIG_FILE_LOCKING
  1327. {
  1328. .procname = "leases-enable",
  1329. .data = &leases_enable,
  1330. .maxlen = sizeof(int),
  1331. .mode = 0644,
  1332. .proc_handler = proc_dointvec,
  1333. },
  1334. #endif
  1335. #ifdef CONFIG_DNOTIFY
  1336. {
  1337. .procname = "dir-notify-enable",
  1338. .data = &dir_notify_enable,
  1339. .maxlen = sizeof(int),
  1340. .mode = 0644,
  1341. .proc_handler = proc_dointvec,
  1342. },
  1343. #endif
  1344. #ifdef CONFIG_MMU
  1345. #ifdef CONFIG_FILE_LOCKING
  1346. {
  1347. .procname = "lease-break-time",
  1348. .data = &lease_break_time,
  1349. .maxlen = sizeof(int),
  1350. .mode = 0644,
  1351. .proc_handler = proc_dointvec,
  1352. },
  1353. #endif
  1354. #ifdef CONFIG_AIO
  1355. {
  1356. .procname = "aio-nr",
  1357. .data = &aio_nr,
  1358. .maxlen = sizeof(aio_nr),
  1359. .mode = 0444,
  1360. .proc_handler = proc_doulongvec_minmax,
  1361. },
  1362. {
  1363. .procname = "aio-max-nr",
  1364. .data = &aio_max_nr,
  1365. .maxlen = sizeof(aio_max_nr),
  1366. .mode = 0644,
  1367. .proc_handler = proc_doulongvec_minmax,
  1368. },
  1369. #endif /* CONFIG_AIO */
  1370. #ifdef CONFIG_INOTIFY_USER
  1371. {
  1372. .procname = "inotify",
  1373. .mode = 0555,
  1374. .child = inotify_table,
  1375. },
  1376. #endif
  1377. #ifdef CONFIG_EPOLL
  1378. {
  1379. .procname = "epoll",
  1380. .mode = 0555,
  1381. .child = epoll_table,
  1382. },
  1383. #endif
  1384. #endif
  1385. {
  1386. .procname = "suid_dumpable",
  1387. .data = &suid_dumpable,
  1388. .maxlen = sizeof(int),
  1389. .mode = 0644,
  1390. .proc_handler = proc_dointvec_minmax,
  1391. .extra1 = &zero,
  1392. .extra2 = &two,
  1393. },
  1394. #if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE)
  1395. {
  1396. .procname = "binfmt_misc",
  1397. .mode = 0555,
  1398. .child = binfmt_misc_table,
  1399. },
  1400. #endif
  1401. /*
  1402. * NOTE: do not add new entries to this table unless you have read
  1403. * Documentation/sysctl/ctl_unnumbered.txt
  1404. */
  1405. { }
  1406. };
  1407. static struct ctl_table debug_table[] = {
  1408. #if defined(CONFIG_X86) || defined(CONFIG_PPC)
  1409. {
  1410. .procname = "exception-trace",
  1411. .data = &show_unhandled_signals,
  1412. .maxlen = sizeof(int),
  1413. .mode = 0644,
  1414. .proc_handler = proc_dointvec
  1415. },
  1416. #endif
  1417. { }
  1418. };
  1419. static struct ctl_table dev_table[] = {
  1420. { }
  1421. };
  1422. static DEFINE_SPINLOCK(sysctl_lock);
  1423. /* called under sysctl_lock */
  1424. static int use_table(struct ctl_table_header *p)
  1425. {
  1426. if (unlikely(p->unregistering))
  1427. return 0;
  1428. p->used++;
  1429. return 1;
  1430. }
  1431. /* called under sysctl_lock */
  1432. static void unuse_table(struct ctl_table_header *p)
  1433. {
  1434. if (!--p->used)
  1435. if (unlikely(p->unregistering))
  1436. complete(p->unregistering);
  1437. }
  1438. /* called under sysctl_lock, will reacquire if has to wait */
  1439. static void start_unregistering(struct ctl_table_header *p)
  1440. {
  1441. /*
  1442. * if p->used is 0, nobody will ever touch that entry again;
  1443. * we'll eliminate all paths to it before dropping sysctl_lock
  1444. */
  1445. if (unlikely(p->used)) {
  1446. struct completion wait;
  1447. init_completion(&wait);
  1448. p->unregistering = &wait;
  1449. spin_unlock(&sysctl_lock);
  1450. wait_for_completion(&wait);
  1451. spin_lock(&sysctl_lock);
  1452. } else {
  1453. /* anything non-NULL; we'll never dereference it */
  1454. p->unregistering = ERR_PTR(-EINVAL);
  1455. }
  1456. /*
  1457. * do not remove from the list until nobody holds it; walking the
  1458. * list in do_sysctl() relies on that.
  1459. */
  1460. list_del_init(&p->ctl_entry);
  1461. }
  1462. void sysctl_head_get(struct ctl_table_header *head)
  1463. {
  1464. spin_lock(&sysctl_lock);
  1465. head->count++;
  1466. spin_unlock(&sysctl_lock);
  1467. }
  1468. void sysctl_head_put(struct ctl_table_header *head)
  1469. {
  1470. spin_lock(&sysctl_lock);
  1471. if (!--head->count)
  1472. kfree(head);
  1473. spin_unlock(&sysctl_lock);
  1474. }
  1475. struct ctl_table_header *sysctl_head_grab(struct ctl_table_header *head)
  1476. {
  1477. if (!head)
  1478. BUG();
  1479. spin_lock(&sysctl_lock);
  1480. if (!use_table(head))
  1481. head = ERR_PTR(-ENOENT);
  1482. spin_unlock(&sysctl_lock);
  1483. return head;
  1484. }
  1485. void sysctl_head_finish(struct ctl_table_header *head)
  1486. {
  1487. if (!head)
  1488. return;
  1489. spin_lock(&sysctl_lock);
  1490. unuse_table(head);
  1491. spin_unlock(&sysctl_lock);
  1492. }
  1493. static struct ctl_table_set *
  1494. lookup_header_set(struct ctl_table_root *root, struct nsproxy *namespaces)
  1495. {
  1496. struct ctl_table_set *set = &root->default_set;
  1497. if (root->lookup)
  1498. set = root->lookup(root, namespaces);
  1499. return set;
  1500. }
  1501. static struct list_head *
  1502. lookup_header_list(struct ctl_table_root *root, struct nsproxy *namespaces)
  1503. {
  1504. struct ctl_table_set *set = lookup_header_set(root, namespaces);
  1505. return &set->list;
  1506. }
  1507. struct ctl_table_header *__sysctl_head_next(struct nsproxy *namespaces,
  1508. struct ctl_table_header *prev)
  1509. {
  1510. struct ctl_table_root *root;
  1511. struct list_head *header_list;
  1512. struct ctl_table_header *head;
  1513. struct list_head *tmp;
  1514. spin_lock(&sysctl_lock);
  1515. if (prev) {
  1516. head = prev;
  1517. tmp = &prev->ctl_entry;
  1518. unuse_table(prev);
  1519. goto next;
  1520. }
  1521. tmp = &root_table_header.ctl_entry;
  1522. for (;;) {
  1523. head = list_entry(tmp, struct ctl_table_header, ctl_entry);
  1524. if (!use_table(head))
  1525. goto next;
  1526. spin_unlock(&sysctl_lock);
  1527. return head;
  1528. next:
  1529. root = head->root;
  1530. tmp = tmp->next;
  1531. header_list = lookup_header_list(root, namespaces);
  1532. if (tmp != header_list)
  1533. continue;
  1534. do {
  1535. root = list_entry(root->root_list.next,
  1536. struct ctl_table_root, root_list);
  1537. if (root == &sysctl_table_root)
  1538. goto out;
  1539. header_list = lookup_header_list(root, namespaces);
  1540. } while (list_empty(header_list));
  1541. tmp = header_list->next;
  1542. }
  1543. out:
  1544. spin_unlock(&sysctl_lock);
  1545. return NULL;
  1546. }
  1547. struct ctl_table_header *sysctl_head_next(struct ctl_table_header *prev)
  1548. {
  1549. return __sysctl_head_next(current->nsproxy, prev);
  1550. }
  1551. void register_sysctl_root(struct ctl_table_root *root)
  1552. {
  1553. spin_lock(&sysctl_lock);
  1554. list_add_tail(&root->root_list, &sysctl_table_root.root_list);
  1555. spin_unlock(&sysctl_lock);
  1556. }
  1557. /*
  1558. * sysctl_perm does NOT grant the superuser all rights automatically, because
  1559. * some sysctl variables are readonly even to root.
  1560. */
  1561. static int test_perm(int mode, int op)
  1562. {
  1563. if (!current_euid())
  1564. mode >>= 6;
  1565. else if (in_egroup_p(0))
  1566. mode >>= 3;
  1567. if ((op & ~mode & (MAY_READ|MAY_WRITE|MAY_EXEC)) == 0)
  1568. return 0;
  1569. return -EACCES;
  1570. }
  1571. int sysctl_perm(struct ctl_table_root *root, struct ctl_table *table, int op)
  1572. {
  1573. int error;
  1574. int mode;
  1575. error = security_sysctl(table, op & (MAY_READ | MAY_WRITE | MAY_EXEC));
  1576. if (error)
  1577. return error;
  1578. if (root->permissions)
  1579. mode = root->permissions(root, current->nsproxy, table);
  1580. else
  1581. mode = table->mode;
  1582. return test_perm(mode, op);
  1583. }
  1584. static void sysctl_set_parent(struct ctl_table *parent, struct ctl_table *table)
  1585. {
  1586. for (; table->procname; table++) {
  1587. table->parent = parent;
  1588. if (table->child)
  1589. sysctl_set_parent(table, table->child);
  1590. }
  1591. }
  1592. static __init int sysctl_init(void)
  1593. {
  1594. sysctl_set_parent(NULL, root_table);
  1595. #ifdef CONFIG_SYSCTL_SYSCALL_CHECK
  1596. {
  1597. int err;
  1598. err = sysctl_check_table(current->nsproxy, root_table);
  1599. }
  1600. #endif
  1601. return 0;
  1602. }
  1603. core_initcall(sysctl_init);
  1604. static struct ctl_table *is_branch_in(struct ctl_table *branch,
  1605. struct ctl_table *table)
  1606. {
  1607. struct ctl_table *p;
  1608. const char *s = branch->procname;
  1609. /* branch should have named subdirectory as its first element */
  1610. if (!s || !branch->child)
  1611. return NULL;
  1612. /* ... and nothing else */
  1613. if (branch[1].procname)
  1614. return NULL;
  1615. /* table should contain subdirectory with the same name */
  1616. for (p = table; p->procname; p++) {
  1617. if (!p->child)
  1618. continue;
  1619. if (p->procname && strcmp(p->procname, s) == 0)
  1620. return p;
  1621. }
  1622. return NULL;
  1623. }
  1624. /* see if attaching q to p would be an improvement */
  1625. static void try_attach(struct ctl_table_header *p, struct ctl_table_header *q)
  1626. {
  1627. struct ctl_table *to = p->ctl_table, *by = q->ctl_table;
  1628. struct ctl_table *next;
  1629. int is_better = 0;
  1630. int not_in_parent = !p->attached_by;
  1631. while ((next = is_branch_in(by, to)) != NULL) {
  1632. if (by == q->attached_by)
  1633. is_better = 1;
  1634. if (to == p->attached_by)
  1635. not_in_parent = 1;
  1636. by = by->child;
  1637. to = next->child;
  1638. }
  1639. if (is_better && not_in_parent) {
  1640. q->attached_by = by;
  1641. q->attached_to = to;
  1642. q->parent = p;
  1643. }
  1644. }
  1645. /**
  1646. * __register_sysctl_paths - register a sysctl hierarchy
  1647. * @root: List of sysctl headers to register on
  1648. * @namespaces: Data to compute which lists of sysctl entries are visible
  1649. * @path: The path to the directory the sysctl table is in.
  1650. * @table: the top-level table structure
  1651. *
  1652. * Register a sysctl table hierarchy. @table should be a filled in ctl_table
  1653. * array. A completely 0 filled entry terminates the table.
  1654. *
  1655. * The members of the &struct ctl_table structure are used as follows:
  1656. *
  1657. * procname - the name of the sysctl file under /proc/sys. Set to %NULL to not
  1658. * enter a sysctl file
  1659. *
  1660. * data - a pointer to data for use by proc_handler
  1661. *
  1662. * maxlen - the maximum size in bytes of the data
  1663. *
  1664. * mode - the file permissions for the /proc/sys file, and for sysctl(2)
  1665. *
  1666. * child - a pointer to the child sysctl table if this entry is a directory, or
  1667. * %NULL.
  1668. *
  1669. * proc_handler - the text handler routine (described below)
  1670. *
  1671. * de - for internal use by the sysctl routines
  1672. *
  1673. * extra1, extra2 - extra pointers usable by the proc handler routines
  1674. *
  1675. * Leaf nodes in the sysctl tree will be represented by a single file
  1676. * under /proc; non-leaf nodes will be represented by directories.
  1677. *
  1678. * sysctl(2) can automatically manage read and write requests through
  1679. * the sysctl table. The data and maxlen fields of the ctl_table
  1680. * struct enable minimal validation of the values being written to be
  1681. * performed, and the mode field allows minimal authentication.
  1682. *
  1683. * There must be a proc_handler routine for any terminal nodes
  1684. * mirrored under /proc/sys (non-terminals are handled by a built-in
  1685. * directory handler). Several default handlers are available to
  1686. * cover common cases -
  1687. *
  1688. * proc_dostring(), proc_dointvec(), proc_dointvec_jiffies(),
  1689. * proc_dointvec_userhz_jiffies(), proc_dointvec_minmax(),
  1690. * proc_doulongvec_ms_jiffies_minmax(), proc_doulongvec_minmax()
  1691. *
  1692. * It is the handler's job to read the input buffer from user memory
  1693. * and process it. The handler should return 0 on success.
  1694. *
  1695. * This routine returns %NULL on a failure to register, and a pointer
  1696. * to the table header on success.
  1697. */
  1698. struct ctl_table_header *__register_sysctl_paths(
  1699. struct ctl_table_root *root,
  1700. struct nsproxy *namespaces,
  1701. const struct ctl_path *path, struct ctl_table *table)
  1702. {
  1703. struct ctl_table_header *header;
  1704. struct ctl_table *new, **prevp;
  1705. unsigned int n, npath;
  1706. struct ctl_table_set *set;
  1707. /* Count the path components */
  1708. for (npath = 0; path[npath].procname; ++npath)
  1709. ;
  1710. /*
  1711. * For each path component, allocate a 2-element ctl_table array.
  1712. * The first array element will be filled with the sysctl entry
  1713. * for this, the second will be the sentinel (procname == 0).
  1714. *
  1715. * We allocate everything in one go so that we don't have to
  1716. * worry about freeing additional memory in unregister_sysctl_table.
  1717. */
  1718. header = kzalloc(sizeof(struct ctl_table_header) +
  1719. (2 * npath * sizeof(struct ctl_table)), GFP_KERNEL);
  1720. if (!header)
  1721. return NULL;
  1722. new = (struct ctl_table *) (header + 1);
  1723. /* Now connect the dots */
  1724. prevp = &header->ctl_table;
  1725. for (n = 0; n < npath; ++n, ++path) {
  1726. /* Copy the procname */
  1727. new->procname = path->procname;
  1728. new->mode = 0555;
  1729. *prevp = new;
  1730. prevp = &new->child;
  1731. new += 2;
  1732. }
  1733. *prevp = table;
  1734. header->ctl_table_arg = table;
  1735. INIT_LIST_HEAD(&header->ctl_entry);
  1736. header->used = 0;
  1737. header->unregistering = NULL;
  1738. header->root = root;
  1739. sysctl_set_parent(NULL, header->ctl_table);
  1740. header->count = 1;
  1741. #ifdef CONFIG_SYSCTL_SYSCALL_CHECK
  1742. if (sysctl_check_table(namespaces, header->ctl_table)) {
  1743. kfree(header);
  1744. return NULL;
  1745. }
  1746. #endif
  1747. spin_lock(&sysctl_lock);
  1748. header->set = lookup_header_set(root, namespaces);
  1749. header->attached_by = header->ctl_table;
  1750. header->attached_to = root_table;
  1751. header->parent = &root_table_header;
  1752. for (set = header->set; set; set = set->parent) {
  1753. struct ctl_table_header *p;
  1754. list_for_each_entry(p, &set->list, ctl_entry) {
  1755. if (p->unregistering)
  1756. continue;
  1757. try_attach(p, header);
  1758. }
  1759. }
  1760. header->parent->count++;
  1761. list_add_tail(&header->ctl_entry, &header->set->list);
  1762. spin_unlock(&sysctl_lock);
  1763. return header;
  1764. }
  1765. /**
  1766. * register_sysctl_table_path - register a sysctl table hierarchy
  1767. * @path: The path to the directory the sysctl table is in.
  1768. * @table: the top-level table structure
  1769. *
  1770. * Register a sysctl table hierarchy. @table should be a filled in ctl_table
  1771. * array. A completely 0 filled entry terminates the table.
  1772. *
  1773. * See __register_sysctl_paths for more details.
  1774. */
  1775. struct ctl_table_header *register_sysctl_paths(const struct ctl_path *path,
  1776. struct ctl_table *table)
  1777. {
  1778. return __register_sysctl_paths(&sysctl_table_root, current->nsproxy,
  1779. path, table);
  1780. }
  1781. /**
  1782. * register_sysctl_table - register a sysctl table hierarchy
  1783. * @table: the top-level table structure
  1784. *
  1785. * Register a sysctl table hierarchy. @table should be a filled in ctl_table
  1786. * array. A completely 0 filled entry terminates the table.
  1787. *
  1788. * See register_sysctl_paths for more details.
  1789. */
  1790. struct ctl_table_header *register_sysctl_table(struct ctl_table *table)
  1791. {
  1792. static const struct ctl_path null_path[] = { {} };
  1793. return register_sysctl_paths(null_path, table);
  1794. }
  1795. /**
  1796. * unregister_sysctl_table - unregister a sysctl table hierarchy
  1797. * @header: the header returned from register_sysctl_table
  1798. *
  1799. * Unregisters the sysctl table and all children. proc entries may not
  1800. * actually be removed until they are no longer used by anyone.
  1801. */
  1802. void unregister_sysctl_table(struct ctl_table_header * header)
  1803. {
  1804. might_sleep();
  1805. if (header == NULL)
  1806. return;
  1807. spin_lock(&sysctl_lock);
  1808. start_unregistering(header);
  1809. if (!--header->parent->count) {
  1810. WARN_ON(1);
  1811. kfree(header->parent);
  1812. }
  1813. if (!--header->count)
  1814. kfree(header);
  1815. spin_unlock(&sysctl_lock);
  1816. }
  1817. int sysctl_is_seen(struct ctl_table_header *p)
  1818. {
  1819. struct ctl_table_set *set = p->set;
  1820. int res;
  1821. spin_lock(&sysctl_lock);
  1822. if (p->unregistering)
  1823. res = 0;
  1824. else if (!set->is_seen)
  1825. res = 1;
  1826. else
  1827. res = set->is_seen(set);
  1828. spin_unlock(&sysctl_lock);
  1829. return res;
  1830. }
  1831. void setup_sysctl_set(struct ctl_table_set *p,
  1832. struct ctl_table_set *parent,
  1833. int (*is_seen)(struct ctl_table_set *))
  1834. {
  1835. INIT_LIST_HEAD(&p->list);
  1836. p->parent = parent ? parent : &sysctl_table_root.default_set;
  1837. p->is_seen = is_seen;
  1838. }
  1839. #else /* !CONFIG_SYSCTL */
  1840. struct ctl_table_header *register_sysctl_table(struct ctl_table * table)
  1841. {
  1842. return NULL;
  1843. }
  1844. struct ctl_table_header *register_sysctl_paths(const struct ctl_path *path,
  1845. struct ctl_table *table)
  1846. {
  1847. return NULL;
  1848. }
  1849. void unregister_sysctl_table(struct ctl_table_header * table)
  1850. {
  1851. }
  1852. void setup_sysctl_set(struct ctl_table_set *p,
  1853. struct ctl_table_set *parent,
  1854. int (*is_seen)(struct ctl_table_set *))
  1855. {
  1856. }
  1857. void sysctl_head_put(struct ctl_table_header *head)
  1858. {
  1859. }
  1860. #endif /* CONFIG_SYSCTL */
  1861. /*
  1862. * /proc/sys support
  1863. */
  1864. #ifdef CONFIG_PROC_SYSCTL
  1865. static int _proc_do_string(void* data, int maxlen, int write,
  1866. void __user *buffer,
  1867. size_t *lenp, loff_t *ppos)
  1868. {
  1869. size_t len;
  1870. char __user *p;
  1871. char c;
  1872. if (!data || !maxlen || !*lenp) {
  1873. *lenp = 0;
  1874. return 0;
  1875. }
  1876. if (write) {
  1877. len = 0;
  1878. p = buffer;
  1879. while (len < *lenp) {
  1880. if (get_user(c, p++))
  1881. return -EFAULT;
  1882. if (c == 0 || c == '\n')
  1883. break;
  1884. len++;
  1885. }
  1886. if (len >= maxlen)
  1887. len = maxlen-1;
  1888. if(copy_from_user(data, buffer, len))
  1889. return -EFAULT;
  1890. ((char *) data)[len] = 0;
  1891. *ppos += *lenp;
  1892. } else {
  1893. len = strlen(data);
  1894. if (len > maxlen)
  1895. len = maxlen;
  1896. if (*ppos > len) {
  1897. *lenp = 0;
  1898. return 0;
  1899. }
  1900. data += *ppos;
  1901. len -= *ppos;
  1902. if (len > *lenp)
  1903. len = *lenp;
  1904. if (len)
  1905. if(copy_to_user(buffer, data, len))
  1906. return -EFAULT;
  1907. if (len < *lenp) {
  1908. if(put_user('\n', ((char __user *) buffer) + len))
  1909. return -EFAULT;
  1910. len++;
  1911. }
  1912. *lenp = len;
  1913. *ppos += len;
  1914. }
  1915. return 0;
  1916. }
  1917. /**
  1918. * proc_dostring - read a string sysctl
  1919. * @table: the sysctl table
  1920. * @write: %TRUE if this is a write to the sysctl file
  1921. * @buffer: the user buffer
  1922. * @lenp: the size of the user buffer
  1923. * @ppos: file position
  1924. *
  1925. * Reads/writes a string from/to the user buffer. If the kernel
  1926. * buffer provided is not large enough to hold the string, the
  1927. * string is truncated. The copied string is %NULL-terminated.
  1928. * If the string is being read by the user process, it is copied
  1929. * and a newline '\n' is added. It is truncated if the buffer is
  1930. * not large enough.
  1931. *
  1932. * Returns 0 on success.
  1933. */
  1934. int proc_dostring(struct ctl_table *table, int write,
  1935. void __user *buffer, size_t *lenp, loff_t *ppos)
  1936. {
  1937. return _proc_do_string(table->data, table->maxlen, write,
  1938. buffer, lenp, ppos);
  1939. }
  1940. static int do_proc_dointvec_conv(int *negp, unsigned long *lvalp,
  1941. int *valp,
  1942. int write, void *data)
  1943. {
  1944. if (write) {
  1945. *valp = *negp ? -*lvalp : *lvalp;
  1946. } else {
  1947. int val = *valp;
  1948. if (val < 0) {
  1949. *negp = -1;
  1950. *lvalp = (unsigned long)-val;
  1951. } else {
  1952. *negp = 0;
  1953. *lvalp = (unsigned long)val;
  1954. }
  1955. }
  1956. return 0;
  1957. }
  1958. static int __do_proc_dointvec(void *tbl_data, struct ctl_table *table,
  1959. int write, void __user *buffer,
  1960. size_t *lenp, loff_t *ppos,
  1961. int (*conv)(int *negp, unsigned long *lvalp, int *valp,
  1962. int write, void *data),
  1963. void *data)
  1964. {
  1965. #define TMPBUFLEN 21
  1966. int *i, vleft, first = 1, neg;
  1967. unsigned long lval;
  1968. size_t left, len;
  1969. char buf[TMPBUFLEN], *p;
  1970. char __user *s = buffer;
  1971. if (!tbl_data || !table->maxlen || !*lenp ||
  1972. (*ppos && !write)) {
  1973. *lenp = 0;
  1974. return 0;
  1975. }
  1976. i = (int *) tbl_data;
  1977. vleft = table->maxlen / sizeof(*i);
  1978. left = *lenp;
  1979. if (!conv)
  1980. conv = do_proc_dointvec_conv;
  1981. for (; left && vleft--; i++, first=0) {
  1982. if (write) {
  1983. while (left) {
  1984. char c;
  1985. if (get_user(c, s))
  1986. return -EFAULT;
  1987. if (!isspace(c))
  1988. break;
  1989. left--;
  1990. s++;
  1991. }
  1992. if (!left)
  1993. break;
  1994. neg = 0;
  1995. len = left;
  1996. if (len > sizeof(buf) - 1)
  1997. len = sizeof(buf) - 1;
  1998. if (copy_from_user(buf, s, len))
  1999. return -EFAULT;
  2000. buf[len] = 0;
  2001. p = buf;
  2002. if (*p == '-' && left > 1) {
  2003. neg = 1;
  2004. p++;
  2005. }
  2006. if (*p < '0' || *p > '9')
  2007. break;
  2008. lval = simple_strtoul(p, &p, 0);
  2009. len = p-buf;
  2010. if ((len < left) && *p && !isspace(*p))
  2011. break;
  2012. s += len;
  2013. left -= len;
  2014. if (conv(&neg, &lval, i, 1, data))
  2015. break;
  2016. } else {
  2017. p = buf;
  2018. if (!first)
  2019. *p++ = '\t';
  2020. if (conv(&neg, &lval, i, 0, data))
  2021. break;
  2022. sprintf(p, "%s%lu", neg ? "-" : "", lval);
  2023. len = strlen(buf);
  2024. if (len > left)
  2025. len = left;
  2026. if(copy_to_user(s, buf, len))
  2027. return -EFAULT;
  2028. left -= len;
  2029. s += len;
  2030. }
  2031. }
  2032. if (!write && !first && left) {
  2033. if(put_user('\n', s))
  2034. return -EFAULT;
  2035. left--, s++;
  2036. }
  2037. if (write) {
  2038. while (left) {
  2039. char c;
  2040. if (get_user(c, s++))
  2041. return -EFAULT;
  2042. if (!isspace(c))
  2043. break;
  2044. left--;
  2045. }
  2046. }
  2047. if (write && first)
  2048. return -EINVAL;
  2049. *lenp -= left;
  2050. *ppos += *lenp;
  2051. return 0;
  2052. #undef TMPBUFLEN
  2053. }
  2054. static int do_proc_dointvec(struct ctl_table *table, int write,
  2055. void __user *buffer, size_t *lenp, loff_t *ppos,
  2056. int (*conv)(int *negp, unsigned long *lvalp, int *valp,
  2057. int write, void *data),
  2058. void *data)
  2059. {
  2060. return __do_proc_dointvec(table->data, table, write,
  2061. buffer, lenp, ppos, conv, data);
  2062. }
  2063. /**
  2064. * proc_dointvec - read a vector of integers
  2065. * @table: the sysctl table
  2066. * @write: %TRUE if this is a write to the sysctl file
  2067. * @buffer: the user buffer
  2068. * @lenp: the size of the user buffer
  2069. * @ppos: file position
  2070. *
  2071. * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
  2072. * values from/to the user buffer, treated as an ASCII string.
  2073. *
  2074. * Returns 0 on success.
  2075. */
  2076. int proc_dointvec(struct ctl_table *table, int write,
  2077. void __user *buffer, size_t *lenp, loff_t *ppos)
  2078. {
  2079. return do_proc_dointvec(table,write,buffer,lenp,ppos,
  2080. NULL,NULL);
  2081. }
  2082. /*
  2083. * Taint values can only be increased
  2084. * This means we can safely use a temporary.
  2085. */
  2086. static int proc_taint(struct ctl_table *table, int write,
  2087. void __user *buffer, size_t *lenp, loff_t *ppos)
  2088. {
  2089. struct ctl_table t;
  2090. unsigned long tmptaint = get_taint();
  2091. int err;
  2092. if (write && !capable(CAP_SYS_ADMIN))
  2093. return -EPERM;
  2094. t = *table;
  2095. t.data = &tmptaint;
  2096. err = proc_doulongvec_minmax(&t, write, buffer, lenp, ppos);
  2097. if (err < 0)
  2098. return err;
  2099. if (write) {
  2100. /*
  2101. * Poor man's atomic or. Not worth adding a primitive
  2102. * to everyone's atomic.h for this
  2103. */
  2104. int i;
  2105. for (i = 0; i < BITS_PER_LONG && tmptaint >> i; i++) {
  2106. if ((tmptaint >> i) & 1)
  2107. add_taint(i);
  2108. }
  2109. }
  2110. return err;
  2111. }
  2112. struct do_proc_dointvec_minmax_conv_param {
  2113. int *min;
  2114. int *max;
  2115. };
  2116. static int do_proc_dointvec_minmax_conv(int *negp, unsigned long *lvalp,
  2117. int *valp,
  2118. int write, void *data)
  2119. {
  2120. struct do_proc_dointvec_minmax_conv_param *param = data;
  2121. if (write) {
  2122. int val = *negp ? -*lvalp : *lvalp;
  2123. if ((param->min && *param->min > val) ||
  2124. (param->max && *param->max < val))
  2125. return -EINVAL;
  2126. *valp = val;
  2127. } else {
  2128. int val = *valp;
  2129. if (val < 0) {
  2130. *negp = -1;
  2131. *lvalp = (unsigned long)-val;
  2132. } else {
  2133. *negp = 0;
  2134. *lvalp = (unsigned long)val;
  2135. }
  2136. }
  2137. return 0;
  2138. }
  2139. /**
  2140. * proc_dointvec_minmax - read a vector of integers with min/max values
  2141. * @table: the sysctl table
  2142. * @write: %TRUE if this is a write to the sysctl file
  2143. * @buffer: the user buffer
  2144. * @lenp: the size of the user buffer
  2145. * @ppos: file position
  2146. *
  2147. * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
  2148. * values from/to the user buffer, treated as an ASCII string.
  2149. *
  2150. * This routine will ensure the values are within the range specified by
  2151. * table->extra1 (min) and table->extra2 (max).
  2152. *
  2153. * Returns 0 on success.
  2154. */
  2155. int proc_dointvec_minmax(struct ctl_table *table, int write,
  2156. void __user *buffer, size_t *lenp, loff_t *ppos)
  2157. {
  2158. struct do_proc_dointvec_minmax_conv_param param = {
  2159. .min = (int *) table->extra1,
  2160. .max = (int *) table->extra2,
  2161. };
  2162. return do_proc_dointvec(table, write, buffer, lenp, ppos,
  2163. do_proc_dointvec_minmax_conv, &param);
  2164. }
  2165. static int __do_proc_doulongvec_minmax(void *data, struct ctl_table *table, int write,
  2166. void __user *buffer,
  2167. size_t *lenp, loff_t *ppos,
  2168. unsigned long convmul,
  2169. unsigned long convdiv)
  2170. {
  2171. #define TMPBUFLEN 21
  2172. unsigned long *i, *min, *max, val;
  2173. int vleft, first=1, neg;
  2174. size_t len, left;
  2175. char buf[TMPBUFLEN], *p;
  2176. char __user *s = buffer;
  2177. if (!data || !table->maxlen || !*lenp ||
  2178. (*ppos && !write)) {
  2179. *lenp = 0;
  2180. return 0;
  2181. }
  2182. i = (unsigned long *) data;
  2183. min = (unsigned long *) table->extra1;
  2184. max = (unsigned long *) table->extra2;
  2185. vleft = table->maxlen / sizeof(unsigned long);
  2186. left = *lenp;
  2187. for (; left && vleft--; i++, min++, max++, first=0) {
  2188. if (write) {
  2189. while (left) {
  2190. char c;
  2191. if (get_user(c, s))
  2192. return -EFAULT;
  2193. if (!isspace(c))
  2194. break;
  2195. left--;
  2196. s++;
  2197. }
  2198. if (!left)
  2199. break;
  2200. neg = 0;
  2201. len = left;
  2202. if (len > TMPBUFLEN-1)
  2203. len = TMPBUFLEN-1;
  2204. if (copy_from_user(buf, s, len))
  2205. return -EFAULT;
  2206. buf[len] = 0;
  2207. p = buf;
  2208. if (*p == '-' && left > 1) {
  2209. neg = 1;
  2210. p++;
  2211. }
  2212. if (*p < '0' || *p > '9')
  2213. break;
  2214. val = simple_strtoul(p, &p, 0) * convmul / convdiv ;
  2215. len = p-buf;
  2216. if ((len < left) && *p && !isspace(*p))
  2217. break;
  2218. if (neg)
  2219. val = -val;
  2220. s += len;
  2221. left -= len;
  2222. if(neg)
  2223. continue;
  2224. if ((min && val < *min) || (max && val > *max))
  2225. continue;
  2226. *i = val;
  2227. } else {
  2228. p = buf;
  2229. if (!first)
  2230. *p++ = '\t';
  2231. sprintf(p, "%lu", convdiv * (*i) / convmul);
  2232. len = strlen(buf);
  2233. if (len > left)
  2234. len = left;
  2235. if(copy_to_user(s, buf, len))
  2236. return -EFAULT;
  2237. left -= len;
  2238. s += len;
  2239. }
  2240. }
  2241. if (!write && !first && left) {
  2242. if(put_user('\n', s))
  2243. return -EFAULT;
  2244. left--, s++;
  2245. }
  2246. if (write) {
  2247. while (left) {
  2248. char c;
  2249. if (get_user(c, s++))
  2250. return -EFAULT;
  2251. if (!isspace(c))
  2252. break;
  2253. left--;
  2254. }
  2255. }
  2256. if (write && first)
  2257. return -EINVAL;
  2258. *lenp -= left;
  2259. *ppos += *lenp;
  2260. return 0;
  2261. #undef TMPBUFLEN
  2262. }
  2263. static int do_proc_doulongvec_minmax(struct ctl_table *table, int write,
  2264. void __user *buffer,
  2265. size_t *lenp, loff_t *ppos,
  2266. unsigned long convmul,
  2267. unsigned long convdiv)
  2268. {
  2269. return __do_proc_doulongvec_minmax(table->data, table, write,
  2270. buffer, lenp, ppos, convmul, convdiv);
  2271. }
  2272. /**
  2273. * proc_doulongvec_minmax - read a vector of long integers with min/max values
  2274. * @table: the sysctl table
  2275. * @write: %TRUE if this is a write to the sysctl file
  2276. * @buffer: the user buffer
  2277. * @lenp: the size of the user buffer
  2278. * @ppos: file position
  2279. *
  2280. * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
  2281. * values from/to the user buffer, treated as an ASCII string.
  2282. *
  2283. * This routine will ensure the values are within the range specified by
  2284. * table->extra1 (min) and table->extra2 (max).
  2285. *
  2286. * Returns 0 on success.
  2287. */
  2288. int proc_doulongvec_minmax(struct ctl_table *table, int write,
  2289. void __user *buffer, size_t *lenp, loff_t *ppos)
  2290. {
  2291. return do_proc_doulongvec_minmax(table, write, buffer, lenp, ppos, 1l, 1l);
  2292. }
  2293. /**
  2294. * proc_doulongvec_ms_jiffies_minmax - read a vector of millisecond values with min/max values
  2295. * @table: the sysctl table
  2296. * @write: %TRUE if this is a write to the sysctl file
  2297. * @buffer: the user buffer
  2298. * @lenp: the size of the user buffer
  2299. * @ppos: file position
  2300. *
  2301. * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
  2302. * values from/to the user buffer, treated as an ASCII string. The values
  2303. * are treated as milliseconds, and converted to jiffies when they are stored.
  2304. *
  2305. * This routine will ensure the values are within the range specified by
  2306. * table->extra1 (min) and table->extra2 (max).
  2307. *
  2308. * Returns 0 on success.
  2309. */
  2310. int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
  2311. void __user *buffer,
  2312. size_t *lenp, loff_t *ppos)
  2313. {
  2314. return do_proc_doulongvec_minmax(table, write, buffer,
  2315. lenp, ppos, HZ, 1000l);
  2316. }
  2317. static int do_proc_dointvec_jiffies_conv(int *negp, unsigned long *lvalp,
  2318. int *valp,
  2319. int write, void *data)
  2320. {
  2321. if (write) {
  2322. if (*lvalp > LONG_MAX / HZ)
  2323. return 1;
  2324. *valp = *negp ? -(*lvalp*HZ) : (*lvalp*HZ);
  2325. } else {
  2326. int val = *valp;
  2327. unsigned long lval;
  2328. if (val < 0) {
  2329. *negp = -1;
  2330. lval = (unsigned long)-val;
  2331. } else {
  2332. *negp = 0;
  2333. lval = (unsigned long)val;
  2334. }
  2335. *lvalp = lval / HZ;
  2336. }
  2337. return 0;
  2338. }
  2339. static int do_proc_dointvec_userhz_jiffies_conv(int *negp, unsigned long *lvalp,
  2340. int *valp,
  2341. int write, void *data)
  2342. {
  2343. if (write) {
  2344. if (USER_HZ < HZ && *lvalp > (LONG_MAX / HZ) * USER_HZ)
  2345. return 1;
  2346. *valp = clock_t_to_jiffies(*negp ? -*lvalp : *lvalp);
  2347. } else {
  2348. int val = *valp;
  2349. unsigned long lval;
  2350. if (val < 0) {
  2351. *negp = -1;
  2352. lval = (unsigned long)-val;
  2353. } else {
  2354. *negp = 0;
  2355. lval = (unsigned long)val;
  2356. }
  2357. *lvalp = jiffies_to_clock_t(lval);
  2358. }
  2359. return 0;
  2360. }
  2361. static int do_proc_dointvec_ms_jiffies_conv(int *negp, unsigned long *lvalp,
  2362. int *valp,
  2363. int write, void *data)
  2364. {
  2365. if (write) {
  2366. *valp = msecs_to_jiffies(*negp ? -*lvalp : *lvalp);
  2367. } else {
  2368. int val = *valp;
  2369. unsigned long lval;
  2370. if (val < 0) {
  2371. *negp = -1;
  2372. lval = (unsigned long)-val;
  2373. } else {
  2374. *negp = 0;
  2375. lval = (unsigned long)val;
  2376. }
  2377. *lvalp = jiffies_to_msecs(lval);
  2378. }
  2379. return 0;
  2380. }
  2381. /**
  2382. * proc_dointvec_jiffies - read a vector of integers as seconds
  2383. * @table: the sysctl table
  2384. * @write: %TRUE if this is a write to the sysctl file
  2385. * @buffer: the user buffer
  2386. * @lenp: the size of the user buffer
  2387. * @ppos: file position
  2388. *
  2389. * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
  2390. * values from/to the user buffer, treated as an ASCII string.
  2391. * The values read are assumed to be in seconds, and are converted into
  2392. * jiffies.
  2393. *
  2394. * Returns 0 on success.
  2395. */
  2396. int proc_dointvec_jiffies(struct ctl_table *table, int write,
  2397. void __user *buffer, size_t *lenp, loff_t *ppos)
  2398. {
  2399. return do_proc_dointvec(table,write,buffer,lenp,ppos,
  2400. do_proc_dointvec_jiffies_conv,NULL);
  2401. }
  2402. /**
  2403. * proc_dointvec_userhz_jiffies - read a vector of integers as 1/USER_HZ seconds
  2404. * @table: the sysctl table
  2405. * @write: %TRUE if this is a write to the sysctl file
  2406. * @buffer: the user buffer
  2407. * @lenp: the size of the user buffer
  2408. * @ppos: pointer to the file position
  2409. *
  2410. * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
  2411. * values from/to the user buffer, treated as an ASCII string.
  2412. * The values read are assumed to be in 1/USER_HZ seconds, and
  2413. * are converted into jiffies.
  2414. *
  2415. * Returns 0 on success.
  2416. */
  2417. int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write,
  2418. void __user *buffer, size_t *lenp, loff_t *ppos)
  2419. {
  2420. return do_proc_dointvec(table,write,buffer,lenp,ppos,
  2421. do_proc_dointvec_userhz_jiffies_conv,NULL);
  2422. }
  2423. /**
  2424. * proc_dointvec_ms_jiffies - read a vector of integers as 1 milliseconds
  2425. * @table: the sysctl table
  2426. * @write: %TRUE if this is a write to the sysctl file
  2427. * @buffer: the user buffer
  2428. * @lenp: the size of the user buffer
  2429. * @ppos: file position
  2430. * @ppos: the current position in the file
  2431. *
  2432. * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
  2433. * values from/to the user buffer, treated as an ASCII string.
  2434. * The values read are assumed to be in 1/1000 seconds, and
  2435. * are converted into jiffies.
  2436. *
  2437. * Returns 0 on success.
  2438. */
  2439. int proc_dointvec_ms_jiffies(struct ctl_table *table, int write,
  2440. void __user *buffer, size_t *lenp, loff_t *ppos)
  2441. {
  2442. return do_proc_dointvec(table, write, buffer, lenp, ppos,
  2443. do_proc_dointvec_ms_jiffies_conv, NULL);
  2444. }
  2445. static int proc_do_cad_pid(struct ctl_table *table, int write,
  2446. void __user *buffer, size_t *lenp, loff_t *ppos)
  2447. {
  2448. struct pid *new_pid;
  2449. pid_t tmp;
  2450. int r;
  2451. tmp = pid_vnr(cad_pid);
  2452. r = __do_proc_dointvec(&tmp, table, write, buffer,
  2453. lenp, ppos, NULL, NULL);
  2454. if (r || !write)
  2455. return r;
  2456. new_pid = find_get_pid(tmp);
  2457. if (!new_pid)
  2458. return -ESRCH;
  2459. put_pid(xchg(&cad_pid, new_pid));
  2460. return 0;
  2461. }
  2462. #else /* CONFIG_PROC_FS */
  2463. int proc_dostring(struct ctl_table *table, int write,
  2464. void __user *buffer, size_t *lenp, loff_t *ppos)
  2465. {
  2466. return -ENOSYS;
  2467. }
  2468. int proc_dointvec(struct ctl_table *table, int write,
  2469. void __user *buffer, size_t *lenp, loff_t *ppos)
  2470. {
  2471. return -ENOSYS;
  2472. }
  2473. int proc_dointvec_minmax(struct ctl_table *table, int write,
  2474. void __user *buffer, size_t *lenp, loff_t *ppos)
  2475. {
  2476. return -ENOSYS;
  2477. }
  2478. int proc_dointvec_jiffies(struct ctl_table *table, int write,
  2479. void __user *buffer, size_t *lenp, loff_t *ppos)
  2480. {
  2481. return -ENOSYS;
  2482. }
  2483. int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write,
  2484. void __user *buffer, size_t *lenp, loff_t *ppos)
  2485. {
  2486. return -ENOSYS;
  2487. }
  2488. int proc_dointvec_ms_jiffies(struct ctl_table *table, int write,
  2489. void __user *buffer, size_t *lenp, loff_t *ppos)
  2490. {
  2491. return -ENOSYS;
  2492. }
  2493. int proc_doulongvec_minmax(struct ctl_table *table, int write,
  2494. void __user *buffer, size_t *lenp, loff_t *ppos)
  2495. {
  2496. return -ENOSYS;
  2497. }
  2498. int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
  2499. void __user *buffer,
  2500. size_t *lenp, loff_t *ppos)
  2501. {
  2502. return -ENOSYS;
  2503. }
  2504. #endif /* CONFIG_PROC_FS */
  2505. /*
  2506. * No sense putting this after each symbol definition, twice,
  2507. * exception granted :-)
  2508. */
  2509. EXPORT_SYMBOL(proc_dointvec);
  2510. EXPORT_SYMBOL(proc_dointvec_jiffies);
  2511. EXPORT_SYMBOL(proc_dointvec_minmax);
  2512. EXPORT_SYMBOL(proc_dointvec_userhz_jiffies);
  2513. EXPORT_SYMBOL(proc_dointvec_ms_jiffies);
  2514. EXPORT_SYMBOL(proc_dostring);
  2515. EXPORT_SYMBOL(proc_doulongvec_minmax);
  2516. EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax);
  2517. EXPORT_SYMBOL(register_sysctl_table);
  2518. EXPORT_SYMBOL(register_sysctl_paths);
  2519. EXPORT_SYMBOL(unregister_sysctl_table);