sysctl.c 62 KB

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