sysctl.c 62 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679
  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 = &show_unhandled_signals,
  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. defined(CONFIG_S390)
  1406. {
  1407. .procname = "exception-trace",
  1408. .data = &show_unhandled_signals,
  1409. .maxlen = sizeof(int),
  1410. .mode = 0644,
  1411. .proc_handler = proc_dointvec
  1412. },
  1413. #endif
  1414. #if defined(CONFIG_OPTPROBES)
  1415. {
  1416. .procname = "kprobes-optimization",
  1417. .data = &sysctl_kprobes_optimization,
  1418. .maxlen = sizeof(int),
  1419. .mode = 0644,
  1420. .proc_handler = proc_kprobes_optimization_handler,
  1421. .extra1 = &zero,
  1422. .extra2 = &one,
  1423. },
  1424. #endif
  1425. { }
  1426. };
  1427. static struct ctl_table dev_table[] = {
  1428. { }
  1429. };
  1430. static DEFINE_SPINLOCK(sysctl_lock);
  1431. /* called under sysctl_lock */
  1432. static int use_table(struct ctl_table_header *p)
  1433. {
  1434. if (unlikely(p->unregistering))
  1435. return 0;
  1436. p->used++;
  1437. return 1;
  1438. }
  1439. /* called under sysctl_lock */
  1440. static void unuse_table(struct ctl_table_header *p)
  1441. {
  1442. if (!--p->used)
  1443. if (unlikely(p->unregistering))
  1444. complete(p->unregistering);
  1445. }
  1446. /* called under sysctl_lock, will reacquire if has to wait */
  1447. static void start_unregistering(struct ctl_table_header *p)
  1448. {
  1449. /*
  1450. * if p->used is 0, nobody will ever touch that entry again;
  1451. * we'll eliminate all paths to it before dropping sysctl_lock
  1452. */
  1453. if (unlikely(p->used)) {
  1454. struct completion wait;
  1455. init_completion(&wait);
  1456. p->unregistering = &wait;
  1457. spin_unlock(&sysctl_lock);
  1458. wait_for_completion(&wait);
  1459. spin_lock(&sysctl_lock);
  1460. } else {
  1461. /* anything non-NULL; we'll never dereference it */
  1462. p->unregistering = ERR_PTR(-EINVAL);
  1463. }
  1464. /*
  1465. * do not remove from the list until nobody holds it; walking the
  1466. * list in do_sysctl() relies on that.
  1467. */
  1468. list_del_init(&p->ctl_entry);
  1469. }
  1470. void sysctl_head_get(struct ctl_table_header *head)
  1471. {
  1472. spin_lock(&sysctl_lock);
  1473. head->count++;
  1474. spin_unlock(&sysctl_lock);
  1475. }
  1476. void sysctl_head_put(struct ctl_table_header *head)
  1477. {
  1478. spin_lock(&sysctl_lock);
  1479. if (!--head->count)
  1480. kfree(head);
  1481. spin_unlock(&sysctl_lock);
  1482. }
  1483. struct ctl_table_header *sysctl_head_grab(struct ctl_table_header *head)
  1484. {
  1485. if (!head)
  1486. BUG();
  1487. spin_lock(&sysctl_lock);
  1488. if (!use_table(head))
  1489. head = ERR_PTR(-ENOENT);
  1490. spin_unlock(&sysctl_lock);
  1491. return head;
  1492. }
  1493. void sysctl_head_finish(struct ctl_table_header *head)
  1494. {
  1495. if (!head)
  1496. return;
  1497. spin_lock(&sysctl_lock);
  1498. unuse_table(head);
  1499. spin_unlock(&sysctl_lock);
  1500. }
  1501. static struct ctl_table_set *
  1502. lookup_header_set(struct ctl_table_root *root, struct nsproxy *namespaces)
  1503. {
  1504. struct ctl_table_set *set = &root->default_set;
  1505. if (root->lookup)
  1506. set = root->lookup(root, namespaces);
  1507. return set;
  1508. }
  1509. static struct list_head *
  1510. lookup_header_list(struct ctl_table_root *root, struct nsproxy *namespaces)
  1511. {
  1512. struct ctl_table_set *set = lookup_header_set(root, namespaces);
  1513. return &set->list;
  1514. }
  1515. struct ctl_table_header *__sysctl_head_next(struct nsproxy *namespaces,
  1516. struct ctl_table_header *prev)
  1517. {
  1518. struct ctl_table_root *root;
  1519. struct list_head *header_list;
  1520. struct ctl_table_header *head;
  1521. struct list_head *tmp;
  1522. spin_lock(&sysctl_lock);
  1523. if (prev) {
  1524. head = prev;
  1525. tmp = &prev->ctl_entry;
  1526. unuse_table(prev);
  1527. goto next;
  1528. }
  1529. tmp = &root_table_header.ctl_entry;
  1530. for (;;) {
  1531. head = list_entry(tmp, struct ctl_table_header, ctl_entry);
  1532. if (!use_table(head))
  1533. goto next;
  1534. spin_unlock(&sysctl_lock);
  1535. return head;
  1536. next:
  1537. root = head->root;
  1538. tmp = tmp->next;
  1539. header_list = lookup_header_list(root, namespaces);
  1540. if (tmp != header_list)
  1541. continue;
  1542. do {
  1543. root = list_entry(root->root_list.next,
  1544. struct ctl_table_root, root_list);
  1545. if (root == &sysctl_table_root)
  1546. goto out;
  1547. header_list = lookup_header_list(root, namespaces);
  1548. } while (list_empty(header_list));
  1549. tmp = header_list->next;
  1550. }
  1551. out:
  1552. spin_unlock(&sysctl_lock);
  1553. return NULL;
  1554. }
  1555. struct ctl_table_header *sysctl_head_next(struct ctl_table_header *prev)
  1556. {
  1557. return __sysctl_head_next(current->nsproxy, prev);
  1558. }
  1559. void register_sysctl_root(struct ctl_table_root *root)
  1560. {
  1561. spin_lock(&sysctl_lock);
  1562. list_add_tail(&root->root_list, &sysctl_table_root.root_list);
  1563. spin_unlock(&sysctl_lock);
  1564. }
  1565. /*
  1566. * sysctl_perm does NOT grant the superuser all rights automatically, because
  1567. * some sysctl variables are readonly even to root.
  1568. */
  1569. static int test_perm(int mode, int op)
  1570. {
  1571. if (!current_euid())
  1572. mode >>= 6;
  1573. else if (in_egroup_p(0))
  1574. mode >>= 3;
  1575. if ((op & ~mode & (MAY_READ|MAY_WRITE|MAY_EXEC)) == 0)
  1576. return 0;
  1577. return -EACCES;
  1578. }
  1579. int sysctl_perm(struct ctl_table_root *root, struct ctl_table *table, int op)
  1580. {
  1581. int error;
  1582. int mode;
  1583. error = security_sysctl(table, op & (MAY_READ | MAY_WRITE | MAY_EXEC));
  1584. if (error)
  1585. return error;
  1586. if (root->permissions)
  1587. mode = root->permissions(root, current->nsproxy, table);
  1588. else
  1589. mode = table->mode;
  1590. return test_perm(mode, op);
  1591. }
  1592. static void sysctl_set_parent(struct ctl_table *parent, struct ctl_table *table)
  1593. {
  1594. for (; table->procname; table++) {
  1595. table->parent = parent;
  1596. if (table->child)
  1597. sysctl_set_parent(table, table->child);
  1598. }
  1599. }
  1600. static __init int sysctl_init(void)
  1601. {
  1602. sysctl_set_parent(NULL, root_table);
  1603. #ifdef CONFIG_SYSCTL_SYSCALL_CHECK
  1604. {
  1605. int err;
  1606. err = sysctl_check_table(current->nsproxy, root_table);
  1607. }
  1608. #endif
  1609. return 0;
  1610. }
  1611. core_initcall(sysctl_init);
  1612. static struct ctl_table *is_branch_in(struct ctl_table *branch,
  1613. struct ctl_table *table)
  1614. {
  1615. struct ctl_table *p;
  1616. const char *s = branch->procname;
  1617. /* branch should have named subdirectory as its first element */
  1618. if (!s || !branch->child)
  1619. return NULL;
  1620. /* ... and nothing else */
  1621. if (branch[1].procname)
  1622. return NULL;
  1623. /* table should contain subdirectory with the same name */
  1624. for (p = table; p->procname; p++) {
  1625. if (!p->child)
  1626. continue;
  1627. if (p->procname && strcmp(p->procname, s) == 0)
  1628. return p;
  1629. }
  1630. return NULL;
  1631. }
  1632. /* see if attaching q to p would be an improvement */
  1633. static void try_attach(struct ctl_table_header *p, struct ctl_table_header *q)
  1634. {
  1635. struct ctl_table *to = p->ctl_table, *by = q->ctl_table;
  1636. struct ctl_table *next;
  1637. int is_better = 0;
  1638. int not_in_parent = !p->attached_by;
  1639. while ((next = is_branch_in(by, to)) != NULL) {
  1640. if (by == q->attached_by)
  1641. is_better = 1;
  1642. if (to == p->attached_by)
  1643. not_in_parent = 1;
  1644. by = by->child;
  1645. to = next->child;
  1646. }
  1647. if (is_better && not_in_parent) {
  1648. q->attached_by = by;
  1649. q->attached_to = to;
  1650. q->parent = p;
  1651. }
  1652. }
  1653. /**
  1654. * __register_sysctl_paths - register a sysctl hierarchy
  1655. * @root: List of sysctl headers to register on
  1656. * @namespaces: Data to compute which lists of sysctl entries are visible
  1657. * @path: The path to the directory the sysctl table is in.
  1658. * @table: the top-level table structure
  1659. *
  1660. * Register a sysctl table hierarchy. @table should be a filled in ctl_table
  1661. * array. A completely 0 filled entry terminates the table.
  1662. *
  1663. * The members of the &struct ctl_table structure are used as follows:
  1664. *
  1665. * procname - the name of the sysctl file under /proc/sys. Set to %NULL to not
  1666. * enter a sysctl file
  1667. *
  1668. * data - a pointer to data for use by proc_handler
  1669. *
  1670. * maxlen - the maximum size in bytes of the data
  1671. *
  1672. * mode - the file permissions for the /proc/sys file, and for sysctl(2)
  1673. *
  1674. * child - a pointer to the child sysctl table if this entry is a directory, or
  1675. * %NULL.
  1676. *
  1677. * proc_handler - the text handler routine (described below)
  1678. *
  1679. * de - for internal use by the sysctl routines
  1680. *
  1681. * extra1, extra2 - extra pointers usable by the proc handler routines
  1682. *
  1683. * Leaf nodes in the sysctl tree will be represented by a single file
  1684. * under /proc; non-leaf nodes will be represented by directories.
  1685. *
  1686. * sysctl(2) can automatically manage read and write requests through
  1687. * the sysctl table. The data and maxlen fields of the ctl_table
  1688. * struct enable minimal validation of the values being written to be
  1689. * performed, and the mode field allows minimal authentication.
  1690. *
  1691. * There must be a proc_handler routine for any terminal nodes
  1692. * mirrored under /proc/sys (non-terminals are handled by a built-in
  1693. * directory handler). Several default handlers are available to
  1694. * cover common cases -
  1695. *
  1696. * proc_dostring(), proc_dointvec(), proc_dointvec_jiffies(),
  1697. * proc_dointvec_userhz_jiffies(), proc_dointvec_minmax(),
  1698. * proc_doulongvec_ms_jiffies_minmax(), proc_doulongvec_minmax()
  1699. *
  1700. * It is the handler's job to read the input buffer from user memory
  1701. * and process it. The handler should return 0 on success.
  1702. *
  1703. * This routine returns %NULL on a failure to register, and a pointer
  1704. * to the table header on success.
  1705. */
  1706. struct ctl_table_header *__register_sysctl_paths(
  1707. struct ctl_table_root *root,
  1708. struct nsproxy *namespaces,
  1709. const struct ctl_path *path, struct ctl_table *table)
  1710. {
  1711. struct ctl_table_header *header;
  1712. struct ctl_table *new, **prevp;
  1713. unsigned int n, npath;
  1714. struct ctl_table_set *set;
  1715. /* Count the path components */
  1716. for (npath = 0; path[npath].procname; ++npath)
  1717. ;
  1718. /*
  1719. * For each path component, allocate a 2-element ctl_table array.
  1720. * The first array element will be filled with the sysctl entry
  1721. * for this, the second will be the sentinel (procname == 0).
  1722. *
  1723. * We allocate everything in one go so that we don't have to
  1724. * worry about freeing additional memory in unregister_sysctl_table.
  1725. */
  1726. header = kzalloc(sizeof(struct ctl_table_header) +
  1727. (2 * npath * sizeof(struct ctl_table)), GFP_KERNEL);
  1728. if (!header)
  1729. return NULL;
  1730. new = (struct ctl_table *) (header + 1);
  1731. /* Now connect the dots */
  1732. prevp = &header->ctl_table;
  1733. for (n = 0; n < npath; ++n, ++path) {
  1734. /* Copy the procname */
  1735. new->procname = path->procname;
  1736. new->mode = 0555;
  1737. *prevp = new;
  1738. prevp = &new->child;
  1739. new += 2;
  1740. }
  1741. *prevp = table;
  1742. header->ctl_table_arg = table;
  1743. INIT_LIST_HEAD(&header->ctl_entry);
  1744. header->used = 0;
  1745. header->unregistering = NULL;
  1746. header->root = root;
  1747. sysctl_set_parent(NULL, header->ctl_table);
  1748. header->count = 1;
  1749. #ifdef CONFIG_SYSCTL_SYSCALL_CHECK
  1750. if (sysctl_check_table(namespaces, header->ctl_table)) {
  1751. kfree(header);
  1752. return NULL;
  1753. }
  1754. #endif
  1755. spin_lock(&sysctl_lock);
  1756. header->set = lookup_header_set(root, namespaces);
  1757. header->attached_by = header->ctl_table;
  1758. header->attached_to = root_table;
  1759. header->parent = &root_table_header;
  1760. for (set = header->set; set; set = set->parent) {
  1761. struct ctl_table_header *p;
  1762. list_for_each_entry(p, &set->list, ctl_entry) {
  1763. if (p->unregistering)
  1764. continue;
  1765. try_attach(p, header);
  1766. }
  1767. }
  1768. header->parent->count++;
  1769. list_add_tail(&header->ctl_entry, &header->set->list);
  1770. spin_unlock(&sysctl_lock);
  1771. return header;
  1772. }
  1773. /**
  1774. * register_sysctl_table_path - register a sysctl table hierarchy
  1775. * @path: The path to the directory the sysctl table is in.
  1776. * @table: the top-level table structure
  1777. *
  1778. * Register a sysctl table hierarchy. @table should be a filled in ctl_table
  1779. * array. A completely 0 filled entry terminates the table.
  1780. *
  1781. * See __register_sysctl_paths for more details.
  1782. */
  1783. struct ctl_table_header *register_sysctl_paths(const struct ctl_path *path,
  1784. struct ctl_table *table)
  1785. {
  1786. return __register_sysctl_paths(&sysctl_table_root, current->nsproxy,
  1787. path, table);
  1788. }
  1789. /**
  1790. * register_sysctl_table - register a sysctl table hierarchy
  1791. * @table: the top-level table structure
  1792. *
  1793. * Register a sysctl table hierarchy. @table should be a filled in ctl_table
  1794. * array. A completely 0 filled entry terminates the table.
  1795. *
  1796. * See register_sysctl_paths for more details.
  1797. */
  1798. struct ctl_table_header *register_sysctl_table(struct ctl_table *table)
  1799. {
  1800. static const struct ctl_path null_path[] = { {} };
  1801. return register_sysctl_paths(null_path, table);
  1802. }
  1803. /**
  1804. * unregister_sysctl_table - unregister a sysctl table hierarchy
  1805. * @header: the header returned from register_sysctl_table
  1806. *
  1807. * Unregisters the sysctl table and all children. proc entries may not
  1808. * actually be removed until they are no longer used by anyone.
  1809. */
  1810. void unregister_sysctl_table(struct ctl_table_header * header)
  1811. {
  1812. might_sleep();
  1813. if (header == NULL)
  1814. return;
  1815. spin_lock(&sysctl_lock);
  1816. start_unregistering(header);
  1817. if (!--header->parent->count) {
  1818. WARN_ON(1);
  1819. kfree(header->parent);
  1820. }
  1821. if (!--header->count)
  1822. kfree(header);
  1823. spin_unlock(&sysctl_lock);
  1824. }
  1825. int sysctl_is_seen(struct ctl_table_header *p)
  1826. {
  1827. struct ctl_table_set *set = p->set;
  1828. int res;
  1829. spin_lock(&sysctl_lock);
  1830. if (p->unregistering)
  1831. res = 0;
  1832. else if (!set->is_seen)
  1833. res = 1;
  1834. else
  1835. res = set->is_seen(set);
  1836. spin_unlock(&sysctl_lock);
  1837. return res;
  1838. }
  1839. void setup_sysctl_set(struct ctl_table_set *p,
  1840. struct ctl_table_set *parent,
  1841. int (*is_seen)(struct ctl_table_set *))
  1842. {
  1843. INIT_LIST_HEAD(&p->list);
  1844. p->parent = parent ? parent : &sysctl_table_root.default_set;
  1845. p->is_seen = is_seen;
  1846. }
  1847. #else /* !CONFIG_SYSCTL */
  1848. struct ctl_table_header *register_sysctl_table(struct ctl_table * table)
  1849. {
  1850. return NULL;
  1851. }
  1852. struct ctl_table_header *register_sysctl_paths(const struct ctl_path *path,
  1853. struct ctl_table *table)
  1854. {
  1855. return NULL;
  1856. }
  1857. void unregister_sysctl_table(struct ctl_table_header * table)
  1858. {
  1859. }
  1860. void setup_sysctl_set(struct ctl_table_set *p,
  1861. struct ctl_table_set *parent,
  1862. int (*is_seen)(struct ctl_table_set *))
  1863. {
  1864. }
  1865. void sysctl_head_put(struct ctl_table_header *head)
  1866. {
  1867. }
  1868. #endif /* CONFIG_SYSCTL */
  1869. /*
  1870. * /proc/sys support
  1871. */
  1872. #ifdef CONFIG_PROC_SYSCTL
  1873. static int _proc_do_string(void* data, int maxlen, int write,
  1874. void __user *buffer,
  1875. size_t *lenp, loff_t *ppos)
  1876. {
  1877. size_t len;
  1878. char __user *p;
  1879. char c;
  1880. if (!data || !maxlen || !*lenp) {
  1881. *lenp = 0;
  1882. return 0;
  1883. }
  1884. if (write) {
  1885. len = 0;
  1886. p = buffer;
  1887. while (len < *lenp) {
  1888. if (get_user(c, p++))
  1889. return -EFAULT;
  1890. if (c == 0 || c == '\n')
  1891. break;
  1892. len++;
  1893. }
  1894. if (len >= maxlen)
  1895. len = maxlen-1;
  1896. if(copy_from_user(data, buffer, len))
  1897. return -EFAULT;
  1898. ((char *) data)[len] = 0;
  1899. *ppos += *lenp;
  1900. } else {
  1901. len = strlen(data);
  1902. if (len > maxlen)
  1903. len = maxlen;
  1904. if (*ppos > len) {
  1905. *lenp = 0;
  1906. return 0;
  1907. }
  1908. data += *ppos;
  1909. len -= *ppos;
  1910. if (len > *lenp)
  1911. len = *lenp;
  1912. if (len)
  1913. if(copy_to_user(buffer, data, len))
  1914. return -EFAULT;
  1915. if (len < *lenp) {
  1916. if(put_user('\n', ((char __user *) buffer) + len))
  1917. return -EFAULT;
  1918. len++;
  1919. }
  1920. *lenp = len;
  1921. *ppos += len;
  1922. }
  1923. return 0;
  1924. }
  1925. /**
  1926. * proc_dostring - read a string sysctl
  1927. * @table: the sysctl table
  1928. * @write: %TRUE if this is a write to the sysctl file
  1929. * @buffer: the user buffer
  1930. * @lenp: the size of the user buffer
  1931. * @ppos: file position
  1932. *
  1933. * Reads/writes a string from/to the user buffer. If the kernel
  1934. * buffer provided is not large enough to hold the string, the
  1935. * string is truncated. The copied string is %NULL-terminated.
  1936. * If the string is being read by the user process, it is copied
  1937. * and a newline '\n' is added. It is truncated if the buffer is
  1938. * not large enough.
  1939. *
  1940. * Returns 0 on success.
  1941. */
  1942. int proc_dostring(struct ctl_table *table, int write,
  1943. void __user *buffer, size_t *lenp, loff_t *ppos)
  1944. {
  1945. return _proc_do_string(table->data, table->maxlen, write,
  1946. buffer, lenp, ppos);
  1947. }
  1948. static int do_proc_dointvec_conv(int *negp, unsigned long *lvalp,
  1949. int *valp,
  1950. int write, void *data)
  1951. {
  1952. if (write) {
  1953. *valp = *negp ? -*lvalp : *lvalp;
  1954. } else {
  1955. int val = *valp;
  1956. if (val < 0) {
  1957. *negp = -1;
  1958. *lvalp = (unsigned long)-val;
  1959. } else {
  1960. *negp = 0;
  1961. *lvalp = (unsigned long)val;
  1962. }
  1963. }
  1964. return 0;
  1965. }
  1966. static int __do_proc_dointvec(void *tbl_data, struct ctl_table *table,
  1967. int write, void __user *buffer,
  1968. size_t *lenp, loff_t *ppos,
  1969. int (*conv)(int *negp, unsigned long *lvalp, int *valp,
  1970. int write, void *data),
  1971. void *data)
  1972. {
  1973. #define TMPBUFLEN 21
  1974. int *i, vleft, first = 1, neg;
  1975. unsigned long lval;
  1976. size_t left, len;
  1977. char buf[TMPBUFLEN], *p;
  1978. char __user *s = buffer;
  1979. if (!tbl_data || !table->maxlen || !*lenp ||
  1980. (*ppos && !write)) {
  1981. *lenp = 0;
  1982. return 0;
  1983. }
  1984. i = (int *) tbl_data;
  1985. vleft = table->maxlen / sizeof(*i);
  1986. left = *lenp;
  1987. if (!conv)
  1988. conv = do_proc_dointvec_conv;
  1989. for (; left && vleft--; i++, first=0) {
  1990. if (write) {
  1991. while (left) {
  1992. char c;
  1993. if (get_user(c, s))
  1994. return -EFAULT;
  1995. if (!isspace(c))
  1996. break;
  1997. left--;
  1998. s++;
  1999. }
  2000. if (!left)
  2001. break;
  2002. neg = 0;
  2003. len = left;
  2004. if (len > sizeof(buf) - 1)
  2005. len = sizeof(buf) - 1;
  2006. if (copy_from_user(buf, s, len))
  2007. return -EFAULT;
  2008. buf[len] = 0;
  2009. p = buf;
  2010. if (*p == '-' && left > 1) {
  2011. neg = 1;
  2012. p++;
  2013. }
  2014. if (*p < '0' || *p > '9')
  2015. break;
  2016. lval = simple_strtoul(p, &p, 0);
  2017. len = p-buf;
  2018. if ((len < left) && *p && !isspace(*p))
  2019. break;
  2020. s += len;
  2021. left -= len;
  2022. if (conv(&neg, &lval, i, 1, data))
  2023. break;
  2024. } else {
  2025. p = buf;
  2026. if (!first)
  2027. *p++ = '\t';
  2028. if (conv(&neg, &lval, i, 0, data))
  2029. break;
  2030. sprintf(p, "%s%lu", neg ? "-" : "", lval);
  2031. len = strlen(buf);
  2032. if (len > left)
  2033. len = left;
  2034. if(copy_to_user(s, buf, len))
  2035. return -EFAULT;
  2036. left -= len;
  2037. s += len;
  2038. }
  2039. }
  2040. if (!write && !first && left) {
  2041. if(put_user('\n', s))
  2042. return -EFAULT;
  2043. left--, s++;
  2044. }
  2045. if (write) {
  2046. while (left) {
  2047. char c;
  2048. if (get_user(c, s++))
  2049. return -EFAULT;
  2050. if (!isspace(c))
  2051. break;
  2052. left--;
  2053. }
  2054. }
  2055. if (write && first)
  2056. return -EINVAL;
  2057. *lenp -= left;
  2058. *ppos += *lenp;
  2059. return 0;
  2060. #undef TMPBUFLEN
  2061. }
  2062. static int do_proc_dointvec(struct ctl_table *table, int write,
  2063. void __user *buffer, size_t *lenp, loff_t *ppos,
  2064. int (*conv)(int *negp, unsigned long *lvalp, int *valp,
  2065. int write, void *data),
  2066. void *data)
  2067. {
  2068. return __do_proc_dointvec(table->data, table, write,
  2069. buffer, lenp, ppos, conv, data);
  2070. }
  2071. /**
  2072. * proc_dointvec - read a vector of integers
  2073. * @table: the sysctl table
  2074. * @write: %TRUE if this is a write to the sysctl file
  2075. * @buffer: the user buffer
  2076. * @lenp: the size of the user buffer
  2077. * @ppos: file position
  2078. *
  2079. * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
  2080. * values from/to the user buffer, treated as an ASCII string.
  2081. *
  2082. * Returns 0 on success.
  2083. */
  2084. int proc_dointvec(struct ctl_table *table, int write,
  2085. void __user *buffer, size_t *lenp, loff_t *ppos)
  2086. {
  2087. return do_proc_dointvec(table,write,buffer,lenp,ppos,
  2088. NULL,NULL);
  2089. }
  2090. /*
  2091. * Taint values can only be increased
  2092. * This means we can safely use a temporary.
  2093. */
  2094. static int proc_taint(struct ctl_table *table, int write,
  2095. void __user *buffer, size_t *lenp, loff_t *ppos)
  2096. {
  2097. struct ctl_table t;
  2098. unsigned long tmptaint = get_taint();
  2099. int err;
  2100. if (write && !capable(CAP_SYS_ADMIN))
  2101. return -EPERM;
  2102. t = *table;
  2103. t.data = &tmptaint;
  2104. err = proc_doulongvec_minmax(&t, write, buffer, lenp, ppos);
  2105. if (err < 0)
  2106. return err;
  2107. if (write) {
  2108. /*
  2109. * Poor man's atomic or. Not worth adding a primitive
  2110. * to everyone's atomic.h for this
  2111. */
  2112. int i;
  2113. for (i = 0; i < BITS_PER_LONG && tmptaint >> i; i++) {
  2114. if ((tmptaint >> i) & 1)
  2115. add_taint(i);
  2116. }
  2117. }
  2118. return err;
  2119. }
  2120. struct do_proc_dointvec_minmax_conv_param {
  2121. int *min;
  2122. int *max;
  2123. };
  2124. static int do_proc_dointvec_minmax_conv(int *negp, unsigned long *lvalp,
  2125. int *valp,
  2126. int write, void *data)
  2127. {
  2128. struct do_proc_dointvec_minmax_conv_param *param = data;
  2129. if (write) {
  2130. int val = *negp ? -*lvalp : *lvalp;
  2131. if ((param->min && *param->min > val) ||
  2132. (param->max && *param->max < val))
  2133. return -EINVAL;
  2134. *valp = val;
  2135. } else {
  2136. int val = *valp;
  2137. if (val < 0) {
  2138. *negp = -1;
  2139. *lvalp = (unsigned long)-val;
  2140. } else {
  2141. *negp = 0;
  2142. *lvalp = (unsigned long)val;
  2143. }
  2144. }
  2145. return 0;
  2146. }
  2147. /**
  2148. * proc_dointvec_minmax - read a vector of integers with min/max values
  2149. * @table: the sysctl table
  2150. * @write: %TRUE if this is a write to the sysctl file
  2151. * @buffer: the user buffer
  2152. * @lenp: the size of the user buffer
  2153. * @ppos: file position
  2154. *
  2155. * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
  2156. * values from/to the user buffer, treated as an ASCII string.
  2157. *
  2158. * This routine will ensure the values are within the range specified by
  2159. * table->extra1 (min) and table->extra2 (max).
  2160. *
  2161. * Returns 0 on success.
  2162. */
  2163. int proc_dointvec_minmax(struct ctl_table *table, int write,
  2164. void __user *buffer, size_t *lenp, loff_t *ppos)
  2165. {
  2166. struct do_proc_dointvec_minmax_conv_param param = {
  2167. .min = (int *) table->extra1,
  2168. .max = (int *) table->extra2,
  2169. };
  2170. return do_proc_dointvec(table, write, buffer, lenp, ppos,
  2171. do_proc_dointvec_minmax_conv, &param);
  2172. }
  2173. static int __do_proc_doulongvec_minmax(void *data, struct ctl_table *table, int write,
  2174. void __user *buffer,
  2175. size_t *lenp, loff_t *ppos,
  2176. unsigned long convmul,
  2177. unsigned long convdiv)
  2178. {
  2179. #define TMPBUFLEN 21
  2180. unsigned long *i, *min, *max, val;
  2181. int vleft, first=1, neg;
  2182. size_t len, left;
  2183. char buf[TMPBUFLEN], *p;
  2184. char __user *s = buffer;
  2185. if (!data || !table->maxlen || !*lenp ||
  2186. (*ppos && !write)) {
  2187. *lenp = 0;
  2188. return 0;
  2189. }
  2190. i = (unsigned long *) data;
  2191. min = (unsigned long *) table->extra1;
  2192. max = (unsigned long *) table->extra2;
  2193. vleft = table->maxlen / sizeof(unsigned long);
  2194. left = *lenp;
  2195. for (; left && vleft--; i++, min++, max++, first=0) {
  2196. if (write) {
  2197. while (left) {
  2198. char c;
  2199. if (get_user(c, s))
  2200. return -EFAULT;
  2201. if (!isspace(c))
  2202. break;
  2203. left--;
  2204. s++;
  2205. }
  2206. if (!left)
  2207. break;
  2208. neg = 0;
  2209. len = left;
  2210. if (len > TMPBUFLEN-1)
  2211. len = TMPBUFLEN-1;
  2212. if (copy_from_user(buf, s, len))
  2213. return -EFAULT;
  2214. buf[len] = 0;
  2215. p = buf;
  2216. if (*p == '-' && left > 1) {
  2217. neg = 1;
  2218. p++;
  2219. }
  2220. if (*p < '0' || *p > '9')
  2221. break;
  2222. val = simple_strtoul(p, &p, 0) * convmul / convdiv ;
  2223. len = p-buf;
  2224. if ((len < left) && *p && !isspace(*p))
  2225. break;
  2226. if (neg)
  2227. val = -val;
  2228. s += len;
  2229. left -= len;
  2230. if(neg)
  2231. continue;
  2232. if ((min && val < *min) || (max && val > *max))
  2233. continue;
  2234. *i = val;
  2235. } else {
  2236. p = buf;
  2237. if (!first)
  2238. *p++ = '\t';
  2239. sprintf(p, "%lu", convdiv * (*i) / convmul);
  2240. len = strlen(buf);
  2241. if (len > left)
  2242. len = left;
  2243. if(copy_to_user(s, buf, len))
  2244. return -EFAULT;
  2245. left -= len;
  2246. s += len;
  2247. }
  2248. }
  2249. if (!write && !first && left) {
  2250. if(put_user('\n', s))
  2251. return -EFAULT;
  2252. left--, s++;
  2253. }
  2254. if (write) {
  2255. while (left) {
  2256. char c;
  2257. if (get_user(c, s++))
  2258. return -EFAULT;
  2259. if (!isspace(c))
  2260. break;
  2261. left--;
  2262. }
  2263. }
  2264. if (write && first)
  2265. return -EINVAL;
  2266. *lenp -= left;
  2267. *ppos += *lenp;
  2268. return 0;
  2269. #undef TMPBUFLEN
  2270. }
  2271. static int do_proc_doulongvec_minmax(struct ctl_table *table, int write,
  2272. void __user *buffer,
  2273. size_t *lenp, loff_t *ppos,
  2274. unsigned long convmul,
  2275. unsigned long convdiv)
  2276. {
  2277. return __do_proc_doulongvec_minmax(table->data, table, write,
  2278. buffer, lenp, ppos, convmul, convdiv);
  2279. }
  2280. /**
  2281. * proc_doulongvec_minmax - read a vector of long integers with min/max values
  2282. * @table: the sysctl table
  2283. * @write: %TRUE if this is a write to the sysctl file
  2284. * @buffer: the user buffer
  2285. * @lenp: the size of the user buffer
  2286. * @ppos: file position
  2287. *
  2288. * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
  2289. * values from/to the user buffer, treated as an ASCII string.
  2290. *
  2291. * This routine will ensure the values are within the range specified by
  2292. * table->extra1 (min) and table->extra2 (max).
  2293. *
  2294. * Returns 0 on success.
  2295. */
  2296. int proc_doulongvec_minmax(struct ctl_table *table, int write,
  2297. void __user *buffer, size_t *lenp, loff_t *ppos)
  2298. {
  2299. return do_proc_doulongvec_minmax(table, write, buffer, lenp, ppos, 1l, 1l);
  2300. }
  2301. /**
  2302. * proc_doulongvec_ms_jiffies_minmax - read a vector of millisecond values with min/max values
  2303. * @table: the sysctl table
  2304. * @write: %TRUE if this is a write to the sysctl file
  2305. * @buffer: the user buffer
  2306. * @lenp: the size of the user buffer
  2307. * @ppos: file position
  2308. *
  2309. * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
  2310. * values from/to the user buffer, treated as an ASCII string. The values
  2311. * are treated as milliseconds, and converted to jiffies when they are stored.
  2312. *
  2313. * This routine will ensure the values are within the range specified by
  2314. * table->extra1 (min) and table->extra2 (max).
  2315. *
  2316. * Returns 0 on success.
  2317. */
  2318. int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
  2319. void __user *buffer,
  2320. size_t *lenp, loff_t *ppos)
  2321. {
  2322. return do_proc_doulongvec_minmax(table, write, buffer,
  2323. lenp, ppos, HZ, 1000l);
  2324. }
  2325. static int do_proc_dointvec_jiffies_conv(int *negp, unsigned long *lvalp,
  2326. int *valp,
  2327. int write, void *data)
  2328. {
  2329. if (write) {
  2330. if (*lvalp > LONG_MAX / HZ)
  2331. return 1;
  2332. *valp = *negp ? -(*lvalp*HZ) : (*lvalp*HZ);
  2333. } else {
  2334. int val = *valp;
  2335. unsigned long lval;
  2336. if (val < 0) {
  2337. *negp = -1;
  2338. lval = (unsigned long)-val;
  2339. } else {
  2340. *negp = 0;
  2341. lval = (unsigned long)val;
  2342. }
  2343. *lvalp = lval / HZ;
  2344. }
  2345. return 0;
  2346. }
  2347. static int do_proc_dointvec_userhz_jiffies_conv(int *negp, unsigned long *lvalp,
  2348. int *valp,
  2349. int write, void *data)
  2350. {
  2351. if (write) {
  2352. if (USER_HZ < HZ && *lvalp > (LONG_MAX / HZ) * USER_HZ)
  2353. return 1;
  2354. *valp = clock_t_to_jiffies(*negp ? -*lvalp : *lvalp);
  2355. } else {
  2356. int val = *valp;
  2357. unsigned long lval;
  2358. if (val < 0) {
  2359. *negp = -1;
  2360. lval = (unsigned long)-val;
  2361. } else {
  2362. *negp = 0;
  2363. lval = (unsigned long)val;
  2364. }
  2365. *lvalp = jiffies_to_clock_t(lval);
  2366. }
  2367. return 0;
  2368. }
  2369. static int do_proc_dointvec_ms_jiffies_conv(int *negp, unsigned long *lvalp,
  2370. int *valp,
  2371. int write, void *data)
  2372. {
  2373. if (write) {
  2374. *valp = msecs_to_jiffies(*negp ? -*lvalp : *lvalp);
  2375. } else {
  2376. int val = *valp;
  2377. unsigned long lval;
  2378. if (val < 0) {
  2379. *negp = -1;
  2380. lval = (unsigned long)-val;
  2381. } else {
  2382. *negp = 0;
  2383. lval = (unsigned long)val;
  2384. }
  2385. *lvalp = jiffies_to_msecs(lval);
  2386. }
  2387. return 0;
  2388. }
  2389. /**
  2390. * proc_dointvec_jiffies - read a vector of integers as seconds
  2391. * @table: the sysctl table
  2392. * @write: %TRUE if this is a write to the sysctl file
  2393. * @buffer: the user buffer
  2394. * @lenp: the size of the user buffer
  2395. * @ppos: file position
  2396. *
  2397. * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
  2398. * values from/to the user buffer, treated as an ASCII string.
  2399. * The values read are assumed to be in seconds, and are converted into
  2400. * jiffies.
  2401. *
  2402. * Returns 0 on success.
  2403. */
  2404. int proc_dointvec_jiffies(struct ctl_table *table, int write,
  2405. void __user *buffer, size_t *lenp, loff_t *ppos)
  2406. {
  2407. return do_proc_dointvec(table,write,buffer,lenp,ppos,
  2408. do_proc_dointvec_jiffies_conv,NULL);
  2409. }
  2410. /**
  2411. * proc_dointvec_userhz_jiffies - read a vector of integers as 1/USER_HZ seconds
  2412. * @table: the sysctl table
  2413. * @write: %TRUE if this is a write to the sysctl file
  2414. * @buffer: the user buffer
  2415. * @lenp: the size of the user buffer
  2416. * @ppos: pointer to the file position
  2417. *
  2418. * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
  2419. * values from/to the user buffer, treated as an ASCII string.
  2420. * The values read are assumed to be in 1/USER_HZ seconds, and
  2421. * are converted into jiffies.
  2422. *
  2423. * Returns 0 on success.
  2424. */
  2425. int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write,
  2426. void __user *buffer, size_t *lenp, loff_t *ppos)
  2427. {
  2428. return do_proc_dointvec(table,write,buffer,lenp,ppos,
  2429. do_proc_dointvec_userhz_jiffies_conv,NULL);
  2430. }
  2431. /**
  2432. * proc_dointvec_ms_jiffies - read a vector of integers as 1 milliseconds
  2433. * @table: the sysctl table
  2434. * @write: %TRUE if this is a write to the sysctl file
  2435. * @buffer: the user buffer
  2436. * @lenp: the size of the user buffer
  2437. * @ppos: file position
  2438. * @ppos: the current position in the file
  2439. *
  2440. * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
  2441. * values from/to the user buffer, treated as an ASCII string.
  2442. * The values read are assumed to be in 1/1000 seconds, and
  2443. * are converted into jiffies.
  2444. *
  2445. * Returns 0 on success.
  2446. */
  2447. int proc_dointvec_ms_jiffies(struct ctl_table *table, int write,
  2448. void __user *buffer, size_t *lenp, loff_t *ppos)
  2449. {
  2450. return do_proc_dointvec(table, write, buffer, lenp, ppos,
  2451. do_proc_dointvec_ms_jiffies_conv, NULL);
  2452. }
  2453. static int proc_do_cad_pid(struct ctl_table *table, int write,
  2454. void __user *buffer, size_t *lenp, loff_t *ppos)
  2455. {
  2456. struct pid *new_pid;
  2457. pid_t tmp;
  2458. int r;
  2459. tmp = pid_vnr(cad_pid);
  2460. r = __do_proc_dointvec(&tmp, table, write, buffer,
  2461. lenp, ppos, NULL, NULL);
  2462. if (r || !write)
  2463. return r;
  2464. new_pid = find_get_pid(tmp);
  2465. if (!new_pid)
  2466. return -ESRCH;
  2467. put_pid(xchg(&cad_pid, new_pid));
  2468. return 0;
  2469. }
  2470. #else /* CONFIG_PROC_FS */
  2471. int proc_dostring(struct ctl_table *table, int write,
  2472. void __user *buffer, size_t *lenp, loff_t *ppos)
  2473. {
  2474. return -ENOSYS;
  2475. }
  2476. int proc_dointvec(struct ctl_table *table, int write,
  2477. void __user *buffer, size_t *lenp, loff_t *ppos)
  2478. {
  2479. return -ENOSYS;
  2480. }
  2481. int proc_dointvec_minmax(struct ctl_table *table, int write,
  2482. void __user *buffer, size_t *lenp, loff_t *ppos)
  2483. {
  2484. return -ENOSYS;
  2485. }
  2486. int proc_dointvec_jiffies(struct ctl_table *table, int write,
  2487. void __user *buffer, size_t *lenp, loff_t *ppos)
  2488. {
  2489. return -ENOSYS;
  2490. }
  2491. int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write,
  2492. void __user *buffer, size_t *lenp, loff_t *ppos)
  2493. {
  2494. return -ENOSYS;
  2495. }
  2496. int proc_dointvec_ms_jiffies(struct ctl_table *table, int write,
  2497. void __user *buffer, size_t *lenp, loff_t *ppos)
  2498. {
  2499. return -ENOSYS;
  2500. }
  2501. int proc_doulongvec_minmax(struct ctl_table *table, int write,
  2502. void __user *buffer, size_t *lenp, loff_t *ppos)
  2503. {
  2504. return -ENOSYS;
  2505. }
  2506. int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
  2507. void __user *buffer,
  2508. size_t *lenp, loff_t *ppos)
  2509. {
  2510. return -ENOSYS;
  2511. }
  2512. #endif /* CONFIG_PROC_FS */
  2513. /*
  2514. * No sense putting this after each symbol definition, twice,
  2515. * exception granted :-)
  2516. */
  2517. EXPORT_SYMBOL(proc_dointvec);
  2518. EXPORT_SYMBOL(proc_dointvec_jiffies);
  2519. EXPORT_SYMBOL(proc_dointvec_minmax);
  2520. EXPORT_SYMBOL(proc_dointvec_userhz_jiffies);
  2521. EXPORT_SYMBOL(proc_dointvec_ms_jiffies);
  2522. EXPORT_SYMBOL(proc_dostring);
  2523. EXPORT_SYMBOL(proc_doulongvec_minmax);
  2524. EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax);
  2525. EXPORT_SYMBOL(register_sysctl_table);
  2526. EXPORT_SYMBOL(register_sysctl_paths);
  2527. EXPORT_SYMBOL(unregister_sysctl_table);