sysctl.c 62 KB

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