sysctl.c 62 KB

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