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